From 3bd28b28ab59f8d1046dbdeed21e8318d6532a80 Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Sun, 22 Mar 2009 08:12:54 -0700 Subject: [PATCH] Fixed nib2cib importing of external custom frameworks and added bundle types. Reviewed by me. --- AppKit/Rakefile | 1 + AppKit/Tools/BlendKit/rakefile | 33 ------------------------------ Foundation/Rakefile | 1 + Rake/lib/objective-j.rb | 22 ++++++++++++++++++++ Rake/lib/objective-j/bundletask.rb | 10 ++++++--- Tools/nib2cib/main.j | 28 ++++++++++++------------- 6 files changed, 45 insertions(+), 50 deletions(-) delete mode 100644 AppKit/Tools/BlendKit/rakefile diff --git a/AppKit/Rakefile b/AppKit/Rakefile index a20ba598b..764afb011 100644 --- a/AppKit/Rakefile +++ b/AppKit/Rakefile @@ -27,6 +27,7 @@ ObjectiveJ::BundleTask.new(:AppKit) do |t| t.build_path = $BUILD_PATH t.flag = 'DEBUG' if $CONFIGURATION == 'Debug' t.platforms = [ObjectiveJ::Platform::Browser, ObjectiveJ::Platform::Rhino] + t.type = ObjectiveJ::Bundle::Type::Framework end # It would be nice to just have ENVIRONMENT_PRODUCT depend on THEME_PRODUCT, diff --git a/AppKit/Tools/BlendKit/rakefile b/AppKit/Tools/BlendKit/rakefile deleted file mode 100644 index caee7358d..000000000 --- a/AppKit/Tools/BlendKit/rakefile +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env ruby - -require 'rake' -require '../../../common' -require 'objective-j' -require 'objective-j/bundletask' - - -$ENVIRONMENT_PRODUCT = File.join($ENVIRONMENT_FRAMEWORKS_DIR, 'BlendKit') -$BUILD_PATH = File.join($BUILD_DIR, $CONFIGURATION, 'BlendKit') - -ObjectiveJ::BundleTask.new(:BlendKit) do |t| - t.name = 'BlendKit' - t.identifier = 'com.280n.BlendKit' - t.version = '0.6.5' - t.author = '280 North, Inc.' - t.email = 'feedback @nospam@ 280north.com' - t.summary = 'BlendKit classes for Cappuccino' - t.sources = FileList['*.j'] - t.resources = FileList['Resources/*'].to_a - t.license = ObjectiveJ::License::LGPL_v2_1 - t.build_path = $BUILD_PATH - t.flag = 'DEBUG' if $CONFIGURATION == 'Debug' -end - -#Framework in environment directory -file_d $ENVIRONMENT_PRODUCT => [:BlendKit] do - cp_r(File.join($BUILD_PATH, '.'), $ENVIRONMENT_PRODUCT) -end - -task :build => [:BlendKit, $ENVIRONMENT_PRODUCT] - -CLOBBER.include($ENVIRONMENT_PRODUCT) diff --git a/Foundation/Rakefile b/Foundation/Rakefile index 8c7ecba25..ea18bce45 100644 --- a/Foundation/Rakefile +++ b/Foundation/Rakefile @@ -23,6 +23,7 @@ ObjectiveJ::BundleTask.new(:Foundation) do |t| t.license = ObjectiveJ::License::LGPL_v2_1 t.build_path = $BUILD_PATH t.flag = 'DEBUG' if $CONFIGURATION == 'Debug' + t.type = ObjectiveJ::Bundle::Type::Framework end #Framework in environment directory diff --git a/Rake/lib/objective-j.rb b/Rake/lib/objective-j.rb index f29eaa719..307b1ba8b 100644 --- a/Rake/lib/objective-j.rb +++ b/Rake/lib/objective-j.rb @@ -51,6 +51,28 @@ module ObjectiveJ end +module ObjectiveJ + + class Bundle + + class Type + + Application = :Application + Framework = :Framework + + CODE_STRINGS = + { + Application => '280N', + Framework => 'FMWK' + } + + def Type.code_string(type) + return CODE_STRINGS[type] || type.to_s + end + end + end +end + def file_d(*args, &block) fileTask = Rake::FileTask.define_task(*args, &block) diff --git a/Rake/lib/objective-j/bundletask.rb b/Rake/lib/objective-j/bundletask.rb index 05e6eecbe..940591902 100644 --- a/Rake/lib/objective-j/bundletask.rb +++ b/Rake/lib/objective-j/bundletask.rb @@ -191,6 +191,7 @@ module ObjectiveJ required_attribute :summary required_attribute :identifier required_attribute :platforms, [Platform::ObjJ] + required_attribute :type, Bundle::Type::Application # ------------------------- OPTIONAL gemspec attributes. @@ -200,7 +201,7 @@ module ObjectiveJ # attribute :platform, Gem::Platform::RUBY array_attribute :authors - array_attribute :sources + attributes :sources array_attribute :resources array_attribute :flags # array_attribute :test_files @@ -407,7 +408,7 @@ module ObjectiveJ end info_plist_path = build_path + '/Info.plist' - info_plist = { 'CPBundleName' => name, 'CPBundleIdentifier' => identifier, 'CPBundleInfoDictionaryVersion' => 6.0, 'CPBundleVersion' => version } + info_plist = { 'CPBundleName' => name, 'CPBundleIdentifier' => identifier, 'CPBundleInfoDictionaryVersion' => 6.0, 'CPBundleVersion' => version, 'CPBundlePackageType' => Bundle::Type.code_string(type) } info_plist['CPBundlePlatforms'] = platforms; @@ -446,7 +447,10 @@ module ObjectiveJ # Yes its unfortunate that we need to regenerate the whole executable if the Info.plist changes. Oh well. file_d executable_path => info_plist_path - sources.each do |source| + platform_sources = sources + platform_sources = sources[platform] if sources.class == Hash + + platform_sources.each do |source| # This needs to be way better. if File.basename(source) == 'index.html' diff --git a/Tools/nib2cib/main.j b/Tools/nib2cib/main.j index 52b5882c1..bf5a97418 100644 --- a/Tools/nib2cib/main.j +++ b/Tools/nib2cib/main.j @@ -164,14 +164,6 @@ function readPlist(/*File*/ aFile) return new CPPropertyListCreateFromData(data); } -function importFiles(filePaths, aCallback) -{ - if (filePaths.length === 0) - aCallback(); - else - objj_import(new File(filePaths.shift()).getCanonicalPath(), YES, function() { importFiles(filePaths, aCallback) }); -} - function loadFrameworks(frameworkPaths, aCallback) { if (frameworkPaths.length === 0) @@ -191,18 +183,26 @@ function loadFrameworks(frameworkPaths, aCallback) if ([infoDictionary objectForKey:@"CPBundlePackageType"] !== "FMWK") { - java.lang.System.out.println("'" + frameworkPath + "' is not a framework ."); + java.lang.System.out.println("'" + frameworkPath + "' is not a framework."); java.lang.System.exit(1); } var files = [infoDictionary objectForKey:@"CPBundleReplacedFiles"], - index = 0, count = files.length; - - for (; index < count; ++index) - files[index] = frameworkPath + '/' + files[index]; - importFiles(files, function() { loadFrameworks(frameworkPaths, aCallback) }); + if (count) + { + var context = new objj_context(); + + context.didCompleteCallback = function() { loadFrameworks(frameworkPaths, aCallback) }; + + while (count--) + context.pushFragment(fragment_create_file(frameworkPath + '/' + files[count], new objj_bundle(""), YES, NULL)); + + context.evaluate(); + } + else + loadFrameworks(frameworkPaths, aCallback); } function main()