Mercurial > projects > doodle
view configure.d @ 129:10ad5417bf07
Checkpoint
author | David Bryant <bagnose@gmail.com> |
---|---|
date | Thu, 12 Jan 2012 16:42:16 +1030 |
parents | 1da160a2c373 |
children | 5920bb2ddd0f bc5baa585b32 |
line wrap: on
line source
// Configure script, to be run with rdmd. // // Checks dependencies, sets up a build directory, builds // a local copy of the builder into the build directory, // and puts assorted scripts into the build directory to // facilitate building. // // If your project depends on installed libraries, you need to // add an options file containing command-line options such as: // -L-lgtkd // You also need to install the libraries somewhere that the compiler // can find them. Two simple options are: // * In the dmd installation directory, or // * Elsewhere, and edit dmd.conf to point to there. // // // The source paths you depend on need to be listed in a uses file. // Uses files are not transitive - only the one in the directory // you execute the configure script applies. // // Usage: rdmd configure.d <target-path> // // eg: rdmd configure.d ~/builds/myproject // import std.stdio; import std.path; import std.file; import std.string; import std.stdio; import std.process; int main(string[] args) { string sourcePath = getcwd; // parse command-line options if (args.length < 2) { writefln("Error - usage is: rdmd <configure.d-path> <build-path>"); return -1; } string targetPath = args[1]; // check that source_path looks like a source tree by making sure // that a README and options file are present writefln("Examining source"); if (!std.path.join(sourcePath, "README").exists || !std.path.join(sourcePath, "options").exists) { writefln("Error - current directory must contain README and options"); return -1; } // ensure that target_path exists writefln("Establishing build directory"); if (targetPath.exists) { writefln("Error - %s exists - abandoning configure", targetPath); return -1; } targetPath.mkdirRecurse; string binPath = std.path.join(targetPath, "bin"); binPath.mkdir; // compile builder into bin_path writefln("Building the builder"); int ret = system(format("dmd -m32 -w -wi %s -O -of%s", std.path.join(sourcePath, "builder.d"), std.path.join(binPath, "builder"))); if (ret) { writefln("Error - builder failed to compile"); return -1; } std.path.join(binPath, "builder.o").remove; // set up scripts { auto file = File(std.path.join(targetPath, "build"), "w"); file.writefln("#!/bin/bash"); file.writefln("%s %s %s", std.path.join(binPath, "builder"), sourcePath, targetPath); } system("chmod +x " ~ std.path.join(targetPath, "build")); writefln("All done"); return 0; }