From dbc2b08a5d71aad1e0fcae1025e1d63943951f83 Mon Sep 17 00:00:00 2001 From: Hwee-Boon Yar Date: Sat, 20 Sep 2014 20:45:57 +0800 Subject: [PATCH] [OS X] Add codesign_frameworks to configuration. Use it to specify which frameworks to codesign. --- lib/motion/project/app.rb | 4 ++++ lib/motion/project/template/osx.rb | 14 ++++++++++++-- lib/motion/project/template/osx/builder.rb | 10 ++++++++++ lib/motion/project/template/osx/config.rb | 3 ++- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/lib/motion/project/app.rb b/lib/motion/project/app.rb index 69a1a436..ee98526b 100644 --- a/lib/motion/project/app.rb +++ b/lib/motion/project/app.rb @@ -86,6 +86,10 @@ def codesign(platform) builder.codesign(config, platform) end + def codesign_framework(framework) + builder.codesign_framework(framework, config) + end + def profile(platform, config_plist) builder.profile(config, platform, config_plist) end diff --git a/lib/motion/project/template/osx.rb b/lib/motion/project/template/osx.rb index d7f2e15a..fade588f 100644 --- a/lib/motion/project/template/osx.rb +++ b/lib/motion/project/template/osx.rb @@ -39,14 +39,24 @@ desc "Build the project for development" task :development do App.build('MacOSX') - App.codesign('MacOSX') if App.config_without_setup.codesign_for_development + if App.config_without_setup.codesign_for_development + App.config.codesign_frameworks.each do |e| + App.codesign_framework(e) + end + App.codesign('MacOSX') + end end desc "Build the project for release" task :release do App.config_without_setup.build_mode = :release App.build('MacOSX') - App.codesign('MacOSX') if App.config_without_setup.codesign_for_release + if App.config_without_setup.codesign_for_release + App.config.codesign_frameworks.each do |e| + App.codesign_framework(e) + end + App.codesign('MacOSX') + end end end diff --git a/lib/motion/project/template/osx/builder.rb b/lib/motion/project/template/osx/builder.rb index 900602e7..046de667 100644 --- a/lib/motion/project/template/osx/builder.rb +++ b/lib/motion/project/template/osx/builder.rb @@ -52,5 +52,15 @@ def codesign(config, platform) sh "/usr/bin/codesign --force --sign \"#{config.codesign_certificate}\" --entitlements \"#{entitlements}\" \"#{app_bundle}\"" end end + + def codesign_framework(framework, config) + app_bundle = config.app_bundle_raw('MacOSX') + path = "#{app_bundle}/Contents/Frameworks/#{framework}/Versions/A" + if File.mtime(config.project_file) > File.mtime(path) \ + or !system("/usr/bin/codesign --verify \"#{path}\" >& /dev/null") + App.info 'Codesign', path + sh "/usr/bin/codesign --force --sign \"#{config.codesign_certificate}\" \"#{path}\"" + end + end end end; end diff --git a/lib/motion/project/template/osx/config.rb b/lib/motion/project/template/osx/config.rb index dffb0b4e..2f533f39 100644 --- a/lib/motion/project/template/osx/config.rb +++ b/lib/motion/project/template/osx/config.rb @@ -33,7 +33,7 @@ class OSXConfig < XcodeConfig variable :icon, :copyright, :category, :embedded_frameworks, :external_frameworks, :codesign_for_development, :codesign_for_release, - :eval_support + :eval_support, :codesign_frameworks def initialize(project_dir, build_mode) super @@ -43,6 +43,7 @@ def initialize(project_dir, build_mode) @frameworks = ['AppKit', 'Foundation', 'CoreGraphics', 'CoreServices'] @codesign_for_development = false @codesign_for_release = true + @codesign_frameworks = [] @eval_support = false end