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