Skip to content

Commit

Permalink
Provide more debugging information in the package spec (#743)
Browse files Browse the repository at this point in the history
* Provide information about disabled packages
* Allow disabling all devel packages
  • Loading branch information
ktf authored Feb 7, 2022
1 parent ea4e34e commit d7ad9ce
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
2 changes: 2 additions & 0 deletions alibuild_helpers/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ def doParseArgs(star):
build_parser.add_argument("--no-local", dest="noDevel", metavar="PKGLIST", default="", type=csv_list,
help=("Do not pick up the following packages from a local checkout. "
"%(metavar)s is a comma-separated list."))
build_parser.add_argument("--force-tracked", dest="forceTracked", default=False, action="store_true",
help=("Do not pick up any packages from a local checkout. "))
build_parser.add_argument("--disable", dest="disable", default=[], metavar="PACKAGE", action="append",
help="Do not build %(metavar)s and all its (unique) dependencies.")

Expand Down
24 changes: 13 additions & 11 deletions alibuild_helpers/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,17 +346,19 @@ def doBuild(args, parser):
"hour": str(now.hour).zfill(2) }

# Check if any of the packages can be picked up from a local checkout
develCandidates = [basename(d) for d in glob("*") if os.path.isdir(d)]
develCandidatesUpper = [basename(d).upper() for d in glob("*") if os.path.isdir(d)]
develPkgs = [p for p in buildOrder
if p in develCandidates and p not in args.noDevel]
develPkgsUpper = [(p, p.upper()) for p in buildOrder
if p.upper() in develCandidatesUpper and p not in args.noDevel]
if set(develPkgs) != {x for x, _ in develPkgsUpper}:
error("The following development packages have the wrong spelling: %s.\n"
"Please check your local checkout and adapt to the correct one indicated.",
", ".join({x.strip() for x, _ in develPkgsUpper} - set(develPkgs)))
return 1
develPkgs = []
if not args.forceTracked:
develCandidates = [basename(d) for d in glob("*") if os.path.isdir(d)]
develCandidatesUpper = [basename(d).upper() for d in glob("*") if os.path.isdir(d)]
develPkgs = [p for p in buildOrder
if p in develCandidates and p not in args.noDevel]
develPkgsUpper = [(p, p.upper()) for p in buildOrder
if p.upper() in develCandidatesUpper and p not in args.noDevel]
if set(develPkgs) != {x for x, _ in develPkgsUpper}:
error("The following development packages have the wrong spelling: %s.\n"
"Please check your local checkout and adapt to the correct one indicated.",
", ".join({x.strip() for x, _ in develPkgsUpper} - set(develPkgs)))
return 1

if buildOrder:
banner("Packages will be built in the following order:\n - %s",
Expand Down
10 changes: 10 additions & 0 deletions alibuild_helpers/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@ def filterByArchitecture(arch, requires):
if re.match(matcher, arch):
yield require

def disabledByArchitecture(arch, requires):
for r in requires:
require, matcher = ":" in r and r.split(":", 1) or (r, ".*")
if not re.match(matcher, arch):
yield require

def readDefaults(configDir, defaults, error, architecture):
defaultsFilename = "%s/defaults-%s.sh" % (configDir, defaults)
if not exists(defaultsFilename):
Expand Down Expand Up @@ -420,6 +426,7 @@ def getPackageList(packages, specs, configDir, preferSystem, noSystem,
else:
disable.append(spec["package"])

spec["disabled"] = disable
if spec["package"] in disable:
continue

Expand All @@ -432,6 +439,9 @@ def getPackageList(packages, specs, configDir, preferSystem, noSystem,
validDefaults = None # no valid default works for all current packages

# For the moment we treat build_requires just as requires.
fn = lambda what: disabledByArchitecture(architecture, spec.get(what, []))
spec["disabled"] += [x for x in fn("requires")]
spec["disabled"] += [x for x in fn("build_requires")]
fn = lambda what: filterByArchitecture(architecture, spec.get(what, []))
spec["requires"] = [x for x in fn("requires") if not x in disable]
spec["build_requires"] = [x for x in fn("build_requires") if not x in disable]
Expand Down
1 change: 1 addition & 0 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ def test_coverDoBuild(self, mock_debug, mock_glob, mock_sys, mock_sync_execute,
autoCleanup=False,
noDevel=[],
fetchRepos=False,
forceTracked=False,
)
mock_sys.version_info = sys.version_info

Expand Down

0 comments on commit d7ad9ce

Please sign in to comment.