Revision: 764 http://trac.macosforge.org/projects/ruby/changeset/764 Author: lsansonetti@apple.com Date: 2008-12-02 23:29:05 -0800 (Tue, 02 Dec 2008) Log Message: ----------- deprecate the 'build_as_embeddable' build config variable, refactor HotCocoa's ApplicationBuilder to support a direct deploy facility, introduce a 'Embed MacRuby' Xcode target that calls HotCocoa's ApplicationBuilder's deploy facility Modified Paths: -------------- MacRuby/trunk/Rakefile MacRuby/trunk/lib/hotcocoa/application_builder.rb Added Paths: ----------- MacRuby/trunk/misc/xcode-templates/Target Templates/ MacRuby/trunk/misc/xcode-templates/Target Templates/Embed MacRuby.trgttmpl Modified: MacRuby/trunk/Rakefile =================================================================== --- MacRuby/trunk/Rakefile 2008-12-03 06:07:05 UTC (rev 763) +++ MacRuby/trunk/Rakefile 2008-12-03 07:29:05 UTC (rev 764) @@ -1,6 +1,6 @@ # User customizable variables. # These variables can be set from the command line. Example: -# $ rake build_as_embeddable=true +# $ rake framework_instdir=~/Library/Frameworks sym_instdir=~/bin def do_option(name, default) val = ENV[name] @@ -28,7 +28,6 @@ FRAMEWORK_INSTDIR = do_option('framework_instdir', '/Library/Frameworks') SYM_INSTDIR = do_option('sym_instdir', '/usr/local') NO_WARN_BUILD = !do_option('allow_build_warnings', false) -BUILD_AS_EMBEDDABLE = do_option('build_as_embeddable', false) ENABLE_STATIC_LIBRARY = do_option('enable_static_library', 'no') { 'yes' } ENABLE_DEBUG_LOGGING = do_option('enable_debug_logging', true) { |x| x == 'true' } @@ -36,6 +35,11 @@ # Everything below this comment should *not* be modified. +if ENV['build_as_embeddable'] + $stderr.puts "The 'build_as_embeddable' build configuration has been removed because it is no longer necessary. To package a full version of MacRuby inside your application, please use `macrake deploy` for HotCocoa apps and the `Embed MacRuby` target for Xcode apps." + exit 1 +end + verbose(true) if `sw_vers -productVersion`.strip.to_f < 10.5 @@ -69,15 +73,7 @@ RUBY_VENDOR_LIB2 = File.join(RUBY_VENDOR_LIB, NEW_RUBY_VERSION) RUBY_VENDOR_ARCHLIB = File.join(RUBY_VENDOR_LIB2, NEW_RUBY_PLATFORM) -INSTALL_NAME = - if BUILD_AS_EMBEDDABLE - File.join("@executable_path/../Frameworks", FRAMEWORK_NAME + '.framework', - 'Versions', MACRUBY_VERSION, 'usr/lib', - 'lib' + RUBY_SO_NAME + '.dylib') - else - File.join(FRAMEWORK_USR_LIB, 'lib' + RUBY_SO_NAME + '.dylib') - end - +INSTALL_NAME = File.join(FRAMEWORK_USR_LIB, 'lib' + RUBY_SO_NAME + '.dylib') ARCHFLAGS = ARCHS.map { |a| '-arch ' + a }.join(' ') CFLAGS = "-I. -I./include -I/usr/include/libxml2 #{ARCHFLAGS} -fno-common -pipe -O2 -g -Wall" CFLAGS << " -Wno-parentheses -Wno-deprecated-declarations -Werror" if NO_WARN_BUILD Modified: MacRuby/trunk/lib/hotcocoa/application_builder.rb =================================================================== --- MacRuby/trunk/lib/hotcocoa/application_builder.rb 2008-12-03 06:07:05 UTC (rev 763) +++ MacRuby/trunk/lib/hotcocoa/application_builder.rb 2008-12-03 07:29:05 UTC (rev 764) @@ -64,7 +64,18 @@ end builder.build end - + + # Used by the "Embed MacRuby" Xcode target. + def self.deploy(path) + raise "Given path `#{path}' does not exist" unless File.exist?(path) + raise "Given path `#{path}' does not look like an application bundle" unless File.extname(path) == '.app' + deployer = new + Dir.chdir(File.dirname(path)) do + deployer.name = File.basename(path, '.app') + deployer.deploy + end + end + def initialize @sources = [] @resources = [] @@ -76,11 +87,15 @@ write_bundle_files copy_sources copy_resources - copy_framework if deploy? - copy_bs_dylibs if deploy? + deploy if deploy? copy_icon_file if icon end - + + def deploy + copy_framework + copy_bs_dylibs + end + def deploy? @deploy end @@ -129,7 +144,10 @@ end def copy_framework - FileUtils.cp_r macruby_framework_path, frameworks_root + unless File.exist?(File.join(frameworks_root, 'MacRuby.framework')) + FileUtils.mkdir_p frameworks_root + FileUtils.cp_r macruby_framework_path, frameworks_root + end `install_name_tool -change #{current_macruby_path}/usr/lib/libmacruby.dylib @executable_path/../Frameworks/MacRuby.framework/Versions/#{current_macruby_version}/usr/lib/libmacruby.dylib '#{macos_root}/#{objective_c_executable_file}'` end Added: MacRuby/trunk/misc/xcode-templates/Target Templates/Embed MacRuby.trgttmpl =================================================================== --- MacRuby/trunk/misc/xcode-templates/Target Templates/Embed MacRuby.trgttmpl (rev 0) +++ MacRuby/trunk/misc/xcode-templates/Target Templates/Embed MacRuby.trgttmpl 2008-12-03 07:29:05 UTC (rev 764) @@ -0,0 +1,13 @@ +{ + Class = Aggregate; + Description = "Target that embeds MacRuby.framework inside the current application bundle."; + CustomBuildSettings = { + }; + BuildPhases = ( + { + Class = ShellScript; + ShellPath = "/bin/sh"; + ShellScript = "PATH=\"$PATH:/usr/local/bin\" /usr/bin/env macruby -r hotcocoa/application_builder -e \"HotCocoa::ApplicationBuilder.deploy(ARGV[0])\" $TARGET_BUILD_DIR/$PROJECT_NAME.app"; + }, + ); +}