Further Tools changes.

Reviewed by me.
This commit is contained in:
Francisco Tolmasky
2009-03-15 15:32:29 -07:00
parent 9c3c239162
commit 101cf4db2c
16 changed files with 61 additions and 877 deletions
+8 -8
View File
@@ -1,7 +1,7 @@
#!/bin/sh
# if OBJJ_HOME isn't set, try to determine it out
if [ -z $OBJJ_HOME ]; then
#if [ -z $OBJJ_HOME ]; then
# get path of the executable
SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && pwd -P) && SELF_PATH=$SELF_PATH/$(basename -- "$0")
@@ -15,13 +15,13 @@ if [ -z $OBJJ_HOME ]; then
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
# 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"
CLASSPATH="$OBJJ_LIB:$OBJJ_LIB/js.jar:$OBJJ_HOME/lib/$(basename $SELF_PATH):$CLASSPATH"
+10 -7
View File
@@ -2,6 +2,7 @@ debug = false;
args = arguments;
// FIXME: remove these Rhino/Java dependencies
/*
var OBJJ_LIB = Packages.java.lang.System.getenv("OBJJ_LIB"); // chicken/egg problem, getenv is defined in bridge.js
if (!this.window)
@@ -15,17 +16,13 @@ if (!this.objj_import)
print("Loading Objective-J.");
load(OBJJ_LIB+'/Frameworks-Rhino/Objective-J/Objective-J.js');
}
var defaultFrameworks = OBJJ_LIB+'/Frameworks-Rhino';
OBJJ_INCLUDE_PATHS = [defaultFrameworks];
*/
OBJJ_INCLUDE_PATHS = [];
var OBJJ_INCLUDE_PATHS_STRING = getenv("OBJJ_INCLUDE_PATHS");
if (OBJJ_INCLUDE_PATHS_STRING)
{
OBJJ_INCLUDE_PATHS = OBJJ_INCLUDE_PATHS_STRING.split(":");
OBJJ_INCLUDE_PATHS.push(defaultFrameworks);
}
OBJJ_INCLUDE_PATHS = OBJJ_INCLUDE_PATHS.concat(OBJJ_INCLUDE_PATHS_STRING.split(":"));
try
{
@@ -37,6 +34,12 @@ try
while (count--)
args[count] = String(args[count]);
while (args.length && args[0].indexOf('-I') === 0)
OBJJ_INCLUDE_PATHS = OBJJ_INCLUDE_PATHS.concat(args.shift().substr(2).split(':'))
}
if (args.length > 0)
{
// Grab the location of the objj file to run.
var mainFilePath = args.shift();
-53
View File
@@ -1,53 +0,0 @@
#!/bin/sh
# if OBJJ_HOME isn't set, try to determine it out
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"
CLASSPATH="$OBJJ_LIB:$OBJJ_LIB/js.jar:$OBJJ_HOME/lib/$(basename $SELF_PATH):$CLASSPATH"
OBJJ="$OBJJ_LIB/objj.js"
RLWRAP=`which rlwrap`
# if there's a "lib" directory, add all the jars from it
if [ -d "lib" ]; then
JARS=`find ./lib -name '*.jar' 2> /dev/null | tr "\n" ":"`
CLASSPATH="$JARS:$CLASSPATH"
fi
# convert paths for Cygwin
if [[ `uname` == CYGWIN* ]]; then
OBJJ_HOME=`cygpath -wp "$OBJJ_HOME"`
OBJJ_LIB=`cygpath -wp "$OBJJ_LIB"`
OBJJ=`cygpath -wp "$OBJJ"`
CLASSPATH=`cygpath -wp "$CLASSPATH"`
fi
export OBJJ_LIB
echo $RLWRAP java -classpath $CLASSPATH main $@
#if [ -e $STEAM_BUILD/Objective-J.build/Release/Rhino ]; then
$RLWRAP java -classpath $CLASSPATH main $@
#$RLWRAP java -classpath $CLASSPATH org.mozilla.javascript.tools.shell.Main $OBJJ $@
#else
# echo "Missing frameworks at $STEAM_BUILD/Objective-J.build/Release/Rhino" 1>&2
#fi
+36
View File
@@ -0,0 +1,36 @@
#!/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"
MAIN="$OBJJ_LIB/$(basename $SELF_PATH)/main.j"
# convert paths for Cygwin
if [[ `uname` == CYGWIN* ]]; then
OBJJ_HOME=`cygpath -w "$OBJJ_HOME"`
BAKE=`cygpath -w "$BLEND"`
fi
objj $MAIN $@
-120
View File
@@ -1,120 +0,0 @@
@import <AppKit/CPTheme.j>
@import <AppKit/CPView.j>
@import "BKUtilities.j"
@implementation BKShowcaseController : CPObject
{
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
contentView = [theWindow contentView],
bounds = [contentView bounds],
themeDescriptorClasses = BKThemeDescriptorClasses();
var tabView = [[CPTabView alloc] initWithFrame:bounds];
[tabView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[contentView addSubview:tabView];
var count = [themeDescriptorClasses count];
while (count--)
{
var theClass = themeDescriptorClasses[count],
item = [[CPTabViewItem alloc] initWithIdentifier:[theClass themeName]],
templates = BKThemeObjectTemplatesForClass(theClass),
templatesCount = [templates count],
viewTemplates = [],
itemSize = CGSizeMake(0.0, 0.0);
while (templatesCount--)
{
var template = templates[templatesCount],
object = [template valueForKey:@"themedObject"];
if ([object isKindOfClass:[CPView class]])
{
var size = [object frame].size,
labelWidth = [[template valueForKey:@"label"] sizeWithFont:[CPFont boldSystemFontOfSize:12.0]].width + 20.0;
if (size.width > itemSize.width)
itemSize.width = size.width;
if (labelWidth > itemSize.width)
itemSize.width = labelWidth;
if (size.height > itemSize.height)
itemSize.height = size.height;
[viewTemplates addObject:template];
}
}
itemSize.height += 30;
var collectionView = [[CPCollectionView alloc] initWithFrame:CGRectMakeZero()],
collectionViewItem = [[CPCollectionViewItem alloc] init];
[collectionViewItem setView:[[BKShowcaseCell alloc] init]];
[collectionView setItemPrototype:collectionViewItem];
[collectionView setMinItemSize:itemSize];
[collectionView setMaxItemSize:itemSize];
[collectionView setVerticalMargin:5.0];
[collectionView setContent:viewTemplates];
[item setLabel:[theClass themeName]];
[item setView:collectionView];
[tabView addTabViewItem:item];
}
[theWindow orderFront:self];
}
@end
@implementation BKShowcaseCell : CPView
{
CPView _view;
CPTextField _label;
}
- (void)setRepresentedObject:(id)anObject
{
if (!_label)
{
_label = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
[_label setAlignment:CPCenterTextAlignment];
[_label setAutoresizingMask:CPViewMinYMargin | CPViewWidthSizable];
[_label setFont:[CPFont boldSystemFontOfSize:12.0]];
[self addSubview:_label];
}
[_label setStringValue:[anObject valueForKey:@"label"]];
[_label sizeToFit];
[_label setFrame:CGRectMake(0.0, CGRectGetHeight([self bounds]) - CGRectGetHeight([_label frame]),
CGRectGetWidth([self bounds]), CGRectGetHeight([_label frame]))];
if (_view)
[_view removeFromSuperview];
_view = [anObject valueForKey:@"themedObject"];
[_view setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin];
[_view setFrameOrigin:CGPointMake((CGRectGetWidth([self bounds]) - CGRectGetWidth([_view frame])) / 2.0, (CGRectGetMinY([_label frame]) - CGRectGetHeight([_view frame])) / 2.0)];
[self addSubview:_view];
}
@end
-145
View File
@@ -1,145 +0,0 @@
@implementation AKThemeTemplate : CPObject
{
CPString _name;
CPString _description;
}
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super init];
if (self)
{
_name = [aCoder decodeObjectForKey:@"AKThemeTemplateName"];
_description = [aCoder decodeObjectForKey:@"AKThemeTemplateDescription"];
}
return self;
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeObject:_name forKey:@"AKThemeTemplateName"];
[aCoder encodeObject:_description forKey:@"AKThemeTemplateDescription"];
}
@end
@implementation AKThemeObjectTemplate : CPView
{
CPString _label;
id _themedObject;
}
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super init];
if (self)
{
_label = [aCoder decodeObjectForKey:@"AKThemeObjectTemplateLabel"];
_themedObject = [aCoder decodeObjectForKey:@"AKThemeObjectTemplateThemedObject"];
}
return self;
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeObject:_label forKey:@"AKThemeObjectTemplateLabel"];
[aCoder encodeObject:_themedObject forKey:@"AKThemeObjectTemplateThemedObject"];
}
@end
function BKThemeDescriptorClasses()
{
// Grab Theme Descriptor Classes.
var themeDescriptorClasses = [];
for (candidate in window)
{
var theClass = objj_getClass(candidate),
theClassName = class_getName(theClass),
index = theClassName.indexOf("ThemeDescriptor");
if ((index >= 0) && (index === theClassName.length - "ThemeDescriptor".length))
themeDescriptorClasses.push(theClass);
}
return themeDescriptorClasses;
}
function BKThemeObjectTemplatesForClass(aClass)
{
var templates = [],
methods = class_copyMethodList(aClass.isa),
count = [methods count];
while (count--)
{
var method = methods[count],
selector = method_getName(method);
if (selector.indexOf("themed") === 0)
{
var impl = method_getImplementation(method),
object = impl(aClass, selector);
if (object)
{
var template = [[AKThemeObjectTemplate alloc] init];
[template setValue:object forKey:@"themedObject"];
[template setValue:BKLabelFromIdentifier(selector) forKey:@"label"];
[templates addObject:template];
}
}
}
return templates;
}
function BKLabelFromIdentifier(anIdentifier)
{
var string = anIdentifier.substr("themed".length);
index = 0,
count = string.length,
label = "",
lastCapital = null,
isLeadingCapital = YES;
for (; index < count; ++index)
{
var character = string.charAt(index),
isCapital = /^[A-Z]/.test(character);
if (isCapital)
{
if (!isLeadingCapital)
{
if (lastCapital === null)
label += ' ' + character.toLowerCase();
else
label += character;
}
lastCapital = character;
}
else
{
if (isLeadingCapital && lastCapital !== null)
label += lastCapital;
label += character;
lastCapital = null;
isLeadingCapital = NO;
}
}
return label;
}
-3
View File
@@ -1,3 +0,0 @@
@import "BKShowcaseController.j"
@import "BKUtilities.j"
-42
View File
@@ -1,42 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Name</key>
<string>BlendKit</string>
<key>Targets</key>
<array>
<dict>
<key>Name</key>
<string>BlendKit</string>
</dict>
</array>
<key>Configurations</key>
<array>
<dict>
<key>Name</key>
<string>Debug</string>
<key>Flags</key>
<string>-DDEBUG -DPLATFORM_DOM -g</string>
</dict>
<dict>
<key>Name</key>
<string>Release</string>
<key>Flags</key>
<string>-DPLATFORM_DOM -O</string>
</dict>
<dict>
<key>Name</key>
<string>Debug-Rhino</string>
<key>Flags</key>
<string>-DDEBUG -g</string>
</dict>
<dict>
<key>Name</key>
<string>Release-Rhino</string>
<key>Flags</key>
<string>-O</string>
</dict>
</array>
</dict>
</plist>
-14
View File
@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CPBundleIdentifier</key>
<string>com.280n.BlendKit</string>
<key>CPBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CPBundleName</key>
<string>BlendKit</string>
<key>CPBundlePackageType</key>
<string>FMWK</string>
</dict>
</plist>
-33
View File
@@ -1,33 +0,0 @@
<?xml version = "1.0"?>
<project name = "BlendKit" default = "build" basedir = "." >
<import file = "../../../common.xml" />
<import file = "${env.OBJJ_LIB}/steam/steam.xml" />
<target name = "clean" depends = "steam-uptodate">
<steam-build>
<arg line = "-f BlendKit.steam -c ${Configuration} clean" />
</steam-build>
<steam-build>
<arg line = "-f BlendKit.steam -c ${Configuration}-Rhino clean" />
</steam-build>
</target>
<target name = "build" depends = "steam-uptodate">
<steam-build>
<arg line = "-f BlendKit.steam -c ${Configuration}" />
</steam-build>
<steam-build>
<arg line = "-f BlendKit.steam -c ${Configuration}-Rhino" />
</steam-build>
<!-- <copy file = "../LICENSE" todir = "${Build}/${Configuration}/AppKit" />-->
</target>
</project>
-57
View File
@@ -1,57 +0,0 @@
#!/bin/sh
#
# blend
# blend
#
# Created by Francisco Tolmasky.
# Copyright 2008, 280 North, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
# 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"
BLEND="$OBJJ_LIB/blend/main.j"
# convert paths for Cygwin
if [[ `uname` == CYGWIN* ]]; then
OBJJ_HOME=`cygpath -w "$OBJJ_HOME"`
BAKE=`cygpath -w "$BLEND"`
fi
objj $BLEND $@
-46
View File
@@ -1,46 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Name</key>
<string>blend</string>
<key>Targets</key>
<array>
<dict>
<key>Name</key>
<string>blend</string>
<key>Excluded</key>
<array>
<string>BlendKit</string>
</array>
</dict>
</array>
<key>Configurations</key>
<array>
<dict>
<key>Name</key>
<string>Debug</string>
<key>Flags</key>
<string>-DDEBUG -DPLATFORM_DOM -g</string>
</dict>
<dict>
<key>Name</key>
<string>Release</string>
<key>Flags</key>
<string>-DPLATFORM_DOM -O</string>
</dict>
<dict>
<key>Name</key>
<string>Debug-Rhino</string>
<key>Flags</key>
<string>-DDEBUG -g</string>
</dict>
<dict>
<key>Name</key>
<string>Release-Rhino</string>
<key>Flags</key>
<string>-O</string>
</dict>
</array>
</dict>
</plist>
-23
View File
@@ -1,23 +0,0 @@
<?xml version = "1.0"?>
<project name = "blend" default = "build" basedir = "." >
<import file = "../../../common.xml" />
<import file = "${env.OBJJ_LIB}/steam/steam.xml" />
<target name = "clean" depends = "steam-uptodate">
<steam-build>
<arg line = "-f blend.steam -c ${Configuration} clean" />
</steam-build>
</target>
<target name = "build" depends = "steam-uptodate">
<steam-build>
<arg line = "-f blend.steam -c ${Configuration}" />
</steam-build>
</target>
</project>
-298
View File
@@ -1,298 +0,0 @@
@import <Foundation/Foundation.j>
@import <AppKit/AppKit.j>
@import <AppKit/CPCib.j>
@import <AppKit/CPTheme.j>
@import <BlendKit/BlendKit.j>
importClass(java.io.File);
importClass(java.io.FileOutputStream);
importClass(java.io.BufferedWriter);
importClass(java.io.OutputStreamWriter);
function main()
{
var index = 0,
count = arguments.length,
outputFilePath = "",
descriptorFiles = [],
resourcesPath = nil,
cibFiles = [];
for (; index < count; ++index)
{
var argument = arguments[index];
switch (argument)
{
case "-c":
case "--cib": cibFiles.push(arguments[++index]);
break;
case "-d":
case "-descriptor": descriptorFiles.push(arguments[++index]);
break;
case "-o": outputFilePath = arguments[++index];
break;
case "-R": resourcesPath = arguments[++index];
break;
default: jExtensionIndex = argument.indexOf(".j");
if ((jExtensionIndex > 0) && (jExtensionIndex === argument.length - ".j".length))
descriptorFiles.push(argument);
else
cibFiles.push(argument);
}
}
if (descriptorFiles.length === 0)
return buildBlendFromCibFiles(cibFiles);
objj_import(descriptorFiles, YES, function()
{
var themeDescriptorClasses = BKThemeDescriptorClasses(),
count = [themeDescriptorClasses count];
while (count--)
{
var theClass = themeDescriptorClasses[count],
themeTemplate = [[AKThemeTemplate alloc] init];
[themeTemplate setValue:[theClass themeName] forKey:@"name"];
var objectTemplates = BKThemeObjectTemplatesForClass(theClass);
data = cibDataFromTopLevelObjects(objectTemplates.concat([themeTemplate])),
temporaryCibFile = File.createTempFile("temp", ".cib"),
temporaryCibFilePath = temporaryCibFile.getAbsolutePath(),
writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(temporaryCibFilePath), "UTF-8"));
writer.write([data string]);
writer.close();
cibFiles.push(temporaryCibFilePath);
}
buildBlendFromCibFiles(cibFiles, outputFilePath, resourcesPath);
});
}
function cibDataFromTopLevelObjects(objects)
{
var data = [CPData data],
archiver = [[CPKeyedArchiver alloc] initForWritingWithMutableData:data],
objectData = [[_CPCibObjectData alloc] init];
objectData._fileOwner = [_CPCibCustomObject new];
objectData._fileOwner._className = @"CPObject";
var index = 0,
count = objects.length;
for (; index < count; ++index)
{
objectData._objectsValues[index] = objectData._fileOwner;
objectData._objectsKeys[index] = objects[index];
}
[archiver encodeObject:objectData forKey:@"CPCibObjectDataKey"];
[archiver finishEncoding];
return data;
}
function getDirectory(aPath)
{
return (aPath).substr(0, (aPath).lastIndexOf('/') + 1)
}
function buildBlendFromCibFiles(cibFiles, outputFilePath, resourcesPath)
{
var resourcesFile = nil;
if (resourcesPath)
resourcesFile = new File(resourcesPath);
var count = cibFiles.length,
replacedFiles = [],
staticContent = @"";
while (count--)
{
var theme = themeFromCibFile(new File(cibFiles[count])),
// Archive our theme.
filePath = [theme name] + ".keyedtheme",
fileContents = [[CPKeyedArchiver archivedDataWithRootObject:theme] string];
replacedFiles.push(filePath);
staticContent += MARKER_PATH + ';' + filePath.length + ';' + filePath + MARKER_TEXT + ';' + fileContents.length + ';' + fileContents;
}
staticContent = "@STATIC;1.0;" + staticContent;
var infoDictionary = [CPDictionary dictionary];
staticContentName = "Aristo";//getFileNameWithoutExtension(project.activeTarget().name());
[infoDictionary setObject:@"Yikes." forKey:@"CPBundleName"];
[infoDictionary setObject:@"Yikes." forKey:@"CPBundleIdentifier"];
[infoDictionary setObject:replacedFiles forKey:@"CPBundleReplacedFiles"];
[infoDictionary setObject:staticContentName forKey:@"CPBundleExecutable"];
var outputFile = new File(outputFilePath).getCanonicalFile();
outputFile.mkdirs();
var writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFilePath + "/Info.plist"), "UTF-8"));
writer.write(CPPropertyListCreate280NorthData(infoDictionary).string);
writer.close();
writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFilePath + '/' + staticContentName), "UTF-8"));
writer.write(staticContent);
writer.close();
if (resourcesPath)
rsync(new File(resourcesPath), new File(outputFilePath));
}
function themeFromCibFile(aFile)
{
var cib = [[CPCib alloc] initWithContentsOfURL:aFile.getCanonicalPath()],
topLevelObjects = [];
[cib _setAwakenCustomResources:NO];
[cib instantiateCibWithExternalNameTable:[CPDictionary dictionaryWithObject:topLevelObjects forKey:CPCibTopLevelObjects]];
var count = topLevelObjects.length,
theme = nil,
templates = [];
while (count--)
{
var object = topLevelObjects[count];
templates = templates.concat([object blendThemeObjectTemplates]);
if ([object isKindOfClass:[AKThemeTemplate class]])
theme = [[CPTheme alloc] initWithName:[object valueForKey:@"name"]];
}
[templates makeObjectsPerformSelector:@selector(blendAddThemedObjectAttributesToTheme:) withObject:theme];
return theme;
}
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 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;
}
@implementation CPObject (BlendAdditions)
- (CPArray)blendThemeObjectTemplates
{
var theClass = [self class];
if ([theClass isKindOfClass:[AKThemeObjectTemplate class]])
return [self];
if ([theClass isKindOfClass:[CPView class]])
{
var templates = [],
subviews = [self subviews],
count = [subviews count];
while (count--)
templates = templates.concat([subviews[count] blendThemeObjectTemplates]);
return templates;
}
return [];
}
@end
@implementation AKThemeObjectTemplate (BlendAdditions)
- (void)blendAddThemedObjectAttributesToTheme:(CPTheme)aTheme
{
var themedObject = [self valueForKey:@"themedObject"];
if (!themedObject)
{
var subviews = [self subviews];
if ([subviews count] > 0)
themedObject = subviews[0];
}
if (themedObject)
{
print(" Recording theme for " + [themedObject className] + ".");
[aTheme takeThemeFromObject:themedObject];
}
}
@end
main.apply(main, args);
-28
View File
@@ -1,28 +0,0 @@
<?xml version = "1.0"?>
<project name = "nib2cib" default = "build" basedir = "." >
<import file = "../../common.xml" />
<import file = "${env.OBJJ_LIB}/steam/steam.xml" />
<filelist id = "Projects" dir = ".">
<file name = "BlendKit/build.xml" />
<file name = "Tool/build.xml" />
</filelist>
<target name = "build">
<iterate target = "build">
<files>
<filelist refid = "Projects" />
</files>
</iterate>
</target>
<target name = "clean">
<iterate target = "clean">
<files>
<filelist refid = "Projects" />
</files>
</iterate>
</target>
</project>
+7
View File
@@ -79,5 +79,12 @@ def cat(files, outfile)
end
end
$OBJJ_TEMPLATE_EXECUTABLE = File.join($HOME_DIR, 'Rake', 'Resources', 'objj-executable')
def make_objj_executable(path)
cp($OBJJ_TEMPLATE_EXECUTABLE, path)
File.chmod 0755, path
end
task :build => [$ENVIRONMENT_JS]
task :default => [:build]