Skip to content
Newer
Older
100644 173 lines (138 sloc) 5.62 KB
9ed0630 Reworked compiling C extensions.
Brian Ford authored Nov 10, 2009
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 Oct 1, 2008
4 #
9ed0630 Reworked compiling C extensions.
Brian Ford authored Nov 10, 2009
5 # rake compile:melbourne_rbx
3610ac3 @rue Build readline as part of `rake build`. Cleaned up lib/bin/compile.rb.
rue authored Oct 14, 2008
6 #
9ed0630 Reworked compiling C extensions.
Brian Ford authored Nov 10, 2009
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 Oct 14, 2008
8
9ed0630 Reworked compiling C extensions.
Brian Ford authored Nov 10, 2009
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 Oct 14, 2008
11
f68acf7 Ensure that bootstrap Melbourne is built for bootstrap ruby.
Brian Ford authored Jun 6, 2011
12 def clean_extension(name)
7766cf5 @brixen Clean new-style C-exts.
brixen authored Nov 10, 2011
13 rm_f FileList["lib/**/ext/#{name}/*.{o,#{$dlext}}"], :verbose => $verbose
f68acf7 Ensure that bootstrap Melbourne is built for bootstrap ruby.
Brian Ford authored Jun 6, 2011
14 end
15
9ed0630 Reworked compiling C extensions.
Brian Ford authored Nov 10, 2009
16 namespace :extensions do
17 desc "Clean all lib/ext files"
93747eb @drbrain Bring in extensions and platform stuff from shotgun
drbrain authored Oct 1, 2008
18 task :clean do
f68acf7 Ensure that bootstrap Melbourne is built for bootstrap ruby.
Brian Ford authored Jun 6, 2011
19 clean_extension("**")
33c8f28 @brixen Split C-API headers for 1.8/1.9.
brixen authored Jun 8, 2011
20 rm_f FileList["lib/tooling/**/*.{o,#{$dlext}}"], :verbose => $verbose
e484ef7 Force reconfigure for C exts when cleaning.
Brian Ford authored May 23, 2010
21 # TODO: implement per extension cleaning. This hack is for
22 # openssl and dl, which use extconf.rb and create Makefile.
23 rm_f FileList["lib/ext/**/Makefile"], :verbose => $verbose
33c8f28 @brixen Split C-API headers for 1.8/1.9.
brixen authored Jun 8, 2011
24 rm_f FileList["lib/tooling/**/Makefile"], :verbose => $verbose
e99f097 Re-enable building DL extension.
Brian Ford authored May 24, 2010
25 rm_f FileList["lib/ext/dl/*.func"], :verbose => $verbose
0eb8c0f Added bigdecimal extension.
Brian Ford authored Apr 13, 2009
26 end
9ed0630 Reworked compiling C extensions.
Brian Ford authored Nov 10, 2009
27 end
0eb8c0f Added bigdecimal extension.
Brian Ford authored Apr 13, 2009
28
b66a3b8 Added ignore flag for building extconf-style C exts.
Brian Ford authored Aug 31, 2010
29 def rbx_build
30 # rbx-build can run even if prefix is used
65305fa @tenderlove fixing unused variable warnings
tenderlove authored Mar 16, 2011
31 File.expand_path "../bin/rbx-build", File.dirname(__FILE__)
b66a3b8 Added ignore flag for building extconf-style C exts.
Brian Ford authored Aug 31, 2010
32 end
33
f5a5246 Fixed building C exts that use extconf.rb.
Brian Ford authored Aug 31, 2010
34 def build_extconf(name, opts)
35 if opts[:ignore_fail]
b66a3b8 Added ignore flag for building extconf-style C exts.
Brian Ford authored Aug 31, 2010
36 fail_block = lambda { |ok, status| }
37 else
38 fail_block = nil
39 end
40
f5a5246 Fixed building C exts that use extconf.rb.
Brian Ford authored Sep 1, 2010
41 redirect = $verbose || !opts[:ignore_fail] ? "" : "> /dev/null 2>&1"
b66a3b8 Added ignore flag for building extconf-style C exts.
Brian Ford authored Aug 31, 2010
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 Jun 8, 2011
47 include18_dir = File.expand_path("../../vm/capi/18/include", __FILE__)
48 include19_dir = File.expand_path("../../vm/capi/19/include", __FILE__)
49
b66a3b8 Added ignore flag for building extconf-style C exts.
Brian Ford authored Aug 31, 2010
50 unless File.directory? BUILD_CONFIG[:runtime]
ed115c4 @brixen More chewing gum, duct tape, and baling wire.
brixen authored Dec 6, 2011
51 if opts[:env] == "-X18"
52 ENV["CFLAGS"] = "-I#{include18_dir}"
53 else
54 ENV["CFLAGS"] = "-I#{include19_dir}"
55 end
b66a3b8 Added ignore flag for building extconf-style C exts.
Brian Ford authored Aug 31, 2010
56 end
57
ed115c4 @brixen More chewing gum, duct tape, and baling wire.
brixen authored Dec 6, 2011
58 ENV["RBXOPT"] = opts[:env]
4ef646f @brixen More fixes for building 1.9 readline C-ext.
brixen authored Nov 5, 2011
59
f5a5246 Fixed building C exts that use extconf.rb.
Brian Ford authored Sep 1, 2010
60 unless opts[:deps] and opts[:deps].all? { |n| File.exists? n }
b66a3b8 Added ignore flag for building extconf-style C exts.
Brian Ford authored Aug 31, 2010
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 Nov 6, 2011
65
66 ENV.delete("RBXOPT")
b66a3b8 Added ignore flag for building extconf-style C exts.
Brian Ford authored Aug 31, 2010
67 end
68
9ed0630 Reworked compiling C extensions.
Brian Ford authored Nov 10, 2009
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 Apr 1, 2011
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 Oct 14, 2008
73
9ed0630 Reworked compiling C extensions.
Brian Ford authored Nov 10, 2009
74 if t = opts[:task]
60f7d84 Fixed toplevel C ext tasks to always delegate to the ext Rakefile.
Brian Ford authored Nov 18, 2009
75 ext_task_name = "build:#{t}"
76 names << t
9ed0630 Reworked compiling C extensions.
Brian Ford authored Nov 10, 2009
77 else
60f7d84 Fixed toplevel C ext tasks to always delegate to the ext Rakefile.
Brian Ford authored Nov 18, 2009
78 ext_task_name = "build"
3610ac3 @rue Build readline as part of `rake build`. Cleaned up lib/bin/compile.rb.
rue authored Oct 14, 2008
79 end
80
ed115c4 @brixen More chewing gum, duct tape, and baling wire.
brixen authored Dec 6, 2011
81 opts[:env] ||= "-X18"
82
60f7d84 Fixed toplevel C ext tasks to always delegate to the ext Rakefile.
Brian Ford authored Nov 18, 2009
83 task_name = names.join "_"
02c813d Put melbourne ext for rbx in a subdir.
Brian Ford authored Nov 3, 2009
84
9ed0630 Reworked compiling C extensions.
Brian Ford authored Nov 10, 2009
85 namespace :extensions do
86 desc "Build #{name.capitalize} extension #{opts[:doc]}"
60f7d84 Fixed toplevel C ext tasks to always delegate to the ext Rakefile.
Brian Ford authored Nov 18, 2009
87 task task_name do
88 ext_helper = File.expand_path "../ext_helper.rb", __FILE__
24f0e34 Use DependencyGrapher in C exts.
Brian Ford authored Mar 29, 2010
89 dep_grapher = File.expand_path "../dependency_grapher.rb", __FILE__
7b1cb48 Configure checks for readline, curses.
Brian Ford authored Nov 4, 2010
90 build_config = File.expand_path "../../config.rb", __FILE__
60f7d84 Fixed toplevel C ext tasks to always delegate to the ext Rakefile.
Brian Ford authored Nov 18, 2009
91 Dir.chdir ext_dir do
fe79104 Begin pulling in the OpenSSL CAPI extension
Evan Phoenix authored Dec 8, 2009
92 if File.exists? "Rakefile"
ed115c4 @brixen More chewing gum, duct tape, and baling wire.
brixen authored Dec 6, 2011
93 ENV["BUILD_VERSION"] = opts[:env][-2..-1]
94
7b1cb48 Configure checks for readline, curses.
Brian Ford authored Nov 5, 2010
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 Dec 9, 2009
96 else
f5a5246 Fixed building C exts that use extconf.rb.
Brian Ford authored Sep 1, 2010
97 build_extconf name, opts
fe79104 Begin pulling in the OpenSSL CAPI extension
Evan Phoenix authored Dec 9, 2009
98 end
60f7d84 Fixed toplevel C ext tasks to always delegate to the ext Rakefile.
Brian Ford authored Nov 18, 2009
99 end
100 end
ad861fe Added Melbourne parser extension.
Brian Ford authored Jul 13, 2009
101 end
60f7d84 Fixed toplevel C ext tasks to always delegate to the ext Rakefile.
Brian Ford authored Nov 18, 2009
102
103 Rake::Task[:extensions].prerequisites << "extensions:#{task_name}"
cc28068 Rearranged rake setup a lot, making browsing more intuitive (build se…
Ryan Davis authored Feb 4, 2008
104 end
9ed0630 Reworked compiling C extensions.
Brian Ford authored Nov 10, 2009
105
f68acf7 Ensure that bootstrap Melbourne is built for bootstrap ruby.
Brian Ford authored Jun 6, 2011
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
ed115c4 @brixen More chewing gum, duct tape, and baling wire.
brixen authored Dec 6, 2011
123 compile_ext "melbourne", :task => "build",
124 :doc => "for bootstrapping"
125
126 melbourne_env = BUILD_CONFIG[:version_list].include?("19") ? "-X19" : "-X18"
127 compile_ext "melbourne", :task => "rbx",
128 :env => melbourne_env,
129 :doc => "for Rubinius"
afcdd56 @brixen Added bigdecimal from 1.9.2p290.
brixen authored Nov 13, 2011
130
964229d @brixen Moved lib/ext/digest to lib/digest/ext.
brixen authored Nov 11, 2011
131 compile_ext "digest", :dir => "lib/digest/ext"
132 compile_ext "digest:md5", :dir => "lib/digest/ext/md5"
133 compile_ext "digest:rmd160", :dir => "lib/digest/ext/rmd160"
134 compile_ext "digest:sha1", :dir => "lib/digest/ext/sha1"
135 compile_ext "digest:sha2", :dir => "lib/digest/ext/sha2"
136 compile_ext "digest:bubblebabble", :dir => "lib/digest/ext/bubblebabble"
55f41fe @brixen Added syck/ from 1.9.2p290.
brixen authored Nov 9, 2011
137
afcdd56 @brixen Added bigdecimal from 1.9.2p290.
brixen authored Nov 14, 2011
138 compile_ext "bigdecimal", :dir => "lib/18/bigdecimal/ext", :env => "-X18"
0611ee8 @brixen Added nkf from 1.9.3p0.
brixen authored Nov 21, 2011
139 compile_ext "bigdecimal", :dir => "lib/19/bigdecimal/ext",
140 :deps => ["Makefile", "extconf.rb"],
141 :env => "-X19"
55f41fe @brixen Added syck/ from 1.9.2p290.
brixen authored Nov 10, 2011
142
143 compile_ext "syck", :dir => "lib/18/syck/ext"
e356726 @brixen Moved ext/nkf to lib/18/nkf.
brixen authored Nov 11, 2011
144 compile_ext "nkf", :dir => "lib/18/nkf/ext", :env => "-X18"
0611ee8 @brixen Added nkf from 1.9.3p0.
brixen authored Nov 21, 2011
145 compile_ext "nkf", :dir => "lib/19/nkf/ext",
146 :deps => ["Makefile", "extconf.rb"],
147 :env => "-X19"
07e6ac4 Moved C-API .h files to include directory.
Brian Ford authored May 23, 2010
148
fe70461 @brixen Fixed building 1.9 readline C-ext, again, hopefully.
brixen authored Nov 7, 2011
149 if BUILD_CONFIG[:readline] == :c_readline
40f8e6a @brixen Moved lib/ext/readline to lib/18/readline/ext.
brixen authored Nov 3, 2011
150 compile_ext "readline", :dir => "lib/18/readline/ext"
4ef646f @brixen More fixes for building 1.9 readline C-ext.
brixen authored Nov 6, 2011
151 compile_ext "readline", :dir => "lib/19/readline/ext",
152 :deps => ["Makefile", "extconf.rb"],
153 :env => "-X19"
40f8e6a @brixen Moved lib/ext/readline to lib/18/readline/ext.
brixen authored Nov 4, 2011
154 end
155
c07dd00 @brixen Build Psych if libyaml is available.
brixen authored Nov 9, 2011
156 if BUILD_CONFIG[:libyaml]
978ee88 @brixen Build Syck even if Psych is available because Syck is still 1.9 default.
brixen authored Nov 10, 2011
157 compile_ext "psych", :deps => ["Makefile"], :dir => "lib/19/psych/ext", :env => "-X19"
c07dd00 @brixen Build Psych if libyaml is available.
brixen authored Nov 9, 2011
158 end
159
978ee88 @brixen Build Syck even if Psych is available because Syck is still 1.9 default.
brixen authored Nov 11, 2011
160 compile_ext "syck", :deps => ["Makefile"], :dir => "lib/19/syck/ext", :env => "-X19"
161
07e6ac4 Moved C-API .h files to include directory.
Brian Ford authored May 23, 2010
162 # rbx must be able to run to build these because they use
163 # extconf.rb, so they must be after melbourne for Rubinius.
c118f41 @brixen Moved lib/ext/openssl to lib/openssl/ext.
brixen authored Nov 12, 2011
164 compile_ext "openssl", :deps => ["Makefile", "extconf.h"], :dir => "lib/openssl/ext"
416a973 @brixen Moved ext/dl to lib/18/dl/ext.
brixen authored Nov 11, 2011
165 compile_ext "dl", :deps => ["Makefile", "dlconfig.h"],
166 :dir => "lib/18/dl/ext", :env => "-X18"
9367db8 @brixen Moved ext/[gs]?dbm to lib/[gs]?dbm/ext.
brixen authored Nov 11, 2011
167 compile_ext "dbm", :ignore_fail => true, :deps => ["Makefile"], :dir => "lib/dbm/ext"
168 compile_ext "gdbm", :ignore_fail => true, :deps => ["Makefile"], :dir => "lib/gdbm/ext"
169 compile_ext "sdbm", :deps => ["Makefile"], :dir => "lib/sdbm/ext"
73fb486 Introduce tooling API, convert profiler to it.
Evan Phoenix authored Apr 1, 2011
170
bb535a4 Enable building with MRI or Rubinius 1.2.
Brian Ford authored Jun 6, 2011
171 compile_ext "profiler", :dir => "lib/tooling/profiler",
73fb486 Introduce tooling API, convert profiler to it.
Evan Phoenix authored Apr 1, 2011
172 :deps => ["Makefile"]
Something went wrong with that request. Please try again.