mirror of
https://github.com/justinian/jsix.git
synced 2025-12-09 16:04:32 -08:00
[build] Fix handling of cog header deps
The last commit was a bandaid, but this needed a real fix. Now we create a .parse_deps.phony file in every module build dir that implicitly depends on that module's dependencies' .parse_deps.phony files, as well as order-only depends on any cog-parsed output for that module. This causes the cog files to get generated first if they never have been, but still leaves real header dependency tracking to clang's depfile generation.
This commit is contained in:
@@ -113,14 +113,19 @@ class Module:
|
||||
includes.append(f"${{module_dir}}/{p}")
|
||||
|
||||
libs = []
|
||||
child_deps = []
|
||||
order_only = []
|
||||
closed = set()
|
||||
children = set(self.depmods)
|
||||
while children:
|
||||
child = children.pop()
|
||||
closed.add(child)
|
||||
|
||||
includes += [f"${{target_dir}}/{child.name}.dir/{i}" for i in child.includes]
|
||||
includes += [f"{child.root}/{i}" for i in child.includes]
|
||||
|
||||
child_deps.append(f"${{target_dir}}/{child.name}.dir/.parse_dep.phony")
|
||||
|
||||
if child.kind == "lib":
|
||||
libs.append(f"${{target_dir}}/{child.output}")
|
||||
else:
|
||||
@@ -135,7 +140,7 @@ class Module:
|
||||
build.variable("libs", ["${libs}"] + libs)
|
||||
|
||||
inputs = []
|
||||
implicits = []
|
||||
parse_deps = []
|
||||
|
||||
for start in self.sources:
|
||||
source = start
|
||||
@@ -144,30 +149,41 @@ class Module:
|
||||
output = source.output
|
||||
|
||||
if source.action.rule:
|
||||
build.newline()
|
||||
build.build(
|
||||
rule = source.action.rule,
|
||||
outputs = output.input,
|
||||
inputs = source.input,
|
||||
implicit = list(map(resolve, source.deps)),
|
||||
implicit = list(map(resolve, source.deps)) +
|
||||
list(source.action.deps),
|
||||
variables = {"name": source.name},
|
||||
)
|
||||
|
||||
elif source.action.implicit:
|
||||
implicits.append(source.input)
|
||||
parse_deps.append(source.input)
|
||||
|
||||
else:
|
||||
inputs.append(source.input)
|
||||
|
||||
source = output
|
||||
build.newline()
|
||||
|
||||
parse_dep = "${module_dir}/.parse_dep.phony"
|
||||
build.newline()
|
||||
build.build(
|
||||
rule = "touch",
|
||||
outputs = [parse_dep],
|
||||
implicit = child_deps,
|
||||
order_only = parse_deps,
|
||||
)
|
||||
|
||||
output = f"${{target_dir}}/{self.output}"
|
||||
dump = f"${{target_dir}}/{self.output}.dump"
|
||||
build.newline()
|
||||
build.build(
|
||||
rule = self.kind,
|
||||
outputs = output,
|
||||
inputs = inputs,
|
||||
implicit = implicits + libs,
|
||||
implicit = [parse_dep] + libs,
|
||||
order_only = order_only,
|
||||
)
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ class Action:
|
||||
name = property(lambda self: self.__name)
|
||||
implicit = property(lambda self: False)
|
||||
rule = property(lambda self: None)
|
||||
deps = property(lambda self: tuple())
|
||||
|
||||
def __init__(self, name):
|
||||
self.__name = name
|
||||
@@ -12,6 +13,7 @@ class Action:
|
||||
|
||||
class Compile(Action):
|
||||
rule = property(lambda self: f'compile_{self.name}')
|
||||
deps = property(lambda self: ("${module_dir}/.parse_dep.phony",))
|
||||
|
||||
def __init__(self, name, suffix = ".o"):
|
||||
super().__init__(name)
|
||||
@@ -46,6 +48,7 @@ class Source:
|
||||
'.cog': Parse('cog'),
|
||||
'.o': Link('o'),
|
||||
'.h': Header('h'),
|
||||
'.inc': Header('inc'),
|
||||
}
|
||||
|
||||
def __init__(self, root, path, output=None, deps=tuple()):
|
||||
|
||||
Reference in New Issue
Block a user