mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-04-27 22:41:16 +08:00
the build mode can now be specified using the 'mode
This commit is contained in:
@@ -101,38 +101,17 @@ task :simulator => ['build:simulator'] do
|
||||
sh "#{env} #{sim} #{debug} #{family_int} #{target} \"#{xcode}\" \"#{app}\""
|
||||
end
|
||||
|
||||
desc "Create archives for everything"
|
||||
task :archive => ['archive:development', 'archive:release']
|
||||
|
||||
def create_ipa
|
||||
app_bundle = App.config.app_bundle('iPhoneOS')
|
||||
archive = App.config.archive
|
||||
if !File.exist?(archive) or File.mtime(app_bundle) > File.mtime(archive)
|
||||
App.info 'Create', archive
|
||||
tmp = "/tmp/ipa_root"
|
||||
sh "/bin/rm -rf #{tmp}"
|
||||
sh "/bin/mkdir -p #{tmp}/Payload"
|
||||
sh "/bin/cp -r \"#{app_bundle}\" #{tmp}/Payload"
|
||||
Dir.chdir(tmp) do
|
||||
sh "/bin/chmod -R 755 Payload"
|
||||
sh "/usr/bin/zip -q -r archive.zip Payload"
|
||||
end
|
||||
sh "/bin/cp #{tmp}/archive.zip \"#{archive}\""
|
||||
end
|
||||
desc "Create an .ipa archive"
|
||||
task :archive => ['build:device'] do
|
||||
App.archive
|
||||
end
|
||||
|
||||
namespace :archive do
|
||||
desc "Create an .ipa archive for development"
|
||||
task :development do
|
||||
App.config_mode = :development
|
||||
Rake::Task["build:device"].execute
|
||||
App.archive
|
||||
end
|
||||
|
||||
desc "Create an .ipa for release (AppStore)"
|
||||
task :release do
|
||||
App.config_mode = :release
|
||||
Rake::Task["build:device"].execute
|
||||
desc "Create an .ipa archive for distribution (AppStore)"
|
||||
task :distribution do
|
||||
App.config_without_setup.build_mode = :release
|
||||
App.config.distribution_mode = true
|
||||
Rake::Task["build:device"].invoke
|
||||
App.archive
|
||||
end
|
||||
end
|
||||
@@ -144,7 +123,7 @@ task :spec do
|
||||
end
|
||||
|
||||
desc "Deploy on the device"
|
||||
task :device => 'archive:development' do
|
||||
task :device => :archive do
|
||||
App.info 'Deploy', App.config.archive
|
||||
device_id = (ENV['id'] or App.config.device_id)
|
||||
unless App.config.provisioned_devices.include?(device_id)
|
||||
|
||||
@@ -37,31 +37,35 @@ module Motion; module Project
|
||||
|
||||
class << self
|
||||
def config_mode
|
||||
@config_mode or :development
|
||||
@config_mode ||= begin
|
||||
if mode = ENV['mode']
|
||||
case mode = mode.intern
|
||||
when :development, :release
|
||||
mode
|
||||
else
|
||||
fail "Invalid value for build mode `#{mode}' (must be :development or :release)"
|
||||
end
|
||||
else
|
||||
:development
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def config_mode=(mode)
|
||||
@config_mode = mode
|
||||
end
|
||||
|
||||
def configs
|
||||
@configs ||= {
|
||||
:development => Motion::Project::Config.new('.', :development),
|
||||
:release => Motion::Project::Config.new('.', :release)
|
||||
}
|
||||
def config_without_setup
|
||||
@configs ||= {}
|
||||
@configs[config_mode] ||= Motion::Project::Config.new('.', config_mode)
|
||||
end
|
||||
|
||||
def config
|
||||
configs[config_mode]
|
||||
config_without_setup.setup
|
||||
end
|
||||
|
||||
def builder
|
||||
@builder ||= Motion::Project::Builder.new
|
||||
end
|
||||
|
||||
def setup
|
||||
configs.each_value { |x| yield x }
|
||||
config.validate
|
||||
def setup(&block)
|
||||
config.setup_blocks << block
|
||||
end
|
||||
|
||||
def build(platform, opts={})
|
||||
|
||||
@@ -86,7 +86,7 @@ module Motion; module Project;
|
||||
# LLVM bitcode.
|
||||
bc = File.join(objs_build_dir, "#{path}.#{arch}.bc")
|
||||
bs_flags = bs_files.map { |x| "--uses-bs \"" + x + "\" " }.join(' ')
|
||||
sh "/usr/bin/env VM_KERNEL_PATH=\"#{kernel}\" #{ruby} #{bs_flags} --emit-llvm \"#{bc}\" #{init_func} \"#{path}\""
|
||||
sh "/usr/bin/env VM_KERNEL_PATH=\"#{kernel}\" VM_OPT_LEVEL=\"#{config.opt_level}\" #{ruby} #{bs_flags} --emit-llvm \"#{bc}\" #{init_func} \"#{path}\""
|
||||
|
||||
# Assembly.
|
||||
asm = File.join(objs_build_dir, "#{path}.#{arch}.s")
|
||||
|
||||
@@ -54,7 +54,8 @@ module Motion; module Project
|
||||
:short_version, :icons, :prerendered_icon, :background_modes, :seed_id,
|
||||
:entitlements, :fonts, :status_bar_style, :motiondir
|
||||
|
||||
attr_accessor :spec_mode
|
||||
# Internal only.
|
||||
attr_accessor :build_mode, :spec_mode, :distribution_mode
|
||||
|
||||
def initialize(project_dir, build_mode)
|
||||
@project_dir = project_dir
|
||||
@@ -98,6 +99,19 @@ module Motion; module Project
|
||||
map
|
||||
end
|
||||
|
||||
def setup_blocks
|
||||
@setup_blocks ||= []
|
||||
end
|
||||
|
||||
def setup
|
||||
if @setup_blocks
|
||||
@setup_blocks.each { |b| b.call(self) }
|
||||
@setup_blocks = nil
|
||||
validate
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
def xcode_dir
|
||||
@xcode_dir ||= begin
|
||||
xcode_dot_app_path = '/Applications/Xcode.app/Contents/Developer'
|
||||
@@ -214,6 +228,14 @@ EOS
|
||||
yield if release?
|
||||
end
|
||||
|
||||
def opt_level
|
||||
@opt_level ||= case @build_mode
|
||||
when :development; 0
|
||||
when :release; 3
|
||||
else; 0
|
||||
end
|
||||
end
|
||||
|
||||
def versionized_build_dir(platform)
|
||||
File.join(build_dir, platform + '-' + deployment_target + '-' + build_mode_name)
|
||||
end
|
||||
@@ -575,7 +597,7 @@ EOS
|
||||
|
||||
def codesign_certificate
|
||||
@codesign_certificate ||= begin
|
||||
cert_type = (development? ? 'Developer' : 'Distribution')
|
||||
cert_type = (distribution_mode ? 'Distribution' : 'Developer')
|
||||
certs = `/usr/bin/security -q find-certificate -a`.scan(/"iPhone #{cert_type}: [^"]+"/).uniq
|
||||
if certs.size == 0
|
||||
App.fail "Can't find an iPhone Developer certificate in the keychain"
|
||||
@@ -638,7 +660,7 @@ EOS
|
||||
|
||||
def entitlements_data
|
||||
dict = entitlements
|
||||
if release?
|
||||
if distribution_mode
|
||||
dict['application-identifier'] ||= seed_id + '.' + identifier
|
||||
else
|
||||
# Required for gdb.
|
||||
|
||||
Reference in New Issue
Block a user