From 8a3857e61bee44e9cc1a22ae9ca2a6209fa72f77 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Mon, 17 Jul 2023 09:58:48 -0700 Subject: [PATCH] Use a temporary directory for cooking recipe This is an attempt to to reduce filename lengths since Windows can hit a limit of 250 characters (CMAKE_OBJECT_PATH_MAX). --- ext/re2/extconf.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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