Skip to content

Commit

Permalink
[OS X] Add codesign_frameworks to configuration. Use it to specify which
Browse files Browse the repository at this point in the history
frameworks to codesign.
  • Loading branch information
hboon committed Sep 20, 2014
1 parent e247650 commit dbc2b08
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
4 changes: 4 additions & 0 deletions lib/motion/project/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions lib/motion/project/template/osx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions lib/motion/project/template/osx/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion lib/motion/project/template/osx/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit dbc2b08

Please sign in to comment.