mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
[build] Return output from add_input call
Allow for dependency chaining in *.module files by returning the expected output from a module.add_input() call.
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
def resolve(path):
|
||||
if path.startswith('/') or path.startswith('$'):
|
||||
return path
|
||||
from pathlib import Path
|
||||
return str(Path(path).resolve())
|
||||
|
||||
class Module:
|
||||
__fields = {
|
||||
@@ -122,6 +127,7 @@ class Module:
|
||||
|
||||
if includes:
|
||||
build.variable("ccflags", ["${ccflags}"] + [f"-I{i}" for i in includes])
|
||||
build.variable("asflags", ["${asflags}"] + [f"-I{i}" for i in includes])
|
||||
|
||||
if libs:
|
||||
build.variable("libs", ["${libs}"] + libs)
|
||||
@@ -133,14 +139,14 @@ class Module:
|
||||
source = start
|
||||
|
||||
while source and source.action:
|
||||
output = source.get_output('${module_dir}')
|
||||
output = source.output
|
||||
|
||||
if source.action.rule:
|
||||
build.build(
|
||||
rule = source.action.rule,
|
||||
outputs = output.input,
|
||||
inputs = source.input,
|
||||
implicit = [f'${{source_root}}/{p}' for p in source.deps or tuple()],
|
||||
implicit = list(map(resolve, source.deps)),
|
||||
variables = {"name": source.name},
|
||||
)
|
||||
|
||||
@@ -178,4 +184,6 @@ class Module:
|
||||
|
||||
def add_input(self, path, **kwargs):
|
||||
from .source import Source
|
||||
self.sources.append(Source(self.root, path, **kwargs))
|
||||
s = Source(self.root, path, **kwargs)
|
||||
self.sources.append(s)
|
||||
return str(s.output)
|
||||
|
||||
@@ -56,14 +56,15 @@ class Source:
|
||||
self.__deps = deps
|
||||
|
||||
def __str__(self):
|
||||
return "{} {}:{}:{}".format(self.action, self.output, self.name, self.input)
|
||||
return self.input
|
||||
|
||||
@property
|
||||
def action(self):
|
||||
suffix = self.__path.suffix
|
||||
return self.Actions.get(suffix)
|
||||
|
||||
def get_output(self, output_root):
|
||||
@property
|
||||
def output(self):
|
||||
if not self.action:
|
||||
return None
|
||||
|
||||
@@ -71,7 +72,7 @@ class Source:
|
||||
if path is None:
|
||||
path = self.action.output_of(self.__path)
|
||||
|
||||
return path and Source(output_root, path)
|
||||
return path and Source("${module_dir}", path)
|
||||
|
||||
deps = property(lambda self: self.__deps)
|
||||
name = property(lambda self: str(self.__path))
|
||||
|
||||
Reference in New Issue
Block a user