[macruby-changes] [725] MacRuby/trunk/lib/hotcocoa
source_changes at macosforge.org
source_changes at macosforge.org
Mon Nov 10 16:15:08 PST 2008
Revision: 725
http://trac.macosforge.org/projects/ruby/changeset/725
Author: rich at infoether.com
Date: 2008-11-10 16:15:08 -0800 (Mon, 10 Nov 2008)
Log Message:
-----------
add standard rake tasks and build support
Modified Paths:
--------------
MacRuby/trunk/lib/hotcocoa/application_builder.rb
Added Paths:
-----------
MacRuby/trunk/lib/hotcocoa/standard_rake_tasks.rb
Modified: MacRuby/trunk/lib/hotcocoa/application_builder.rb
===================================================================
--- MacRuby/trunk/lib/hotcocoa/application_builder.rb 2008-11-11 00:11:52 UTC (rev 724)
+++ MacRuby/trunk/lib/hotcocoa/application_builder.rb 2008-11-11 00:15:08 UTC (rev 725)
@@ -37,9 +37,9 @@
ApplicationBundlePackage = "APPL????"
- attr_accessor :name, :load_file, :sources, :overwrite, :icon, :version, :info_string, :secure, :resources
+ attr_accessor :name, :load_file, :sources, :overwrite, :icon, :version, :info_string, :secure, :resources, :deploy
- def self.build(config)
+ def self.build(config, options={:deploy => false})
unless config.kind_of?(Configuration)
require 'rbconfig'
puts "Your Rakefile needs to be updated. Please copy the Rakefile from:"
@@ -47,6 +47,7 @@
exit
end
builder = new
+ builder.deploy = options[:deploy] == true ? true : false
builder.secure = config.secure?
builder.name = config.name
builder.load_file = config.load
@@ -74,9 +75,14 @@
write_bundle_files
copy_sources
copy_resources
+ copy_framework if deploy?
copy_icon_file if icon
end
+ def deploy?
+ @deploy
+ end
+
def overwrite?
@overwrite
end
@@ -108,6 +114,7 @@
def build_bundle_structure
Dir.mkdir(bundle_root) unless File.exist?(bundle_root)
Dir.mkdir(contents_root) unless File.exist?(contents_root)
+ Dir.mkdir(frameworks_root) unless File.exist?(frameworks_root)
Dir.mkdir(macos_root) unless File.exist?(macos_root)
Dir.mkdir(resources_root) unless File.exist?(resources_root)
end
@@ -119,6 +126,11 @@
write_ruby_main
end
+ def copy_framework
+ FileUtils.cp_r macruby_framework_path, frameworks_root
+ `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
+
def copy_sources
if secure?
data = {}
@@ -211,10 +223,9 @@
require 'hotcocoa/virtual_file_system'
f.puts VirtualFileSystem.code_to_load(load_file)
else
- f.puts %{
- $:.unshift NSBundle.mainBundle.resourcePath.fileSystemRepresentation
- load '#{load_file}'
- }
+ f.puts "$:.map! { |x| x.sub(/^\\/Library\\/Frameworks/, NSBundle.mainBundle.privateFrameworksPath) }" if deploy?
+ f.puts "$:.unshift NSBundle.mainBundle.resourcePath.fileSystemRepresentation"
+ f.puts "load '#{load_file}'"
end
end
end
@@ -226,6 +237,10 @@
def contents_root
File.join(bundle_root, "Contents")
end
+
+ def frameworks_root
+ File.join(contents_root, "Frameworks")
+ end
def macos_root
File.join(contents_root, "MacOS")
@@ -258,6 +273,22 @@
def main_ruby_source_file
File.join(resources_root, "rb_main.rb")
end
+
+ def current_macruby_version
+ NSFileManager.defaultManager.pathContentOfSymbolicLinkAtPath(File.join(macruby_versions_path, "Current"))
+ end
+
+ def current_macruby_path
+ File.join(macruby_versions_path, current_macruby_version)
+ end
+
+ def macruby_versions_path
+ File.join(macruby_framework_path, "Versions")
+ end
+
+ def macruby_framework_path
+ "/Library/Frameworks/MacRuby.framework"
+ end
end
Added: MacRuby/trunk/lib/hotcocoa/standard_rake_tasks.rb
===================================================================
--- MacRuby/trunk/lib/hotcocoa/standard_rake_tasks.rb (rev 0)
+++ MacRuby/trunk/lib/hotcocoa/standard_rake_tasks.rb 2008-11-11 00:15:08 UTC (rev 725)
@@ -0,0 +1,17 @@
+AppConfig = ApplicationBuilder::Configuration.new("config/build.yml")
+
+task :deploy => [:clean] do
+ ApplicationBuilder.build(AppConfig, :deploy => true)
+end
+
+task :build do
+ ApplicationBuilder.build(AppConfig)
+end
+
+task :run => [:build] do
+ `/usr/bin/open "#{AppConfig.name}.app"`
+end
+
+task :clean do
+ `/bin/rm -rf "#{AppConfig.name}.app"`
+end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20081110/c247c897/attachment.html>
More information about the macruby-changes
mailing list