From 80e04ee430be055ee27419d7d26ed67634a03ee6 Mon Sep 17 00:00:00 2001 From: Dmitry Arkhipov Date: Thu, 18 Dec 2025 18:22:59 +0300 Subject: [PATCH] resolve subprojects of projects with rooted id (#483) --- src/build/project.jam | 28 ++++++++++++++++++++++++++-- test/project_sub_resolution.py | 26 ++++++++++++++++++++++++++ test/test_all.py | 1 + 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100755 test/project_sub_resolution.py diff --git a/src/build/project.jam b/src/build/project.jam index b19be1253..a4bb7a307 100644 --- a/src/build/project.jam +++ b/src/build/project.jam @@ -163,6 +163,7 @@ rule find ( name : current-location ) { name = [ NORMALIZE_PATH $(name) ] ; local project-module ; + local location ; # Try interpreting name as project id. if [ path.is-rooted $(name) ] @@ -195,14 +196,37 @@ rule find ( name : current-location ) load-used-projects $(caller-module) ; } } + else + { + local sub = [ path.basename $(name) ] ; + local root = [ path.parent $(name) ] ; + while $(root) != / + { + local m = $($(root).jamfile-module) ; + if $(m) + { + location = [ path.root $(sub) + [ attribute $(m) location ] ] ; + root = / ; + } + else + { + sub = [ path.join [ path.basename $(root) ] $(sub) ] ; + root = [ path.parent $(root) ] ; + } + } + } project-module = $($(name).jamfile-module) ; } } if ! $(project-module) { - local location = [ path.root [ path.make $(name) ] $(current-location) ] - ; + if ! $(location) + { + location = [ path.root [ path.make $(name) ] $(current-location) ] + ; + } # If no project is registered for the given location, try to load it. # First see if we have a Jamfile. If not, then see if we might have a diff --git a/test/project_sub_resolution.py b/test/project_sub_resolution.py new file mode 100755 index 000000000..f4c69159a --- /dev/null +++ b/test/project_sub_resolution.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +# Copyright 2025 Dmitry Arkhipov +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt) + +# Test that subprojects of a project with rooted id can be resolved. + +import BoostBuild + +t = BoostBuild.Tester(use_test_config=False) + +t.write("jamroot.jam", """ +project /A ; +alias x ; +alias y : /A/B/C//c ; +alias z : /A/B//b ; +""") + +t.write("B/build.jam", "alias b ;") + +t.write("B/C/build.jam", "alias c ;") + +t.run_build_system() + +t.cleanup() diff --git a/test/test_all.py b/test/test_all.py index 744aed281..8bfa81ea9 100755 --- a/test/test_all.py +++ b/test/test_all.py @@ -412,6 +412,7 @@ tests = [ "project_dependencies", "project_glob", "project_id", + "project_sub_resolution", "project_root_constants", "project_root_rule", "project_test3",