Add new includes config for tree structure include
There are cases when we have header files in a folder structure, so we should not flatten the included paths. So this commit adds get_includes_paths_tree, that should be self explaining, and renames get_includes_paths to get_includes_paths_flat. Change-Id: I2cff35687adb2a6caee1f4d3c631e62b8c5b53e4
This commit is contained in:
parent
a7b1979768
commit
e4085f78e7
pybuild
@ -524,8 +524,10 @@ def copy_files_to_include(build_cfg):
|
||||
LOG.info("******************************************************")
|
||||
LOG.info("Start copying extra included source files")
|
||||
start_time = time.time()
|
||||
include_paths = build_cfg.get_includes_paths()
|
||||
src_dst_dir = build_cfg.get_src_code_dst_dir()
|
||||
|
||||
# Copy some files flat to the destination directory
|
||||
include_paths = build_cfg.get_includes_paths_flat()
|
||||
files = []
|
||||
for include_path in include_paths:
|
||||
if os.path.isdir(include_path):
|
||||
@ -543,6 +545,16 @@ def copy_files_to_include(build_cfg):
|
||||
for file_ in files:
|
||||
shutil.copy2(file_, src_dst_dir)
|
||||
LOG.debug("copied %s to %s", file_, src_dst_dir)
|
||||
|
||||
# Copy some directories as is to the destination directory
|
||||
include_tree_paths = [Path(p) for p in build_cfg.get_includes_paths_tree()]
|
||||
existing_tree_paths = [p for p in include_tree_paths if p.exists()]
|
||||
missing_tree_paths = [p for p in include_tree_paths if not p.exists()]
|
||||
if missing_tree_paths:
|
||||
LOG.warning(f"Missing include paths: {missing_tree_paths}")
|
||||
for path in existing_tree_paths:
|
||||
shutil.copytree(path, src_dst_dir, dirs_exist_ok=True)
|
||||
LOG.debug(f"copied {path} to {src_dst_dir}")
|
||||
LOG.info(
|
||||
"Finished copying extra included files (in %4.2f s)", time.time() - start_time
|
||||
)
|
||||
|
@ -305,11 +305,16 @@ class BuildProjConfig:
|
||||
units = units.union(set(runits))
|
||||
self._all_units = list(units)
|
||||
|
||||
def get_includes_paths(self):
|
||||
"""Return list of paths to files to include in source directory."""
|
||||
def get_includes_paths_flat(self):
|
||||
"""Return list of paths to files to be included flat in source directory."""
|
||||
includes_paths = self._prj_cfg.get('includesPaths', [])
|
||||
return [os.path.join(self.get_root_dir(), os.path.normpath(path)) for path in includes_paths]
|
||||
|
||||
def get_includes_paths_tree(self):
|
||||
"""Return list of paths to files to included with directories in source directory."""
|
||||
includes_paths_tree = self._prj_cfg.get('includesPathsTree', [])
|
||||
return [os.path.join(self.get_root_dir(), os.path.normpath(path)) for path in includes_paths_tree]
|
||||
|
||||
def get_all_units(self):
|
||||
"""Return a list of all the units."""
|
||||
return self._all_units
|
||||
|
Loading…
x
Reference in New Issue
Block a user