Created
September 9, 2016 17:52
-
-
Save paulp/932903abc36af4f118f4af796bd77c24 to your computer and use it in GitHub Desktop.
Compiling quasar files from the command line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Dependencies: | |
# coursier ( on OSX: brew install --HEAD paulp/extras/coursier ) | |
# zinc ( on OSX: brew install zinc ) | |
# | |
set -euo pipefail | |
# You can compile code in different projects by overriding these, e.g. | |
# | |
# PROJECT=foundation SCOPE=test <qscalac> ./foundation/src/test/**/*.scala | |
# | |
: ${PROJECT=core} | |
: ${SCOPE=compile} | |
run () { echo >&2 "$@" && "$@"; } | |
scalacArgs () { cat <<EOM | |
-language:_ | |
-target:jvm-1.8 | |
-Ybackend:GenBCode | |
-Ydelambdafy:method | |
-Yno-imports | |
-Ypartial-unification | |
-Yliteral-types | |
-Ywarn-dead-code | |
-Ywarn-numeric-widen | |
-Ywarn-value-discard | |
-Ywarn-unused-import | |
EOM | |
} | |
scalacPlugins () { cat <<EOM | |
org.spire-math:kind-projector_2.11:0.8.2 | |
com.github.mpilquist:simulacrum_2.11:0.7.0 | |
org.scalamacros:paradise_2.11.8:2.1.0 | |
org.wartremover:wartremover_2.11:1.1.1 | |
EOM | |
} | |
expandPlugins () { | |
for plugin in $(scalacPlugins); do | |
marker="$(echo "$plugin" | sed 's/:.*//' | sed 's/.*[.]//')" | |
coursier fetch $plugin | egrep "$marker" | |
done | |
} | |
cpfile="$PROJECT/.classpath-$SCOPE" | |
[[ -s "$cpfile" ]] || { | |
sbt "export $PROJECT/$SCOPE:fullClasspath" | tail -n1 | tr : "\n" > "$cpfile" | |
} | |
run zinc \ | |
-nailed \ | |
-scala-path $(coursier fetch org.typelevel:scala-compiler:2.11.8 | paste -sd: -) \ | |
-classpath "$(cat "$cpfile" | paste -sd: -)" \ | |
$(printf -- " -S-Xplugin:%s" $(expandPlugins)) \ | |
$(printf -- " -S%s" $(scalacArgs)) \ | |
"$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
set -euo pipefail | |
export PROJECT SCOPE | |
# This setup echos the times to stderr as they accrue, then | |
# prints the whole list sorted by time to stdout when complete. | |
IFS='\n' | |
declare -a results=() | |
for file in "$@"; do | |
elapsed="$( quasar-scalac -S-Ystop-before:jvm "$file" |& tail -n1 | perl -pe 's#^.*?[\s+]\[(.*?)\]#\1#' )" | |
results+=( "$( printf "%-12s %s\n" $elapsed "$file" | tee /dev/stderr )" ) | |
done | |
printf "\nSorted times:\n\n" | |
printf "%s\n" "${results[@]}" | gsort -nr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% PROJECT=foundation quasar-scalac-timings foundation/src/main/scala/**/*e*.scala | |
0.533s foundation/src/main/scala/quasar/Predef.scala | |
1.993s foundation/src/main/scala/quasar/RenderTree.scala | |
0.386s foundation/src/main/scala/quasar/concurrent/NamedDaemonThreadFactory.scala | |
0.528s foundation/src/main/scala/quasar/fp/ExternallyManaged.scala | |
0.568s foundation/src/main/scala/quasar/fp/TaskRef.scala | |
0.453s foundation/src/main/scala/quasar/fp/binder/Binder.scala | |
0.826s foundation/src/main/scala/quasar/fp/binder/package.scala | |
0.577s foundation/src/main/scala/quasar/fp/catchable.scala | |
0.785s foundation/src/main/scala/quasar/fp/eitherT.scala | |
0.536s foundation/src/main/scala/quasar/fp/enumeratee.scala | |
0.627s foundation/src/main/scala/quasar/fp/free/Interpreter.scala | |
0.616s foundation/src/main/scala/quasar/fp/free/package.scala | |
0.589s foundation/src/main/scala/quasar/fp/kleisli.scala | |
0.640s foundation/src/main/scala/quasar/fp/numeric/package.scala | |
2.823s foundation/src/main/scala/quasar/fp/package.scala | |
0.795s foundation/src/main/scala/quasar/fp/process.scala | |
Sorted times: | |
2.823s foundation/src/main/scala/quasar/fp/package.scala | |
1.993s foundation/src/main/scala/quasar/RenderTree.scala | |
0.826s foundation/src/main/scala/quasar/fp/binder/package.scala | |
0.795s foundation/src/main/scala/quasar/fp/process.scala | |
0.785s foundation/src/main/scala/quasar/fp/eitherT.scala | |
0.640s foundation/src/main/scala/quasar/fp/numeric/package.scala | |
0.627s foundation/src/main/scala/quasar/fp/free/Interpreter.scala | |
0.616s foundation/src/main/scala/quasar/fp/free/package.scala | |
0.589s foundation/src/main/scala/quasar/fp/kleisli.scala | |
0.577s foundation/src/main/scala/quasar/fp/catchable.scala | |
0.568s foundation/src/main/scala/quasar/fp/TaskRef.scala | |
0.536s foundation/src/main/scala/quasar/fp/enumeratee.scala | |
0.533s foundation/src/main/scala/quasar/Predef.scala | |
0.528s foundation/src/main/scala/quasar/fp/ExternallyManaged.scala | |
0.453s foundation/src/main/scala/quasar/fp/binder/Binder.scala | |
0.386s foundation/src/main/scala/quasar/concurrent/NamedDaemonThreadFactory.scala |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment