Skip to content

Commit

Permalink
Revert unwinding directories to file tasks
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
larskanis committed Jan 9, 2025
1 parent 7cc3cf2 commit 10a3042
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 16 deletions.
8 changes: 6 additions & 2 deletions recipes/installer-inno/50-generate-filelist.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 0 additions & 11 deletions recipes/sandbox/50-gather-sandbox-files.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions recipes/sandbox/60-side-by-side-assembly.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 19 additions & 3 deletions recipes/sandbox/80-copy-msys-files.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 10a3042

Please sign in to comment.