Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added some linker options to rubyc

git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@4472 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information...
commit 181e4da5b66299c56200695494f811fa6ef7d7c9 1 parent 4cb1803
@jballanc jballanc authored
Showing with 27 additions and 12 deletions.
  1. +7 −3 bin/rubyc
  2. +20 −9 rubyc.1
View
10 bin/rubyc
@@ -16,6 +16,7 @@ class Compiler
@archs = []
@internal = argv.delete('--internal')
@frameworks = %w{Foundation}
+ @linkf = []
# Parse arguments.
OptionParser.new do |opts|
@@ -26,6 +27,9 @@ class Compiler
opts.on('--framework <name>', "Link standalone static executable with given framework") { |p| @frameworks << p }
opts.on('--sdk <path>', "Use SDK when compiling standalone static executable") { |x| @sdk = x }
opts.on('--dylib', "Create a dynamic library") { @dylib = true }
+ opts.on('--compatibility_version <VERSION>', "Compatibility Version for linking") { |ver| @linkf << "-compatibility_version #{ver}" }
+ opts.on('--current_version <VERSION>', "Current Version for linking") { |ver| @linkf << "-current_version #{ver}" }
+ opts.on('--install_name <NAME>', "Install Name for linking") { |name| @linkf << "-install_name #{name}" }
opts.on('-C', 'Compile, assemble and link a loadable object file') { @bundle = true }
opts.on('-a', '--arch <ARCH>', 'Compile for specified CPU architecture') { |arch| @archs << arch }
opts.on('-v', '--version', 'Display the version') { puts RUBY_DESCRIPTION; exit 1 }
@@ -139,7 +143,7 @@ class Compiler
end
def cleanup
- @tmpfiles.each { |x| File.delete(x) }
+ @tmpfiles.each { |x| File.delete(x) if File.exist?(x) }
end
private
@@ -224,9 +228,9 @@ EOS
# Build.
main = gen_tmpfile('main', 'c')
File.open(main, 'w') { |io| io.write(main_txt) }
- linkf = @internal ? "-L. -lmacruby" : "-L#{RbConfig::CONFIG['libdir']} -lmacruby"
+ @linkf << @internal ? "-L. -lmacruby" : "-L#{RbConfig::CONFIG['libdir']} -lmacruby"
objs = objs_data.map { |obj, f| "\"#{obj}\"" }.join(' ')
- execute("#{@gcxx} \"#{main}\" -dynamiclib -dynamic -undefined suppress -flat_namespace #{arch_flags} #{linkf} #{objs} -o \"#{output}\"")
+ execute("#{@gcxx} \"#{main}\" -dynamiclib -dynamic -undefined suppress -flat_namespace #{arch_flags} #{@linkf.join(' ')} #{objs} -o \"#{output}\"")
strip(output)
end
View
29 rubyc.1
@@ -45,15 +45,6 @@ using a default file name which consists of the source file name with the .rbo f
.Nm require
method.
.Pp
-.It Fl -dylib
-Create a dynamic library instead of an executable. This option compiles every Ruby source file passed to
-.Nm macrubyc
-and produces a Mach-O dynamic library (.dylib). This library is compiled with a global constructor that will register every Ruby machine code file into the MacRuby runtime once it's loaded by the dynamic linker, at runtime. This library is intended to be linked against an executable that uses the MacRuby runtime, for example executables generated by
-.Nm macrubyc .
-The
-.Fl o
-option must be provided when building dynamic libraries.
-.Pp
.It Fl h, Fl -help
Display a short description of the command line options.
.Pp
@@ -64,6 +55,26 @@ If this option is not given,
.Nm macrubyc
will try to determine a default output file name based on the object file type that is being generated. For executables, the default is a.out. For objects, the default is the original source file name with the object type extension. For dynamic libraries, this option is mandatory.
.Pp
+.It Fl -dylib
+Create a dynamic library instead of an executable. This option compiles every Ruby source file passed to
+.Nm macrubyc
+and produces a Mach-O dynamic library (.dylib). This library is compiled with a global constructor that will register every Ruby machine code file into the MacRuby runtime once it's loaded by the dynamic linker, at runtime. This library is intended to be linked against an executable that uses the MacRuby runtime, for example executables generated by
+.Nm macrubyc .
+The
+.Fl o
+option must be provided when building dynamic libraries.
+.Pp
+.Bl -tag -width XXXXXXXXXX
+The
+.Fl -dylib
+option can also take the following optional linker arguments (see
+.Xr libtool 1
+for more information):
+.It Fl -compatibility_version Ar VERSION
+.It Fl -current_version Ar VERSION
+.It Fl -install_name Ar NAME
+.El
+.Pp
.It Fl -static
Create a standalone, static executable. By default, executables created by
.Nm macrubyc
Please sign in to comment.
Something went wrong with that request. Please try again.