diff --git a/ext/re2/extconf.rb b/ext/re2/extconf.rb index 4e8c7e9..2438fa9 100644 --- a/ext/re2/extconf.rb +++ b/ext/re2/extconf.rb @@ -158,6 +158,20 @@ def delete_cmake_generator_option!(options) indices.reverse_each { |index| options.delete_at(index) } end +def with_temp_dir + cwd = Dir.pwd + + Dir.mktmpdir do |temp_dir| + Dir.chdir(temp_dir) + + yield + + Dir.chdir(cwd) + end +ensure + Dir.chdir(cwd) +end + # # main # @@ -307,7 +321,9 @@ def process_recipe(name, version) end end - recipe.cook + # Use a temporary base directory to reduce filename lengths since + # Windows can hit a limit of 250 characters (CMAKE_OBJECT_PATH_MAX). + with_temp_dir { recipe.cook } FileUtils.touch(checkpoint) end