Skip to content

Commit

Permalink
Merge pull request #139 from mudge/freebsd-cmake
Browse files Browse the repository at this point in the history
Prefer cc and c++ when using CMake on FreeBSD
  • Loading branch information
flavorjones committed Apr 12, 2024
2 parents dc73b84 + e0de764 commit 5fe79a4
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
33 changes: 31 additions & 2 deletions .github/workflows/ci.yml
Expand Up @@ -71,6 +71,10 @@ jobs:
- run: bundle exec rake test:examples

fedora: # see https://github.com/flavorjones/mini_portile/issues/118
strategy:
fail-fast: false
matrix:
task: ["test:unit", "test:examples"]
runs-on: ubuntu-latest
container:
image: fedora:35
Expand All @@ -84,5 +88,30 @@ jobs:
path: examples/ports/archives
key: examples-${{ hashFiles('examples/Rakefile') }}
- run: bundle install
- run: bundle exec rake test:unit
- run: bundle exec rake test:examples
- run: bundle exec rake ${{ matrix.task }}

freebsd:
strategy:
fail-fast: false
matrix:
task: ["test:unit", "test:examples"]
runs-on: ubuntu-latest
env:
MAKE: gmake
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: examples/ports/archives
key: examples-${{ hashFiles('examples/Rakefile') }}
- uses: vmactions/freebsd-vm@v1
with:
envs: MAKE
usesh: true
copyback: false
prepare: pkg install -y ruby devel/ruby-gems pkgconf git cmake devel/gmake textproc/libyaml security/gnupg
run: |
git config --global --add safe.directory /home/runner/work/mini_portile/mini_portile
gem install bundler
bundle install
bundle exec rake ${{ matrix.task }}
3 changes: 3 additions & 0 deletions lib/mini_portile2/mini_portile_cmake.rb
Expand Up @@ -94,6 +94,9 @@ def find_c_and_cxx_compilers(host)
if MiniPortile.darwin?
c_compiler ||= 'clang'
cxx_compiler ||='clang++'
elsif MiniPortile.freebsd?
c_compiler ||= 'cc'
cxx_compiler ||= 'c++'
else
c_compiler ||= 'gcc'
cxx_compiler ||= 'g++'
Expand Down
23 changes: 23 additions & 0 deletions test/test_cmake.rb
Expand Up @@ -107,6 +107,29 @@ def test_configure_defaults_with_macos
end
end

def test_configure_defaults_with_freebsd
recipe = init_recipe
recipe.host = 'some-host'

with_env({ "CC" => nil, "CXX" => nil }) do
with_stubbed_target(os: 'freebsd14') do
with_compilers(recipe, c_compiler: 'cc', cxx_compiler: 'c++') do
Open3.stub(:capture2, cmake_help_mock('Unix')) do
assert_equal(
[
"-DCMAKE_SYSTEM_NAME=FreeBSD",
"-DCMAKE_SYSTEM_PROCESSOR=x86_64",
"-DCMAKE_C_COMPILER=cc",
"-DCMAKE_CXX_COMPILER=c++",
"-DCMAKE_BUILD_TYPE=Release"
],
recipe.configure_defaults)
end
end
end
end
end

def test_configure_defaults_with_manual_system_name
recipe = init_recipe
recipe.system_name = 'Custom'
Expand Down

0 comments on commit 5fe79a4

Please sign in to comment.