mirror of
https://github.com/kp2pml30/ya-build.git
synced 2026-02-17 00:14:42 +04:00
support multiple outputs
This commit is contained in:
parent
4f740ebe4e
commit
d14a86efee
1 changed files with 9 additions and 22 deletions
31
ya-build
31
ya-build
|
|
@ -72,7 +72,7 @@ def escape_args_to(buf, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
class Target
|
class Target
|
||||||
attr_reader :trg_name, :meta
|
attr_reader :trg_name, :meta, :outputs
|
||||||
|
|
||||||
def initialize(trg_name, dependencies)
|
def initialize(trg_name, dependencies)
|
||||||
@meta = OpenStruct.new
|
@meta = OpenStruct.new
|
||||||
|
|
@ -83,6 +83,7 @@ class Target
|
||||||
if @trg_name.kind_of?(Pathname)
|
if @trg_name.kind_of?(Pathname)
|
||||||
@trg_name = @trg_name.to_s
|
@trg_name = @trg_name.to_s
|
||||||
end
|
end
|
||||||
|
@outputs = [trg_name]
|
||||||
raise "target name is not a string (got `#{@trg_name}`)" if not @trg_name.kind_of?(String)
|
raise "target name is not a string (got `#{@trg_name}`)" if not @trg_name.kind_of?(String)
|
||||||
@dependencies = dependencies
|
@dependencies = dependencies
|
||||||
end
|
end
|
||||||
|
|
@ -96,7 +97,9 @@ class Target
|
||||||
end
|
end
|
||||||
|
|
||||||
def dump_rules(buf)
|
def dump_rules(buf)
|
||||||
buf << "build #{trg_name}: #{mode}"
|
buf << "build "
|
||||||
|
escape_args_to(buf, outputs)
|
||||||
|
buf << ": #{mode}"
|
||||||
@dependencies.each { |d|
|
@dependencies.each { |d|
|
||||||
buf << ' '
|
buf << ' '
|
||||||
if d.kind_of?(Target)
|
if d.kind_of?(Target)
|
||||||
|
|
@ -160,23 +163,8 @@ class ConfigureGeneratedTarget < Target
|
||||||
@configurator = configurator
|
@configurator = configurator
|
||||||
super(output_file, [])
|
super(output_file, [])
|
||||||
end
|
end
|
||||||
def dump_rules(buf)
|
def dump_rules_impl(buf)
|
||||||
buf << "build #{trg_name}: #{mode}"
|
|
||||||
@configurator.instance_eval { @ya_files }.each { |d|
|
|
||||||
buf << ' '
|
|
||||||
if d.kind_of?(Target)
|
|
||||||
buf << d.trg_name
|
|
||||||
elsif d.kind_of?(Pathname)
|
|
||||||
buf << d.to_s
|
|
||||||
elsif d.kind_of?(String)
|
|
||||||
buf << d
|
|
||||||
else
|
|
||||||
raise "Invalid dependency #{d} : #{d.class}"
|
|
||||||
end
|
|
||||||
}
|
|
||||||
buf << "\n"
|
|
||||||
buf << " pool = console\n"
|
buf << " pool = console\n"
|
||||||
buf << "\n"
|
|
||||||
end
|
end
|
||||||
def mode
|
def mode
|
||||||
"RERUN_YA_BUILD"
|
"RERUN_YA_BUILD"
|
||||||
|
|
@ -261,8 +249,8 @@ class Configurator
|
||||||
|
|
||||||
@all = AliasTarget.new('all', [])
|
@all = AliasTarget.new('all', [])
|
||||||
|
|
||||||
@targets = [@all]
|
@config_target = ConfigureGeneratedTarget.new(self, 'build.ninja')
|
||||||
mark_as_config_generated('build.ninja')
|
@targets = [@all, @config_target]
|
||||||
|
|
||||||
@stack = []
|
@stack = []
|
||||||
|
|
||||||
|
|
@ -517,8 +505,7 @@ EOF
|
||||||
end
|
end
|
||||||
|
|
||||||
def mark_as_config_generated(file)
|
def mark_as_config_generated(file)
|
||||||
register_target(ConfigureGeneratedTarget.new(self, file))
|
@config_target.outputs.push file
|
||||||
return
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue