Skip to content

Commit

Permalink
Prefer cc_command to gcc_command
Browse files Browse the repository at this point in the history
But still support `gcc_command`
  • Loading branch information
flavorjones committed May 29, 2024
1 parent f768b5a commit b1a6fbd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 4 additions & 3 deletions lib/mini_portile2/mini_portile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion test/test_cook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b1a6fbd

Please sign in to comment.