-
Notifications
You must be signed in to change notification settings - Fork 0
research build wiring extconf rb
ext/duckling/extconf.rb exists in the gem but is empty (0 bytes). The
gemspec already declares spec.extensions = ["ext/duckling/extconf.rb"], so
RubyGems and rake-compiler know to invoke it.
Source: examples/rust_blank/ext/rust_blank/extconf.rb
Exact content:
require "mkmf"
require "rb_sys/mkmf"
create_rust_makefile("rust_blank/rust_blank")Three lines. This is the complete file.
create_rust_makefile is provided by the rb_sys gem (version 0.9.128 in
Gemfile.lock). It:
- Locates the Cargo workspace/crate in the same directory as
extconf.rb - Generates a
Makefilethat delegates tocargo build - Sets
CARGO_BUILD_TARGETand Ruby-specific environment variables so the native extension links against the currently running Ruby
The string argument "rust_blank/rust_blank" is the output path for the
compiled shared library relative to lib/. So "duckling/duckling" would
produce lib/duckling/duckling.bundle (macOS) or lib/duckling/duckling.so
(Linux).
This file is generated during rake compile and also during gem install
when the gem is installed from source. RubyGems invokes extconf.rb via
ruby extconf.rb, which writes the Makefile, and then make is run in the
extension directory.
require "mkmf"
require "rb_sys/mkmf"
create_rust_makefile("duckling/duckling")The argument "duckling/duckling" matches:
- The
lib_dir = "lib/duckling"setting in Rake::ExtensionTask (see rakefile-setup.md) - The
require "duckling/duckling"call expected insidelib/duckling.rb
duckling.gemspec declares:
spec.extensions = ["ext/duckling/extconf.rb"]
spec.add_dependency "rb_sys", "~> 0.9.39"The rb_sys runtime dependency is what provides rb_sys/mkmf to end-users
who install the gem from source. Gemfile.lock pins rb_sys to 0.9.128.
-
Does
create_rust_makefileneed Cargo in PATH at gem install time? Yes — the Makefile it generates invokescargo build. End-users installing from source must have Rust/Cargo installed. The gem shipped as a source-only gem (see CI Configuration), so this requirement is real for every installer, not just a hypothetical. -
Does rb_sys/mkmf need to be required before mkmf? Yes, confirmed —
ext/duckling/extconf.rbonmainrequiresmkmffirst, thenrb_sys/mkmf, exactly matching the "Content needed" prediction above and the rust_blank reference ordering.