summaryrefslogtreecommitdiff
path: root/OMakefile
blob: 29f0616480f16dbc7212cacd408f8ad9d84d6c45 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
######################################################################

# If you aren't running on a LAMP system, you need to make sure you 
# have JAVA_HOME and JAVACMD (and optionally JAVAC) set correctly.
JAVA_HOME = $(getenv JAVA_HOME,  /home/linuxsoft/apps/java-1.6/)
JAVACMD = $(getenv JAVACMD, $(JAVA_HOME)$(DIRSEP)bin$(DIRSEP)java)
JAVAC = $(getenv JAVAC, $(JAVA_HOME)$(DIRSEP)bin$(DIRSEP)javac)
JAVAP = $(JAVA_HOME)$(DIRSEP)bin$(DIRSEP)javap

# Default options for the JVM
JAVA_OPTS = $(getenv JAVA_OPTS, -Xms1024M -Xmx1024M -XX:MaxPermSize=256M)

DIFF=diff
DIFF_OPTS=-r

######################################################################

# The current copyright string
COPYRIGHT_STRING = Copyright 2002-2009, LAMP/EPFL
# Need to generate this correctly
VERSION_NUMBER = 2.7.2

# The directory where the STARR is kept
LIB_DIR = .$(DIRSEP)lib
# The directory where we store the built files
BUILD_DIR = .$(DIRSEP)build
# The directory where the locker files are kept
LOCKER_DIR = $(BUILD_DIR)$(DIRSEP)locker
LOCKER_CLASS_DIR = $(LOCKER_DIR)$(DIRSEP)classes
# The directory where the quick files are kept
QUICK_DIR = $(BUILD_DIR)$(DIRSEP)quick
QUICK_CLASS_DIR = $(QUICK_DIR)$(DIRSEP)classes
# The directory where the strap files are kept
STRAP_DIR = $(BUILD_DIR)$(DIRSEP)strap
STRAP_CLASS_DIR = $(STRAP_DIR)$(DIRSEP)classes

# Scala compiler class
SCALAC_CLASS = scala.tools.nsc.Main

# The Partest class
PARTEST_CLASS = scala.tools.partest.nest.NestRunner

# Arguments used to configure which tests are run
PARTEST_ARGS = --pos --neg --run --jvm --jvm5 --res --shootout

######################################################################

# CLASSPATHs for the various build modes
COMMON_CLASSPATH = $(addprefix $(LIB_DIR)$(DIRSEP), jline.jar msil.jar fjbg.jar)

STARR_CLASSPATH = $(array $(addprefix $(LIB_DIR)$(DIRSEP), scala-library.jar scala-compiler.jar) $(COMMON_CLASSPATH))
# Debugging remove
#println($(string $(STARR_CLASSPATH)))
LOCKER_CLASSPATH = $(array $(addprefix $(LOCKER_CLASS_DIR)$(DIRSEP), compiler library) $(COMMON_CLASSPATH))
QUICK_CLASSPATH = $(array $(addprefix $(QUICK_CLASS_DIR)$(DIRSEP), compiler library partest) $(COMMON_CLASSPATH))
STRAP_CLASSPATH = $(array $(addprefix $(STRAP_CLASS_DIR)$(DIRSEP), compiler library partest) $(COMMON_CLASSPATH))

######################################################################

# Helper functions

# Convert a sequence to a path by concatenating it together with
# the appropriate separator for the current platform
topath(seq) =
  return $(concat $(PATHSEP), $(seq))

# Create an empty file
touch(file) =
  close($(fopen $(file), w))

# "idempotent-mkdir", create a directory if it doesn't already exist
idem-mkdir(dir) =
  if $(not $(file-exists $(dir)))
    # println(Creating directory $(dir))
    mkdir(-p $(dir))

# compare two classes using javap 
javap-diff(cpath1, cpath2, cls) =
  tmp1 = $(tmpfile javap1, .txt)
  tmp2 = $(tmpfile javap2, .txt)
  $(JAVAP) -classpath $(cpath1) -private $(cls) > $(tmp1)
  $(JAVAP) -classpath $(cpath2) -private $(cls) > $(tmp2)
  ($(DIFF) $(tmp1) $(tmp2)) || echo $(cls) is different in $(cpath1) and $(cpath2)

