Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 348 lines (298 sloc) 12.362 kB
88a5bc3 adding macruby_deploy, a tool to help embedding macruby inside an app…
Laurent Sansonetti authored
1 #!/usr/bin/ruby
2 # MacRuby Deployer.
3 #
4 # This file is covered by the Ruby license.
5 #
7d7d3e8 @ferrous26 Change ownership to The MacRuby Team and update copyrights
ferrous26 authored
6 # Copyright (C) 2012, The MacRuby Team
9595725 update copyrights to 2011
Laurent Sansonetti authored
7 # Copyright (C) 2009-2011, Apple Inc
88a5bc3 adding macruby_deploy, a tool to help embedding macruby inside an app…
Laurent Sansonetti authored
8
9 require 'optparse'
10 require 'rbconfig'
c779569 @alloy Get first requirement for ruby_deploy running.
alloy authored
11 begin
12 load File.join(File.dirname(__FILE__), 'macrubyc')
13 rescue LoadError
14 load File.join(File.dirname(__FILE__), 'rubyc')
15 end
88a5bc3 adding macruby_deploy, a tool to help embedding macruby inside an app…
Laurent Sansonetti authored
16
17 class Deployer
18 NAME = File.basename(__FILE__)
19
20 def initialize(argv)
d430e56 @alloy ruby_deploy: Add --verbose and --stdlib. The latter option allows you…
alloy authored
21 @stdlib = []
793eeed add a --gem option to macruby_deploy which will embed the given gem(s…
Laurent Sansonetti authored
22 @gems = []
d430e56 @alloy ruby_deploy: Add --verbose and --stdlib. The latter option allows you…
alloy authored
23
88a5bc3 adding macruby_deploy, a tool to help embedding macruby inside an app…
Laurent Sansonetti authored
24 OptionParser.new do |opts|
25 opts.banner = "Usage: #{NAME} [options] application-bundle"
8fbcf8c @danielwestendorf Fixed typo, tested on a real MAS App, returned no errors
danielwestendorf authored
26 opts.on('--compile', 'Compile the bundle source code') { @compile = true }
27 opts.on('--embed', 'Embed MacRuby inside the bundle') { @embed = true }
28 opts.on('--no-stdlib', 'Do not embed the standard library') { @no_stdlib = true }
29 opts.on('--stdlib [LIB]', 'Embed only LIB from the standard library') { |lib| @stdlib << lib }
30 opts.on('--gem [GEM]', 'Embed GEM and its dependencies') { |gem| @gems << gem }
31 opts.on('--bs', 'Embed the system BridgeSupport files') { @embed_bs = true }
32 opts.on('--verbose', 'Log all commands to standard out') { @verbose = true }
33 opts.on('--codesign [CERT]', String, 'Sign the files with the specified certificate') { |cert| @certificate = cert }
34 opts.on('-v', '--version', 'Display the version') do
88a5bc3 adding macruby_deploy, a tool to help embedding macruby inside an app…
Laurent Sansonetti authored
35 puts RUBY_DESCRIPTION
7d9fd02 @ferrous26 macruby_deploy should exit with code 0 when asked for version info
ferrous26 authored
36 exit 0
88a5bc3 adding macruby_deploy, a tool to help embedding macruby inside an app…
Laurent Sansonetti authored
37 end
38 begin
39 opts.parse!(argv)
40 rescue OptionParser::InvalidOption => e
41 die e, opts
42 end
7ae86f3 retrieve the app bundle path from the xcode environment because xcode…
Laurent Sansonetti authored
43 if argv.empty?
44 # If we are ran from Xcode, determine the application bundle from the environment.
45 build_dir = ENV['TARGET_BUILD_DIR']
46 project_name = ENV['PROJECT_NAME']
47 if build_dir and project_name
48 @app_bundle = File.join(build_dir, project_name + '.app')
49 end
50 end
51 unless @app_bundle
52 die opts if argv.size != 1
53 @app_bundle = argv[0]
54 end
88a5bc3 adding macruby_deploy, a tool to help embedding macruby inside an app…
Laurent Sansonetti authored
55 end
56
ced3d91 @ferrous26 Add a helpful message to ruby_deploy if the app bundle does not exist
ferrous26 authored
57 ensure_path @app_bundle, 'The application bundle was not found; make sure you build the app before running macruby_deploy'
d430e56 @alloy ruby_deploy: Add --verbose and --stdlib. The latter option allows you…
alloy authored
58 ensure_path File.join(@app_bundle, 'Contents'), "Path `%s' doesn't seem to be a valid application bundle"
88a5bc3 adding macruby_deploy, a tool to help embedding macruby inside an app…
Laurent Sansonetti authored
59
60 # Locate necessary programs.
61 @install_name_tool = locate('install_name_tool')
62
63 # Locate the MacRuby framework.
2a41d83 @ferrous26 Use RbConfig instead of Config in rubyc and ruby_deploy
ferrous26 authored
64 @macruby_framework_path = RbConfig::CONFIG['libdir'].scan(/^.+MacRuby\.framework/)[0]
d430e56 @alloy ruby_deploy: Add --verbose and --stdlib. The latter option allows you…
alloy authored
65 ensure_path @macruby_framework_path, "Cannot locate MacRuby.framework from rbconfig.rb"
775a7b3 Don't forget deploy :-)
Thibault Martin-Lagardette authored
66 @macruby_install_version = RbConfig::CONFIG["INSTALL_VERSION"]
88a5bc3 adding macruby_deploy, a tool to help embedding macruby inside an app…
Laurent Sansonetti authored
67 end
68
69 def run
73f1c4f added --compile option to macruby_deploy that AOT compiles a given .a…
Laurent Sansonetti authored
70 die "Nothing to do, please specify --compile or --embed" if !@compile and !@embed
71 die "--no-stdlib can only be used with --embed" if @no_stdlib and !@embed
d430e56 @alloy ruby_deploy: Add --verbose and --stdlib. The latter option allows you…
alloy authored
72 die "--stdlib can only be used with --embed" if !@stdlib.empty? and !@embed
885f29c add --bs option to macruby_deploy which embeds the BridgeSupport syst…
Laurent Sansonetti authored
73 die "--bs can only be used with --embed" if @embed_bs and !@embed
74 log "Deployment started"
73f1c4f added --compile option to macruby_deploy that AOT compiles a given .a…
Laurent Sansonetti authored
75 embed if @embed
d430e56 @alloy ruby_deploy: Add --verbose and --stdlib. The latter option allows you…
alloy authored
76 compile if @compile
ac58771 @danielwestendorf Preliminary codesigning switch added
danielwestendorf authored
77 sign if @certificate
885f29c add --bs option to macruby_deploy which embeds the BridgeSupport syst…
Laurent Sansonetti authored
78 log "Deployment ended"
73f1c4f added --compile option to macruby_deploy that AOT compiles a given .a…
Laurent Sansonetti authored
79 end
80
81 private
82
d430e56 @alloy ruby_deploy: Add --verbose and --stdlib. The latter option allows you…
alloy authored
83 # FileUtils::Verbose doesn't work with MacRuby yet. However, it doesn't print
84 # out failures anyways, just the command. Use the command-line tools directly
85 # to circumvent this.
a26f367 @chrislloyd Rather than removing the 'Current' symlink when embedding MacRuby.fra…
chrislloyd authored
86 { :cp => 'cp', :cp_r => 'cp -R', :mkdir_p => 'mkdir -p', :rm_rf => 'rm -rf', :rsync => 'rsync', :mv => 'mv' }.each do |name, cmd|
dd64b74 @ferrous26 Refactor use of #module_eval with #define_method in ruby_deploy
ferrous26 authored
87 define_method(name) do |*args|
88 arg_string = args.map { |a| "'#{a}'" }.join(' ')
89 execute "#{cmd} #{arg_string}"
90 end
d430e56 @alloy ruby_deploy: Add --verbose and --stdlib. The latter option allows you…
alloy authored
91 end
92
93 def app_frameworks
a26f367 @chrislloyd Rather than removing the 'Current' symlink when embedding MacRuby.fra…
chrislloyd authored
94 File.join(@app_bundle, 'Contents', 'Frameworks')
d430e56 @alloy ruby_deploy: Add --verbose and --stdlib. The latter option allows you…
alloy authored
95 end
96
885f29c add --bs option to macruby_deploy which embeds the BridgeSupport syst…
Laurent Sansonetti authored
97 def app_resources
a26f367 @chrislloyd Rather than removing the 'Current' symlink when embedding MacRuby.fra…
chrislloyd authored
98 File.join(@app_bundle, 'Contents', 'Resources')
885f29c add --bs option to macruby_deploy which embeds the BridgeSupport syst…
Laurent Sansonetti authored
99 end
100
101 def app_bs
102 File.join(app_resources, 'BridgeSupport')
103 end
104
d430e56 @alloy ruby_deploy: Add --verbose and --stdlib. The latter option allows you…
alloy authored
105 def app_macruby
106 File.join(app_frameworks, 'MacRuby.framework')
107 end
108
109 def app_macruby_usr
530fef9 during --embed, always refer to Current as the framework versioning i…
Laurent Sansonetti authored
110 File.join(app_macruby, 'Versions', 'Current', 'usr')
d430e56 @alloy ruby_deploy: Add --verbose and --stdlib. The latter option allows you…
alloy authored
111 end
112
82ab10e @alloy Compile ruby source files for the archs in either ENV['ARCHS'] or the…
alloy authored
113 def app_binary
114 File.join(@app_bundle, 'Contents', 'MacOS', File.basename(@app_bundle, '.app'))
115 end
116
117 def app_archs
118 unless @archs
119 @archs = if ENV['ARCHS']
120 # Use Xcode ARCHS env var to determine which archs to compile for
121 ENV['ARCHS'].strip.split
122 else
49a95fc @ferrous26 Fix checking archs in ruby_deploy when app names have spaces
ferrous26 authored
123 # Try to infer the archs the app was built for from output like:
82ab10e @alloy Compile ruby source files for the archs in either ENV['ARCHS'] or the…
alloy authored
124 # * Architectures in the fat file: /usr/bin/ruby are: x86_64 i386 ppc7400
125 # * Non-fat file: Progress.app/Contents/MacOS/Progress is architecture: x86_64
49a95fc @ferrous26 Fix checking archs in ruby_deploy when app names have spaces
ferrous26 authored
126 `/usr/bin/lipo -info "#{app_binary}"`.split(':').last.split
82ab10e @alloy Compile ruby source files for the archs in either ENV['ARCHS'] or the…
alloy authored
127 end
128 # Check that `archs' contains valid values
129 supported_archs = RbConfig::CONFIG['ARCH_FLAG'].gsub('-arch', '').strip.split
130 unsupported_archs = @archs - supported_archs
131 @archs -= unsupported_archs
132 unless unsupported_archs.empty?
133 count = unsupported_archs.size
134 msg = "Can't build for arch#{'s' if count > 1} `#{unsupported_archs.join(' ')}', "
135 msg << "because #{count == 1 ? 'it is' : 'they are'} not supported by this MacRuby build (#{supported_archs.join(' ')})."
136 # No point in trying to compile for no archs.
137 @archs.empty? ? die(msg) : puts(msg)
138 end
139 end
140 @archs
141 end
142
9f1c8b2 @ferrous26 Exclude Xcode templates when embedding MacRuby
ferrous26 authored
143 def macruby_version_base
144 @macruby_version_base ||= ensure_path(File.join(@macruby_framework_path, 'Versions', @macruby_install_version))
145 end
146
d430e56 @alloy ruby_deploy: Add --verbose and --stdlib. The latter option allows you…
alloy authored
147 def macruby_usr
9f1c8b2 @ferrous26 Exclude Xcode templates when embedding MacRuby
ferrous26 authored
148 @macruby_usr ||= ensure_path(File.join(macruby_version_base, 'usr'))
d430e56 @alloy ruby_deploy: Add --verbose and --stdlib. The latter option allows you…
alloy authored
149 end
150
151 def compile_files
a26f367 @chrislloyd Rather than removing the 'Current' symlink when embedding MacRuby.fra…
chrislloyd authored
152 Dir.glob(File.join(app_resources, '**', '*.rb'))
d430e56 @alloy ruby_deploy: Add --verbose and --stdlib. The latter option allows you…
alloy authored
153 end
154
6d161ad @ferrous26 Make ruby_deploy cleanup .rb files properly when using --compile
ferrous26 authored
155 def try_to_compile(source, to: obj)
156 unless File.exist?(obj) && File.mtime(obj) > File.mtime(source)
157 MacRuby::Compiler.compile_file(source, archs: app_archs)
158 end
159 rescue
160 die "Can't compile \"#{source}\""
161 end
162
73f1c4f added --compile option to macruby_deploy that AOT compiles a given .a…
Laurent Sansonetti authored
163 def compile
885f29c add --bs option to macruby_deploy which embeds the BridgeSupport syst…
Laurent Sansonetti authored
164 log "Compiling files"
d430e56 @alloy ruby_deploy: Add --verbose and --stdlib. The latter option allows you…
alloy authored
165 compile_files.each do |source|
73f1c4f added --compile option to macruby_deploy that AOT compiles a given .a…
Laurent Sansonetti authored
166 base = File.basename(source, '.rb')
167 next if base == 'rb_main'
6d161ad @ferrous26 Make ruby_deploy cleanup .rb files properly when using --compile
ferrous26 authored
168
73f1c4f added --compile option to macruby_deploy that AOT compiles a given .a…
Laurent Sansonetti authored
169 obj = File.join(File.dirname(source), base + '.rbo')
6d161ad @ferrous26 Make ruby_deploy cleanup .rb files properly when using --compile
ferrous26 authored
170 try_to_compile(source, to: obj)
171 rm_rf(source) if File.exists?(obj) # mtime doesn't matter, MR prefers .rbo
73f1c4f added --compile option to macruby_deploy that AOT compiles a given .a…
Laurent Sansonetti authored
172 end
6d161ad @ferrous26 Make ruby_deploy cleanup .rb files properly when using --compile
ferrous26 authored
173
d430e56 @alloy ruby_deploy: Add --verbose and --stdlib. The latter option allows you…
alloy authored
174 fix_install_name if File.exist?(app_macruby)
73f1c4f added --compile option to macruby_deploy that AOT compiles a given .a…
Laurent Sansonetti authored
175 end
176
793eeed add a --gem option to macruby_deploy which will embed the given gem(s…
Laurent Sansonetti authored
177 def gem_deps_libdirs(gem_name)
178 # Locate gem spec.
179 require 'rubygems'
42c0ba0 @aspitz Updated ruby_deploy to make use of Gem::Specification instead of Gem.…
aspitz authored
180 begin
181 gemspec = Gem::Specification::find_by_name(gem_name)
182 rescue Gem::LoadError
793eeed add a --gem option to macruby_deploy which will embed the given gem(s…
Laurent Sansonetti authored
183 die "Cannot locate gem `#{gem_name}' in #{Gem.path}"
184 end
185
186 # Load dependencies libdirs first.
187 gem_libdirs = []
188 gemspec.runtime_dependencies.each do |dep|
189 gem_libdirs.concat(gem_deps_libdirs(dep.name))
190 end
191
192 # Load the gem libdirs.
193 gem_libdirs.concat(gemspec.require_paths.map { |x| File.join(gemspec.full_gem_path, x) })
194 return gem_libdirs
195 end
196
d430e56 @alloy ruby_deploy: Add --verbose and --stdlib. The latter option allows you…
alloy authored
197 STDLIB_PATTERN = "lib/ruby/{,site_ruby/}1.9.*{,/universal-darwin*}"
198 KEEP_STDLIB_PATTERN = "{%s}{,{.,/**/*.}{rb,rbo,bundle}}"
199
73f1c4f added --compile option to macruby_deploy that AOT compiles a given .a…
Laurent Sansonetti authored
200 def embed
793eeed add a --gem option to macruby_deploy which will embed the given gem(s…
Laurent Sansonetti authored
201 # Prepare the list of gems to embed.
202 gems_libdirs_to_embed = @gems.map { |x| gem_deps_libdirs(x) }.flatten
203
007bff0 @ferrous26 Use rsync instead of cp for embedding MacRuby in ruby_deploy
ferrous26 authored
204 # Exclude unnecessary things in the MacRuby.framework copy.
9f1c8b2 @ferrous26 Exclude Xcode templates when embedding MacRuby
ferrous26 authored
205 dirs = ['bin', 'include', 'lib/libmacruby-static.a', 'share', 'lib/ruby/Gems']
007bff0 @ferrous26 Use rsync instead of cp for embedding MacRuby in ruby_deploy
ferrous26 authored
206 dirs << 'lib/ruby' if @no_stdlib
9f1c8b2 @ferrous26 Exclude Xcode templates when embedding MacRuby
ferrous26 authored
207 exclude_dirs = dirs.map { |dir| "usr/#{dir}" }
208 exclude_dirs << 'Resources/Templates' # do not include Xcode templates
209
210 relative_base = macruby_version_base.sub(/#{@macruby_framework_path}\//, '')
211 exclude_dirs.map! { |dir| "--exclude='#{File.join(relative_base,dir)}'" }
007bff0 @ferrous26 Use rsync instead of cp for embedding MacRuby in ruby_deploy
ferrous26 authored
212
213 # Only copy the Current version of the MacRuby.framework.
214 Dir.glob(File.join(@macruby_framework_path, 'Versions/*')).select { |x|
215 base = File.basename(x)
216 base != @macruby_install_version and base != 'Current'
217 }.each { |x|
218 exclude_dirs << "--exclude='#{x.sub(/#{@macruby_framework_path}\//, '')}'"
219 }
220
a26f367 @chrislloyd Rather than removing the 'Current' symlink when embedding MacRuby.fra…
chrislloyd authored
221
88a5bc3 adding macruby_deploy, a tool to help embedding macruby inside an app…
Laurent Sansonetti authored
222 # Copy MacRuby.framework inside MyApp.app/Contents/Frameworks.
885f29c add --bs option to macruby_deploy which embeds the BridgeSupport syst…
Laurent Sansonetti authored
223 log "Embedding MacRuby.framework"
88a5bc3 adding macruby_deploy, a tool to help embedding macruby inside an app…
Laurent Sansonetti authored
224 mkdir_p(app_frameworks)
225 rm_rf(app_macruby)
007bff0 @ferrous26 Use rsync instead of cp for embedding MacRuby in ruby_deploy
ferrous26 authored
226 rsync('-rl', *exclude_dirs, @macruby_framework_path, app_frameworks)
88a5bc3 adding macruby_deploy, a tool to help embedding macruby inside an app…
Laurent Sansonetti authored
227
a9ee534 @chrislloyd Continue to strip headers but remove the symlinks to them.
chrislloyd authored
228 # Orphaned symlinks prevent AppStore validation.
229 rm_rf(File.join(app_macruby, 'Headers'))
230 rm_rf(File.join(app_macruby, 'Versions', 'Current', 'Headers'))
231
b98b9da @ferrous26 Make ruby_deploy remove .rb files their .rbo equivalent exists
ferrous26 authored
232 lib = File.join(app_macruby_usr, STDLIB_PATTERN)
233 all = Dir.glob(File.join(lib, '**/*'))
234 # Only if specific libs from stdlib are being kept.
d430e56 @alloy ruby_deploy: Add --verbose and --stdlib. The latter option allows you…
alloy authored
235 unless @stdlib.empty?
b98b9da @ferrous26 Make ruby_deploy remove .rb files their .rbo equivalent exists
ferrous26 authored
236 keep = Dir.glob(File.join(lib, KEEP_STDLIB_PATTERN % @stdlib.join(',')))
d430e56 @alloy ruby_deploy: Add --verbose and --stdlib. The latter option allows you…
alloy authored
237 all.select { |f| keep.grep(/^#{f}/).empty? }.each { |x| rm_rf(x) }
238 end
b98b9da @ferrous26 Make ruby_deploy remove .rb files their .rbo equivalent exists
ferrous26 authored
239 # Remove .rb files if the .rbo exists
240 all.each do |f|
241 rm_rf f if File.extname(f) == '.rb' && all.include?("#{f}o")
242 end
d430e56 @alloy ruby_deploy: Add --verbose and --stdlib. The latter option allows you…
alloy authored
243
793eeed add a --gem option to macruby_deploy which will embed the given gem(s…
Laurent Sansonetti authored
244 # Copy the gems libdirs.
245 unless gems_libdirs_to_embed.empty?
885f29c add --bs option to macruby_deploy which embeds the BridgeSupport syst…
Laurent Sansonetti authored
246 log "Embed RubyGems libdirs: #{gems_libdirs_to_embed.join(', ')}"
793eeed add a --gem option to macruby_deploy which will embed the given gem(s…
Laurent Sansonetti authored
247 gems_libdirs_dest = File.join(app_macruby_usr, 'lib', 'ruby', 'site_ruby', RUBY_VERSION)
248 mkdir_p(gems_libdirs_dest)
249 gems_libdirs_to_embed.each do |libdir|
4efb798 fix a bug when using --gem on gems containing a space character in th…
Laurent Sansonetti authored
250 execute("/usr/bin/ditto \"#{libdir}\" \"#{gems_libdirs_dest}\"")
8828203 @ferrous26 Update macruby_deploy to use the Compiler class
ferrous26 authored
251 end
793eeed add a --gem option to macruby_deploy which will embed the given gem(s…
Laurent Sansonetti authored
252 end
253
885f29c add --bs option to macruby_deploy which embeds the BridgeSupport syst…
Laurent Sansonetti authored
254 # Copy the system BridgeSupport files if asked
255 if @embed_bs
256 log "Embed BridgeSupport system files"
257 mkdir_p(app_bs)
258 Dir.glob('/System/Library/Frameworks/**/BridgeSupport/*.{bridgesupport,dylib}').each do |path|
259 cp(path, app_bs)
260 end
261 end
262
d430e56 @alloy ruby_deploy: Add --verbose and --stdlib. The latter option allows you…
alloy authored
263 # Wait with fixing install name until all binaries are available.
5ab8eb2 fix a bug in macruby_deploy with --embed where the main application's…
Laurent Sansonetti authored
264 fix_install_name
8c90461 @ferrous26 Make ruby_deploy check the entire embedded framework
ferrous26 authored
265 check_linked_bundles
d430e56 @alloy ruby_deploy: Add --verbose and --stdlib. The latter option allows you…
alloy authored
266 end
267
268 # Hack the application binaries to link against the MacRuby.framework copy.
269 def fix_install_name
885f29c add --bs option to macruby_deploy which embeds the BridgeSupport syst…
Laurent Sansonetti authored
270 log "Fix install path of binaries"
d430e56 @alloy ruby_deploy: Add --verbose and --stdlib. The latter option allows you…
alloy authored
271 patterns = [File.join(@app_bundle, 'Contents/MacOS/*'),
272 File.join(app_macruby_usr, 'lib/ruby/**/*.{bundle,rbo}'),
e8bc645 @MSch Fix ruby_deploy's fix_install_name to performa a deep search in Conte…
MSch authored
273 File.join(@app_bundle, 'Contents/Resources/**/*.rbo')]
88a5bc3 adding macruby_deploy, a tool to help embedding macruby inside an app…
Laurent Sansonetti authored
274 patterns.each do |pat|
275 Dir.glob(pat).each do |bin|
530fef9 during --embed, always refer to Current as the framework versioning i…
Laurent Sansonetti authored
276 execute("#{@install_name_tool} -change #{macruby_usr}/lib/libmacruby.dylib @executable_path/../Frameworks/MacRuby.framework/Versions/Current/usr/lib/libmacruby.dylib '#{bin}'")
88a5bc3 adding macruby_deploy, a tool to help embedding macruby inside an app…
Laurent Sansonetti authored
277 end
278 end
f75361d during --embed, fix the libmacruby dyld identification name, to confo…
Laurent Sansonetti authored
279 log "Fix identification name of libmacruby"
280 patterns = [ File.join(app_macruby_usr, 'lib/libmacruby*.dylib') ]
281 patterns.each do |pat|
282 Dir.glob(pat).each do |bin|
530fef9 during --embed, always refer to Current as the framework versioning i…
Laurent Sansonetti authored
283 execute("#{@install_name_tool} -id @executable_path/../Frameworks/MacRuby.framework/Versions/Current/usr/lib/libmacruby.dylib '#{bin}'")
f75361d during --embed, fix the libmacruby dyld identification name, to confo…
Laurent Sansonetti authored
284 end
285 end
88a5bc3 adding macruby_deploy, a tool to help embedding macruby inside an app…
Laurent Sansonetti authored
286 end
287
8c90461 @ferrous26 Make ruby_deploy check the entire embedded framework
ferrous26 authored
288 def check_linked_bundles
289 dirs = [%r{^/opt}, %r{^/usr/local/lib}, %r{^/Users}, %r{^/Library}]
290 Dir.glob(File.join(app_macruby, '**', '*.bundle')).each do |bundle|
0e17543 @ferrous26 Quote path given to otool during deployment
ferrous26 authored
291 libs = execute("/usr/bin/otool -L \"#{bundle}\"").split("\n").map(&:strip)
8c90461 @ferrous26 Make ruby_deploy check the entire embedded framework
ferrous26 authored
292 libs[1..-1].each do |lib|
293 bad_libs = dirs.map { |dir| lib.match(dir) ? lib : nil }.compact
294 next if bad_libs.empty?
295 name = File.basename(bundle)
296 warn '******WARNING******'
297 warn "'#{name}' is linked against libraries that are not standard to Mac OS X"
298 warn "#{bundle}\n links against:"
299 bad_libs.each { |lib| warn "\t#{lib}" }
300 warn '******WARNING******'
301 end
302 end
303 end
304
d430e56 @alloy ruby_deploy: Add --verbose and --stdlib. The latter option allows you…
alloy authored
305 def execute(line, error_message = nil)
306 $stdout.puts(line) if @verbose
88a5bc3 adding macruby_deploy, a tool to help embedding macruby inside an app…
Laurent Sansonetti authored
307 ret = `#{line}`
d430e56 @alloy ruby_deploy: Add --verbose and --stdlib. The latter option allows you…
alloy authored
308 die(error_message || "Error when executing `#{line}'") unless $?.success?
88a5bc3 adding macruby_deploy, a tool to help embedding macruby inside an app…
Laurent Sansonetti authored
309 ret
310 end
311
312 def locate(progname)
313 path = `which #{progname}`.strip
314 die "Can't locate program `#{progname}'" if path.empty?
315 path
316 end
317
d430e56 @alloy ruby_deploy: Add --verbose and --stdlib. The latter option allows you…
alloy authored
318 def ensure_path(path, message = "Path does not exist `%s'")
319 die(message % path) unless File.exist?(path)
320 path
321 end
322
88a5bc3 adding macruby_deploy, a tool to help embedding macruby inside an app…
Laurent Sansonetti authored
323 def die(*args)
324 $stderr.puts args
325 exit 1
326 end
885f29c add --bs option to macruby_deploy which embeds the BridgeSupport syst…
Laurent Sansonetti authored
327
328 def log(msg)
329 $stderr.puts "*** #{msg}"
330 end
ac58771 @danielwestendorf Preliminary codesigning switch added
danielwestendorf authored
331
332 def sign
333 log "Using codesign to sign files with #{@certificate}"
334 files = []
bb7af4b @danielwestendorf Added dylib files
danielwestendorf authored
335 #get the .bundle, .rbo, .rb, .dylib, and .framework
8fbcf8c @danielwestendorf Fixed typo, tested on a real MAS App, returned no errors
danielwestendorf authored
336 files += Dir.glob(File.join(@app_bundle, '**', '*.bundle'))
337 files += Dir.glob(File.join(@app_bundle, '**', '*.rbo'))
338 files += Dir.glob(File.join(@app_bundle, '**', '*.rb'))
339 files += Dir.glob(File.join(@app_bundle, '**', '*.dylib'))
340 files += Dir.glob(File.join(@app_bundle, '**', '*.framework'))
ac58771 @danielwestendorf Preliminary codesigning switch added
danielwestendorf authored
341 files << @app_bundle
342
17c59c0 @danielwestendorf Added support for file names that have spaces
danielwestendorf authored
343 execute("/usr/bin/codesign -f -s \"#{@certificate}\" #{files.collect {|f| "\"#{f}\"" }.join(' ')}")
ac58771 @danielwestendorf Preliminary codesigning switch added
danielwestendorf authored
344 end
88a5bc3 adding macruby_deploy, a tool to help embedding macruby inside an app…
Laurent Sansonetti authored
345 end
346
347 Deployer.new(ARGV).run
Something went wrong with that request. Please try again.