Skip to content

Commit

Permalink
Cleanup some build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
tlrobinson committed Dec 19, 2009
1 parent deed92c commit bab0024
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 30 deletions.
16 changes: 8 additions & 8 deletions Jakefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ task ("install", ["CommonJS"], function()
{
// FIXME: require("narwhal/tusk/install").install({}, $COMMONJS);
// Doesn't work due to some weird this.print business.
OS.system("sudo tusk install --force " + $BUILD_CJS_OBJECTIVE_J + " " + $BUILD_CJS_CAPPUCCINO);
OS.system(["sudo", "tusk", "install", "--force", $BUILD_CJS_OBJECTIVE_J, $BUILD_CJS_CAPPUCCINO]);
});

// Documentation
Expand All @@ -61,7 +61,7 @@ task ("documentation", function()
{
if (executableExists("doxygen"))
{
if (OS.system("doxygen " + FILE.join("Tools", "Documentation", "Cappuccino.doxygen")))
if (OS.system(["doxygen", FILE.join("Tools", "Documentation", "Cappuccino.doxygen")]))
OS.exit(1); //rake abort if ($? != 0)

rm_rf($DOCUMENTATION_BUILD);
Expand Down Expand Up @@ -95,7 +95,7 @@ filedir ($STARTER_DOWNLOAD_APPLICATION, ["CommonJS"], function()
rm_rf($STARTER_DOWNLOAD_APPLICATION);
FILE.mkdirs($STARTER_DOWNLOAD);

if (OS.system("capp gen " + $STARTER_DOWNLOAD_APPLICATION + " -t Application --noconfig"))
if (OS.system(["capp", "gen", $STARTER_DOWNLOAD_APPLICATION, "-t", "Application", "--noconfig"]))
// FIXME: uncomment this: we get conversion errors
//OS.exit(1); // rake abort if ($? != 0)
{}
Expand Down Expand Up @@ -161,13 +161,14 @@ task ("deploy", ["downloads"], function()

// Testing

task ("test", ["build"], function()
task("test", ["build", "test-only"]);

task("test-only", function()
{
var tests = new FileList('Tests/**/*Test.j');
var cmd = ["ojtest"].concat(tests.items());
var cmdString = cmd.map(OS.enquote).join(" ");

var code = OS.system(cmdString);
var code = OS.system(cmd);
if (code !== 0)
OS.exit(code);
});
Expand Down Expand Up @@ -198,8 +199,7 @@ function pushPackage(path, remote)
["git", "push", "origin", "master"]
];

var cmdString = cmds.map(function(cmd)
{
var cmdString = cmds.map(function(cmd) {
return cmd.map(OS.enquote).join(" ");
}).join(" && ");

Expand Down
69 changes: 51 additions & 18 deletions Objective-J/Jakefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,32 @@ require("../common.jake");

$BUILD_OBJECTIVE_J = FILE.join($BUILD_CONFIGURATION_DIR, "Objective-J");

Files = new FileList("Runtime/constants.js", "Runtime/utilities.js", "Runtime/json2.js", "Runtime/runtime.js", "Runtime/dictionary.js", "Runtime/plist.js", "Runtime/file.js", "Runtime/exception.js", "Runtime/preprocess.js", "Runtime/evaluate.js", "Runtime/bootstrap.js");
var OBJECTIVE_J_FILES = new FileList(
"Runtime/constants.js",
"Runtime/utilities.js",
"Runtime/json2.js",
"Runtime/runtime.js",
"Runtime/dictionary.js",
"Runtime/plist.js",
"Runtime/file.js",
"Runtime/exception.js",
"Runtime/preprocess.js",
"Runtime/evaluate.js",
"Runtime/bootstrap.js"
);

if ($CONFIGURATION === "Debug")
Files.include("Runtime/debug.js");
OBJECTIVE_J_FILES.include("Runtime/debug.js");

$BUILD_BROWSER_FILE = FILE.join($BUILD_OBJECTIVE_J, "Objective-J.js");
$BUILD_CJS_FILE = FILE.join($BUILD_OBJECTIVE_J, "CommonJS.environment", "Objective-J.js");

filedir ($BUILD_BROWSER_FILE, Files, function(aTask)
filedir($BUILD_BROWSER_FILE, OBJECTIVE_J_FILES, function(aTask)
{
build_product(aTask.name(), environmentFlags("ObjJ") + " -DPLATFORM_USERAGENT");
});

filedir ($BUILD_CJS_FILE, Files, function(aTask)
filedir($BUILD_CJS_FILE, OBJECTIVE_J_FILES, function(aTask)
{
flags = environmentFlags("CommonJS", "ObjJ");
flags += ' -DRHINO'
Expand All @@ -52,7 +64,7 @@ filedir ($BUILD_CJS_FILE, Files, function(aTask)
$LICENSE = FILE.join("CommonJS", "lib", "objective-j", "jake", "LICENSES", "LGPL-v2.1");
$BUILD_LICENSE = FILE.join($BUILD_OBJECTIVE_J, "LICENSE");

filedir ($BUILD_LICENSE, [$LICENSE], function()
filedir($BUILD_LICENSE, [$LICENSE], function()
{
FILE.copy($LICENSE, $BUILD_LICENSE);
});
Expand Down Expand Up @@ -83,7 +95,7 @@ new FileList("CommonJS/**/*").forEach(function(aFilename)

$BUILD_CJS_OBJECTIVE_J_FRAMEWORK = FILE.join($BUILD_CJS_OBJECTIVE_J, "Frameworks", "Objective-J");

filedir ($BUILD_CJS_OBJECTIVE_J_FRAMEWORK, function()
filedir($BUILD_CJS_OBJECTIVE_J_FRAMEWORK, function()
{
cp_r($BUILD_OBJECTIVE_J, $BUILD_CJS_OBJECTIVE_J_FRAMEWORK);
});
Expand All @@ -92,24 +104,45 @@ CLOBBER.include($BUILD_OBJECTIVE_J);

function environmentFlags()
{
return "-DENVIRONMENTS=\"[" + Array.prototype.map.apply(arguments, [function(anEnvironment)
{
return "-DENVIRONMENTS=\"[" + Array.prototype.map.apply(arguments, [function(anEnvironment) {
return "\\\"" + anEnvironment + "\\\"";
}]).join(", ") + "]\"";
}

function build_product(path, flags)
{
OS.system("cat Runtime/header.txt > " + OS.enquote(path));
OS.system("cat " +
Files.filter(function(aName)
{
return !!aName.match(/\.js$/);
}).map(function(aName)
{
return OS.enquote(aName);
}).join(' ') + " | gcc " + flags + " -E -x c -P - >> " + OS.enquote(path));
var sources = OBJECTIVE_J_FILES.filter(function(aName) { return !!aName.match(/\.js$/); });

var productOut = FILE.open(path, "w", { charset : "UTF-8" });

FILE.open("Runtime/header.txt", "r", { charset : "UTF-8" })
.copy(productOut)
.close();

var preprocessor = OS.popen("gcc " + flags + " -E -x c -P -");

sources.forEach(function(source) {
FILE.open(source, "r", { charset : "UTF-8" })
.copy(preprocessor.stdin)
.close();
});

preprocessor.stdin.close();
preprocessor.stdout.copy(productOut);

productOut.close();

var code = preprocessor.wait();

// this is equivalent to the above, but less cross platform:
//OS.system(["cp", "Runtime/header.txt", path]);
//var code = OS.system("cat " + sources.map(OS.enquote).join(' ') + " | gcc " + flags + " -E -x c -P - >> " + OS.enquote(path));

if (code !== 0) {
FILE.remove(path);
OS.exit(1);
}
// rake abort if ($? != 0)
}

task ("build", [$BUILD_BROWSER_FILE, $BUILD_CJS_FILE, $BUILD_LICENSE, $BUILD_CJS_OBJECTIVE_J_FRAMEWORK]);
task("build", [$BUILD_BROWSER_FILE, $BUILD_CJS_FILE, $BUILD_LICENSE, $BUILD_CJS_OBJECTIVE_J_FRAMEWORK]);
9 changes: 5 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/usr/bin/env ruby

print('
puts <<-eos
Building with rake is no longer supported, use "jake" instead.
The commands are all the same (e.g. rake install -> jake install).
If you do not have jake, you can run sudo ./bootstrap.sh to install it and its dependencies.
If you do not have jake, you can run sudo ./bootstrap.sh to install jake and it's dependencies.
PLEASE remove your Build folder ($CAPP_BUILD if it's set) when switching from rake to jake.
eos

PLEASE remove your Build folder when switching from rake to jake.
');
exit(1);
3 changes: 3 additions & 0 deletions common.jake
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ function partial_require(path, exports)
// FIXME: is there a better way to do this???
OS.system = function(aCommand)
{
if (Array.isArray(aCommand))
aCommand = aCommand.map(OS.enquote).join(" ");

return system("PATH=" + OS.enquote(bin) + ":$PATH " + aCommand);
}

Expand Down

0 comments on commit bab0024

Please sign in to comment.