From 87f7dd589bc8f47ad2bff8b8a1b6a6b20b03b262 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Wed, 2 Oct 2024 15:32:20 +0200 Subject: [PATCH] Add --only-deps option for caching --- 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 2716bf14..3ef98a8f 100644 --- a/alibuild_helpers/build.py +++ b/alibuild_helpers/build.py @@ -697,6 +697,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 a4b48358..a18a8441 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -285,6 +285,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"