From 0f6af69a8762904c106a7de288563943d3d778f8 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Fri, 14 Jul 2023 00:41:22 -0700 Subject: [PATCH] Add Windows and other cross-compilation targets Windows builds were previously failing because mini_portile2 adds an unnecessary option to the `cmake` configure step. This commit adds other targets: - arm-linux - arm64-darwin - x64-mingw-ucrt - x86-linux - x86-mingw32 --- Rakefile | 4 ++++ ext/re2/extconf.rb | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/Rakefile b/Rakefile index daee260..8ed1c6a 100644 --- a/Rakefile +++ b/Rakefile @@ -25,7 +25,11 @@ end CROSS_RUBY_VERSIONS = %w[3.2.0 3.1.0 3.0.0 2.7.0].join(':') CROSS_RUBY_PLATFORMS = %w[ aarch64-linux + arm-linux arm64-darwin + x64-mingw-ucrt + x86-linux + x86-mingw32 x86_64-darwin x86_64-linux ].freeze diff --git a/ext/re2/extconf.rb b/ext/re2/extconf.rb index d05723f..ce33a62 100644 --- a/ext/re2/extconf.rb +++ b/ext/re2/extconf.rb @@ -114,6 +114,21 @@ def cmake_compile_flags(host) ] end +# By default, mini_portile2 might add an unnecessary options: +# https://github.com/flavorjones/mini_portile/blob/5084a2aeab12076f534cf0cabc81a4d5f84b5c25/lib/mini_portile2/mini_portile_cmake.rb#L17 +def delete_cmake_generator_option!(options) + indices = [] + + options.each_with_index do |element, index| + if element == '-G' && index + 1 < options.length + indices << index + indices << index + 1 + end + end + + indices.reverse_each { |index| options.delete_at(index) } +end + # # main # @@ -240,6 +255,7 @@ def process_recipe(name, version) '-DCMAKE_INSTALL_LIBDIR=lib' ] recipe.configure_options += cmake_compile_flags(recipe.host) + delete_cmake_generator_option!(recipe.configure_options) yield recipe