allow multiple preloads

This commit is contained in:
kp2pml30 2024-10-01 13:34:56 +04:00
parent 502e5af815
commit f86aff0986

View file

@ -252,7 +252,7 @@ class Configurator
ret ret
end end
def initialize(src, build, preload) def initialize(src, build, preloads)
@rules = [] @rules = []
@root_src = Pathname.new(src).realpath @root_src = Pathname.new(src).realpath
@root_build = Pathname.new(build) @root_build = Pathname.new(build)
@ -283,12 +283,12 @@ class Configurator
@config = self.instance_eval(cnf.read, cnf.to_s) @config = self.instance_eval(cnf.read, cnf.to_s)
end end
if not preload.nil? preloads.each { |preload|
preload = Pathname.new(preload).realpath preload = Pathname.new(preload).realpath
@config_target.add_deps(preload) @config_target.add_deps(preload)
contents = preload.read contents = preload.read
self.instance_eval(contents, preload.to_s) self.instance_eval(contents, preload.to_s)
end }
end end
private def extend_config_impl(l, r) private def extend_config_impl(l, r)
@ -545,18 +545,22 @@ def config()
:src => '.', :src => '.',
:build => 'build', :build => 'build',
:config => nil, :config => nil,
:preloads => [],
} }
OptionParser.new do |opts| OptionParser.new do |opts|
opts.on '-b=DIR', '--build=DIR', 'Output directory' opts.on '-b=DIR', '--build=DIR', 'Output directory'
opts.on '-s=DIR', '--src=DIR', 'Project root directory' opts.on '-s=DIR', '--src=DIR', 'Project root directory'
opts.on '--preload=FILE', 'Toolchain file' opts.on '--preload=FILE', 'Toolchain file' do |f|
options[:preloads] << f
nil
end
opts.on '--help' do opts.on '--help' do
puts opts puts opts
exit false exit false
end end
end.parse!(into: options) end.parse!(into: options)
configurator = Configurator.new(options[:src], options[:build], options[:preload]) configurator = Configurator.new(options[:src], options[:build], options[:preloads])
configurator.run configurator.run
end end