mirror of
https://github.com/justinian/jsix.git
synced 2025-12-09 16:04: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:
|
class Module:
|
||||||
__fields = {
|
__fields = {
|
||||||
@@ -122,6 +127,7 @@ class Module:
|
|||||||
|
|
||||||
if includes:
|
if includes:
|
||||||
build.variable("ccflags", ["${ccflags}"] + [f"-I{i}" for i in 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:
|
if libs:
|
||||||
build.variable("libs", ["${libs}"] + libs)
|
build.variable("libs", ["${libs}"] + libs)
|
||||||
@@ -133,14 +139,14 @@ class Module:
|
|||||||
source = start
|
source = start
|
||||||
|
|
||||||
while source and source.action:
|
while source and source.action:
|
||||||
output = source.get_output('${module_dir}')
|
output = source.output
|
||||||
|
|
||||||
if source.action.rule:
|
if source.action.rule:
|
||||||
build.build(
|
build.build(
|
||||||
rule = source.action.rule,
|
rule = source.action.rule,
|
||||||
outputs = output.input,
|
outputs = output.input,
|
||||||
inputs = source.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},
|
variables = {"name": source.name},
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -178,4 +184,6 @@ class Module:
|
|||||||
|
|
||||||
def add_input(self, path, **kwargs):
|
def add_input(self, path, **kwargs):
|
||||||
from .source import Source
|
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
|
self.__deps = deps
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{} {}:{}:{}".format(self.action, self.output, self.name, self.input)
|
return self.input
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def action(self):
|
def action(self):
|
||||||
suffix = self.__path.suffix
|
suffix = self.__path.suffix
|
||||||
return self.Actions.get(suffix)
|
return self.Actions.get(suffix)
|
||||||
|
|
||||||
def get_output(self, output_root):
|
@property
|
||||||
|
def output(self):
|
||||||
if not self.action:
|
if not self.action:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -71,7 +72,7 @@ class Source:
|
|||||||
if path is None:
|
if path is None:
|
||||||
path = self.action.output_of(self.__path)
|
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)
|
deps = property(lambda self: self.__deps)
|
||||||
name = property(lambda self: str(self.__path))
|
name = property(lambda self: str(self.__path))
|
||||||
|
|||||||
Reference in New Issue
Block a user