mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-10-22 07:21:21 +00:00
build system: convert bin2h call from Ruby executable to built-in function
This commit is contained in:
parent
a77be987e3
commit
3d015db49b
3
Rakefile
3
Rakefile
@ -200,7 +200,8 @@ rule '.o' => '.rc' do |t|
|
||||
end
|
||||
|
||||
rule '.h' => '.png' do |t|
|
||||
runq " BIN2H #{t.source}", "#{c(:top_srcdir)}/rake.d/bin/bin2h.rb #{t.source} #{t.name}"
|
||||
puts " BIN2H #{t.source}" if !ENV['V'].to_bool
|
||||
bin2h t.source, t.name
|
||||
end
|
||||
|
||||
# Resources depend on the manifest.xml file for Windows builds.
|
||||
|
@ -1,31 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
if ARGV.size != 2
|
||||
puts "Syntax: bin2h.rb source.ext destination.h"
|
||||
exit 1
|
||||
end
|
||||
|
||||
bin_name = File.basename(ARGV[0]).gsub(/[^a-z\d]/i, '_').gsub(/_+/, '_') + '_bin'
|
||||
|
||||
File.open(ARGV[1], "w") do |file|
|
||||
file.puts <<EOT
|
||||
// Automatically generated. Do not modify.
|
||||
#ifndef BIN2H__#{bin_name.upcase}_INCLUDED
|
||||
#define BIN2H__#{bin_name.upcase}_INCLUDED
|
||||
|
||||
static unsigned char #{bin_name}[] = {
|
||||
EOT
|
||||
|
||||
data = IO.binread(ARGV[0]).unpack("C*")
|
||||
data.each_with_index do |byte, idx|
|
||||
file.write sprintf("0x%02x", byte)
|
||||
file.write(((idx + 1) % 13) != 0 ? ", " : ",\n") unless (idx == data.size - 1)
|
||||
end
|
||||
|
||||
file.puts <<EOT
|
||||
|
||||
};
|
||||
|
||||
#endif // BIN2H__#{bin_name.upcase}_INCLUDED
|
||||
EOT
|
||||
end
|
@ -70,6 +70,33 @@ def runq(msg, cmdline, options = {})
|
||||
run cmdline, options.clone.merge(:dont_echo => !verbose)
|
||||
end
|
||||
|
||||
def bin2h bin_file_name, h_file_name
|
||||
bin_name = File.basename(bin_file_name).gsub(/[^a-z\d]/i, '_').gsub(/_+/, '_') + '_bin'
|
||||
|
||||
File.open(h_file_name, "w") do |file|
|
||||
file.puts <<EOT
|
||||
// Automatically generated. Do not modify.
|
||||
#ifndef BIN2H__#{bin_name.upcase}_INCLUDED
|
||||
#define BIN2H__#{bin_name.upcase}_INCLUDED
|
||||
|
||||
static unsigned char #{bin_name}[] = {
|
||||
EOT
|
||||
|
||||
data = IO.binread(bin_file_name).unpack("C*")
|
||||
data.each_with_index do |byte, idx|
|
||||
file.write sprintf("0x%02x", byte)
|
||||
file.write(((idx + 1) % 13) != 0 ? ", " : ",\n") unless (idx == data.size - 1)
|
||||
end
|
||||
|
||||
file.puts <<EOT
|
||||
|
||||
};
|
||||
|
||||
#endif // BIN2H__#{bin_name.upcase}_INCLUDED
|
||||
EOT
|
||||
end
|
||||
end
|
||||
|
||||
def create_dependency_dirs
|
||||
[ $dependency_dir, $dependency_tmp_dir ].each do |dir|
|
||||
File.unlink(dir) if FileTest.exist?(dir) && !FileTest.directory?(dir)
|
||||
|
Loading…
Reference in New Issue
Block a user