-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mkmf: Add the extra option --with-verbose
to enable verbose mode.
#7863
Conversation
This commit is to add an extra option to enable verbose mode (V=1) in the generated `Makefile` at runtime of the Ruby to print compiler command lines by the commands below when building native extensions. It's possible to enable the verbose mode by setting the environment variable `MAKEFLAGS="V=1"`[1] implemented in GNU make. However, I wanted to make a consistent user-interface not depending on the specific make's implementation. ``` $ ruby /path/to/extconf.rb -- --with-verbose ``` You can also add the extra option via rake-compiler gem. ``` $ rake compiler -- --with-verbose ``` If the extra option is not given, the value of the `RbConfig::CONFIG["MKMF_VERBOSE"]` enabled by the configure option below is used. ``` $ ./configure --enable-mkmf-verbose ``` For the unit tests, updated the following files. * The `test/mkmf/test_configuration.rb` was created to test the cases with the `configuration` method and this implementation. * Updated the `TestMkmf#assert_separately` to set the extra arguments in `test/mkmf/base.rb`. Updated tests using the `assert_separately`. * Added tests for `MakeMakefile#with_config` in the `test/mkmf/test_config.rb`. [1] https://www.gnu.org/software/make/manual/html_node/Variables_002fRecursion.html Fixes [Bug #19695] Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
c89ac67
to
49ea4bb
Compare
def assert_separately(args, src, *rest, **options) | ||
super(args + ["-r#{__FILE__}"], "extend TestMkmf::Base; setup\nEND{teardown}\n#{src}", *rest, **options) | ||
def assert_separately(args, extra_args, src, *rest, **options) | ||
super(args + ["-r#{__FILE__}"] + %w[- --] + extra_args, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this part, I wanted to write args + %w[-r#{__FILE__} - --] + extra_args
. However, I saw the #{__FILE__}
was not converted to the value. So, the ["-r#{__FILE__}"] + %w[- --]
is a bit compromised way.
$ ruby -v
ruby 3.3.0dev (2023-05-25T12:45:21Z wip/mkmf-verbose-r.. cbeba2ed16) [x86_64-linux]
$ which irb
~/.local/ruby-cbeba2ed16/bin/irb
$ irb
irb(main):001:0> %w[-r#{__FILE__} - --]
=> ["-r\#{__FILE__}", "-", "--"]
irb(main):002:0> %[-r#{__FILE__} - --]
=> "-r(irb) - --"
I rebased, fixing the review items. Thanks for that. I squashed the 3 commits to 1 commit. |
The Ruby ticket is https://bugs.ruby-lang.org/issues/19695.
This PR is to add the new extra argument
--with-verbose
to themkmf.rb
, and the PR has 3 commits.--with-verbose
to enable verbose mode.MakeMakefile#with_config
.mkmf: Add the extra option
--with-verbose
to enable verbose mode.The first commit is the main one of the feature.
This commit is to add an extra option to enable verbose mode (V=1) in the generated
Makefile
at runtime of the Ruby to print compiler command lines by the commands below when building native extensions. It's possible to enable the verbose mode by setting the environment variableMAKEFLAGS="V=1"
[1] implemented in GNU make. However, I wanted to make a consistent user-interface not depending on the specific make's implementation.You can also add the extra option via rake-compiler gem.
If the extra option is not given, the value of the
RbConfig::CONFIG["MKMF_VERBOSE"]
enabled by the configure option below is used.[1] https://www.gnu.org/software/make/manual/html_node/Variables_002fRecursion.html
Co-authored-by: Nobuyoshi Nakada nobu@ruby-lang.org
mkmf: Add tests for
MakeMakefile#with_config
.This second commit is to test the
MakeMakefile#with_config
that is used in the main commit. As I couldn't find the test of thewith_config
, I created it.mkmf: Add tests to test the verbose mode in MakeMakefile#configuration.
The third commit is the tests to test the use cases of the first commit.