Skip to content

Commit

Permalink
trivial improvements (#105)
Browse files Browse the repository at this point in the history
* set CMAKE_BUILD_PARALLEL_LEVEL before configuring
just in case some monster decides to build from within the configuration step (cough cough aws-c-cal/cmake/modules/aws-lc.cmake)

* more natural traversal order
  • Loading branch information
graebm authored Mar 15, 2021
1 parent fd71e71 commit 1f9b9ca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
6 changes: 3 additions & 3 deletions builder/actions/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ def _build_project(env, project, cmake_extra, build_tests=False):
with open(toolchain.env_file, 'a') as f:
f.writelines(build_env)

# configure
sh.exec(*toolchain.shell_env, cmake, cmake_args, check=True)

# set parallism via env var (cmake's --parallel CLI option doesn't exist until 3.12)
if os.environ.get('CMAKE_BUILD_PARALLEL_LEVEL') is None:
sh.setenv('CMAKE_BUILD_PARALLEL_LEVEL', str(os.cpu_count()))

# configure
sh.exec(*toolchain.shell_env, cmake, cmake_args, check=True)

# build
sh.exec(*toolchain.shell_env, cmake, "--build", project_build_dir, "--config",
build_config, check=True)
Expand Down
24 changes: 10 additions & 14 deletions builder/core/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,20 +596,16 @@ def get_flattened_dependencies(self, spec, *, include_self=False):
Gets full tree of dependencies as flat list with duplicates removed.
Items are ordered such that building Projects in the order given should just work.
"""
# first, gather flat list of deps, in breadth-first order, with duplicates included
def _gather_all(project, spec):
deps = project.get_dependencies(spec)
for dep in deps.copy():
deps += _gather_all(dep, spec)
return deps

all_deps = _gather_all(self, spec)
if include_self:
all_deps.insert(0, self)

# remove duplicates and put everything in proper build-order
unique_deps = UniqueList(reversed(all_deps))
return unique_deps

# each project inserts dependencies before self
def _post_order(project, spec, deps):
for dep in project.get_dependencies(spec):
_post_order(dep, spec, deps)
deps.append(project)

deps = UniqueList()
_post_order(self, spec, deps)
return deps

def get_consumers(self, spec):
""" Gets consumers for a given BuildSpec, filters by target """
Expand Down

0 comments on commit 1f9b9ca

Please sign in to comment.