33Phobos V3 Build Script
44
55Usage:
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]
710*/
811
912import std.conv ;
@@ -18,12 +21,23 @@ int main(string[] args)
1821{
1922 int result = 0 ;
2023
24+ immutable compiler = environment.get (" DMD" , " dmd" ).buildNormalizedPath();
25+
2126 bool buildUnittest = false ;
2227 bool buildRelease = false ;
23- if (args.length > 1 )
28+
29+ if (args.length > 1 )
2430 {
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+ }
2741 }
2842
2943 string argFilePath = buildNormalizedPath(getcwd(), " phobosbuildargs.txt" );
@@ -47,7 +61,7 @@ int main(string[] args)
4761 if (exists(unittestExecutable)) remove(unittestExecutable);
4862 }
4963
50- result = runCommand(" dmd --version" , getcwd());
64+ result = runCommand(format( " %s --version" , compiler) , getcwd());
5165 if (result != 0 )
5266 {
5367 writeln(" Compiler Failure." );
@@ -69,7 +83,6 @@ int main(string[] args)
6983 {
7084 argFile.writeln(" -main" );
7185 argFile.writeln(" -unittest" );
72- argFile.writeln(" -debug" );
7386
7487 version (Windows )
7588 {
@@ -80,24 +93,19 @@ int main(string[] args)
8093 argFile.writeln(" -of=unittest" );
8194 }
8295 }
83- else if (buildRelease)
84- {
85- argFile.writeln(" -release -O" );
86- argFile.writeln(" -lib" );
87- argFile.writeln(" -of=libphobos3" );
88- }
8996 else
9097 {
91- argFile.writeln(" -debug" );
9298 argFile.writeln(" -lib" );
93- argFile.writeln (" -of=libphobos3-debug" );
99+ argFile.writefln (" -of=libphobos3%s " , buildRelease ? " " : " -debug" );
94100 }
95101
102+ argFile.writeln(buildRelease ? " -release -O" : " -debug" );
103+
96104 argFile.flush();
97105 argFile.close();
98106
99107 // Run the build.
100- result = runCommand(" dmd @ \" " ~ argFilePath ~ " \" " , getcwd());
108+ result = runCommand(format( ` %s @"%s" ` , compiler, argFilePath) , getcwd());
101109 if (result != 0 )
102110 {
103111 writeln(" Build failed." );
0 commit comments