Skip to content

Commit b520a43

Browse files
committed
Build bundled gems extensions under src/main/c too
* To avoid mutating lib/gems during build which is causing many complications.
1 parent b2a4dc6 commit b520a43

File tree

4 files changed

+32
-54
lines changed

4 files changed

+32
-54
lines changed

doc/contributor/updating-ruby.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ Update all of these:
144144
* Update `.ruby-version`, `TruffleRuby.LANGUAGE_VERSION`
145145
* Reset `truffleruby-abi-version.h` to `$RUBY_VERSION.1` and `lib/cext/ABI_check.txt` to `1` if `RUBY_VERSION` was updated.
146146
* Update `versions.json` (with gem versions provided by `cat ../ruby/gems/bundled_gems | sort`, `ls -l lib/gems/specifications/default` and `grep 'VERSION =' lib/mri/rubygems.rb`)
147-
* Also update version numbers for `debug` and `rbs` in `src/main/c/Makefile` and in `mx.truffleruby/suite.py`.
147+
* Also update version numbers for `debug` and `rbs` in `src/main/c/Makefile`, `mx.truffleruby/suite.py` and `lib/gems/gems/debug-*/ext/debug/extconf.rb`.
148148
* Copy and paste `-h` and `--help` output to `RubyLauncher` (instructions are in the end of the file `src/launcher/java/org/truffleruby/launcher/RubyLauncher.java`)
149149
* This is a good time to get `jt build` working.
150150
* Copy and paste the TruffleRuby `--help` output to `doc/user/options.md` (e.g., with `jt ruby --help | xsel -b`)

lib/gems/gems/debug-1.7.1/ext/debug/extconf.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'mkmf'
2-
require_relative '../../lib/debug/version'
3-
File.write("debug_version.h", "#define RUBY_DEBUG_VERSION \"#{DEBUGGER__::VERSION}\"\n")
2+
# TruffleRuby: hardcode the version here to avoid depending on version.rb which is not copied to src/main/c/debug
3+
File.write("debug_version.h", "#define RUBY_DEBUG_VERSION \"#{"1.7.1"}\"\n")
44
$distcleanfiles << "debug_version.h"
55

66
if defined? RubyVM

