build env: simplify handling of parallel jobs (#11524)

This PR implements several refactors requested in #11373, specifically:

- Config scopes are used to handle builtin defaults, command line overrides 
  and package overrides (`parallel=False`)
- `Package.make_jobs` attribute has been removed; `make_jobs` remains
  as a module-scope variable in the build environment.
- The use of the argument `-j` has been rationalized across commands
  - move '-j'/'--jobs' argument into `spack.cmd.common.arguments`
- Add unit tests to check that setting parallel jobs works as expected
  - add new test to ensure that build job setting is isolated to each build
- Fix packages that used `Package.make_jobs` (i.e. `bazel`)
This commit is contained in:
Massimiliano Culpo
2019-05-24 20:45:22 +02:00
committed by Todd Gamblin
parent 1bd4521f72
commit c291866b9a
11 changed files with 104 additions and 37 deletions

View File

@@ -32,6 +32,8 @@ class A(AutotoolsPackage):
depends_on('b', when='foobar=bar')
parallel = False
def with_or_without_fee(self, activated):
if not activated:
return '--no-fee'

View File

@@ -3,6 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import inspect
from spack import *
from multiprocessing import cpu_count
from spack.util.environment import env_flag
@@ -90,8 +92,9 @@ def __call__(self, *args, **kwargs):
return super(BazelExecutable, self).__call__(*args, **kwargs)
jobs = cpu_count()
dependent_module = inspect.getmodule(dependent_spec.package)
if not dependent_spec.package.parallel:
jobs = 1
elif dependent_spec.package.make_jobs:
jobs = dependent_spec.package.make_jobs
elif dependent_module.make_jobs:
jobs = dependent_module.make_jobs
module.bazel = BazelExecutable('bazel', 'build', jobs)