Skip to content
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

Create release binary with cmake explicitly #136

Merged
merged 2 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading