3
3
Phobos V3 Build Script
4
4
5
5
Usage:
6
- ./build_v3.d [debug,release,unittest]
6
+ ./build_v3.d [debug|release|unittest|unittest-debug|unittest-release]
7
+
8
+ Environment Variables:
9
+ DMD=[/path/to/compiler]
7
10
*/
8
11
9
12
import std.conv ;
@@ -18,12 +21,23 @@ int main(string[] args)
18
21
{
19
22
int result = 0 ;
20
23
24
+ immutable compiler = environment.get (" DMD" , " dmd" ).buildNormalizedPath();
25
+
21
26
bool buildUnittest = false ;
22
27
bool buildRelease = false ;
23
- if (args.length > 1 )
28
+
29
+ if (args.length > 1 )
24
30
{
25
- buildUnittest = args[1 ] == " unittest" ;
26
- buildRelease = args[1 ] == " release" ;
31
+ switch (args[1 ])
32
+ {
33
+ case " release" : buildRelease = true ; break ;
34
+ // This should be changed to run the tests in both debug and release
35
+ // modes, but that's a larger change.
36
+ case " unittest" : buildUnittest = true ; break ;
37
+ case " unittest-debug" : buildUnittest = true ; break ;
38
+ case " unittest-release" : buildUnittest = true ; goto case " release" ;
39
+ default : break ;
40
+ }
27
41
}
28
42
29
43
string argFilePath = buildNormalizedPath(getcwd(), " phobosbuildargs.txt" );
@@ -47,7 +61,7 @@ int main(string[] args)
47
61
if (exists(unittestExecutable)) remove(unittestExecutable);
48
62
}
49
63
50
- result = runCommand(" dmd --version" , getcwd());
64
+ result = runCommand(format( " %s --version" , compiler) , getcwd());
51
65
if (result != 0 )
52
66
{
53
67
writeln(" Compiler Failure." );
@@ -69,7 +83,6 @@ int main(string[] args)
69
83
{
70
84
argFile.writeln(" -main" );
71
85
argFile.writeln(" -unittest" );
72
- argFile.writeln(" -debug" );
73
86
74
87
version (Windows )
75
88
{
@@ -80,24 +93,19 @@ int main(string[] args)
80
93
argFile.writeln(" -of=unittest" );
81
94
}
82
95
}
83
- else if (buildRelease)
84
- {
85
- argFile.writeln(" -release -O" );
86
- argFile.writeln(" -lib" );
87
- argFile.writeln(" -of=libphobos3" );
88
- }
89
96
else
90
97
{
91
- argFile.writeln(" -debug" );
92
98
argFile.writeln(" -lib" );
93
- argFile.writeln (" -of=libphobos3-debug" );
99
+ argFile.writefln (" -of=libphobos3%s " , buildRelease ? " " : " -debug" );
94
100
}
95
101
102
+ argFile.writeln(buildRelease ? " -release -O" : " -debug" );
103
+
96
104
argFile.flush();
97
105
argFile.close();
98
106
99
107
// Run the build.
100
- result = runCommand(" dmd @ \" " ~ argFilePath ~ " \" " , getcwd());
108
+ result = runCommand(format( ` %s @"%s" ` , compiler, argFilePath) , getcwd());
101
109
if (result != 0 )
102
110
{
103
111
writeln(" Build failed." );
0 commit comments