From e45487b48ba53e7267923c2a44868d272aa6da25 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Thu, 3 Oct 2024 11:38:22 +0200 Subject: [PATCH] Add --only-deps option for caching (#870) --- alibuild_helpers/args.py | 2 ++ alibuild_helpers/build.py | 6 ++++++ tests/test_build.py | 1 + 3 files changed, 9 insertions(+) diff --git a/alibuild_helpers/args.py b/alibuild_helpers/args.py index 8f48bc42..da45b0bc 100644 --- a/alibuild_helpers/args.py +++ b/alibuild_helpers/args.py @@ -107,6 +107,8 @@ def doParseArgs(): "in multiple packages. The comment will only be stored if " "PACKAGE is compiled or downloaded during this run; if it " "already exists, this does not happen.")) + build_parser.add_argument("--only-deps", dest="onlyDeps", default=False, action="store_true", + help="Only build dependencies, not the main package (e.g. for caching)") build_docker = build_parser.add_argument_group(title="Build inside a container", description="""\ Builds can be done inside a Docker container, to make it easier to get a diff --git a/alibuild_helpers/build.py b/alibuild_helpers/build.py index fccc30bb..ebcf086d 100644 --- a/alibuild_helpers/build.py +++ b/alibuild_helpers/build.py @@ -693,6 +693,12 @@ def doBuild(args, parser): deps=",".join(buildOrder[:-1]), ), args.architecture) + # If we are building only the dependencies, the last package in + # the build order can be considered done. + if args.onlyDeps and len(buildOrder) > 1: + mainPackage = buildOrder.pop() + warning("Not rebuilding %s because --only-deps option provided.", mainPackage) + while buildOrder: p = buildOrder[0] spec = specs[p] diff --git a/tests/test_build.py b/tests/test_build.py index 246f00fb..a0f4ed72 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -276,6 +276,7 @@ def test_coverDoBuild(self, mock_debug, mock_listdir, mock_warning, mock_sys, mo environment={}, autoCleanup=False, noDevel=[], + onlyDeps=False, fetchRepos=False, forceTracked=False, plugin="legacy"