Skip to content

Commit

Permalink
Add Windows and other cross-compilation targets
Browse files Browse the repository at this point in the history
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
  • Loading branch information
stanhu committed Jul 14, 2023
1 parent f0e2f35 commit 0f6af69
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions ext/re2/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 0f6af69

Please sign in to comment.