Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ninja file generated by Kati depends on irrelevant variables #238

Closed
asmundak opened this issue Oct 14, 2021 · 0 comments
Closed

Ninja file generated by Kati depends on irrelevant variables #238

asmundak opened this issue Oct 14, 2021 · 0 comments

Comments

@asmundak
Copy link
Contributor

Kati converts the following makefile (when invoked with with --gen_all_targets option):

first: foo
foo:
	@echo foo

second: bar
bar:
	@echo bar

into

build first: phony foo
rule rule0
 description = build $out
 command = /bin/sh -c "echo foo"
build foo: rule0
build second: phony bar
rule rule1
 description = build $out
 command = /bin/sh -c "echo bar"
build bar: rule1

default first

However, adding a variable assignment second:= in front:

second := 
first: foo
foo:
	@echo foo

second: bar
bar:
	@echo bar

results in the output with the build statement for the top-level target second before the build statement for the first:

build second: phony bar
rule rule0
 description = build $out
 command = /bin/sh -c "echo bar"
build bar: rule0
build first: phony foo
rule rule1
 description = build $out
 command = /bin/sh -c "echo foo"
build foo: rule1

default first

The reason is that Kati generates build statements by iterating over the list of the top-level targets in the order their identifiers were added to the symbol table. As the symbol table contains the variable names, too, second makes it into the symbol table before first for the latter makefile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant