diff --git a/AppKit/Tools/blend/main.j b/AppKit/Tools/blend/main.j index d441154e4b..4b6faf9cb4 100644 --- a/AppKit/Tools/blend/main.j +++ b/AppKit/Tools/blend/main.j @@ -294,5 +294,3 @@ function exec(/*Array*/ command, /*Boolean*/ showOutput) } @end - -main.apply(main, args); diff --git a/AppKit/Tools/blend/rakefile b/AppKit/Tools/blend/rakefile index dbffcf2a05..19afc0502f 100644 --- a/AppKit/Tools/blend/rakefile +++ b/AppKit/Tools/blend/rakefile @@ -34,5 +34,5 @@ file_d $ENVIRONMENT_BIN_PRODUCT do end file_d $ENVIRONMENT_LIB_PRODUCT => [:blend] do - cp_r($BUILD_PATH, $ENVIRONMENT_LIB_PRODUCT) + cp_r(File.join($BUILD_PATH, '.'), $ENVIRONMENT_LIB_PRODUCT) end diff --git a/Objective-J/Tools/objj/main.js b/Objective-J/Tools/objj/main.js index d4d1ba9d4e..99414de969 100644 --- a/Objective-J/Tools/objj/main.js +++ b/Objective-J/Tools/objj/main.js @@ -49,7 +49,7 @@ try if (debug) print("Loading: " + mainFilePath); - objj_import(mainFilePath, YES, function() { if (typeof main === "Function") main.apply(main, args); } ); + objj_import(mainFilePath, YES, function() { if (typeof main === "function") main.apply(main, args); } ); serviceTimeouts(); diff --git a/Tools/Rakefile b/Tools/Rakefile new file mode 100644 index 0000000000..05ee29aa5c --- /dev/null +++ b/Tools/Rakefile @@ -0,0 +1,15 @@ +#!/usr/bin/env ruby + +require 'rake' +require '../common' + + +subprojects = %w{capp nib2cib} + +%w(build clean).each do |task_name| + task task_name do + subrake(subprojects) + end +end + +#task :deploy => [:build] \ No newline at end of file diff --git a/Tools/Utilities/bridge.js b/Tools/Utilities/bridge.js index d86c724715..1306ef2c09 100644 --- a/Tools/Utilities/bridge.js +++ b/Tools/Utilities/bridge.js @@ -584,4 +584,86 @@ if (!OBJJ_HOME) { OBJJ_HOME = "/usr/local/share/objj"; alert("OBJJ_HOME environment variable not set, defaulting to " + OBJJ_HOME); -} \ No newline at end of file +} + +function exec(/*Array*/ command, /*Boolean*/ showOutput) +{ + var line = "", + output = "", + + process = Packages.java.lang.Runtime.getRuntime().exec(command),//jsArrayToJavaArray(command)); + reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(process.getInputStream())); + + while (line = reader.readLine()) + { + if (showOutput) + Packages.java.lang.System.out.println(line); + + output += line + '\n'; + } + + reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(process.getErrorStream())); + + while (line = reader.readLine()) + Packages.java.lang.System.out.println(line); + + try + { + if (process.waitFor() != 0) + Packages.java.lang.System.err.println("exit value = " + process.exitValue()); + } + catch (anException) + { + Packages.java.lang.System.err.println(anException); + } + + return output; +} + + +function getFiles(/*File*/ sourceDirectory, /*nil|String|Array*/ extensions, /*Array*/ exclusions) +{ + var matches = [], + files = sourceDirectory.listFiles(), + hasMultipleExtensions = typeof extensions !== "string"; + + if (files) + { + var index = 0, + count = files.length; + + for (; index < count; ++index) + { + var file = files[index].getCanonicalFile(), + name = String(file.getName()), + isValidExtension = !extensions; + + if (exclusions && fileArrayContainsFile(exclusions, file)) + continue; + + if (!isValidExtension) + if (hasMultipleExtensions) + { + var extensionCount = extensions.length; + + while (extensionCount-- && !isValidExtension) + { + var extension = extensions[extensionCount]; + + if (name.substring(name.length - extension.length - 1) === ("." + extension)) + isValidExtension = true; + } + } + else if (name.substring(name.length - extensions.length - 1) === ("." + extensions)) + isValidExtension = true; + + if (isValidExtension) + matches.push(file); + + if (file.isDirectory()) + matches = matches.concat(getFiles(file, extensions, exclusions)); + } + } + + return matches; +} diff --git a/Tools/capp/Rakefile b/Tools/capp/Rakefile new file mode 100644 index 0000000000..13f047fdf8 --- /dev/null +++ b/Tools/capp/Rakefile @@ -0,0 +1,38 @@ +#!/usr/bin/env ruby + +require 'rake' +require '../../common' +require 'objective-j' +require 'objective-j/bundletask' + + +$PRODUCT = :capp +$BUILD_PATH = File.join($BUILD_DIR, $CONFIGURATION, 'capp') +$ENVIRONMENT_BIN_PRODUCT = File.join($ENVIRONMENT_BIN_DIR, 'capp') +$ENVIRONMENT_LIB_PRODUCT = File.join($ENVIRONMENT_LIB_DIR, 'capp') + +task :build => [:capp, $ENVIRONMENT_BIN_PRODUCT, $ENVIRONMENT_LIB_PRODUCT] + +# Debug Framework +ObjectiveJ::BundleTask.new(:capp) do |t| + t.name = 'capp' + t.identifier = 'com.280n.capp' + t.version = '0.6.5' + t.author = '280 North, Inc.' + t.email = 'feedback @nospam@ 280north.com' + t.summary = 'Setup up Cappuccino projects' + t.sources = FileList['*.j'] + t.resources = FileList['Resources/*'] + t.license = ObjectiveJ::License::LGPL_v2_1 + t.build_path = $BUILD_PATH + t.flag = 'DEBUG' if $CONFIGURATION == 'Debug' +end + +#executable in environment directory +file_d $ENVIRONMENT_BIN_PRODUCT do + make_objj_executable($ENVIRONMENT_BIN_PRODUCT) +end + +file_d $ENVIRONMENT_LIB_PRODUCT => [:capp] do + cp_r(File.join($BUILD_PATH, '.'), $ENVIRONMENT_LIB_PRODUCT) +end diff --git a/Tools/steam/Templates/Application/AppController.j b/Tools/capp/Templates/Application/AppController.j similarity index 100% rename from Tools/steam/Templates/Application/AppController.j rename to Tools/capp/Templates/Application/AppController.j diff --git a/Tools/steam/Templates/Application/Info.plist b/Tools/capp/Templates/Application/Info.plist similarity index 100% rename from Tools/steam/Templates/Application/Info.plist rename to Tools/capp/Templates/Application/Info.plist diff --git a/Tools/steam/Templates/Application/index-debug.html b/Tools/capp/Templates/Application/index-debug.html similarity index 100% rename from Tools/steam/Templates/Application/index-debug.html rename to Tools/capp/Templates/Application/index-debug.html diff --git a/Tools/steam/Templates/Application/index.html b/Tools/capp/Templates/Application/index.html similarity index 100% rename from Tools/steam/Templates/Application/index.html rename to Tools/capp/Templates/Application/index.html diff --git a/Tools/steam/Templates/Application/main.j b/Tools/capp/Templates/Application/main.j similarity index 100% rename from Tools/steam/Templates/Application/main.j rename to Tools/capp/Templates/Application/main.j diff --git a/Tools/steam/Templates/ThemeDescriptor/Info.plist b/Tools/capp/Templates/ThemeDescriptor/Info.plist similarity index 100% rename from Tools/steam/Templates/ThemeDescriptor/Info.plist rename to Tools/capp/Templates/ThemeDescriptor/Info.plist diff --git a/Tools/steam/Templates/ThemeDescriptor/ThemeDescriptors.j b/Tools/capp/Templates/ThemeDescriptor/ThemeDescriptors.j similarity index 100% rename from Tools/steam/Templates/ThemeDescriptor/ThemeDescriptors.j rename to Tools/capp/Templates/ThemeDescriptor/ThemeDescriptors.j diff --git a/Tools/steam/Templates/ThemeDescriptor/index-debug.html b/Tools/capp/Templates/ThemeDescriptor/index-debug.html similarity index 100% rename from Tools/steam/Templates/ThemeDescriptor/index-debug.html rename to Tools/capp/Templates/ThemeDescriptor/index-debug.html diff --git a/Tools/steam/Templates/ThemeDescriptor/index.html b/Tools/capp/Templates/ThemeDescriptor/index.html similarity index 100% rename from Tools/steam/Templates/ThemeDescriptor/index.html rename to Tools/capp/Templates/ThemeDescriptor/index.html diff --git a/Tools/steam/Templates/ThemeDescriptor/main.j b/Tools/capp/Templates/ThemeDescriptor/main.j similarity index 100% rename from Tools/steam/Templates/ThemeDescriptor/main.j rename to Tools/capp/Templates/ThemeDescriptor/main.j diff --git a/Tools/steam/create-frameworks.js b/Tools/capp/main.j similarity index 56% rename from Tools/steam/create-frameworks.js rename to Tools/capp/main.j index 89b355ea91..6d3545d490 100644 --- a/Tools/steam/create-frameworks.js +++ b/Tools/capp/main.j @@ -1,9 +1,21 @@ -function createFrameworks() + +importClass(java.io.File); +importClass(java.io.FileOutputStream); +importClass(java.io.BufferedWriter); +importClass(java.io.OutputStreamWriter); + +function main() { - var shouldSymbolicallyLink = false, - index = 0, + if (arguments.length < 1) + return printUsage(); + + var index = 0, count = arguments.length, + shouldSymbolicallyLink = false, + justFrameworks = false, + + template = "Application", destination = ""; for (; index < count; ++index) @@ -12,14 +24,50 @@ function createFrameworks() switch (arguments[index]) { - case "-l": shouldSymbolicallyLink = true; - break; + case "-l": shouldSymbolicallyLink = true; + break; + + case "-h": + case "--help": printUsage(); + return; - default: destination = argument; + case "-t": + case "--template": template = arguments[++index]; + break; + + case "-f": + case "--frameworks": justFrameworks = true; + break; + + default: destination = argument; } } - createFrameworksInFile(new File(destination), shouldSymbolicallyLink); + var sourceTemplate = new File(OBJJ_HOME + "/lib/steam/Templates/" + template), + destinationProject = new File(destination); + + if (!destinationProject.exists()) + { + exec(["cp", "-vR", sourceTemplate.getCanonicalPath(), destinationProject.getCanonicalPath()], true); + + var files = getFiles(destinationProject, ['j', "plist", "html"]), + index = 0, + count = files.length; + + for (; index < count; ++index) + { + var file = files[index], + contents = readFile(file); + + contents = contents.replace(/__Product__/g, destinationProject.getName()); + + writeContentsToFile(contents, file); + } + + createFrameworksInFile(destinationProject, shouldSymbolicallyLink); + } + else + System.out.println("Directory already exists"); } function createFrameworksInFile(/*File*/ aFile, /*Boolean*/ shouldSymbolicallyLink) @@ -63,4 +111,9 @@ function createFrameworksInFile(/*File*/ aFile, /*Boolean*/ shouldSymbolicallyLi exec(["ln", "-s", new File(STEAM_BUILD + "/Debug/AppKit").getCanonicalPath(), new File(aFile.getCanonicalPath() + "/Frameworks/Debug/AppKit").getCanonicalPath()], true); -} \ No newline at end of file +} + +function printUsage() +{ + print("capp /path/to/your/app [options]"); +} diff --git a/Tools/nib2cib/Rakefile b/Tools/nib2cib/Rakefile index 201dc116d2..1d28a345f3 100644 --- a/Tools/nib2cib/Rakefile +++ b/Tools/nib2cib/Rakefile @@ -34,5 +34,5 @@ file_d $ENVIRONMENT_BIN_PRODUCT do end file_d $ENVIRONMENT_LIB_PRODUCT => [:nib2cib] do - cp_r($BUILD_PATH, $ENVIRONMENT_LIB_PRODUCT) + cp_r(File.join($BUILD_PATH, '.'), $ENVIRONMENT_LIB_PRODUCT) end diff --git a/Tools/nib2cib/main.j b/Tools/nib2cib/main.j index cda30b1e3a..52b5882c16 100644 --- a/Tools/nib2cib/main.j +++ b/Tools/nib2cib/main.j @@ -248,5 +248,3 @@ function main() else convert(inputFileName, outputFileName, resourcesPath); } - -main.apply(main, args); diff --git a/Tools/steam/Project.js b/Tools/steam/Project.js deleted file mode 100644 index 3e48b401c7..0000000000 --- a/Tools/steam/Project.js +++ /dev/null @@ -1,331 +0,0 @@ - -importClass(java.io.FileOutputStream); -importClass(java.io.BufferedWriter); -importClass(java.io.OutputStreamWriter); - -function Target(dictionary) -{ - this._name = dictionary_getValue(dictionary, "Name"); - - var flagsString = dictionary_getValue(dictionary, "Flags"); - - this._flags = flagsString ? flagsString.split(/\s+/) : []; - - this._type = dictionary_getValue(dictionary, "Type"); - - if (!this._type) - this._type = "280N.application"; - - this._exclusions = []; - - var exclusions = dictionary_getValue(dictionary, "Excluded"); - - if (exclusions) - { - var index = 0, - count = exclusions.length; - - for (; index < count; ++index) - this._exclusions.push(new File((exclusions[index])).getCanonicalFile()); - } - - return this; -} - -Target.prototype.name = function() -{ - return this._name; -} - -Target.prototype.exclusions = function() -{ - return this._exclusions; -} - -Target.prototype.flags = function() -{ - return this._flags; -} - -Target.prototype.type = function() -{ - return this._type; -} - -function Configuration(dictionary) -{ - this._name = dictionary_getValue(dictionary, "Name"); - - var flagsString = dictionary_getValue(dictionary, "Flags"); - - this._flags = flagsString ? flagsString.split(/\s+/) : []; - - return this; -} - -Configuration.prototype.name = function() -{ - return this._name; -} - -Configuration.prototype.flags = function() -{ - return this._flags; -} - -function Project(/*String*/ aFilePath, /*String*/ aBuildPath) -{ - this._file = new File(aFilePath).getCanonicalFile(); - this._root = this._file.getParentFile(); - - // Read the project file (its just a plist). - this._properties = readPlist(this._file); - - this._name = dictionary_getValue(this._properties, "Name"); - - // Read existing Info.plist if it exists. - var infoPlist = new File(this._root.getAbsolutePath() + "/Info.plist"); - - if (infoPlist.exists()) - this._infoDictionary = readPlist(new File(this._root.getAbsolutePath() + "/Info.plist")); - else - this._infoDictionary = new objj_dictionary(); - - this.buildPath = aBuildPath; - - // Covert target dictionaries to target objects. - var targetDictionaries = dictionary_getValue(this._properties, "Targets"); - - this._targets = []; - - for (var index = 0, count = targetDictionaries.length; index < count; ++index) - this._targets.push(new Target(targetDictionaries[index])); - - this.setActiveTarget(this._targets[0]); - - // Covert target dictionaries to target objects. - var configurationDictionaries = dictionary_getValue(this._properties, "Configurations"); - - this._configurations = []; - - for (index = 0, count = configurationDictionaries.length; index < count; ++index) - this._configurations.push(new Configuration(configurationDictionaries[index])); - - this.setActiveConfiguration(this._configurations[0]); - - // Grab the Resources Directory (if it exists) - this._resources = new File(this._root.getAbsolutePath() + "/Resources/").getCanonicalFile(); - - return this; -} - -Project.prototype.name = function() -{ - return this._name; -} - -Project.prototype.targetWithName = function(/*String*/ aName) -{ - var targets = this._targets, - index = 0, - count = targets.length; - - for (; index < count; ++index) - { - var target = targets[index]; - - if (target.name() == aName) - return target; - } - - return null; -} - -Project.prototype.configurationWithName = function(/*String*/ aName) -{ - var configurations = this._configurations, - index = 0, - count = configurations.length; - - for (; index < count; ++index) - { - var configuration = configurations[index]; - - if (configuration.name() == aName) - return configuration; - } - - return null; -} - -Project.prototype.setActiveTarget = function(/*Target*/ aTarget) -{ - this._activeTarget = aTarget; - - this._buildProducts = null; - this._buildIntermediates = null; - this._buildObjects = null; -} - -Project.prototype.activeTarget = function() -{ - return this._activeTarget; -} - -Project.prototype.setActiveConfiguration = function(/*Configuration*/ aConfiguration) -{ - this._activeConfiguration = aConfiguration; - - this._buildProducts = null; - this._buildIntermediates = null; - this._buildObjects = null; -} - -Project.prototype.activeConfiguration = function() -{ - return this._activeConfiguration; -} - -Project.prototype.buildProducts = function() -{ - if (!this._buildProducts) - { - this._buildProducts = new File(this.buildPath + '/' + this._activeConfiguration.name() + '/' + this._activeTarget.name()).getCanonicalFile(); - this._buildProducts.mkdirs(); - } - - return this._buildProducts; -} - -Project.prototype.buildIntermediates = function() -{ - if (!this._buildIntermediates) - { - this._buildIntermediates = new File(this.buildPath + '/' + this._activeTarget.name() + ".build/" + this._activeConfiguration.name()).getCanonicalFile(); - this._buildIntermediates.mkdirs(); - } - - return this._buildIntermediates; -} - -Project.prototype.buildObjects = function() -{ - if (!this._buildObjects) - { - this._buildObjects = new File(this.buildIntermediates().getAbsolutePath() + '/' + this._activeTarget.name()).getCanonicalFile(); - this._buildObjects.mkdirs(); - } - - return this._buildObjects; -} - -Project.prototype.activeFlags = function() -{ - return this.activeTarget().flags().concat(this.activeConfiguration().flags()); -} - -Project.prototype.build = function() -{ - java.lang.System.out.println("Building Target \"" + this.activeTarget().name() + - "\" of Project \"" + this.name() + - "\" with Configuration \"" + this.activeConfiguration().name() + "\"."); - - var jFiles = getFiles(this._root, "j", this._activeTarget.exclusions()), - replacedFiles = []; - hasModifiedJFiles = false; - shouldObjjPreprocess = true, - shouldGzip = this._gzip, - objjcComponents = ["sh", OBJJ_HOME + "/bin/objjc"]; - - objjcComponents = objjcComponents.concat(this.activeFlags()); - - if (!shouldObjjPreprocess) - objjcComponents.push("-E"); - - var buildObjects = this.buildObjects(), - buildProducts = this.buildProducts(); - - for (index = 0, count = jFiles.length; index < count; ++index) - { - var file = jFiles[index], - builtFile = new File(buildObjects.getAbsolutePath() + '/' + getFileNameWithoutExtension(file) + '.o'); - - replacedFiles.push(file.getName() + ""); - - if (builtFile.exists() && file.lastModified() < builtFile.lastModified()) - continue; - else - hasModifiedJFiles = true; - - objjcComponents.push(file.getAbsolutePath()); - - objjcComponents.push("-o"); - objjcComponents.push(buildObjects.getAbsolutePath() + '/' + getFileNameWithoutExtension(file) + '.o'); - } - - exec(objjcComponents, true); - - var oFiles = getFiles(buildObjects, 'o'), - sjFile = new File(buildProducts.getCanonicalPath() + '/' + this._activeTarget.name() + ".sj"); - - if (hasModifiedJFiles) - { - // concatenate sjheader.txt and individual .o - exec(["sh", "-c", "cat '" + OBJJ_STEAM + "/sjheader.txt' '" + oFiles.join("' '") + "' > '" + sjFile.getCanonicalPath() + "'"], true); - } - - if (shouldGzip) - { - // gzip and copy .htaccess file - exec(["sh", "-c", "gzip -c '" + sjFile.getCanonicalPath() + "' > '" + sjFile.getCanonicalPath() + ".gz'"], true); - exec(["cp", OBJJ_HOME + "/lib/htaccess", sjFile.getParentFile().getCanonicalPath() + "/.htaccess"], true); - } - else - { - // remove gzip and .htaccess file if present - exec(["rm", "-f", sjFile.getParentFile().getCanonicalPath() + "/.htaccess", sjFile.getCanonicalPath() + ".gz"], true); - } - - dictionary_setValue(this._infoDictionary, "CPBundleExecutable", this._activeTarget.name() + ".sj"); - dictionary_setValue(this._infoDictionary, "CPBundleReplacedFiles", replacedFiles); - - this.writeInfoPlist(); - - this.copyResources(); - - // FIXME: This should be, if this is an app... - if (dictionary_getValue(this._infoDictionary, "CPBundlePackageType") == "280N") - this.copyIndexFile(); - -} - -Project.prototype.clean = function() -{ - java.lang.System.out.println("Cleaning Target \"" + this.activeTarget().name() + - "\" of Project \"" + this.name() + - "\" with Configuration \"" + this.activeConfiguration().name() + "\"."); - - exec(["rm", "-rf", this.buildIntermediates().getAbsolutePath()], true); - exec(["rm", "-rf", this.buildProducts().getAbsolutePath()], true); -} - -Project.prototype.copyIndexFile = function() -{ - var indexFile = new File(this._root.getAbsolutePath() + "/index.html").getCanonicalFile(); - - rsync(indexFile, this.buildProducts()); -} - -Project.prototype.writeInfoPlist = function() -{ - var writer = new BufferedWriter(new FileWriter(this.buildProducts().getAbsolutePath() + '/' + "Info.plist")); - - writer.write(CPPropertyListCreateXMLData(this._infoDictionary).string); - - writer.close(); -} - -Project.prototype.copyResources = function() -{ - rsync(this._resources, this.buildProducts()); -} diff --git a/Tools/steam/build.js b/Tools/steam/build.js deleted file mode 100644 index 042decf115..0000000000 --- a/Tools/steam/build.js +++ /dev/null @@ -1,102 +0,0 @@ -function build() -{ - var index = 0, - count = arguments.length, - - actions = [], - - targetName = null, - configurationName = null, - - buildPath = null, - projectFilePath = null, - - gzip = false; - - for (; index < count; ++index) - { - switch (arguments[index]) - { - case "-f": if (index + 1 == count) - throw "-f needs project file."; - - projectFilePath = arguments[++index]; - break; - - case "-t": if (index + 1 == count) - throw "-t needs a target"; - - targetName = arguments[++index]; - break; - - case "-c": if (index + 1 == count) - throw "-c needs configuration"; - - configurationName = arguments[++index]; - break; - - case "-b": if (index + 1 == count) - throw "-b needs a build location"; - - buildPath = arguments[++index]; - break; - - case "--gzip": gzip = true; - break; - - case "clean": - case "build": actions.push(arguments[index]); - break; - } - } - - // If no project file was specified, look for one. - if (!projectFilePath) - { - var candidates = getFiles(new File('.'), "steam"); - - if (candidates.length < 1) - throw "No project file specified or found."; - - projectFilePath = candidates[0]; - } - - // Construct the Build Directory - if (!buildPath) - { - buildPath = System.getenv("STEAM_BUILD"); - - if (!buildPath) - buildPath = "Build"; - } - - var project = new Project(projectFilePath, buildPath); - - project._gzip = gzip; - - if (targetName) - { - var target = project.targetWithName(targetName); - - if (!target) - throw "Target \"" + targetName + "\" not found in project."; - - project.setActiveTarget(target); - } - - if (configurationName) - { - var configuration = project.configurationWithName(configurationName); - - if (!configuration) - throw "Configuration \"" + configurationName + "\" not found in project."; - - project.setActiveConfiguration(configuration); - } - - if (!actions.length) - actions.push("build"); - - for (index = 0, count = actions.length; index < count; ++index) - project[actions[index]](); -} diff --git a/Tools/steam/build.xml b/Tools/steam/build.xml deleted file mode 100644 index 723ea5b2f5..0000000000 --- a/Tools/steam/build.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tools/steam/create.js b/Tools/steam/create.js deleted file mode 100644 index 73abaa8dcb..0000000000 --- a/Tools/steam/create.js +++ /dev/null @@ -1,54 +0,0 @@ -function create() -{ - if (arguments.length < 1) - printUsage("create"); - - var shouldSymbolicallyLink = false, - index = 0, - count = arguments.length, - - template = "Application", - destination = ""; - - for (; index < count; ++index) - { - var argument = arguments[index]; - - switch (arguments[index]) - { - case "-l": shouldSymbolicallyLink = true; - break; - - case "--template": template = arguments[++index]; - break; - - default: destination = argument; - } - } - - var sourceTemplate = new File(OBJJ_HOME + "/lib/steam/Templates/" + template), - destinationProject = new File(destination); - - if (!destinationProject.exists()) - { - exec(["cp", "-vR", sourceTemplate.getCanonicalPath(), destinationProject.getCanonicalPath()], true); - - var files = getFiles(destinationProject, ['j', "plist", "html"]), - index = 0, - count = files.length; - - for (; index < count; ++index) - { - var file = files[index], - contents = readFile(file); - - contents = contents.replace(/__Product__/g, destinationProject.getName()); - - writeContentsToFile(contents, file); - } - - createFrameworksInFile(destinationProject, shouldSymbolicallyLink); - } - else - System.out.println("Directory already exists"); -} diff --git a/Tools/steam/htaccess b/Tools/steam/htaccess deleted file mode 100644 index 6afc67f106..0000000000 --- a/Tools/steam/htaccess +++ /dev/null @@ -1,12 +0,0 @@ -Options +FollowSymLinks - -AddEncoding x-gzip .gz -AddType text/plain .gz - -RewriteEngine on - -# These conditions slow down the requests significantly. We can probably assume they're always true. -# We should ensure the gzipped version always exists if we include this .htaccess. All supported browsers accept gzip encoding. -#RewriteCond %{REQUEST_FILENAME}.gz -f -#RewriteCond %{HTTP:Accept-Encoding} gzip -RewriteRule ^(.*\.(sj|js))$ %{REQUEST_URI}/../$1.gz diff --git a/Tools/steam/inline-bundle.js b/Tools/steam/inline-bundle.js deleted file mode 100644 index 2e2dc8643c..0000000000 --- a/Tools/steam/inline-bundle.js +++ /dev/null @@ -1,156 +0,0 @@ -function inlineBundle() -{ - var index = 0, - count = arguments.length, - bundlePath = NULL; - - for (; index < count; ++index) - { - var argument = arguments[index]; - - switch (arguments[index]) - { - case "-d": directoryPath = arguments[++index]; - break; - - default: bundlePath = argument; - } - } - - var bundleFile = new File(bundlePath).getCanonicalFile(), - bundlePath = String(bundleFile.getCanonicalPath()), - inlinedBundle = readBundle(bundleFile, true), - inlinedFiles = [], - replacedFiles = [], - staticContent = ""; - - // Find all internal bundles. - var bundleCandidates = getFiles(bundleFile, "plist"), - bundleCandidatesCount = bundleCandidates.length; - - while (bundleCandidatesCount--) - { - var bundleCandidate = bundleCandidates[bundleCandidatesCount]; - - // We only care about Info.plists, specifically the ones that aren't us. - if (String(bundleCandidate.getName()) !== "Info.plist" || String(bundleCandidate.getCanonicalPath()) === inlinedBundle.path) - continue; - - var infoDictionary = readPlist(bundleCandidate); - - // At least one of these two has to be present for this to be a real deal bundle. - if (!dictionary_getValue(infoDictionary, "CPBundleIdentifier") && !dictionary_getValue(infoDictionary, "CPBundleName")) - continue; - - java.lang.System.out.println(" Examining " + pathRelativeTo(bundleCandidate.getCanonicalPath(), bundlePath)); - - dictionary_removeValue(infoDictionary, "CPBundleExecutable"); - - var bundle = readBundle(bundleCandidate.getParentFile(), true); - - bundle.path = pathRelativeTo(bundle.path, bundlePath); - - // We want to inline the info plist too. - var inlinedFiles = [makeOBJJPlistFile(infoDictionary, bundleCandidate, bundle)].concat(bundle.files), - index = 0, - count = inlinedFiles.length; - - for (; index < count; ++index) - { - var file = inlinedFiles[index]; - - file.path = pathRelativeTo(String(file.path), bundlePath); - - java.lang.System.out.println(" Inlining " + file.path); - - replacedFiles.push(file.path); - staticContent += fileToMarkedString(inlinedFiles[index], true); - } - } - - var index = 0, - existingStaticFiles = inlinedBundle.files, - count = existingStaticFiles.length, - topLevelContent = "@STATIC;1.0;"; - - for (; index < count; ++index) - { - var file = existingStaticFiles[index]; - - // If this isn't actually part of our bundle, drop it! - if (file.bundle !== inlinedBundle) - continue; - - file.path = pathRelativeTo(String(file.path), bundlePath); - - replacedFiles.push(file.path); - topLevelContent += fileToMarkedString(file, false); - } - - dictionary_setValue(inlinedBundle.info, "CPBundleReplacedFiles", replacedFiles); - - writeContentsToFile(CPPropertyListCreateXMLData(inlinedBundle.info).string, inlinedBundle.path); - writeContentsToFile(topLevelContent + staticContent, inlinedBundle._staticContentPath); -} - -function fileToMarkedString(anOBJJFile, encodeBundle) -{ - var markedString = ""; - - markedString += MARKER_PATH + ';' + anOBJJFile.path.length + ';' + anOBJJFile.path; - - if (encodeBundle) - markedString += MARKER_BUNDLE + ';' + anOBJJFile.bundle.path.length + ';' + anOBJJFile.bundle.path; - - var fragments = anOBJJFile.fragments; - - if (fragments && fragments.length > 0) - { - var fragmentIndex = 0, - fragmentCount = fragments.length; - - for (; fragmentIndex < fragmentCount; ++fragmentIndex) - markedString += fragments[fragmentIndex].toMarkedString(); - } - - else - markedString += MARKER_TEXT + ';' + anOBJJFile.contents.length + ';' + anOBJJFile.contents; - - return markedString; -} - -function makeOBJJPlistFile(aDictionary, aFile, aBundle) -{ - var file = new objj_file(); - - file.path = typeof aFile === "string" ? aFile : aFile.getCanonicalPath(); - file.bundle = aBundle; - file.contents = CPPropertyListCreate280NorthData(aDictionary).string; - - return file; -} - -function pathRelativeTo(target, relativeTo) -{ - var components = [], - targetParts = target.split("/"), - relativeParts = relativeTo ? relativeTo.split("/") : []; - - var i = 0; - while (i < targetParts.length) - { - if (targetParts[i] != relativeParts[i]) - break; - i++; - } - - for (var j = i; j < relativeParts.length; j++) - components.push(".."); - - for (var j = i; j < targetParts.length; j++) - components.push(targetParts[j]); - - var result = components.join("/"); - - return result; -} \ No newline at end of file diff --git a/Tools/steam/main.js b/Tools/steam/main.js deleted file mode 100644 index d007905f76..0000000000 --- a/Tools/steam/main.js +++ /dev/null @@ -1,203 +0,0 @@ - -importPackage(java.lang); -importPackage(java.util); - -importClass(java.io.File); -importClass(java.io.BufferedReader); -importClass(java.io.FileReader); -importClass(java.io.BufferedWriter); -importClass(java.io.FileWriter); -importClass(java.io.SequenceInputStream); - -#include "../Utilities/bundle.js" - -#include "Project.js" - -OBJJ_STEAM = OBJJ_HOME + "/lib/steam/"; - -function main() -{ - if (arguments.length < 1) - printUsage(); - - var command = Array.prototype.shift.apply(arguments); - - switch (command) - { - case "create": create.apply(create, arguments); - break; - - case "create-frameworks": createFrameworks.apply(createFrameworks, arguments); - break; - - - case "inline-bundle": inlineBundle.apply(inlineBundle, arguments); - break; - - case "build": build.apply(build, arguments); - break; - - case "help": printUsage(arguments[1]); - break; - - case "version": - case "--version": printVersion(); - break; - - default : printUsage(command); - } - -} - -function fileArrayContainsFile(/*Array*/ files, /*File*/ aFile) -{ - var index = 0, - count = files.length; - - for (; index < count; ++index) - if (files[index].equals(aFile)) - return true; - - return false; -} - -function getFiles(/*File*/ sourceDirectory, /*nil|String|Array*/ extensions, /*Array*/ exclusions) -{ - var matches = [], - files = sourceDirectory.listFiles(), - hasMultipleExtensions = typeof extensions !== "string"; - - if (files) - { - var index = 0, - count = files.length; - - for (; index < count; ++index) - { - var file = files[index].getCanonicalFile(), - name = String(file.getName()), - isValidExtension = !extensions; - - if (exclusions && fileArrayContainsFile(exclusions, file)) - continue; - - if (!isValidExtension) - if (hasMultipleExtensions) - { - var extensionCount = extensions.length; - - while (extensionCount-- && !isValidExtension) - { - var extension = extensions[extensionCount]; - - if (name.substring(name.length - extension.length - 1) === ("." + extension)) - isValidExtension = true; - } - } - else if (name.substring(name.length - extensions.length - 1) === ("." + extensions)) - isValidExtension = true; - - if (isValidExtension) - matches.push(file); - - if (file.isDirectory()) - matches = matches.concat(getFiles(file, extensions, exclusions)); - } - } - - return matches; -} - -function exec(/*Array*/ command, /*Boolean*/ showOutput) -{ - var line = "", - output = "", - - process = Packages.java.lang.Runtime.getRuntime().exec(command),//jsArrayToJavaArray(command)); - reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(process.getInputStream())); - - while (line = reader.readLine()) - { - if (showOutput) - System.out.println(line); - - output += line + '\n'; - } - - reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(process.getErrorStream())); - - while (line = reader.readLine()) - System.out.println(line); - - try - { - if (process.waitFor() != 0) - System.err.println("exit value = " + process.exitValue()); - } - catch (anException) - { - System.err.println(anException); - } - - return output; -} - -function rsync(srcFile, dstFile) -{ - var src, dst; - - if (String(java.lang.System.getenv("OS")).indexOf("Windows") < 0) - { - src = srcFile.getAbsolutePath(); - dst = dstFile.getAbsolutePath(); - } - else - { - src = exec(["cygpath", "-u", srcFile.getAbsolutePath() + '/']); - dst = exec(["cygpath", "-u", dstFile.getAbsolutePath() + "/Resources"]); - } - - if (srcFile.exists()) - exec(["rsync", "-avz", src, dst]); -} - -function getFileName(aPath) -{ - var index = aPath.lastIndexOf('/'); - - if (index == -1) - return aPath; - - return aPath.substr(index + 1); -} - -function getFileNameWithoutExtension(aFileOrFileName) -{ - var name = typeof aFileOrFileName === "string" ? aFileOrFileName : aFileOrFileName.getName(), - index = name.lastIndexOf('.'); - - if (index == -1 || index == 0) - return name; - - return name.substr(0, index); -} - -function getFileExtension(aPath) -{ - var slash = aPath.lastIndexOf('/'), - period = aPath.lastIndexOf('.'); - - if (period < slash || (period == slash + 1)) - return ""; - - return aPath.substr(period + 1); -} - -main.apply(main, arguments); - -#include "build.js" -#include "create.js" -#include "create-frameworks.js" -#include "inline-bundle.js" -#include "usage.js" -#include "version.js" diff --git a/Tools/steam/sjheader.txt b/Tools/steam/sjheader.txt deleted file mode 100644 index 57390737c9..0000000000 --- a/Tools/steam/sjheader.txt +++ /dev/null @@ -1 +0,0 @@ -@STATIC;1.0; \ No newline at end of file diff --git a/Tools/steam/steam b/Tools/steam/steam deleted file mode 100644 index e661474789..0000000000 --- a/Tools/steam/steam +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh - -# if OBJJ_HOME isn't set, try to determine it -if [ -z $OBJJ_HOME ]; then - # get path of the executable - SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && pwd -P) && SELF_PATH=$SELF_PATH/$(basename -- "$0") - - # resolve symlinks - if [ -h $SELF_PATH ]; then - SELF_PATH=`readlink $SELF_PATH` - fi - - # get second ancestor directory - SELF_DIR=`dirname $SELF_PATH` - export OBJJ_HOME=`dirname $SELF_DIR` - - # check to ensure it exists, print message - if [ -d $OBJJ_HOME ]; then - echo "OBJJ_HOME not set, defaulting to $OBJJ_HOME" 1>&2 - else - echo "OBJJ_HOME not set, default at $OBJJ_HOME doesn't exist, exiting" 1>&2 - exit 2 - fi -fi - -OBJJ_LIB="$OBJJ_HOME/lib" -STEAM="$OBJJ_LIB/steam" -CLASSPATH="$STEAM:$OBJJ_LIB:$OBJJ_LIB/js.jar" - -# convert paths for Cygwin -if [[ `uname` == CYGWIN* ]]; then - CLASSPATH=`cygpath -wp "$CLASSPATH"` - STEAM_BUILD=`cygpath -wp "$STEAM_BUILD"` -fi - -export OBJJ_LIB - -java -classpath $CLASSPATH steam $@ diff --git a/Tools/steam/steam.xml b/Tools/steam/steam.xml deleted file mode 100644 index 8b5e0a9f66..0000000000 --- a/Tools/steam/steam.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/steam/usage.js b/Tools/steam/usage.js deleted file mode 100644 index 389fadc537..0000000000 --- a/Tools/steam/usage.js +++ /dev/null @@ -1,22 +0,0 @@ -function printUsage(command) -{ - var usage = "usage: steam COMMAND [ARGS]\n\n"+ -"The most commonly used steam commands are:\n"+ -"\tbuild Build a project\n"+ -"\tcreate Create a new project\n\n"+ -"See 'steam help COMMAND' for more information on a specific command."; - - switch (command) - { - case "--help": - case undefined: java.lang.System.out.println(usage); - break; - - case "create": java.lang.System.out.println("Creates a new Cappuccino project.\n\nusage: steam create PROJECT_NAME [-l]\n\n"+ - "\t-l Link Frameworks to $STEAM_BUILD/Release, instead of installing default Frameworks"); - break; - - default: java.lang.System.out.println("steam: '" + command + "' is not a steam command. See 'steam --help'."); - } - java.lang.System.exit(1); -} diff --git a/Tools/steam/version.js b/Tools/steam/version.js deleted file mode 100644 index c22171a3fd..0000000000 --- a/Tools/steam/version.js +++ /dev/null @@ -1,5 +0,0 @@ -function printVersion() -{ - java.lang.System.out.println("steam version 0.6"); - java.lang.System.exit(1); -} \ No newline at end of file diff --git a/rakefile b/rakefile index 253d35f74e..a52f5a6578 100644 --- a/rakefile +++ b/rakefile @@ -4,7 +4,7 @@ require 'rake' require 'common' -subprojects = %w{Objective-J Foundation AppKit} +subprojects = %w{Objective-J Foundation AppKit Tools} %w(build clean).each do |task_name| task task_name do