1 from lib.utils import join_path
4 class BuildEnvironment:
5 def __init__(self, workspace_dir) -> None:
6 self.__config_provider = None
10 self.__ws_dir = workspace_dir
12 def set_config_provider(self, provider):
13 self.__config_provider = provider
15 def config_provider(self):
16 return self.__config_provider
18 def add_sources(self, sources):
19 self.__sources += sources
21 def add_headers(self, sources):
23 if not os.path.isdir(h):
24 self.__headers.append(h)
26 self.__inc_dir.append(h)
28 def to_wspath(self, file):
29 path = join_path(self.__ws_dir, file)
30 return os.path.relpath(path, self.__ws_dir)
32 def export(self, out_dir):
33 path = os.path.join(out_dir, "sources.list")
34 with open(path, "w") as f:
35 f.write("\n".join(self.__sources))
37 path = os.path.join(out_dir, "headers.list")
38 with open(path, "w") as f:
39 f.write("\n".join(self.__headers))
41 path = os.path.join(out_dir, "includes.list")
42 with open(path, "w") as f:
43 f.write("\n".join(self.__inc_dir))