Added provide and --all-targets

This commit is contained in:
Sleepy Monax 2022-07-06 23:11:10 +02:00
parent a290e8388c
commit 59cec04d0e
5 changed files with 44 additions and 11 deletions

View file

@ -43,13 +43,22 @@ def runCmd(opts: dict, args: list[str]) -> None:
def buildCmd(opts: dict, args: list[str]) -> None:
allTargets = opts.get('all-targets', False)
targetName = opts.get('target', 'default')
if len(args) == 0:
build.buildAll(targetName)
if allTargets:
for target in targets.available():
if len(args) == 0:
build.buildAll(target)
else:
for component in args:
build.buildOne(target, component)
else:
for component in args:
build.buildOne(targetName, component)
if len(args) == 0:
build.buildAll(targetName)
else:
for component in args:
build.buildOne(targetName, component)
def listCmd(opts: dict, args: list[str]) -> None:

View file

@ -107,7 +107,7 @@ def buildAll(targetId: str) -> None:
target, _ = prepare(targetId)
print(f"{utils.Colors.BOLD}Building all components for target '{targetId}{utils.Colors.RESET}'")
try:
utils.runCmd("ninja", "-j", "1", "-f", target["ninjafile"])
utils.runCmd("ninja", "-v", "-j", "1", "-f", target["ninjafile"])
except:
raise utils.CliException(
"Failed to build all for " + target["key"])
@ -121,7 +121,7 @@ def buildOne(targetId: str, componentId: str) -> str:
raise utils.CliException("Unknown component: " + componentId)
try:
utils.runCmd("ninja", "-j", "1", "-f",
utils.runCmd("ninja", "-v", "-j", "1", "-f",
target["ninjafile"], manifests[componentId]["out"])
except:
raise utils.CliException(

View file

@ -55,8 +55,26 @@ def doInjects(manifests: dict) -> dict:
def resolveDeps(manifests: dict) -> dict:
manifests = copy.deepcopy(manifests)
def findProvide(key: str) -> str:
if key in manifests:
return key
result = []
for pkg in manifests:
if key in manifests[pkg].get("provide", []):
result.append(pkg)
if len(result) == 0:
raise utils.CliException(f"Failed to resolve dependency {key}")
if len(result) == 1:
return result[0]
raise utils.CliException(f"Multiple providers for {key}: {result}")
def resolve(key: str, stack: list[str] = []) -> list[str]:
result: list[str] = []
if key in stack:
raise utils.CliException("Circular dependency detected: " +
str(stack) + " -> " + key)
@ -66,10 +84,14 @@ def resolveDeps(manifests: dict) -> dict:
if "deps" in manifests[key]:
stack.append(key)
result.extend(manifests[key]["deps"])
for dep in manifests[key]["deps"]:
dep = findProvide(dep)
result.append(dep)
result += resolve(dep, stack)
stack.pop()
return result
for key in manifests:

View file

@ -173,9 +173,10 @@ def processJson(e: any) -> any:
for i in range(len(e)):
e[i] = processJson(e[i])
elif isinstance(e, str):
if e == "@sysname":
e = os.uname().sysname.lower()
elif e.startswith("@include("):
e = e.replace("@uname(sysname)", os.uname().sysname.lower())
e = e.replace("@uname(machine)", os.uname().machine.lower())
if e.startswith("@include("):
e = loadJson(e[9:-1])
return e

View file

@ -2,7 +2,8 @@ from setuptools import setup
setup(
name="osdk",
version="0.0.1",
version="0.1.0",
python_requires='>=3.10',
description="Operating System Development Kit",
author="The DEVSE Community",
author_email="contact@devse.wiki",