Mercurial > projects > doodle
annotate configure.d @ 92:a98116479793
Removed GL support. Improved grid.
author | daveb |
---|---|
date | Fri, 20 Aug 2010 18:34:32 +0930 |
parents | 6c3993f4c3eb |
children | 0d427170a805 |
rev | line source |
---|---|
28
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
1 // Configure script, to be run with rdmd. |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
2 // |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
3 // Checks dependencies, sets up a build directory, builds |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
4 // a local copy of the builder into the build directory, |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
5 // and puts assorted scripts into the build directory to |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
6 // facilitate building. |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
7 // |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
8 // If your project depends on installed libraries, you need to |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
9 // add an options file containing command-line options such as: |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
10 // -L-lgtkd |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
11 // You also need to install the libraries somewhere that the compiler |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
12 // can find them. Two simple options are: |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
13 // * In the dmd installation directory, or |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
14 // * Elsewhere, and edit dmd.conf to point to there. |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
15 // |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
16 // |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
17 // The source paths you depend on need to be listed in a uses file. |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
18 // Uses files are not transitive - only the one in the directory |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
19 // you execute the configure script applies. |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
20 // |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
21 // Usage: rdmd configure.d <target-path> |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
22 // |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
23 // eg: rdmd configure.d ~/builds/myproject |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
24 // |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
25 |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
26 |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
27 import std.stdio; |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
28 import std.path; |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
29 import std.file; |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
30 import std.string; |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
31 import std.stdio; |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
32 import std.process; |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
33 |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
34 |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
35 int main(string[] args) { |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
36 |
59 | 37 string sourcePath = getcwd; |
28
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
38 |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
39 // parse command-line options |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
40 if (args.length < 2) { |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
41 writefln("Error - usage is: rdmd <configure.d-path> <build-path>"); |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
42 return -1; |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
43 } |
59 | 44 string targetPath = args[1]; |
28
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
45 |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
46 // check that source_path looks like a source tree by making sure |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
47 // that a README and options file are present |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
48 writefln("Examining source"); |
59 | 49 if (!sourcePath.join("README").exists || !sourcePath.join("options").exists) { |
28
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
50 writefln("Error - current directory must contain README and options"); |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
51 return -1; |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
52 } |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
53 |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
54 // ensure that target_path exists |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
55 writefln("Establishing build directory"); |
59 | 56 if (targetPath.exists) { |
57 writefln("Error - %s exists - abandoning configure", targetPath); | |
28
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
58 return -1; |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
59 } |
59 | 60 targetPath.mkdirRecurse; |
61 string binPath = targetPath.join("bin"); | |
62 binPath.mkdir; | |
28
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
63 |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
64 // compile builder into bin_path |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
65 writefln("Building the builder"); |
43 | 66 int ret = system(format("dmd -w -wi %s -O -of%s", |
59 | 67 sourcePath.join("builder.d"), binPath.join("builder"))); |
28
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
68 if (ret) { |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
69 writefln("Error - builder failed to compile"); |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
70 return -1; |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
71 } |
59 | 72 binPath.join("builder.o").remove; |
28
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
73 |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
74 // set up scripts |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
75 { |
59 | 76 auto file = File(targetPath.join("build"), "w"); |
28
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
77 file.writefln("#!/bin/bash"); |
59 | 78 file.writefln("%s %s %s", binPath.join("builder"), sourcePath, targetPath); |
28
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
79 } |
59 | 80 system("chmod +x " ~ targetPath.join("build")); |
28
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
81 writefln("All done"); |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
82 |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
83 return 0; |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
diff
changeset
|
84 } |