mx.truffleruby/suite.py

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,8 @@
404404
"src/main/c/ripper/<extsuffix:ripper>",
405405
"src/main/c/syslog/<extsuffix:syslog>",
406406
"src/main/c/zlib/<extsuffix:zlib>",
407-
"lib/gems/gems/debug-1.7.1/lib/debug/<extsuffix:debug>",
408-
"lib/gems/gems/rbs-2.8.2/lib/<extsuffix:rbs_extension>",
407+
"src/main/c/debug/<extsuffix:debug>",
408+
"src/main/c/rbs/<extsuffix:rbs_extension>",
409409
],
410410
"license": [
411411
"EPL-2.0", # JRuby (we're choosing EPL out of EPL,GPL,LGPL)
@@ -696,14 +696,10 @@
696696
"fileListPurpose": 'native-image-resources',
697697
"native": True,
698698
"platformDependent": False,
699-
# The project org.truffleruby.cext touches lib/gems/gems/debug-1.7.1/ext
700-
# and lib/gems/extensions/$ARCH-$OS/$ABI/rbs-2.8.2/gem.build_complete.
701-
# This causes this layout distribution to be rebuilt even though nothing changes in the result.
702-
# To avoid that we force org.truffleruby.cext to complete first.
703-
"dependencies": ["org.truffleruby.cext"],
704699
"layout": {
705700
"lib/": [
706701
"file:lib/json",
702+
"file:lib/gems",
707703
"file:lib/mri",
708704
"file:lib/patches",
709705
"file:lib/truffle",
@@ -714,23 +710,6 @@
714710
"lib/cext/include/": [
715711
"file:lib/cext/include/*",
716712
],
717-
"lib/gems/": [
718-
{
719-
"source_type": "file",
720-
"path": "lib/gems/*",
721-
"exclude": [
722-
# The debug and rbs gems have native extensions.
723-
# Do not ship ext/ as it includes an unnecessary copy of the .so and intermediate files.
724-
# The .so in lib/ are copied in the platform-specific distribution.
725-
# <extsuffix:...> does not work in exclude, so use .* here (.{so,bundle} does not work either).
726-
"lib/gems/extensions",
727-
"lib/gems/gems/debug-1.7.1/ext",
728-
"lib/gems/gems/debug-1.7.1/lib/debug/debug.*",
729-
"lib/gems/gems/rbs-2.8.2/ext",
730-
"lib/gems/gems/rbs-2.8.2/lib/rbs_extension.*",
731-
],
732-
},
733-
],
734713
},
735714
"license": [
736715
"EPL-2.0", # JRuby (we're choosing EPL out of EPL,GPL,LGPL)
@@ -759,9 +738,12 @@
759738
# Create the complete files to let RubyGems know the gems are fully built
760739
"lib/gems/extensions/<cruby_arch>-<os>/<truffleruby_abi_version>/debug-1.7.1/gem.build_complete": "string:",
761740
"lib/gems/extensions/<cruby_arch>-<os>/<truffleruby_abi_version>/rbs-2.8.2/gem.build_complete": "string:",
762-
# The platform-specific files from debug and rbs, see comment above
763-
"lib/gems/gems/debug-1.7.1/lib/debug/": "dependency:org.truffleruby.cext/lib/gems/gems/debug-1.7.1/lib/debug/<extsuffix:debug>",
764-
"lib/gems/gems/rbs-2.8.2/lib/": "dependency:org.truffleruby.cext/lib/gems/gems/rbs-2.8.2/lib/<extsuffix:rbs_extension>",
741+
"lib/gems/gems/debug-1.7.1/lib/debug/": [
742+
"dependency:org.truffleruby.cext/src/main/c/debug/<extsuffix:debug>",
743+
],
744+
"lib/gems/gems/rbs-2.8.2/lib/": [
745+
"dependency:org.truffleruby.cext/src/main/c/rbs/<extsuffix:rbs_extension>",
746+
],
765747
"lib/mri/": [
766748
"dependency:org.truffleruby.cext/src/main/c/bigdecimal/<extsuffix:bigdecimal>",
767749
"dependency:org.truffleruby.cext/src/main/c/date/<extsuffix:date_core>",

src/main/c/Makefile

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,15 @@ BASIC_EXTCONF_DEPS := $(BASIC_DEPS) $(RBCONFIG) $(MKMF)
3232
# However, if libtruffleruby is recompiled, there is no need to rebuild C extensions, so it's a order-only-prerequisite.
3333
EXTCONF_DEPS := $(BASIC_EXTCONF_DEPS) | $(LIBTRUFFLERUBY)
3434

35-
DEBUG_GEM := $(ROOT)/lib/gems/gems/debug-1.7.1
36-
DEBUG_GEM_EXT := $(DEBUG_GEM)/ext/debug
37-
DEBUG_GEM_EXT_SO := $(DEBUG_GEM_EXT)/debug.$(DLEXT)
38-
DEBUG_GEM_LIB_SO := $(DEBUG_GEM)/lib/debug/debug.$(DLEXT)
39-
40-
RBS_GEM := $(ROOT)/lib/gems/gems/rbs-2.8.2
41-
RBS_GEM_EXT := $(RBS_GEM)/ext/rbs_extension
42-
RBS_GEM_EXT_SO := $(RBS_GEM_EXT)/rbs_extension.$(DLEXT)
43-
RBS_GEM_LIB_SO := $(RBS_GEM)/lib/rbs_extension.$(DLEXT)
35+
DEBUG_GEM_EXT := $(ROOT)/lib/gems/gems/debug-1.7.1/ext/debug
36+
RBS_GEM_EXT := $(ROOT)/lib/gems/gems/rbs-2.8.2/ext/rbs_extension
4437

4538
IF_EXTCONF_FAIL := ( echo "`pwd`/extconf.rb failed:" 1>&2 && cat mkmf.log && false )
4639

4740
all: $(TRAMPOLINE) $(LIBTRUFFLERUBY) openssl/openssl.$(DLEXT) zlib/zlib.$(DLEXT) \
4841
psych/psych.$(DLEXT) ripper/ripper.$(DLEXT) syslog/syslog.$(DLEXT) nkf/nkf.$(DLEXT) \
4942
bigdecimal/bigdecimal.$(DLEXT) date/date_core.$(DLEXT) io-console/console.$(DLEXT) etc/etc.$(DLEXT) \
50-
rbconfig-sizeof/sizeof.$(DLEXT) $(DEBUG_GEM_LIB_SO) $(RBS_GEM_LIB_SO)
43+
rbconfig-sizeof/sizeof.$(DLEXT) debug/debug.$(DLEXT) rbs/rbs_extension.$(DLEXT)
5144

5245
clean: clean_cexts clean_truffleposix clean_trampoline
5346

@@ -70,8 +63,8 @@ clean_cexts:
7063
$(Q) rm -f io-console/Makefile io-console/*.o io-console/console.$(DLEXT)
7164
$(Q) rm -f etc/Makefile etc/*.o etc/etc.$(DLEXT) etc/constdefs.h
7265
$(Q) rm -f rbconfig-sizeof/Makefile rbconfig-sizeof/*.o rbconfig-sizeof/sizeof.$(DLEXT)
73-
$(Q) rm -f $(DEBUG_GEM_EXT)/Makefile $(DEBUG_GEM_EXT)/*.o $(DEBUG_GEM_EXT_SO) $(DEBUG_GEM_LIB_SO)
74-
$(Q) rm -f $(RBS_GEM_EXT)/Makefile $(RBS_GEM_EXT)/*.o $(RBS_GEM_EXT_SO) $(RBS_GEM_LIB_SO)
66+
$(Q) rm -f debug/Makefile debug/*.o debug/debug.$(DLEXT)
67+
$(Q) rm -f rbs/Makefile rbs/*.o rbs/rbs_extension.$(DLEXT)
7568

7669
# spawn-helper
7770
$(SPAWN_HELPER): spawn-helper/Makefile spawn-helper/spawn-helper.c
@@ -178,21 +171,24 @@ psych/psych.$(DLEXT): psych/Makefile psych/*.c psych/*.h
178171
$(Q) cd psych && $(MAKE) $(MKMF_MAKEFILE_SUBPROCESS_FLAGS)
179172

180173
# debug bundled gem
181-
$(DEBUG_GEM_EXT)/Makefile: $(DEBUG_GEM_EXT)/extconf.rb $(EXTCONF_DEPS)
182-
$(Q) cd $(DEBUG_GEM_EXT) && $(RUBY) extconf.rb || $(IF_EXTCONF_FAIL)
174+
debug/extconf.rb: $(DEBUG_GEM_EXT)/extconf.rb $(DEBUG_GEM_EXT)/*.c
175+
$(Q) mkdir -p debug
176+
$(Q) cd debug && cp $(DEBUG_GEM_EXT)/*.{rb,c} .
183177

184-
$(DEBUG_GEM_EXT_SO): $(DEBUG_GEM_EXT)/Makefile $(DEBUG_GEM_EXT)/*.c
185-
$(Q) cd $(DEBUG_GEM_EXT) && $(MAKE) $(MKMF_MAKEFILE_SUBPROCESS_FLAGS)
178+
debug/Makefile: debug/extconf.rb $(EXTCONF_DEPS)
179+
$(Q) cd debug && $(RUBY) extconf.rb || $(IF_EXTCONF_FAIL)
186180

187-
$(DEBUG_GEM_LIB_SO): $(DEBUG_GEM_EXT_SO)
188-
$(Q) cp $< $@
181+
debug/debug.$(DLEXT): debug/Makefile
182+
$(Q) cd debug && $(MAKE) $(MKMF_MAKEFILE_SUBPROCESS_FLAGS)
189183

190184
# rbs bundled gem
191-
$(RBS_GEM_EXT)/Makefile: $(RBS_GEM_EXT)/extconf.rb $(EXTCONF_DEPS)
192-
$(Q) cd $(RBS_GEM_EXT) && $(RUBY) extconf.rb || $(IF_EXTCONF_FAIL)
185+
rbs/extconf.rb: $(RBS_GEM_EXT)/extconf.rb $(RBS_GEM_EXT)/*.c $(RBS_GEM_EXT)/*.h
186+
$(Q) mkdir -p rbs
187+
$(Q) cd rbs && cp $(RBS_GEM_EXT)/*.{rb,c,h} .
188+
189+
rbs/Makefile: rbs/extconf.rb $(EXTCONF_DEPS)
190+
$(Q) cd rbs && $(RUBY) extconf.rb || $(IF_EXTCONF_FAIL)
193191

194-
$(RBS_GEM_EXT_SO): $(RBS_GEM_EXT)/Makefile $(RBS_GEM_EXT)/*.c $(RBS_GEM_EXT)/*.h
195-
$(Q) cd $(RBS_GEM_EXT) && $(MAKE) $(MKMF_MAKEFILE_SUBPROCESS_FLAGS)
192+
rbs/rbs_extension.$(DLEXT): rbs/Makefile
193+
$(Q) cd rbs && $(MAKE) $(MKMF_MAKEFILE_SUBPROCESS_FLAGS)
196194

197-
$(RBS_GEM_LIB_SO): $(RBS_GEM_EXT_SO)
198-
$(Q) cp $< $@

0 commit comments

Comments
 (0)