-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Multiple fixes for bin/dotc
and bin/dotr
#1324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
488cd7a
81034c5
0a8020b
156066d
574681e
a338ac7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,3 +38,6 @@ scala-scala | |
# Ignore output files but keep the directory | ||
out/ | ||
!out/.keep | ||
|
||
# Ignore build-file | ||
.packages |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
#!/bin/bash | ||
|
||
# Finds in dotty build file a line containing PATTERN | ||
# returns last "" escaped string in this line | ||
function getLastStringOnLineWith { | ||
PATTERN="$1" | ||
grep "$PATTERN" "$DOTTY_ROOT/project/Build.scala"|sed -n 's/.*\"\(.*\)\".*/\1/'p | ||
} | ||
|
||
# Configuration | ||
SCALA_VERSION=$(getLastStringOnLineWith "scalaVersion in") | ||
SCALA_BINARY_VERSION=2.11 | ||
SCALA_COMPILER_VERSION=$(getLastStringOnLineWith "scala-compiler") | ||
JLINE_VERSION=$(getLastStringOnLineWith "jline") | ||
SBT_VERSION=$(grep "sbt.version=" "$DOTTY_ROOT/project/build.properties" | sed 's/sbt.version=//') | ||
bootcp=true | ||
bootstrapped=false | ||
default_java_opts="-Xmx768m -Xms768m" | ||
programName=$(basename "$0") | ||
# uncomment next line to enable debug output | ||
#debug=true | ||
|
||
declare -a java_args scala_args residual_args | ||
unset verbose quiet cygwin toolcp colors saved_stty CDPATH | ||
|
||
function find_jar { | ||
# Usage: | ||
# find_jar path/to/location file.jar | ||
local artifact="$1/$2" | ||
|
||
if [ ! -f "$artifact" ]; then | ||
artifact=$(find "$HOME/.coursier/cache" -iname "$2") | ||
fi | ||
|
||
echo "$artifact" | ||
} | ||
|
||
# Autodetecting the scala-library location, in case it wasn't provided by an environment variable | ||
if [ "$SCALA_LIBRARY_JAR" == "" ]; then | ||
SCALA_LIBRARY_JAR=$(find_jar "$HOME/.ivy2/cache/org.scala-lang/scala-library/jars" "scala-library-$SCALA_VERSION.jar") | ||
fi | ||
|
||
if [ "$SCALA_REFLECT_JAR" == "" ]; then | ||
SCALA_REFLECT_JAR=$(find_jar "$HOME/.ivy2/cache/org.scala-lang/scala-reflect/jars" "scala-reflect-$SCALA_VERSION.jar") | ||
fi | ||
|
||
if [ "$SCALA_COMPILER_JAR" == "" ]; then | ||
SCALA_COMPILER_JAR=$(find_jar "$HOME/.ivy2/cache/me.d-d/scala-compiler/jars" "scala-compiler-$SCALA_COMPILER_VERSION.jar") | ||
fi | ||
|
||
if [ "$JLINE_JAR" == "" ]; then | ||
JLINE_JAR=$(find_jar "$HOME/.ivy2/cache/jline/jline/jars" "jline-$JLINE_VERSION.jar") | ||
fi | ||
|
||
if [ "$SBT_INTERFACE_JAR" == "" ]; then | ||
SBT_INTERFACE_JAR=$(find_jar "$HOME/.ivy2/cache/org.scala-sbt/interface/jars" "interface-$SBT_VERSION.jar") | ||
fi | ||
|
||
function build_jar { | ||
# Usage: | ||
# build_jar package path/to/jar/dir ['/some/sed/command'] | ||
# | ||
# Last arg is optional | ||
cd $DOTTY_ROOT >& /dev/null | ||
local build_output=$(sbt "$1") | ||
local jar=$(echo $build_output | sed -n 's/.*Packaging //g; s/ \.\.\..*//g; /^\/.*/p') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice) |
||
|
||
local sedjar="$3" | ||
if [ "$sedjar" == "" ]; then | ||
sedjar="/.*\.jar/p" | ||
fi | ||
|
||
if [ "$jar" == "" ]; then | ||
# Didn't build a jar - could've run sbt by oneself, get latest jar in target: | ||
jar="$DOTTY_ROOT/$2/$(ls -1t "$2" | sed -n "$sedjar" | awk 'NR==1')" | ||
fi | ||
|
||
cd - >& /dev/null | ||
|
||
echo $jar | ||
} | ||
|
||
function update_packages { | ||
echo "$INTERFACES_JAR" > $DOTTY_ROOT/.packages | ||
echo "$MAIN_JAR" >> $DOTTY_ROOT/.packages | ||
echo "$TEST_JAR" >> $DOTTY_ROOT/.packages | ||
} | ||
|
||
function build_all { | ||
echo "The script is going to build the required jar files" | ||
|
||
printf "Building dotty-interfaces..." | ||
INTERFACES_JAR=$(build_jar dotty-interfaces/package interfaces/target) | ||
printf "done\n" | ||
|
||
printf "Building dotty..." | ||
MAIN_JAR=$(build_jar package target/scala-2.11) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SCALA_BINARY_VERSION |
||
printf "done\n" | ||
|
||
printf "Building tests..." | ||
TEST_JAR=$(build_jar test:package target/scala-2.11 '/dotty.*-tests\.jar/p') | ||
printf "done\n" | ||
|
||
update_packages | ||
} | ||
|
||
# Check if .packages file does not exist - if so assume old build and rebuild all | ||
if [ ! -f "$DOTTY_ROOT/.packages" ]; then | ||
build_all | ||
else | ||
IFS=$'\r\n' GLOBIGNORE='*' command eval 'JARS=($(cat $DOTTY_ROOT/.packages))' | ||
|
||
if [ "${#JARS[@]}" == "3" ]; then | ||
INTERFACES_JAR="${JARS[0]}" | ||
MAIN_JAR="${JARS[1]}" | ||
TEST_JAR="${JARS[2]}" | ||
else | ||
echo "Corrupted .packages file" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of |
||
build_all | ||
fi | ||
fi | ||
|
||
################# After this point, jar variables will be set ################# | ||
function check_jar { | ||
# Usage: | ||
# check_jar "name" "path/to/package.jar" "sources/dir" 'lambda to exec on failure' | ||
local new_files="$(find "$3" \( -iname "*.scala" -o -iname "*.java" \) -newer "$2")" | ||
if [ ! -z "$new_files" ]; then | ||
printf "New files detected in $1, rebuilding..." | ||
eval "$4" | ||
printf "done\n" | ||
update_packages | ||
fi | ||
} | ||
|
||
check_jar "dotty-interfaces" $INTERFACES_JAR "interfaces" 'INTERFACES_JAR=$(build_jar dotty-interfaces/package interfaces/target)' | ||
check_jar "dotty" $MAIN_JAR "src" 'MAIN_JAR=$(build_jar package target/scala-2.11)' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2.11 -> SCALA_BINARY_VERSION. Same on next line. |
||
check_jar "dotty-tests" $TEST_JAR "test" 'TEST_JAR=$(build_jar test:package target/scala-2.11 /dotty.*-tests\.jar/p)' |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,11 +8,25 @@ fi | |
DOTTY_ROOT="$(dirname "$DOTTY_ROOT")" | ||
DOTTY_ROOT="$( cd "$DOTTY_ROOT" >& /dev/null && pwd )/.." # absolute | ||
|
||
# CLASS_PATH is derived from the DOTTY_ROOT | ||
CLASS_PATH="-J-Xbootclasspath/a:.:$DOTTY_ROOT/target/scala-2.11/classes/" | ||
# Load common functions and variables | ||
source $DOTTY_ROOT/bin/common | ||
|
||
# CLASS_PATH is derived from the DOTTY_ROOT and SCALA_LIBRARY_JAR | ||
CLASS_PATH="-Xbootclasspath/a:.:$DOTTY_ROOT/target/scala-2.11/classes/:.:$SCALA_LIBRARY_JAR" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SCALA_BINARY_VERSION instead of 2.11. |
||
|
||
function runMain { | ||
scala $CLASS_PATH $@ | ||
local jbin=$(which "java") | ||
|
||
if [ ! -z "$JAVA_BIN" ]; then | ||
jbin=$JAVA_BIN | ||
fi | ||
|
||
if [ "$jbin" == "" ]; then | ||
echo "java bin not detected - please specify with \$JAVA_BIN or install java to a default location" | ||
exit 1 | ||
else | ||
eval "$jbin $CLASS_PATH $@" | ||
fi | ||
} | ||
|
||
if [ -z "$1" ]; then | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we get it from
sbt
config?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes