Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 207 lines (165 sloc) 6.977 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
f68acf7 @brixen Ensure that bootstrap Melbourne is built for bootstrap ruby.
brixen authored
12 def clean_extension(name)
7766cf5 @brixen Clean new-style C-exts.
brixen authored
13 rm_f FileList["lib/**/ext/#{name}/*.{o,#{$dlext}}"], :verbose => $verbose
f68acf7 @brixen Ensure that bootstrap Melbourne is built for bootstrap ruby.
brixen authored
14 end
15
9ed0630 @brixen Reworked compiling C extensions.
brixen authored
16 namespace :extensions do
17 desc "Clean all lib/ext files"
93747eb @drbrain Bring in extensions and platform stuff from shotgun
drbrain authored
18 task :clean do
f68acf7 @brixen Ensure that bootstrap Melbourne is built for bootstrap ruby.
brixen authored
19 clean_extension("**")
33c8f28 @brixen Split C-API headers for 1.8/1.9.
brixen authored
20 rm_f FileList["lib/tooling/**/*.{o,#{$dlext}}"], :verbose => $verbose
e484ef7 @brixen Force reconfigure for C exts when cleaning.
brixen authored
21 # TODO: implement per extension cleaning. This hack is for
22 # openssl and dl, which use extconf.rb and create Makefile.
0d0a9a4 @brixen Build json extension.
brixen authored
23 rm_f FileList["lib/**/ext/**/Makefile"], :verbose => $verbose
33c8f28 @brixen Split C-API headers for 1.8/1.9.
brixen authored
24 rm_f FileList["lib/tooling/**/Makefile"], :verbose => $verbose
e99f097 @brixen Re-enable building DL extension.
brixen authored
25 rm_f FileList["lib/ext/dl/*.func"], :verbose => $verbose
0eb8c0f @brixen Added bigdecimal extension.
brixen authored
26 end
9ed0630 @brixen Reworked compiling C extensions.
brixen authored
27 end
0eb8c0f @brixen Added bigdecimal extension.
brixen authored
28
b66a3b8 @brixen Added ignore flag for building extconf-style C exts.
brixen authored
29 def rbx_build
30 # rbx-build can run even if prefix is used
65305fa @tenderlove fixing unused variable warnings
tenderlove authored
31 File.expand_path "../bin/rbx-build", File.dirname(__FILE__)
b66a3b8 @brixen Added ignore flag for building extconf-style C exts.
brixen authored
32 end
33
f5a5246 @brixen Fixed building C exts that use extconf.rb.
brixen authored
34 def build_extconf(name, opts)
35 if opts[:ignore_fail]
b66a3b8 @brixen Added ignore flag for building extconf-style C exts.
brixen authored
36 fail_block = lambda { |ok, status| }
37 else
38 fail_block = nil
39 end
40
f5a5246 @brixen Fixed building C exts that use extconf.rb.
brixen authored
41 redirect = $verbose || !opts[:ignore_fail] ? "" : "> /dev/null 2>&1"
b66a3b8 @brixen Added ignore flag for building extconf-style C exts.
brixen authored
42
43 puts "Building #{name}"
44
45 ENV["BUILD_RUBY"] = BUILD_CONFIG[:build_ruby]
46
7ebcd2e @brixen Fixed installing with C-API changes.
brixen authored
47 include18_dir = File.expand_path("../../vm/capi/18/include", __FILE__)
48 include19_dir = File.expand_path("../../vm/capi/19/include", __FILE__)
49
b66a3b8 @brixen Added ignore flag for building extconf-style C exts.
brixen authored
50 unless File.directory? BUILD_CONFIG[:runtime]
ed115c4 @brixen More chewing gum, duct tape, and baling wire.
brixen authored
51 if opts[:env] == "-X18"
52 ENV["CFLAGS"] = "-I#{include18_dir}"
53 else
54 ENV["CFLAGS"] = "-I#{include19_dir}"
55 end
b66a3b8 @brixen Added ignore flag for building extconf-style C exts.
brixen authored
56 end
57
ed115c4 @brixen More chewing gum, duct tape, and baling wire.
brixen authored
58 ENV["RBXOPT"] = opts[:env]
4ef646f @brixen More fixes for building 1.9 readline C-ext.
brixen authored
59
f5a5246 @brixen Fixed building C exts that use extconf.rb.
brixen authored
60 unless opts[:deps] and opts[:deps].all? { |n| File.exists? n }
b66a3b8 @brixen Added ignore flag for building extconf-style C exts.
brixen authored
61 sh("#{rbx_build} extconf.rb #{redirect}", &fail_block)
62 end
63
64 sh("make #{redirect}", &fail_block)
36896d7 @dbussink Make sure to also delete RBXOPT if we set it
dbussink authored
65
66 ENV.delete("RBXOPT")
b66a3b8 @brixen Added ignore flag for building extconf-style C exts.
brixen authored
67 end
68
9ed0630 @brixen Reworked compiling C extensions.
brixen authored
69 def compile_ext(name, opts={})
70 names = name.split ":"
71 name = names.last
73fb486 Introduce tooling API, convert profiler to it.
Evan Phoenix authored
72 ext_dir = opts[:dir] || File.join("lib/ext", names)
3610ac3 @rue Build readline as part of `rake build`. Cleaned up lib/bin/compile.rb.
rue authored
73
9ed0630 @brixen Reworked compiling C extensions.
brixen authored
74 if t = opts[:task]
60f7d84 @brixen Fixed toplevel C ext tasks to always delegate to the ext Rakefile.
brixen authored
75 ext_task_name = "build:#{t}"
76 names << t
9ed0630 @brixen Reworked compiling C extensions.
brixen authored
77 else
60f7d84 @brixen Fixed toplevel C ext tasks to always delegate to the ext Rakefile.
brixen authored
78 ext_task_name = "build"
3610ac3 @rue Build readline as part of `rake build`. Cleaned up lib/bin/compile.rb.
rue authored
79 end
80
ed115c4 @brixen More chewing gum, duct tape, and baling wire.
brixen authored
81 opts[:env] ||= "-X18"
82
60f7d84 @brixen Fixed toplevel C ext tasks to always delegate to the ext Rakefile.
brixen authored
83 task_name = names.join "_"
02c813d @brixen Put melbourne ext for rbx in a subdir.
brixen authored
84
9ed0630 @brixen Reworked compiling C extensions.
brixen authored
85 namespace :extensions do
86 desc "Build #{name.capitalize} extension #{opts[:doc]}"
60f7d84 @brixen Fixed toplevel C ext tasks to always delegate to the ext Rakefile.
brixen authored
87 task task_name do
88 ext_helper = File.expand_path "../ext_helper.rb", __FILE__
24f0e34 @brixen Use DependencyGrapher in C exts.
brixen authored
89 dep_grapher = File.expand_path "../dependency_grapher.rb", __FILE__
7b1cb48 @brixen Configure checks for readline, curses.
brixen authored
90 build_config = File.expand_path "../../config.rb", __FILE__
60f7d84 @brixen Fixed toplevel C ext tasks to always delegate to the ext Rakefile.
brixen authored
91 Dir.chdir ext_dir do
fe79104 Begin pulling in the OpenSSL CAPI extension
Evan Phoenix authored
92 if File.exists? "Rakefile"
ed115c4 @brixen More chewing gum, duct tape, and baling wire.
brixen authored
93 ENV["BUILD_VERSION"] = opts[:env][-2..-1]
94
7b1cb48 @brixen Configure checks for readline, curses.
brixen authored
95 sh "#{BUILD_CONFIG[:build_ruby]} -S #{BUILD_CONFIG[:build_rake]} #{'-t' if $verbose} -r #{build_config} -r #{ext_helper} -r #{dep_grapher} #{ext_task_name}"
fe79104 Begin pulling in the OpenSSL CAPI extension
Evan Phoenix authored
96 else
f5a5246 @brixen Fixed building C exts that use extconf.rb.
brixen authored
97 build_extconf name, opts
fe79104 Begin pulling in the OpenSSL CAPI extension
Evan Phoenix authored
98 end
60f7d84 @brixen Fixed toplevel C ext tasks to always delegate to the ext Rakefile.
brixen authored
99 end
100 end
ad861fe @brixen Added Melbourne parser extension.
brixen authored
101 end
60f7d84 @brixen Fixed toplevel C ext tasks to always delegate to the ext Rakefile.
brixen authored
102
103 Rake::Task[:extensions].prerequisites << "extensions:#{task_name}"
cc28068 Rearranged rake setup a lot, making browsing more intuitive (build secti...
Ryan Davis authored
104 end
9ed0630 @brixen Reworked compiling C extensions.
brixen authored
105
f68acf7 @brixen Ensure that bootstrap Melbourne is built for bootstrap ruby.
brixen authored
106 # TODO: we must completely rebuild the bootstrap version of Melbourne if the
107 # configured build ruby changes. We add the version to be extra sure.
108 build_ruby = "lib/ext/melbourne/.build_ruby"
109 build_version = "#{BUILD_CONFIG[:build_ruby]}:#{RUBY_VERSION}"
110
111 if File.exists?(build_ruby)
112 File.open(build_ruby, "rb") do |f|
113 clean_extension("melbourne/**") if f.read.chomp != build_version
114 end
115 else
116 clean_extension("melbourne/**")
117 end
118
119 File.open(build_ruby, "wb") do |f|
120 f.puts build_version
121 end
122
028cb3d @brixen Only build C-ext for enabled language versions.
brixen authored
123 enabled_18 = BUILD_CONFIG[:version_list].include?("18")
124 enabled_19 = BUILD_CONFIG[:version_list].include?("19")
125
ed115c4 @brixen More chewing gum, duct tape, and baling wire.
brixen authored
126 compile_ext "melbourne", :task => "build",
127 :doc => "for bootstrapping"
128
028cb3d @brixen Only build C-ext for enabled language versions.
brixen authored
129 melbourne_env = enabled_19 ? "-X19" : "-X18"
ed115c4 @brixen More chewing gum, duct tape, and baling wire.
brixen authored
130 compile_ext "melbourne", :task => "rbx",
131 :env => melbourne_env,
132 :doc => "for Rubinius"
afcdd56 @brixen Added bigdecimal from 1.9.2p290.
brixen authored
133
964229d @brixen Moved lib/ext/digest to lib/digest/ext.
brixen authored
134 compile_ext "digest", :dir => "lib/digest/ext"
135 compile_ext "digest:md5", :dir => "lib/digest/ext/md5"
136 compile_ext "digest:rmd160", :dir => "lib/digest/ext/rmd160"
137 compile_ext "digest:sha1", :dir => "lib/digest/ext/sha1"
138 compile_ext "digest:sha2", :dir => "lib/digest/ext/sha2"
139 compile_ext "digest:bubblebabble", :dir => "lib/digest/ext/bubblebabble"
55f41fe @brixen Added syck/ from 1.9.2p290.
brixen authored
140
028cb3d @brixen Only build C-ext for enabled language versions.
brixen authored
141 if enabled_18
142 compile_ext "18/bigdecimal", :dir => "lib/18/bigdecimal/ext", :env => "-X18"
143
144 compile_ext "18/syck", :dir => "lib/18/syck/ext"
145 compile_ext "18/nkf", :dir => "lib/18/nkf/ext", :env => "-X18"
146
147 if BUILD_CONFIG[:readline] == :c_readline
4ce87a2 @brixen Use extconf.rb to build 1.8 readline C-ext.
brixen authored
148 compile_ext "18/readline", :dir => "lib/18/readline/ext",
149 :deps => ["Makefile", "extconf.rb"],
150 :env => "-X18"
028cb3d @brixen Only build C-ext for enabled language versions.
brixen authored
151 end
152
153 # rbx must be able to run to build these because they use
154 # extconf.rb, so they must be after melbourne for Rubinius.
155 compile_ext "18/openssl", :deps => ["Makefile", "extconf.h"],
156 :dir => "lib/18/openssl/ext",
157 :env => "-X18"
158
159 compile_ext "18/dl", :deps => ["Makefile", "dlconfig.h"],
160 :dir => "lib/18/dl/ext", :env => "-X18"
40f8e6a @brixen Moved lib/ext/readline to lib/18/readline/ext.
brixen authored
161
028cb3d @brixen Only build C-ext for enabled language versions.
brixen authored
162 compile_ext "18/pty", :deps => ["Makefile"],
163 :dir => "lib/18/pty/ext",
164 :env => "-X18"
c07dd00 @brixen Build Psych if libyaml is available.
brixen authored
165 end
166
028cb3d @brixen Only build C-ext for enabled language versions.
brixen authored
167 if enabled_19
168 compile_ext "19/bigdecimal", :dir => "lib/19/bigdecimal/ext",
169 :deps => ["Makefile", "extconf.rb"],
170 :env => "-X19"
171 compile_ext "19/nkf", :dir => "lib/19/nkf/ext",
172 :deps => ["Makefile", "extconf.rb"],
173 :env => "-X19"
174 if BUILD_CONFIG[:readline] == :c_readline
175 compile_ext "19/readline", :dir => "lib/19/readline/ext",
176 :deps => ["Makefile", "extconf.rb"],
177 :env => "-X19"
178 end
179
180 if BUILD_CONFIG[:libyaml]
181 compile_ext "19/psych", :deps => ["Makefile"], :dir => "lib/19/psych/ext", :env => "-X19"
182 end
183
184 compile_ext "19/syck", :deps => ["Makefile"], :dir => "lib/19/syck/ext", :env => "-X19"
185
186 compile_ext "json/parser", :deps => ["Makefile", "extconf.rb"],
187 :dir => "lib/19/json/ext/parser",
188 :env => "-X19"
189 compile_ext "json/generator", :deps => ["Makefile", "extconf.rb"],
190 :dir => "lib/19/json/ext/generator",
191 :env => "-X19"
192
193 compile_ext "19/openssl", :deps => ["Makefile", "extconf.h"],
194 :dir => "lib/19/openssl/ext",
195 :env => "-X19"
196 compile_ext "19/pty", :deps => ["Makefile"],
197 :dir => "lib/19/pty/ext",
198 :env => "-X19"
199 end
a420bda @evanphx First cut at porting the 1.8 pty C extension
evanphx authored
200
9367db8 @brixen Moved ext/[gs]?dbm to lib/[gs]?dbm/ext.
brixen authored
201 compile_ext "dbm", :ignore_fail => true, :deps => ["Makefile"], :dir => "lib/dbm/ext"
202 compile_ext "gdbm", :ignore_fail => true, :deps => ["Makefile"], :dir => "lib/gdbm/ext"
203 compile_ext "sdbm", :deps => ["Makefile"], :dir => "lib/sdbm/ext"
73fb486 Introduce tooling API, convert profiler to it.
Evan Phoenix authored
204
bb535a4 @brixen Enable building with MRI or Rubinius 1.2.
brixen authored
205 compile_ext "profiler", :dir => "lib/tooling/profiler",
73fb486 Introduce tooling API, convert profiler to it.
Evan Phoenix authored
206 :deps => ["Makefile"]
Something went wrong with that request. Please try again.