Skip to content

Commit

Permalink
Refactor handling of encoding support files
Browse files Browse the repository at this point in the history
- Moved the collection and builder duplication instructions for encoding support files into a delegation block.
- Instead of adding collected encoding support files to features, directly called the builder's duplicate_to_exec_prefix method since the destination (exec_prefix directory) is evident.
- Streamlined the implementation of the collection logic for encoding support files.
  • Loading branch information
shinokaro committed Jun 24, 2024
1 parent 6edeb4a commit 877410a
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions bin/ocran
Original file line number Diff line number Diff line change
Expand Up @@ -533,22 +533,6 @@ EOF
gem_files, gemspecs = [], []
end

# Include encoding support files
if Ocran.enc
all_load_paths.each do |path|
if path.subpath?(exec_prefix)
encpath = path / "enc"
if encpath.exist?
encfiles = encpath.find.select { |pn| pn.file? && pn.extname?(".so") }
Ocran.msg "Including #{encfiles.size} encoding support files (#{encfiles.sum(0, &:size)} bytes, use --no-enc to exclude)"
features.push(*encfiles)
end
end
end
else
Ocran.msg "Not including encoding support files"
end

direction = proc do |builder|
Ocran.msg "Building #{Ocran.output_executable}"
require_relative "../lib/ocran/builder_ops_logger"
Expand Down Expand Up @@ -636,6 +620,23 @@ EOF
end
end

# Include encoding support files
if Ocran.enc
exec_prefix_load_path = all_load_paths.select { |path| path.subpath?(exec_prefix) }
exec_prefix_load_path.each do |load_path|
enc_dir = load_path / "enc"
next unless enc_dir.directory?

enc_files = enc_dir.find.select { |path| path.file? && path.extname?(".so") }
Ocran.msg "Including #{enc_files.size} encoding support files (#{enc_files.sum(0, &:size)} bytes, use --no-enc to exclude)"
enc_files.each do |path|
builder.duplicate_to_exec_prefix(path)
end
end
else
Ocran.msg "Not including encoding support files"
end

# Workaround: RubyInstaller cannot find the msys folder if ../msys64/usr/bin/msys-2.0.dll is not present (since RubyInstaller-2.4.1 rubyinstaller 2 issue 23)
# Add an empty file to /msys64/usr/bin/msys-2.0.dll if the dll was not required otherwise
builder.touch('msys64/usr/bin/msys-2.0.dll')
Expand Down

0 comments on commit 877410a

Please sign in to comment.