Skip to content

Commit

Permalink
Merge pull request #136 from Watson1978/release-build
Browse files Browse the repository at this point in the history
Create release binary with cmake explicitly
  • Loading branch information
flavorjones authored Oct 13, 2023
2 parents 6897bb9 + d2a6035 commit 579704b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
8 changes: 7 additions & 1 deletion lib/mini_portile2/mini_portile_cmake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def configure_prefix
def initialize(name, version, **kwargs)
super(name, version, **kwargs)
@cmake_command = kwargs[:cmake_command]
@cmake_build_type = kwargs[:cmake_build_type]
end

def configure_defaults
Expand Down Expand Up @@ -49,6 +50,10 @@ def cmake_cmd
(ENV["CMAKE"] || @cmake_command || "cmake").dup
end

def cmake_build_type
(ENV["CMAKE_BUILD_TYPE"] || @cmake_build_type || "Release").dup
end

private

def generator_defaults
Expand All @@ -69,7 +74,8 @@ def cmake_compile_flags
"-DCMAKE_SYSTEM_NAME=#{cmake_system_name}",
"-DCMAKE_SYSTEM_PROCESSOR=#{cpu_type}",
"-DCMAKE_C_COMPILER=#{c_compiler}",
"-DCMAKE_CXX_COMPILER=#{cxx_compiler}"
"-DCMAKE_CXX_COMPILER=#{cxx_compiler}",
"-DCMAKE_BUILD_TYPE=#{cmake_build_type}",
]
end

Expand Down
20 changes: 17 additions & 3 deletions test/test_cmake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ def test_configure_defaults_with_macos
"-DCMAKE_SYSTEM_NAME=Darwin",
"-DCMAKE_SYSTEM_PROCESSOR=arm64",
"-DCMAKE_C_COMPILER=some-host-clang",
"-DCMAKE_CXX_COMPILER=some-host-clang++"
"-DCMAKE_CXX_COMPILER=some-host-clang++",
"-DCMAKE_BUILD_TYPE=Release"
],
recipe.configure_defaults)
end
Expand All @@ -119,7 +120,8 @@ def test_configure_defaults_with_manual_system_name
"-DCMAKE_SYSTEM_NAME=Custom",
"-DCMAKE_SYSTEM_PROCESSOR=x86_64",
"-DCMAKE_C_COMPILER=gcc",
"-DCMAKE_CXX_COMPILER=g++"
"-DCMAKE_CXX_COMPILER=g++",
"-DCMAKE_BUILD_TYPE=Release"
],
recipe.configure_defaults)
end
Expand Down Expand Up @@ -194,6 +196,17 @@ def test_cmake_command_configuration
end
end

def test_cmake_build_type_configuration
without_env("CMAKE_BUILD_TYPE") do
assert_equal("Release", MiniPortileCMake.new("test", "1.0.0").cmake_build_type)
assert_equal("xyzzy", MiniPortileCMake.new("test", "1.0.0", cmake_build_type: "xyzzy").cmake_build_type)
end
with_env("CMAKE_BUILD_TYPE"=>"Debug") do
assert_equal("Debug", MiniPortileCMake.new("test", "1.0.0").cmake_build_type)
assert_equal("Debug", MiniPortileCMake.new("test", "1.0.0", cmake_build_type: "xyzzy").cmake_build_type)
end
end

private

def with_stubbed_target(os: 'linux', cpu: 'x86_64')
Expand Down Expand Up @@ -227,7 +240,8 @@ def default_x86_compile_flags
"-DCMAKE_SYSTEM_NAME=Linux",
"-DCMAKE_SYSTEM_PROCESSOR=x86_64",
"-DCMAKE_C_COMPILER=gcc",
"-DCMAKE_CXX_COMPILER=g++"
"-DCMAKE_CXX_COMPILER=g++",
"-DCMAKE_BUILD_TYPE=Release"
]
end

Expand Down

0 comments on commit 579704b

Please sign in to comment.