From 10a30420db770d510b133fa0bb32818e3f3ac419 Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Mon, 6 Jan 2025 19:47:07 +0100 Subject: [PATCH] Revert unwinding directories to file tasks Adding file tasks within a rake tasks doesn't work. Dependencies must be defined prior to running the rake resolver. It also had the downside of priting too many log messages. Implementing own cp_r which invokes tasks definitions is the better solution. --- .../installer-inno/50-generate-filelist.rake | 8 +++++-- recipes/sandbox/50-gather-sandbox-files.rake | 11 ---------- recipes/sandbox/60-side-by-side-assembly.rake | 5 +++++ recipes/sandbox/80-copy-msys-files.rake | 22 ++++++++++++++++--- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/recipes/installer-inno/50-generate-filelist.rake b/recipes/installer-inno/50-generate-filelist.rake index 244d5bf4b..68c980147 100644 --- a/recipes/installer-inno/50-generate-filelist.rake +++ b/recipes/installer-inno/50-generate-filelist.rake @@ -13,12 +13,16 @@ file filelist_iss => [__FILE__, ovl_expand_file(sandbox_task.sandboxfile_listfil else components = "ruby" end - unless File.directory?(path) + args = if File.directory?(path) + flags = "recursesubdirs createallsubdirs #{flags}" + source = "../../#{path}/*" + dest = "{app}/#{reltosandbox_path}" + else source = "../../#{path}" dest = "{app}/#{File.dirname(reltosandbox_path)}" - "Source: #{source}; DestDir: #{dest}; Flags: #{flags}; Components: #{components}" end + "Source: #{source}; DestDir: #{dest}; Flags: #{flags}; Components: #{components}" end.join("\n") File.write(filelist_iss, out) end diff --git a/recipes/sandbox/50-gather-sandbox-files.rake b/recipes/sandbox/50-gather-sandbox-files.rake index 6e49201f5..3eb024ba1 100644 --- a/recipes/sandbox/50-gather-sandbox-files.rake +++ b/recipes/sandbox/50-gather-sandbox-files.rake @@ -4,14 +4,3 @@ sandboxfiles_rel = File.readlines(ovl_expand_file(sandboxfile_listfile)) + File. sandboxfiles_rel = sandboxfiles_rel.map{|path| path.chomp } sandboxfiles_rel += import_files.values self.sandboxfiles += sandboxfiles_rel.map{|path| File.join(sandboxdir, path)} -# go through directories and gather all files recursively -self.sandboxfiles = sandboxfiles.flat_map do |path| - unpack_path = path.sub(sandboxdir, unpackdirmgw) - if File.directory?(unpack_path) - Dir.glob(File.join(unpack_path, "**/*")).map do |pa| - pa.sub(unpackdirmgw, sandboxdir) - end - else - path - end -end diff --git a/recipes/sandbox/60-side-by-side-assembly.rake b/recipes/sandbox/60-side-by-side-assembly.rake index 95fa56a80..e8b744206 100644 --- a/recipes/sandbox/60-side-by-side-assembly.rake +++ b/recipes/sandbox/60-side-by-side-assembly.rake @@ -25,6 +25,11 @@ core_dll_defs = [ /^libgcc_s_.*.dll$/, ] +# create rake tasks to trigger additional processing of so files +ext_dll_defs.keys.each do |so_file| + self.sandboxfiles << File.join(sandboxdir, so_file) +end + core_dlls, dlls = dlls.partition do |destpath| core_dll_defs.any? { |re| re =~ File.basename(destpath) } end diff --git a/recipes/sandbox/80-copy-msys-files.rake b/recipes/sandbox/80-copy-msys-files.rake index 73597a3be..975107211 100644 --- a/recipes/sandbox/80-copy-msys-files.rake +++ b/recipes/sandbox/80-copy-msys-files.rake @@ -2,10 +2,26 @@ self.sandboxfiles.each do |destpath| directory File.dirname(destpath) unless Rake::Task.task_defined?(destpath) file destpath => [destpath.sub(sandboxdir, unpackdirmgw), File.dirname(destpath)] do |t| - if File.file?(t.prerequisites.first) + # Copy file like cp_r, but excluding files with task definition + # cp_r(t.prerequisites.first, t.name) + + if FileTest.directory?(t.prerequisites.first) + Dir.glob("**/*", base: t.prerequisites.first, flags: File::FNM_DOTMATCH) do |rel| + dst = File.join(t.name, rel) + if Rake::Task.task_defined?(dst) + # invoke task definition and skip cp + Rake::Task[dst].invoke + next + end + src = File.join(t.prerequisites.first, rel) + if FileTest.directory?(src) + mkdir(dst, verbose: false) unless FileTest.directory?(dst) + else + cp(src, dst, verbose: false) + end + end + else cp(t.prerequisites.first, t.name) - elsif File.directory?(t.prerequisites.first) && !File.exist?(t.name) - mkdir t.name end end end