Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 107 lines (89 sloc) 3.172 kB
9ed0630 @brixen Reworked compiling C extensions.
brixen authored
1 # Tasks for building C extensions used mainly by Rubinius, but also by MRI in
2 # the case of the Melbourne parser extension. The task names are defined to
3 # permit running the tasks directly, eg
93747eb @drbrain Bring in extensions and platform stuff from shotgun
drbrain authored
4 #
9ed0630 @brixen Reworked compiling C extensions.
brixen authored
5 # rake compile:melbourne_rbx
3610ac3 @rue Build readline as part of `rake build`. Cleaned up lib/bin/compile.rb.
rue authored
6 #
9ed0630 @brixen Reworked compiling C extensions.
brixen authored
7 # See rakelib/ext_helper.rb for the helper methods and Rake rules.
3610ac3 @rue Build readline as part of `rake build`. Cleaned up lib/bin/compile.rb.
rue authored
8
9ed0630 @brixen Reworked compiling C extensions.
brixen authored
9 desc "Build extensions from lib/ext"
10 task :extensions
3610ac3 @rue Build readline as part of `rake build`. Cleaned up lib/bin/compile.rb.
rue authored
11
9ed0630 @brixen Reworked compiling C extensions.
brixen authored
12 namespace :extensions do
13 desc "Clean all lib/ext files"
93747eb @drbrain Bring in extensions and platform stuff from shotgun
drbrain authored
14 task :clean do
9ed0630 @brixen Reworked compiling C extensions.
brixen authored
15 rm_f FileList["lib/ext/**/*.{o,#{$dlext}}"], :verbose => $verbose
e484ef7 @brixen Force reconfigure for C exts when cleaning.
brixen authored
16 # TODO: implement per extension cleaning. This hack is for
17 # openssl and dl, which use extconf.rb and create Makefile.
18 rm_f FileList["lib/ext/**/Makefile"], :verbose => $verbose
e99f097 @brixen Re-enable building DL extension.
brixen authored
19 rm_f FileList["lib/ext/dl/*.func"], :verbose => $verbose
0eb8c0f @brixen Added bigdecimal extension.
brixen authored
20 end
9ed0630 @brixen Reworked compiling C extensions.
brixen authored
21 end
0eb8c0f @brixen Added bigdecimal extension.
brixen authored
22
b66a3b8 @brixen Added ignore flag for building extconf-style C exts.
brixen authored
23 def rbx_build
24 # rbx-build can run even if prefix is used
25 rbx = File.expand_path "../bin/rbx-build", File.dirname(__FILE__)
26 end
27
f5a5246 @brixen Fixed building C exts that use extconf.rb.
brixen authored
28 def build_extconf(name, opts)
29 if opts[:ignore_fail]
b66a3b8 @brixen Added ignore flag for building extconf-style C exts.
brixen authored
30 fail_block = lambda { |ok, status| }
31 else
32 fail_block = nil
33 end
34
f5a5246 @brixen Fixed building C exts that use extconf.rb.
brixen authored
35 redirect = $verbose || !opts[:ignore_fail] ? "" : "> /dev/null 2>&1"
b66a3b8 @brixen Added ignore flag for building extconf-style C exts.
brixen authored
36
37 puts "Building #{name}"
38
39 ENV["BUILD_RUBY"] = BUILD_CONFIG[:build_ruby]
40
41 unless File.directory? BUILD_CONFIG[:runtime]
42 ENV["CFLAGS"] = "-Ivm/capi/include"
43 end
44
f5a5246 @brixen Fixed building C exts that use extconf.rb.
brixen authored
45 unless opts[:deps] and opts[:deps].all? { |n| File.exists? n }
46 # unless File.exists?("Makefile") and File.exists?("extconf.h")
b66a3b8 @brixen Added ignore flag for building extconf-style C exts.
brixen authored
47 sh("#{rbx_build} extconf.rb #{redirect}", &fail_block)
48 end
49
50 sh("make #{redirect}", &fail_block)
51 end
52
9ed0630 @brixen Reworked compiling C extensions.
brixen authored
53 def compile_ext(name, opts={})
54 names = name.split ":"
55 name = names.last
56 ext_dir = File.join "lib/ext", names
3610ac3 @rue Build readline as part of `rake build`. Cleaned up lib/bin/compile.rb.
rue authored
57
9ed0630 @brixen Reworked compiling C extensions.
brixen authored
58 if t = opts[:task]
60f7d84 @brixen Fixed toplevel C ext tasks to always delegate to the ext Rakefile.
brixen authored
59 ext_task_name = "build:#{t}"
60 names << t
9ed0630 @brixen Reworked compiling C extensions.
brixen authored
61 else
60f7d84 @brixen Fixed toplevel C ext tasks to always delegate to the ext Rakefile.
brixen authored
62 ext_task_name = "build"
3610ac3 @rue Build readline as part of `rake build`. Cleaned up lib/bin/compile.rb.
rue authored
63 end
64
60f7d84 @brixen Fixed toplevel C ext tasks to always delegate to the ext Rakefile.
brixen authored
65 task_name = names.join "_"
02c813d @brixen Put melbourne ext for rbx in a subdir.
brixen authored
66
9ed0630 @brixen Reworked compiling C extensions.
brixen authored
67 namespace :extensions do
68 desc "Build #{name.capitalize} extension #{opts[:doc]}"
60f7d84 @brixen Fixed toplevel C ext tasks to always delegate to the ext Rakefile.
brixen authored
69 task task_name do
70 ext_helper = File.expand_path "../ext_helper.rb", __FILE__
24f0e34 @brixen Use DependencyGrapher in C exts.
brixen authored
71 dep_grapher = File.expand_path "../dependency_grapher.rb", __FILE__
60f7d84 @brixen Fixed toplevel C ext tasks to always delegate to the ext Rakefile.
brixen authored
72 Dir.chdir ext_dir do
fe79104 Begin pulling in the OpenSSL CAPI extension
Evan Phoenix authored
73 if File.exists? "Rakefile"
9465976 @brixen Generalize building with MRI 1.8/1.9 or rbx.
brixen authored
74 sh "#{BUILD_CONFIG[:build_ruby]} -S rake #{'-t' if $verbose} -r #{ext_helper} -r #{dep_grapher} #{ext_task_name}"
fe79104 Begin pulling in the OpenSSL CAPI extension
Evan Phoenix authored
75 else
f5a5246 @brixen Fixed building C exts that use extconf.rb.
brixen authored
76 build_extconf name, opts
fe79104 Begin pulling in the OpenSSL CAPI extension
Evan Phoenix authored
77 end
60f7d84 @brixen Fixed toplevel C ext tasks to always delegate to the ext Rakefile.
brixen authored
78 end
79 end
ad861fe @brixen Added Melbourne parser extension.
brixen authored
80 end
60f7d84 @brixen Fixed toplevel C ext tasks to always delegate to the ext Rakefile.
brixen authored
81
82 Rake::Task[:extensions].prerequisites << "extensions:#{task_name}"
cc28068 Rearranged rake setup a lot, making browsing more intuitive (build se…
Ryan Davis authored
83 end
9ed0630 @brixen Reworked compiling C extensions.
brixen authored
84
85 compile_ext "bigdecimal"
86 compile_ext "readline"
87 compile_ext "digest"
88 compile_ext "digest:md5"
89 compile_ext "digest:rmd160"
90 compile_ext "digest:sha1"
91 compile_ext "digest:sha2"
92 compile_ext "digest:bubblebabble"
93 compile_ext "syck"
60f7d84 @brixen Fixed toplevel C ext tasks to always delegate to the ext Rakefile.
brixen authored
94 compile_ext "melbourne", :task => "rbx", :doc => "for Rubinius"
9465976 @brixen Generalize building with MRI 1.8/1.9 or rbx.
brixen authored
95 if BUILD_CONFIG[:which_ruby] == :ruby
96 compile_ext "melbourne", :task => "mri", :doc => "for MRI"
97 end
35a1b4e @brixen Added NKF ext from MRI 1.8.7. Closes #304.
brixen authored
98 compile_ext "nkf"
07e6ac4 @brixen Moved C-API .h files to include directory.
brixen authored
99
100 # rbx must be able to run to build these because they use
101 # extconf.rb, so they must be after melbourne for Rubinius.
f5a5246 @brixen Fixed building C exts that use extconf.rb.
brixen authored
102 compile_ext "openssl", :deps => ["Makefile", "extconf.h"]
103 compile_ext "dl", :deps => ["Makefile", "dlconfig.h"]
104 compile_ext "dbm", :ignore_fail => true, :deps => ["Makefile"]
105 compile_ext "gdbm", :ignore_fail => true, :deps => ["Makefile"]
106 compile_ext "sdbm", :deps => ["Makefile"]
Something went wrong with that request. Please try again.