forked from scalation/scalation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Build.scala
156 lines (143 loc) · 5.85 KB
/
Build.scala
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
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
/** @author John Miller
* @version 1.0
* @date Mon Dec 21 15:14:59 EST 2009
* @see LICENSE (MIT style license file).
*/
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
/** This object is used to build the scalation Scala-based Simulation System.
* Comment out lines using // for customized builds. To build the complete
* scalation system, type the following two commands:
* > scalac Build.scala
* > scala Build
* Check the file called 'errorlog' for errors generated by any of the
* build functions. Note, this Build object may be replaced with the
* Simple Build Tool (sbt) in the future.
*/
object Build extends App
{
private val base_dir = ""
private val source_dir = base_dir + "src"
private val class_dir = base_dir + "classes"
private val doc_dir = base_dir + "doc"
private val ex_dir = base_dir + "examples"
private val runsys = Runtime.getRuntime ()
private var command = Array ("")
/** The packages making up scalation -- comment out (//) for selective builds
*/
private val packages = Array ("scalation/util",
"scalation/math",
"scalation/linalgebra",
"scalation/linalgebra_gen",
"scalation/calculus",
"scalation/random",
"scalation/stat",
"scalation/scala2d",
"scalation/plot",
"scalation",
"scalation/animation",
"scalation/minima",
"scalation/maxima",
"scalation/analytics",
"scalation/metamodel",
"scalation/queueingnet",
"scalation/dynamics",
"scalation/activity",
"scalation/event",
"scalation/process",
"scalation/state")
/** The example simulation models -- comment out (//) for selective builds
*/
private val examples = Array ("dynamics",
"activity",
"event",
"montecarlo",
"process",
"state",
"analytics",
"simopt",
"game")
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
/** Clear the error log. The errorlog file shows errors generated any of the
* build functions shown below.
*/
def clearlog
{
command = Array ("/bin/sh", "-c", "/bin/date > errorlog")
runsys.exec(command)
println (command.deep)
} // clearlog
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
/** Start a clean build by removing all old .class files.
*/
def clean
{
for (p <- packages) {
command = Array ("/bin/sh", "-c", "/bin/rm " + class_dir + "/" + p + "/*.class")
runsys.exec(command)
println (command.deep)
} // for
} // clean
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
/** Compile the source files (.scala) for all the packages in scalation.
*/
def compile
{
for (p <- packages) {
command = Array ("/bin/sh", "-c", "scalac -cp " + class_dir + " -d " + class_dir + " " +
source_dir + "/" + p + "/*.scala" + " 2>> errorlog")
val cmd = Array ("/bin/sh", "-c", "echo ----- " + p + " >> errorlog")
println (cmd.deep)
val proccmd = runsys.exec (cmd)
proccmd.waitFor ()
val proc = runsys.exec (command)
proc.waitFor ()
println (command.deep)
} // for
} // compile
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
/** Compile the source files (.scala) for all the example models.
*/
def compileEx
{
for (e <- examples) {
val ex = ex_dir + "/" + e
command = Array ("/bin/sh", "-c", "scalac -cp " + class_dir + " -d " + ex + "/classes " +
ex + "/*.scala" + " 2>> errorlog")
val proc = runsys.exec (command)
proc.waitFor ()
println (command.deep)
} // for
} // compileEx
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
/** Generate scaladoc files for all the scalation packages.
*/
def doc
{
command = Array ("/bin/sh", "-c", "scaladoc -J-mx1024m -cp classes -d " + doc_dir + " " +
source_dir + "/" + "scalation/*/*.scala" + " 2>> errorlog")
val proc = runsys.exec (command)
proc.waitFor ()
println (command.deep)
} // doc
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
/** Generate index.html for browsing the source code.
*/
def genIndexHtml
{
command = Array ("/bin/sh", "-c", "scala -cp " + class_dir +
" scalation.util.GenIndexHtml 2>> errorlog")
val proc = runsys.exec (command)
proc.waitFor ()
println (command.deep)
} // genIndexHtml
// select build functions by moving the comment delimiters (/***, ***/)
clearlog
clean
compile
compileEx
genIndexHtml
doc
/***
***/
} // Build