mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-04-03 09:45:14 +08:00
introduce deployment_target project variable, misc fixes
This commit is contained in:
@@ -27,11 +27,11 @@ end
|
||||
desc "Run the simulator"
|
||||
task :simulator => ['build:simulator'] do
|
||||
app = App.config.app_bundle('iPhoneSimulator')
|
||||
sdk_version = App.config.sdk_version
|
||||
target = App.config.deployment_target
|
||||
|
||||
# Cleanup the simulator application sandbox, to avoid having old resource files there.
|
||||
if ENV['clean']
|
||||
sim_apps = File.expand_path("~/Library/Application Support/iPhone Simulator/#{sdk_version}/Applications")
|
||||
sim_apps = File.expand_path("~/Library/Application Support/iPhone Simulator/#{target}/Applications")
|
||||
Dir.glob("#{sim_apps}/**/*.app").each do |app_bundle|
|
||||
if File.basename(app_bundle) == File.basename(app)
|
||||
rm_rf File.dirname(app_bundle)
|
||||
@@ -52,7 +52,7 @@ task :simulator => ['build:simulator'] do
|
||||
sim = File.join(App.config.bindir, 'sim')
|
||||
debug = (ENV['debug'] || '0') == '1' ? 1 : 0
|
||||
App.info 'Simulate', app
|
||||
sh "#{sim} #{debug} #{family_int} #{sdk_version} \"#{app}\""
|
||||
sh "#{sim} #{debug} #{family_int} #{target} \"#{app}\""
|
||||
end
|
||||
|
||||
desc "Create an .ipa archive"
|
||||
|
||||
@@ -23,7 +23,7 @@ module Motion; module Project;
|
||||
cc = File.join(config.platform_dir(platform), 'Developer/usr/bin/gcc')
|
||||
cxx = File.join(config.platform_dir(platform), 'Developer/usr/bin/g++')
|
||||
|
||||
build_dir = File.join(config.build_dir, platform)
|
||||
build_dir = File.join(config.versionized_build_dir, platform)
|
||||
|
||||
# Prepare the list of BridgeSupport files needed.
|
||||
bs_files = config.bridgesupport_files
|
||||
@@ -37,7 +37,7 @@ module Motion; module Project;
|
||||
end
|
||||
|
||||
# Build object files.
|
||||
objs_build_dir = File.join(build_dir, config.sdk_version + '-sdk-objs')
|
||||
objs_build_dir = File.join(build_dir, 'objs')
|
||||
FileUtils.mkdir_p(objs_build_dir)
|
||||
project_file_changed = File.mtime(config.project_file) > File.mtime(objs_build_dir)
|
||||
build_file = Proc.new do |path|
|
||||
@@ -232,7 +232,7 @@ EOS
|
||||
main_o = File.join(objs_build_dir, 'main.o')
|
||||
if !(File.exist?(main) and File.exist?(main_o) and File.read(main) == main_txt)
|
||||
File.open(main, 'w') { |io| io.write(main_txt) }
|
||||
sh "#{cxx} \"#{main}\" #{arch_flags} -fexceptions -fblocks -isysroot \"#{sdk}\" -miphoneos-version-min=#{config.sdk_version} -fobjc-legacy-dispatch -fobjc-abi-version=2 -c -o \"#{main_o}\""
|
||||
sh "#{cxx} \"#{main}\" #{arch_flags} -fexceptions -fblocks -isysroot \"#{sdk}\" -miphoneos-version-min=#{config.deployment_target} -fobjc-legacy-dispatch -fobjc-abi-version=2 -c -o \"#{main_o}\""
|
||||
end
|
||||
|
||||
# Prepare bundle.
|
||||
@@ -256,7 +256,7 @@ EOS
|
||||
stubs_obj = File.join(datadir, platform, "#{framework}_stubs.o")
|
||||
framework_stubs_objs << "\"#{stubs_obj}\"" if File.exist?(stubs_obj)
|
||||
end
|
||||
sh "#{cxx} -o \"#{main_exec}\" #{objs_list} #{arch_flags} #{framework_stubs_objs.join(' ')} -isysroot \"#{sdk}\" -miphoneos-version-min=#{config.sdk_version} -L#{File.join(datadir, platform)} -lmacruby-static -lobjc -licucore #{frameworks} #{config.libs.join(' ')} #{vendor_libs.map { |x| '-force_load ' + x }.join(' ')}"
|
||||
sh "#{cxx} -o \"#{main_exec}\" #{objs_list} #{arch_flags} #{framework_stubs_objs.join(' ')} -isysroot \"#{sdk}\" -miphoneos-version-min=#{config.deployment_target} -L#{File.join(datadir, platform)} -lmacruby-static -lobjc -licucore #{frameworks} #{config.libs.join(' ')} #{vendor_libs.map { |x| '-force_load ' + x }.join(' ')}"
|
||||
end
|
||||
|
||||
# Create bundle/Info.plist.
|
||||
@@ -369,7 +369,7 @@ PLIST
|
||||
if File.mtime(config.project_file) > File.mtime(bundle_path) \
|
||||
or !system("#{codesign_cmd} --verify \"#{bundle_path}\" >& /dev/null")
|
||||
App.info 'Codesign', bundle_path
|
||||
entitlements = File.join(config.build_dir, platform, "Entitlements.plist")
|
||||
entitlements = File.join(config.versionized_build_dir, platform, "Entitlements.plist")
|
||||
File.open(entitlements, 'w') { |io| io.write(config.entitlements_data) }
|
||||
sh "#{codesign_cmd} -f -s \"#{config.codesign_certificate}\" --resource-rules=\"#{resource_rules_plist}\" --entitlements #{entitlements} \"#{bundle_path}\""
|
||||
end
|
||||
|
||||
@@ -24,11 +24,11 @@ module Motion; module Project
|
||||
end
|
||||
end
|
||||
|
||||
variable :files, :platforms_dir, :sdk_version, :frameworks, :libs,
|
||||
:delegate_class, :name, :build_dir, :resources_dir, :specs_dir,
|
||||
:identifier, :codesign_certificate, :provisioning_profile, :device_family,
|
||||
:interface_orientations, :version, :icons, :prerendered_icon, :seed_id,
|
||||
:entitlements
|
||||
variable :files, :platforms_dir, :sdk_version, :deployment_target,
|
||||
:frameworks, :libs, :delegate_class, :name, :build_dir, :resources_dir,
|
||||
:specs_dir, :identifier, :codesign_certificate, :provisioning_profile,
|
||||
:device_family, :interface_orientations, :version, :icons,
|
||||
:prerendered_icon, :seed_id, :entitlements
|
||||
|
||||
def initialize(project_dir)
|
||||
@project_dir = project_dir
|
||||
@@ -74,28 +74,39 @@ module Motion; module Project
|
||||
App.fail "Can't locate #{platform} SDK #{sdk_version} at `#{sdk_path}'"
|
||||
end
|
||||
end
|
||||
|
||||
# deployment_target
|
||||
if deployment_target > sdk_version
|
||||
App.fail "Deployment target `#{deployment_target}' must be equal or lesser than SDK version `#{sdk_version}'"
|
||||
end
|
||||
unless File.exist?(datadir)
|
||||
App.fail "iOS SDK #{sdk_version} is not supported by this version of RubyMotion"
|
||||
App.fail "iOS deployment target #{deployment_target} is not supported by this version of RubyMotion"
|
||||
end
|
||||
end
|
||||
|
||||
def build_dir
|
||||
tried = false
|
||||
begin
|
||||
FileUtils.mkdir_p(@build_dir)
|
||||
rescue Errno::EACCES
|
||||
raise if tried
|
||||
require 'digest/sha1'
|
||||
hash = Digest::SHA1.hexdigest(File.expand_path(project_dir))
|
||||
tmp = File.join(ENV['TMPDIR'], hash)
|
||||
App.warn "Cannot create build_dir `#{@build_dir}'. Check the permissions. Using a temporary build directory instead: `#{tmp}'"
|
||||
@build_dir = tmp
|
||||
tried = true
|
||||
retry
|
||||
unless File.directory?(@build_dir)
|
||||
tried = false
|
||||
begin
|
||||
FileUtils.mkdir_p(@build_dir)
|
||||
rescue Errno::EACCES
|
||||
raise if tried
|
||||
require 'digest/sha1'
|
||||
hash = Digest::SHA1.hexdigest(File.expand_path(project_dir))
|
||||
tmp = File.join(ENV['TMPDIR'], hash)
|
||||
App.warn "Cannot create build_dir `#{@build_dir}'. Check the permissions. Using a temporary build directory instead: `#{tmp}'"
|
||||
@build_dir = tmp
|
||||
tried = true
|
||||
retry
|
||||
end
|
||||
end
|
||||
@build_dir
|
||||
end
|
||||
|
||||
def versionized_build_dir
|
||||
File.join(build_dir, deployment_target)
|
||||
end
|
||||
|
||||
attr_reader :project_dir
|
||||
|
||||
def project_file
|
||||
@@ -190,8 +201,8 @@ module Motion; module Project
|
||||
File.join(motiondir, 'bin')
|
||||
end
|
||||
|
||||
def datadir
|
||||
File.join(motiondir, 'data', sdk_version)
|
||||
def datadir(target=deployment_target)
|
||||
File.join(motiondir, 'data', target)
|
||||
end
|
||||
|
||||
def platform_dir(platform)
|
||||
@@ -205,28 +216,34 @@ module Motion; module Project
|
||||
end
|
||||
if versions.size == 0
|
||||
App.fail "Can't find an iOS SDK in `#{platforms_dir}'"
|
||||
#elsif versions.size > 1
|
||||
# $stderr.puts "found #{versions.size} SDKs, will use the latest one"
|
||||
end
|
||||
versions.max
|
||||
supported_vers = versions.reverse.find { |vers| File.exist?(datadir(vers)) }
|
||||
unless supported_vers
|
||||
App.fail "RubyMotion doesn't support any of these SDK versions: #{versions.join(', ')}"
|
||||
end
|
||||
supported_vers
|
||||
end
|
||||
end
|
||||
|
||||
def deployment_target
|
||||
@deployment_target ||= @sdk_version
|
||||
end
|
||||
|
||||
def sdk(platform)
|
||||
File.join(platform_dir(platform), 'Developer/SDKs',
|
||||
platform + sdk_version + '.sdk')
|
||||
end
|
||||
|
||||
def app_bundle(platform)
|
||||
File.join(@build_dir, platform, @name + '.app')
|
||||
File.join(versionized_build_dir, platform, @name + '.app')
|
||||
end
|
||||
|
||||
def app_bundle_dsym(platform)
|
||||
File.join(@build_dir, platform, @name + '.dSYM')
|
||||
File.join(versionized_build_dir, platform, @name + '.dSYM')
|
||||
end
|
||||
|
||||
def archive
|
||||
File.join(@build_dir, @name + '.ipa')
|
||||
File.join(versionized_build_dir, @name + '.ipa')
|
||||
end
|
||||
|
||||
def identifier
|
||||
@@ -263,7 +280,7 @@ module Motion; module Project
|
||||
def info_plist
|
||||
@info_plist ||= {
|
||||
'BuildMachineOSBuild' => `sw_vers -buildVersion`.strip,
|
||||
'MinimumOSVersion' => sdk_version,
|
||||
'MinimumOSVersion' => deployment_target,
|
||||
'CFBundleDevelopmentRegion' => 'en',
|
||||
'CFBundleName' => @name,
|
||||
'CFBundleDisplayName' => @name,
|
||||
|
||||
Reference in New Issue
Block a user