10
10
DOTTY_ROOT=" $( dirname " $DOTTY_ROOT " ) "
11
11
DOTTY_ROOT=" $( cd " $DOTTY_ROOT " >& /dev/null && pwd ) /.." # absolute
12
12
13
- # Finds in dotty build file a line containing PATTERN
14
- # returns last "" escaped string in this line
15
- function getLastStringOnLineWith {
16
- PATTERN=" $1 "
17
- grep " $PATTERN " " $DOTTY_ROOT /project/Build.scala" | sed -n ' s/.*\"\(.*\)\".*/\1/' p
18
- }
19
-
20
- # Configuration
21
- SCALA_VERSION=$( getLastStringOnLineWith " scalaVersion in" )
22
- SCALA_BINARY_VERSION=2.11
23
- SCALA_COMPILER_VERSION=$( getLastStringOnLineWith " scala-compiler" )
24
- JLINE_VERSION=$( getLastStringOnLineWith " jline" )
25
- SBT_VERSION=$( grep " sbt.version=" " $DOTTY_ROOT /project/build.properties" | sed ' s/sbt.version=//' )
26
- bootcp=true
27
- bootstrapped=false
28
- default_java_opts=" -Xmx768m -Xms768m"
29
- programName=$( basename " $0 " )
30
- # uncomment next line to enable debug output
31
- # debug=true
32
-
33
- declare -a java_args scala_args residual_args
34
- unset verbose quiet cygwin toolcp colors saved_stty CDPATH
35
-
36
- function build_jar {
37
- # Usage:
38
- # build_jar package path/to/jar/dir ['/some/sed/command']
39
- #
40
- # Last arg is optional
41
- cd $DOTTY_ROOT >& /dev/null
42
- local build_output=$( sbt " $1 " )
43
- local jar=$( echo $build_output | sed -n ' s/.*Packaging //g; s/ \.\.\..*//g; /^\/.*/p' )
44
-
45
- local sedjar=" $3 "
46
- if [ " $sedjar " == " " ]; then
47
- sedjar=" /.*\.jar/p"
48
- fi
49
-
50
- if [ " $jar " == " " ]; then
51
- # Didn't build a jar - could've run sbt by oneself, get latest jar in target:
52
- jar=" $DOTTY_ROOT /$2 /$( ls -1t " $2 " | sed -n " $sedjar " | awk ' NR==1' ) "
53
- fi
54
-
55
- cd - >& /dev/null
56
-
57
- echo $jar
58
- }
59
-
60
- function update_packages {
61
- echo " $INTERFACES_JAR " > $DOTTY_ROOT /.packages
62
- echo " $MAIN_JAR " >> $DOTTY_ROOT /.packages
63
- echo " $TEST_JAR " >> $DOTTY_ROOT /.packages
64
- }
65
-
66
- function build_all {
67
- echo " The script is going to build the required jar files"
68
-
69
- printf " Building dotty-interfaces..."
70
- INTERFACES_JAR=$( build_jar dotty-interfaces/package interfaces/target)
71
- printf " done\n"
72
-
73
- printf " Building dotty..."
74
- MAIN_JAR=$( build_jar package target/scala-2.11)
75
- printf " done\n"
76
-
77
- printf " Building tests..."
78
- TEST_JAR=$( build_jar test:package target/scala-2.11 ' /dotty.*-tests\.jar/p' )
79
- printf " done\n"
80
-
81
- update_packages
82
- }
83
-
84
-
85
- # Check if .packages file does not exist - if so assume old build and rebuild all
86
- if [ ! -f " $DOTTY_ROOT /.packages" ]; then
87
- build_all
88
- else
89
- IFS=$' \r\n ' GLOBIGNORE=' *' command eval ' JARS=($(cat $DOTTY_ROOT/.packages))'
90
-
91
- if [ " ${# JARS[@]} " == " 3" ]; then
92
- INTERFACES_JAR=" ${JARS[0]} "
93
- MAIN_JAR=" ${JARS[1]} "
94
- TEST_JAR=" ${JARS[2]} "
95
- else
96
- echo " Corrupted .packages file"
97
- build_all
98
- fi
99
- fi
100
-
101
- # ################ After this point, jar variables will be set #################
102
- function check_jar {
103
- # Usage:
104
- # check_jar "name" "path/to/package.jar" "sources/dir" 'lambda to exec on failure'
105
- local new_files=" $( find " $3 " \( -iname " *.scala" -o -iname " *.java" \) -newer " $2 " ) "
106
- if [ ! -z " $new_files " ]; then
107
- printf " New files detected in $1 , rebuilding..."
108
- eval " $4 "
109
- printf " done\n"
110
- update_packages
111
- fi
112
- }
113
-
114
- check_jar " dotty-interfaces" $INTERFACES_JAR " interfaces" ' INTERFACES_JAR=$(build_jar dotty-interfaces/package interfaces/target)'
115
- check_jar " dotty" $MAIN_JAR " src" ' MAIN_JAR=$(build_jar package target/scala-2.11)'
116
- check_jar " dotty-tests" $TEST_JAR " test" ' TEST_JAR=$(build_jar test:package target/scala-2.11 /dotty.*-tests\.jar/p)'
13
+ source $DOTTY_ROOT /bin/common
117
14
118
15
# dotc.build test places bootstrapped jar here
119
16
DOTTY_JAR=$DOTTY_ROOT /dotty.jar
@@ -122,39 +19,6 @@ CompilerMain=dotty.tools.dotc.Main
122
19
FromTasty=dotty.tools.dotc.FromTasty
123
20
ReplMain=dotty.tools.dotc.repl.Main
124
21
125
- function find_jar {
126
- # Usage:
127
- # find_jar path/to/location file.jar
128
- local artifact=" $1 /$2 "
129
-
130
- if [ ! -f " $artifact " ]; then
131
- artifact=$( find " $HOME /.coursier/cache" -iname " $2 " )
132
- fi
133
-
134
- echo " $artifact "
135
- }
136
-
137
- # Autodetecting the scala-library location, in case it wasn't provided by an environment variable
138
- if [ " $SCALA_LIBRARY_JAR " == " " ]; then
139
- SCALA_LIBRARY_JAR=$( find_jar " $HOME /.ivy2/cache/org.scala-lang/scala-library/jars" " scala-library-$SCALA_VERSION .jar" )
140
- fi
141
-
142
- if [ " $SCALA_REFLECT_JAR " == " " ]; then
143
- SCALA_REFLECT_JAR=$( find_jar " $HOME /.ivy2/cache/org.scala-lang/scala-reflect/jars" " scala-reflect-$SCALA_VERSION .jar" )
144
- fi
145
-
146
- if [ " $SCALA_COMPILER_JAR " == " " ]; then
147
- SCALA_COMPILER_JAR=$( find_jar " $HOME /.ivy2/cache/me.d-d/scala-compiler/jars" " scala-compiler-$SCALA_COMPILER_VERSION .jar" )
148
- fi
149
-
150
- if [ " $JLINE_JAR " == " " ]; then
151
- JLINE_JAR=$( find_jar " $HOME /.ivy2/cache/jline/jline/jars" " jline-$JLINE_VERSION .jar" )
152
- fi
153
-
154
- if [ " $SBT_INTERFACE_JAR " == " " ]; then
155
- SBT_INTERFACE_JAR=$( find_jar " $HOME /.ivy2/cache/org.scala-sbt/interface/jars" " interface-$SBT_VERSION .jar" )
156
- fi
157
-
158
22
if [ ! -f " $SCALA_LIBRARY_JAR " -o ! -f " $SCALA_REFLECT_JAR " -o ! -f " $SCALA_COMPILER_JAR " -o ! -f " $JLINE_JAR " -o ! -f " $SBT_INTERFACE_JAR " ]
159
23
then
160
24
echo To use this script please set
0 commit comments