X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/1025235c72c31f7fa7b648c0e32ddcaa68a8f66a..29891c3ccec4f1d28e0440d87ea2e2708377d2ee:/lunaix-os/scripts/build-tools/lbuild/common.py?ds=sidebyside diff --git a/lunaix-os/scripts/build-tools/lbuild/common.py b/lunaix-os/scripts/build-tools/lbuild/common.py index c559b0a..a973760 100644 --- a/lunaix-os/scripts/build-tools/lbuild/common.py +++ b/lunaix-os/scripts/build-tools/lbuild/common.py @@ -2,12 +2,15 @@ from lib.utils import join_path import os class BuildEnvironment: - def __init__(self, workspace_dir) -> None: + def __init__(self, workspace_dir, generator) -> None: self.__config_provider = None self.__sources = [] self.__headers = [] self.__inc_dir = [] self.__ws_dir = workspace_dir + self.__ext_object = {} + self.__ext_function = {} + self.__generator = generator def set_config_provider(self, provider): self.__config_provider = provider @@ -29,15 +32,28 @@ class BuildEnvironment: path = join_path(self.__ws_dir, file) return os.path.relpath(path, self.__ws_dir) - def export(self, out_dir): - path = os.path.join(out_dir, "sources.list") - with open(path, "w") as f: - f.write("\n".join(self.__sources)) - - path = os.path.join(out_dir, "headers.list") - with open(path, "w") as f: - f.write("\n".join(self.__headers)) - - path = os.path.join(out_dir, "includes.list") - with open(path, "w") as f: - f.write("\n".join(self.__inc_dir)) \ No newline at end of file + def export(self): + self.__generator.generate(self) + + def get_object(self, key, _default=None): + return _default if key not in self.__ext_object else self.__ext_object[key] + + def set_object(self, key, object): + self.__ext_object[key] = object + + def srcs(self): + return list(self.__sources) + + def headers(self): + return list(self.__headers) + + def includes(self): + return list(self.__inc_dir) + + def add_external_func(self, function): + name = function.__name__ + invk = lambda *args, **kwargs: function(self, *args, **kwargs) + self.__ext_function[name] = invk + + def external_func_table(self): + return self.__ext_function \ No newline at end of file