Skip to content

Commit 5affd5f

Browse files
committed
Build bundled-gem extensions for docs targets
After b5e6e0a (Use rbs-integrated RDoc), tool/rdoc-srcdir does require 'rdoc/rdoc' which activates rdoc-7.2.0 and its new add_dependency 'rbs', '>= 4.0.0'. RubyGems then needs rbs's gemspec in .bundle/specifications/ and its C extension built. ext/extmk.rb already handles both via each per-gem Makefile (all -> install -> gemspec copies .bundled.rbs-*.gemspec into specifications/, and the TARGET_SO recipe writes gem.build_complete) -- but only if ext/configure-ext.mk has seen .bundle/gems/ populated when its template's Dir.glob(".bundle/gems/**/extconf.rb") runs. On a clean tree, ext/configure-ext.mk regenerates before prepare-gems extracts anything, so its template glob finds nothing, exts.mk lacks rules for bundled-gem extensions, the rbs C extension never compiles, and RubyGems aborts with "Ignoring rbs-4.0.2 because its extensions are not built." Add prepare-gems as a prereq of ext/configure-ext.mk, scoped via MAKECMDGOALS to docs goals only (rdoc, rdoc:%, html, html-server, rdoc-coverage, undocumented). Plain `make` is untouched, so an offline-fresh-checkout build doesn't reach prepare-gems -> update-gems. Also fix tool/update-deps: with the new dep, `make -p all` now includes rules from inside .bundle/gems/<gem>/ext/<ext>/, where make prints relative targets like `bigdecimal.o:` whose curdir is under .bundle/. The existing filter checked the raw target string, missing these; move the check onto `dir + target` so the full path is what's inspected. Bundled gems own their depend files, so skipping them here matches the intent of the original filter. https://claude.ai/code/session_01YRoRyZPew2LtN6u6BX8bzx
1 parent b5e6e0a commit 5affd5f

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

defs/gmake.mk

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,21 @@ $(srcdir)/gems/%.gem:
358358
extract-gems: | $(patsubst %,$(srcdir)/.bundle/gems/%,$(bundled-gems))
359359
extract-gems: | $(call foreach-bundled-gems-rev,bundled-gem-extracted)
360360

361+
# Docs targets call $(RDOC) -> tool/rdoc-srcdir, which loads rdoc/rdoc and
362+
# activates its `add_dependency 'rbs', '>= 4.0.0'`. Activation requires
363+
# the bundled rbs gem to be discoverable and its C extension built. The
364+
# existing per-bundled-gem Makefile generated by ext/extmk.rb does both
365+
# (extension build + copy of .bundled.rbs-*.gemspec into
366+
# .bundle/specifications/), but only if ext/configure-ext.mk has seen
367+
# `.bundle/gems/` populated when its template's
368+
# `Dir.glob(".bundle/gems/**/extconf.rb")` runs. On a clean tree
369+
# prepare-gems may not have run yet, so make the dep explicit for the
370+
# docs goals. Other targets are left alone so a plain `make` doesn't
371+
# reach for prepare-gems -> update-gems (network).
372+
ifneq ($(filter rdoc rdoc:% html html-server rdoc-coverage undocumented,$(MAKECMDGOALS)),)
373+
ext/configure-ext.mk: $(HAVE_BASERUBY:yes=prepare-gems)
374+
endif
375+
361376
$(srcdir)/.bundle/gems/%: $(srcdir)/gems/%.gem | .bundle/gems
362377
$(ECHO) Extracting bundle gem $*...
363378
$(Q) $(BASERUBY) -C "$(srcdir)" \

tool/update-deps

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,12 +328,13 @@ def read_make_deps(cwd)
328328
next if /libyjit.o\z/ =~ target.to_s # skip YJIT Rust object (no corresponding C source)
329329
next if /libzjit.o\z/ =~ target.to_s # skip ZJIT Rust object (no corresponding C source)
330330
next if /target\/release\/libruby.o\z/ =~ target.to_s # skip YJIT+ZJIT Rust object (no corresponding C source)
331-
next if /\.bundle\// =~ target.to_s
332331
next if /\A\./ =~ target.to_s # skip rules such as ".c.o"
333332
#p [curdir, target, deps]
334333
dir = curdir || dirstack.last
335-
dependencies[dir + target] ||= []
336-
dependencies[dir + target] |= deps.map {|dep| dir + dep }
334+
key = dir + target
335+
next if /\.bundle\// =~ key.to_s # bundled gem extensions manage their own depend files
336+
dependencies[key] ||= []
337+
dependencies[key] |= deps.map {|dep| dir + dep }
337338
elsif data_base_end
338339
curdir = nil
339340
elsif directory_leave

0 commit comments

Comments
 (0)