# Write a property file
propfile(file) =
  handle = $(fopen $(file), w)
  # Need to correctly generated date/time
  fprint($(handle), \# Generated at some time\n)
  fprint($(handle), copyright.string=$(COPYRIGHT_STRING)\n)
  fprint($(handle), version.number=$(VERSION_NUMBER)\n)
  close($(handle))

# Compile the Scala files in the sequence args with the specified
# classpath, placing the generated class files in the directory outdir
scalac(classpath, outdir, args) =
  # println(scalac compiling $(string $(args)))
  $(JAVACMD) -cp $(topath $(classpath)) $(JAVA_OPTS) $(SCALAC_CLASS) -d $(outdir) $(args)

# Compile the Java files in the sequence args with the specified 
# classpath, placing the generated class files in the directory outdir
javac(classpath, outdir, args) =
  # println(javac compiling $(string $(args)))
  $(JAVAC) -cp $(topath $(classpath)) -d $(outdir) $(args)

# Build an instance of the Scala compiler and libraries using 
# the compiler in the specified classpath as the bootstrap 
# compiler, and placing the result in the directory outdir
buildscala(classpath, outdir) =
  idem-mkdir($(outdir)$(DIRSEP)classes$(DIRSEP)compiler)
  scalac($(classpath), $(outdir)$(DIRSEP)classes$(DIRSEP)compiler, \
    $(find ./src/compiler/scala/tools/nsc -name *.scala) $(find ./src/compiler/scala/tools/util -name *.scala))
  propfile($(outdir)$(DIRSEP)classes$(DIRSEP)compiler$(DIRSEP)compiler.properties)
  # For compatibility with the old ant script we'll create a flag 
  # touch($(outdir)$(DIRSEP)compiler.complete)
  idem-mkdir($(outdir)$(DIRSEP)classes$(DIRSEP)library)
  javac($(classpath), $(outdir)$(DIRSEP)classes$(DIRSEP)library, \
    $(find ./src/library -name *.java) $(find ./src/actors -name *.java))
  scalac($(classpath), $(outdir)$(DIRSEP)classes$(DIRSEP)library, \
    $(find ./src/library -name *.scala) \
    $(find ./src/dbc -name *.scala) \
    $(find ./src/swing -name *.scala) \
    $(find ./src/actors -name *.scala))
  # Need to copy over script.js and style.css for scaladoc to find them
  cp($(addprefix ./src/compiler/scala/tools/nsc/doc/,script.js style.css) \
    $(outdir)$(DIRSEP)classes$(DIRSEP)compiler$(DIRSEP)scala$(DIRSEP)tools$(DIRSEP)nsc$(DIRSEP)doc)
  propfile($(outdir)$(DIRSEP)classes$(DIRSEP)library$(DIRSEP)library.properties)
  # For compatibility with the old ant script we'll create some flags
  touch($(outdir)$(DIRSEP)library.complete)
  # touch($(outdir)$(DIRSEP)all.complete)

# Run partest with respect to the specified classpath
partest(classpath) =
  # println(testing)
  $(JAVACMD) -cp $(topath $(classpath)) $(JAVA_OPTS) \
    $(PARTEST_CLASS) --classpath $(QUICK_CLASS_DIR) --show-diff $(PARTEST_ARGS)

######################################################################

# Specify those targets that are "phony", as in, they do not
# correspond to actual files that will be created.

.PHONY : locker quick partest test clean all.clean locker.clean strap stability

# Specify the default target
.DEFAULT : test

######################################################################

# Just clean out the quick build
clean :
  $(rm -rf $(QUICK_DIR))

# Just clean out the locker
locker.clean :
  $(rm -rf $(LOCKER_DIR))

# Clean up everything
all.clean :
  $(rm -rf $(BUILD_DIR))

######################################################################

locker $(LOCKER_DIR) :
  buildscala($(STARR_CLASSPATH), $(LOCKER_DIR))

quick $(QUICK_DIR) : $(LOCKER_DIR)
  buildscala($(LOCKER_CLASSPATH), $(QUICK_DIR))

strap $(STRAP_DIR) : $(QUICK_DIR)
  buildscala($(QUICK_CLASSPATH), $(STRAP_DIR))

test.stability : $(STRAP_DIR)
#  javap-diff($(QUICK_CLASS_DIR)/library, $(STRAP_CLASS_DIR)/library, "scala.swing.Key")
  $(DIFF) $(DIFF_OPTS) $(QUICK_CLASS_DIR) $(STRAP_CLASS_DIR)

partest : quick
  idem-mkdir($(QUICK_CLASS_DIR)$(DIRSEP)partest)
  javac($(LOCKER_CLASSPATH), $(QUICK_CLASS_DIR)$(DIRSEP)partest, \
    $(find ./src/partest/scala -name *.java))
  scalac($(LOCKER_CLASSPATH), $(QUICK_CLASS_DIR)$(DIRSEP)partest, \
    $(filter-out %PartestTask.scala %AntRunner.scala, $(find ./src/partest/scala -name *.scala)))
  # For compatibility with the old ant script we'll create a flag
  # touch($(QUICK_DIR)$(DIRSEP)partest.complete)

test : partest
  partest($(QUICK_CLASSPATH))