mruby-regexp, mruby-task: ask the build what it defines - #7171
Conversation
The two case folding test files assert opposite things about the same
patterns, so the gem drops one of them by asking whether this build folds
Unicode. It asked `build.cc.defines`, which is the C compiler's list alone.
A build that turns the option on through `conf.defines`, which puts it on
every compiler, compiles the engine with `-DMRB_REGEXP_UNICODE_CASE` and was
handed the ASCII file, which asserts that `/i` refuses the patterns the
engine now folds:
```ruby
MRuby::Build.new('probe') do |conf|
conf.toolchain
conf.gembox 'full-core'
conf.defines << 'MRB_REGEXP_UNICODE_CASE'
conf.enable_test
end
```
`rake -m test` on that config reports `KO: 1`, on `Regexp - /i refuses what
ASCII folding cannot answer`.
`MRuby::Build#has_define?` spans both places a define can come from and
matches on the name, so one written as `FOO=1` answers under `FOO`. It has
to be asked from `build_settings`, since a gem contributes its defines while
the gems are still being set up and the answer would otherwise depend on
where this gem sits in the list. This gem sets no build command in its own
block, so the reset that comes with `build_settings` drops nothing.
### Verified
The config above now reports `Total 2302 KO 0`, one test fewer than the
2303 of the same config without the option, which is the ASCII file's two
tests giving way to the Unicode file's one.
`MRUBY_CONFIG=ci/gcc-clang rake -m test`, four builds and the bintests, KO 0.
`full-debug` sets the option through `conf.cc.defines` and still gets the
Unicode file:
bintest 117 bintests
bintest 2303 Skip 10
byte-string 2239 Skip 29
cxx_abi 2303 Skip 10
full-debug 2302 Skip 2
`MRB_TASK_BUILD_DEMO` is a switch a build configuration throws to get `bin/mruby_task_demo`, and the gem read it out of `spec.build.cc.defines`, the C compiler's list alone. Thrown through `conf.defines`, which puts it on every compiler, nothing happened and nothing said so: the tool the option asks for simply did not appear. `MRuby::Build#has_define?` spans both places a define can come from and matches on the name. It has to be asked from `build_settings`, since a gem contributes its defines while the gems are still being set up, and that block resets the gem's build commands to the build's. The `winmm` library and the pkg-config query move in with it: left outside they would be set during setup and then dropped. ### Verified On a config that carries `conf.ports :glib` and turns the option on through `conf.defines`, the gem now takes `mruby_task_demo` as its binary and holds the two pkg-config answers on its compiler and its linker, where before it took no binary at all. `build_config/glib_hal_test.rb`, which sets the option through `conf.cc.defines` and builds under `-fsanitize=address,undefined`, produces `bin/mruby_task_demo`, and the demo runs all of its scenarios to `All scenarios completed.` The same config minus the demo passes `rake -m test` with `Total 832 KO 0`, so the glib port still compiles and links from the flags this block gathers. `MRUBY_CONFIG=ci/gcc-clang rake -m test` and `MRUBY_CONFIG=default rake -m test` are unaffected, KO 0, since neither carries the gem. Not fixed here: `rake test` on a build that turns the demo on cannot link `mrbtest`, because `MRuby::Gem::List#linker_attrs` drops a gem that owns a binary and the glib libraries go with it. That predates this commit.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe regexp and task gem build configurations now evaluate build-dependent settings inside ChangesDeferred build settings
Estimated code review effort: 2 (Simple) | ~15 minutes Merge Risk: ⚪ Minimal · up to The change makes the two GEMs honor build-wide defines so their selected tests and optional tooling match the actual build configuration; the supplied checks pass, and no actionable merge-blocking risk remains. Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Two GEMs read a build define out of
build.cc.defines, which is the C compiler's list alone. A build that sets the define throughconf.defines, which puts it on every compiler, compiles under the-Dand is not seen here, so the GEM configures itself for a build it is not in. One symptom is a failing test, the other is a tool that never appears.mruby-regexphands mrbtest the wrong test fileThe engine is compiled with Unicode simple case folding, and the GEM hands mrbtest
test/ascii_case.rb, the file that asserts/irefuses the very patterns the engine now folds. On master:mruby-taskdrops the tool the option asks forMRB_TASK_BUILD_DEMOis a switch a build configuration throws to getbin/mruby_task_demo. Thrown throughconf.defines, the GEM takes no binary, and nothing reports that the option went nowhere.Both ask
MRuby::Build#has_define?insteada3513b6 added that reader for this and left it without a caller. It spans
build.definesand every compiler's list, and matches on the name, so a define written asFOO=1answers underFOO.It has to be asked from
spec.build_settings: a GEM contributes its defines while the GEMs are still being set up, so the answer during that phase depends on where the caller sits in the list, andhas_define?refuses there rather than give one.build_settingsresets a GEM's build commands to the build's, somruby-task'swinmmlibrary and its pkg-config query move into the block along with the question. Left outside they would be set during setup and then dropped.mruby-regexpsets no build command in its own block, so nothing moves there.Verified
The
conf.definesconfig above reportsTotal 2302 KO 0, one test fewer than the 2303 of the same config without the option, which is the ASCII file's two tests giving way to the Unicode file's one.MRUBY_CONFIG=ci/gcc-clang rake -m test, four builds and the bintests, KO 0.full-debugsets the option throughconf.cc.definesand still gets the Unicode file:MRUBY_CONFIG=default rake -m test,Total 2085 KO 0plus 106 bintests, on each commit of this PR.For
mruby-task,build_config/glib_hal_test.rbsets the option throughconf.cc.definesand builds under-fsanitize=address,undefined: it producesbin/mruby_task_demo, and the demo runs every scenario through toAll scenarios completed.The same config without the demo passesrake -m testwithTotal 832 KO 0, so the glib port still compiles and links from the flags this block gathers.Not fixed here
rake teston a build that turns the demo on cannot linkmrbtest:MRuby::Gem::List#linker_attrsdrops a GEM that owns a binary, and the glib libraries go with it. That is on master today and is a separate matter from which list the define is read out of.Summary by CodeRabbit