diff --git a/CHANGELOG.md b/CHANGELOG.md index f5abc3e..dd05487 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ ## mini_portile changelog +### next / unreleased + +#### Added + +- When setting the C compiler through the `MiniPortile` constructor, the preferred keyword argument is now `:cc_command`. The original `:gcc_command` is still supported. + + ### 2.8.6 / 2024-04-14 #### Added diff --git a/README.md b/README.md index 6642e53..f2d0df8 100644 --- a/README.md +++ b/README.md @@ -85,21 +85,23 @@ system-wide installation. Some keyword arguments can be passed to the constructor to configure the commands used: -#### `gcc_command` +#### `cc_command` The compiler command that is used is configurable, and in order of preference will use: - the `CC` environment variable (if present) -- the `gcc_command` value passed in to the constructor +- the `:cc_command` keyword argument passed in to the constructor - `RbConfig::CONFIG["CC"]` - `"gcc"` You can pass it in like so: ``` ruby -MiniPortile.new("libiconv", "1.13.1", gcc_command: "cc") +MiniPortile.new("libiconv", "1.13.1", cc_command: "cc") ``` +For backwards compatibility, the constructor also supports a keyword argument `:gcc_command`. + #### `make_command` The configuration/make command that is used is configurable, and in order of preference will use: diff --git a/lib/mini_portile2/mini_portile.rb b/lib/mini_portile2/mini_portile.rb index 335fa48..72df973 100644 --- a/lib/mini_portile2/mini_portile.rb +++ b/lib/mini_portile2/mini_portile.rb @@ -106,7 +106,7 @@ def initialize(name, version, **kwargs) @logger = STDOUT @source_directory = nil - @gcc_command = kwargs[:gcc_command] + @cc_command = kwargs[:cc_command] || kwargs[:gcc_command] @make_command = kwargs[:make_command] @open_timeout = kwargs[:open_timeout] || DEFAULT_TIMEOUT @read_timeout = kwargs[:read_timeout] || DEFAULT_TIMEOUT @@ -372,9 +372,10 @@ def lib_path File.join(path, "lib") end - def gcc_cmd - (ENV["CC"] || @gcc_command || RbConfig::CONFIG["CC"] || "gcc").dup + def cc_cmd + (ENV["CC"] || @cc_command || RbConfig::CONFIG["CC"] || "gcc").dup end + alias :gcc_cmd :cc_cmd def make_cmd (ENV["MAKE"] || @make_command || ENV["make"] || "make").dup diff --git a/test/test_cook.rb b/test/test_cook.rb index 414f3c6..031a43a 100644 --- a/test/test_cook.rb +++ b/test/test_cook.rb @@ -79,14 +79,22 @@ def test_make_command_configuration end end - def test_gcc_command_configuration + def test_cc_command_configuration without_env("CC") do expected_compiler = RbConfig::CONFIG["CC"] || "gcc" + assert_equal(expected_compiler, MiniPortile.new("test", "1.0.0").cc_cmd) assert_equal(expected_compiler, MiniPortile.new("test", "1.0.0").gcc_cmd) + assert_equal("xyzzy", MiniPortile.new("test", "1.0.0", cc_command: "xyzzy").cc_cmd) + assert_equal("xyzzy", MiniPortile.new("test", "1.0.0", gcc_command: "xyzzy").cc_cmd) + assert_equal("xyzzy", MiniPortile.new("test", "1.0.0", cc_command: "xyzzy").gcc_cmd) assert_equal("xyzzy", MiniPortile.new("test", "1.0.0", gcc_command: "xyzzy").gcc_cmd) end with_env("CC"=>"asdf") do + assert_equal("asdf", MiniPortile.new("test", "1.0.0").cc_cmd) assert_equal("asdf", MiniPortile.new("test", "1.0.0").gcc_cmd) + assert_equal("asdf", MiniPortile.new("test", "1.0.0", cc_command: "xyzzy").cc_cmd) + assert_equal("asdf", MiniPortile.new("test", "1.0.0", gcc_command: "xyzzy").cc_cmd) + assert_equal("asdf", MiniPortile.new("test", "1.0.0", cc_command: "xyzzy").gcc_cmd) assert_equal("asdf", MiniPortile.new("test", "1.0.0", gcc_command: "xyzzy").gcc_cmd) end end