Added simple osdk.json config.
This commit is contained in:
parent
18aa5a8ca8
commit
5492d67962
|
@ -95,7 +95,7 @@ def listCmd(opts: dict, args: list[str]) -> None:
|
|||
props = propsFromOptions(opts)
|
||||
targetName = opts.get('target', 'default')
|
||||
target = targets.load(targetName, props)
|
||||
components = manifests.loadAll("src", target)
|
||||
components = manifests.loadAll(["src"], target)
|
||||
|
||||
print(f"Available components for target '{targetName}':")
|
||||
componentsNames = list(components.keys())
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from typing import TextIO, Tuple
|
||||
import json
|
||||
import copy
|
||||
import os
|
||||
|
||||
from . import ninja
|
||||
from . import manifests as m
|
||||
|
@ -101,7 +102,17 @@ def genNinja(out: TextIO, manifests: dict, target: dict) -> None:
|
|||
|
||||
def prepare(targetId: str, props: dict) -> Tuple[dict, dict]:
|
||||
target = targets.load(targetId, props)
|
||||
manifests = m.loadAll("src", target)
|
||||
|
||||
includes = ["src"]
|
||||
|
||||
if os.path.exists("osdk.json"):
|
||||
with open("osdk.json", "r") as f:
|
||||
osdk = json.load(f)
|
||||
includes = osdk["includes"]
|
||||
print("includes: ", includes)
|
||||
|
||||
manifests = m.loadAll(includes, target)
|
||||
|
||||
utils.mkdirP(target["dir"])
|
||||
genNinja(open(target["ninjafile"], "w"), manifests, target)
|
||||
|
||||
|
|
|
@ -4,14 +4,15 @@ from pathlib import Path
|
|||
from . import utils
|
||||
|
||||
|
||||
def loadJsons(basedir: str) -> dict:
|
||||
def loadJsons(basedirs: list[str]) -> dict:
|
||||
result = {}
|
||||
for root, dirs, files in os.walk(basedir):
|
||||
for filename in files:
|
||||
if filename == 'manifest.json':
|
||||
filename = os.path.join(root, filename)
|
||||
manifest = utils.loadJson(filename)
|
||||
result[manifest["id"]] = manifest
|
||||
for basedir in basedirs:
|
||||
for root, dirs, files in os.walk(basedir):
|
||||
for filename in files:
|
||||
if filename == 'manifest.json':
|
||||
filename = os.path.join(root, filename)
|
||||
manifest = utils.loadJson(filename)
|
||||
result[manifest["id"]] = manifest
|
||||
|
||||
return result
|
||||
|
||||
|
@ -48,8 +49,10 @@ def doInjects(manifests: dict) -> dict:
|
|||
|
||||
|
||||
def providersFor(key: str, manifests: dict) -> dict:
|
||||
print("providersFor: " + key)
|
||||
result = []
|
||||
for k in manifests:
|
||||
print(" " + k)
|
||||
if manifests[k]["enabled"] and key in manifests[k].get("provide", []):
|
||||
result.append(k)
|
||||
return result
|
||||
|
@ -65,6 +68,7 @@ def resolveDeps(manifests: dict) -> dict:
|
|||
providers = providersFor(key, manifests)
|
||||
|
||||
if len(providers) == 0:
|
||||
print("No providers for " + key)
|
||||
return False, "", []
|
||||
|
||||
if len(providers) > 1:
|
||||
|
@ -176,15 +180,10 @@ def cincludes(manifests: dict) -> str:
|
|||
return " -I" + " -I".join(include_paths)
|
||||
|
||||
|
||||
cache: dict = {}
|
||||
|
||||
|
||||
def loadAll(basedir: str, target: dict) -> dict:
|
||||
cacheKey = basedir + ":" + target["id"]
|
||||
if cacheKey in cache:
|
||||
return cache[cacheKey]
|
||||
|
||||
manifests = loadJsons(basedir)
|
||||
def loadAll(basedirs: list[str], target: dict) -> dict:
|
||||
manifests = loadJsons(basedirs)
|
||||
manifests = filter(manifests, target)
|
||||
manifests = doInjects(manifests)
|
||||
manifests = resolveDeps(manifests)
|
||||
|
@ -192,5 +191,4 @@ def loadAll(basedir: str, target: dict) -> dict:
|
|||
manifests = prepareTests(manifests)
|
||||
manifests = prepareInOut(manifests, target)
|
||||
|
||||
cache[cacheKey] = manifests
|
||||
return manifests
|
||||
|
|
Loading…
Reference in a new issue