Add list sub command.

This commit is contained in:
Sleepy Monax 2022-06-26 11:36:26 +02:00
parent 01840c7312
commit 45a5ca6592

View file

@ -1,12 +1,12 @@
import importlib
import shutil
import sys
import random
from types import ModuleType
import osdk.build as build
import osdk.utils as utils
import osdk.targets as targets
import osdk.manifests as manifests
CMDS = {}
@ -52,6 +52,19 @@ def buildCmd(opts: dict, args: list[str]) -> None:
build.buildOne(targetName, component)
def listCmd(opts: dict, args: list[str]) -> None:
targetName = opts.get('target', 'host-clang')
target = targets.load(targetName)
components = manifests.loadAll("src", target)
print(f"Available components for target '{targetName}':")
componentsNames = list(components.keys())
componentsNames.sort()
for component in componentsNames:
print(" " + component)
print("")
def cleanCmd(opts: dict, args: list[str]) -> None:
shutil.rmtree(".build", ignore_errors=True)
@ -61,12 +74,6 @@ def nukeCmd(opts: dict, args: list[str]) -> None:
shutil.rmtree(".cache", ignore_errors=True)
def idCmd(opts: dict, args: list[str]) -> None:
i = hex(random.randint(0, 2**64))
print("64bit: " + i)
print("32bit: " + i[:10])
def helpCmd(opts: dict, args: list[str]) -> None:
print(f"Usage: osdk <command> [options...] [<args...>]")
print("")
@ -104,6 +111,10 @@ CMDS = {
"func": buildCmd,
"desc": "Build one or more components",
},
"list": {
"func": listCmd,
"desc": "List available components",
},
"clean": {
"func": cleanCmd,
"desc": "Clean the build directory",