From d8a3349daa47968de529c901779927e288cbe230 Mon Sep 17 00:00:00 2001 From: cemeceme <26171877+cemeceme@users.noreply.github.com> Date: Mon, 8 Sep 2025 14:21:37 +0200 Subject: [PATCH 1/3] Fix for arch specific subrepos using the wrong parent configs. --- src/core/state.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/core/state.go b/src/core/state.go index 3596885b5..ab1f0b458 100644 --- a/src/core/state.go +++ b/src/core/state.go @@ -1240,7 +1240,10 @@ func (state *BuildState) ForTarget(target *BuildTarget) *BuildState { func (state *BuildState) ForArch(arch cli.Arch) *BuildState { state.progress.mutex.Lock() defer state.progress.mutex.Unlock() + return state.forArch(arch) +} +func (state *BuildState) forArch(arch cli.Arch) *BuildState { for _, s := range state.progress.allStates { if s.Arch == arch && s.CurrentSubrepo == state.CurrentSubrepo { return s @@ -1269,8 +1272,15 @@ func (state *BuildState) ForArch(arch cli.Arch) *BuildState { s.Config = config s.RepoConfig = repoConfig s.Arch = arch - state.progress.allStates = append(state.progress.allStates, s) + // Make sure that any parent states are also for the requested arch. + if s.ParentState != nil { + if s.ParentState.Arch != arch { + s.ParentState = s.ParentState.forArch(arch) + } + } + + state.progress.allStates = append(state.progress.allStates, s) return s } From a900c93f80a0721fbc490dc313edbfd43520c27e Mon Sep 17 00:00:00 2001 From: cemeceme <26171877+cemeceme@users.noreply.github.com> Date: Sat, 27 Sep 2025 03:11:16 +0200 Subject: [PATCH 2/3] Added e2e test. --- test/subrepo/arch_subrepo_config/BUILD | 9 +++++ .../arch_subrepo_config/test_repo/.plzconfig | 4 +++ .../test_repo/.plzconfig_test_arch | 4 +++ .../arch_subrepo_config/test_repo/BUILD_FILE | 33 +++++++++++++++++++ .../test_repo/plugin/.plzconfig | 10 ++++++ .../test_repo/plugin/BUILD_FILE | 7 ++++ .../test_repo/subrepo/.plzconfig | 4 +++ .../test_repo/subrepo/.plzconfig_test_arch | 4 +++ .../test_repo/subrepo/BUILD_FILE | 16 +++++++++ 9 files changed, 91 insertions(+) create mode 100644 test/subrepo/arch_subrepo_config/BUILD create mode 100644 test/subrepo/arch_subrepo_config/test_repo/.plzconfig create mode 100644 test/subrepo/arch_subrepo_config/test_repo/.plzconfig_test_arch create mode 100644 test/subrepo/arch_subrepo_config/test_repo/BUILD_FILE create mode 100644 test/subrepo/arch_subrepo_config/test_repo/plugin/.plzconfig create mode 100644 test/subrepo/arch_subrepo_config/test_repo/plugin/BUILD_FILE create mode 100644 test/subrepo/arch_subrepo_config/test_repo/subrepo/.plzconfig create mode 100644 test/subrepo/arch_subrepo_config/test_repo/subrepo/.plzconfig_test_arch create mode 100644 test/subrepo/arch_subrepo_config/test_repo/subrepo/BUILD_FILE diff --git a/test/subrepo/arch_subrepo_config/BUILD b/test/subrepo/arch_subrepo_config/BUILD new file mode 100644 index 000000000..dff19e15a --- /dev/null +++ b/test/subrepo/arch_subrepo_config/BUILD @@ -0,0 +1,9 @@ +subinclude("//test/build_defs") + + +please_repo_e2e_test( + name = "arch_subrepo_config", + expected_failure = False, + plz_command = "plz build --arch test_arch //:testFile", + repo = "test_repo" +) \ No newline at end of file diff --git a/test/subrepo/arch_subrepo_config/test_repo/.plzconfig b/test/subrepo/arch_subrepo_config/test_repo/.plzconfig new file mode 100644 index 000000000..4e552569c --- /dev/null +++ b/test/subrepo/arch_subrepo_config/test_repo/.plzconfig @@ -0,0 +1,4 @@ + +[Plugin "plugin"] +Target = //:plugin +teststring = "RootString" \ No newline at end of file diff --git a/test/subrepo/arch_subrepo_config/test_repo/.plzconfig_test_arch b/test/subrepo/arch_subrepo_config/test_repo/.plzconfig_test_arch new file mode 100644 index 000000000..b91e82611 --- /dev/null +++ b/test/subrepo/arch_subrepo_config/test_repo/.plzconfig_test_arch @@ -0,0 +1,4 @@ + +[Plugin "plugin"] +Target = //:plugin +teststring = "RootArchString" \ No newline at end of file diff --git a/test/subrepo/arch_subrepo_config/test_repo/BUILD_FILE b/test/subrepo/arch_subrepo_config/test_repo/BUILD_FILE new file mode 100644 index 000000000..665976cdc --- /dev/null +++ b/test/subrepo/arch_subrepo_config/test_repo/BUILD_FILE @@ -0,0 +1,33 @@ + +local_repository( + name="subrepo", + path="./subrepo" +) + +subrepo( + name="plugin", + path="./plugin", + plugin=True +) + +subinclude("///plugin//:plugin") + +# Parse the subrepo twice; by calling it as the host arch via tool, and by calling it as the target arch. +build_rule( + name="testFile", + cmd="echo " + CONFIG.PLUGIN.TESTSTRING + " > testFile", + outs=["testFile"], + tools="///subrepo//:subrepoFile", + deps= + [ + "///subrepo//:subrepoFile" + ], + visibility=["PUBLIC"] +) + +# Fail if the plugin config value is unexpected. +if( + (CONFIG.OS == "test" and CONFIG.PLUGIN.TESTSTRING != "RootArchString") or + (CONFIG.OS == CONFIG.HOSTOS and CONFIG.PLUGIN.TESTSTRING != "RootString") + ): + log.fatal("Wrong option set: " + CONFIG.PLUGIN.TESTSTRING + " (in " + CONFIG.OS + ") with the host arch: " + CONFIG.HOSTARCH + "_" + CONFIG.HOSTOS) \ No newline at end of file diff --git a/test/subrepo/arch_subrepo_config/test_repo/plugin/.plzconfig b/test/subrepo/arch_subrepo_config/test_repo/plugin/.plzconfig new file mode 100644 index 000000000..59344bf5b --- /dev/null +++ b/test/subrepo/arch_subrepo_config/test_repo/plugin/.plzconfig @@ -0,0 +1,10 @@ + + +:Define a simple plugin with an inherited string key to test with. +[PluginDefinition] +name = plugin + +[PluginConfig "teststring"] +ConfigKey = teststring +DefaultValue = "DefaultString" +Inherit = true \ No newline at end of file diff --git a/test/subrepo/arch_subrepo_config/test_repo/plugin/BUILD_FILE b/test/subrepo/arch_subrepo_config/test_repo/plugin/BUILD_FILE new file mode 100644 index 000000000..e057d2555 --- /dev/null +++ b/test/subrepo/arch_subrepo_config/test_repo/plugin/BUILD_FILE @@ -0,0 +1,7 @@ + +# Empty plugin to load config. +filegroup( + name = "plugin", + srcs = [], + visibility = ["PUBLIC"] +) \ No newline at end of file diff --git a/test/subrepo/arch_subrepo_config/test_repo/subrepo/.plzconfig b/test/subrepo/arch_subrepo_config/test_repo/subrepo/.plzconfig new file mode 100644 index 000000000..98168cc32 --- /dev/null +++ b/test/subrepo/arch_subrepo_config/test_repo/subrepo/.plzconfig @@ -0,0 +1,4 @@ + +[Plugin "plugin"] +Target = //:plugin +teststring = "subrepoString" \ No newline at end of file diff --git a/test/subrepo/arch_subrepo_config/test_repo/subrepo/.plzconfig_test_arch b/test/subrepo/arch_subrepo_config/test_repo/subrepo/.plzconfig_test_arch new file mode 100644 index 000000000..3d2288134 --- /dev/null +++ b/test/subrepo/arch_subrepo_config/test_repo/subrepo/.plzconfig_test_arch @@ -0,0 +1,4 @@ + +[Plugin "plugin"] +Target = //:plugin +teststring = "subrepoArchString" diff --git a/test/subrepo/arch_subrepo_config/test_repo/subrepo/BUILD_FILE b/test/subrepo/arch_subrepo_config/test_repo/subrepo/BUILD_FILE new file mode 100644 index 000000000..6164df7a0 --- /dev/null +++ b/test/subrepo/arch_subrepo_config/test_repo/subrepo/BUILD_FILE @@ -0,0 +1,16 @@ + +subinclude("///plugin//:plugin") + +build_rule( + name="subrepoFile", + cmd="echo " + CONFIG.PLUGIN.TESTSTRING + " > subrepoFile", + outs=["subrepoFile"], + visibility=["PUBLIC"] +) + +# Fail if the plugin config value is unexpected. +if( + (CONFIG.OS == "test" and CONFIG.PLUGIN.TESTSTRING != "RootArchString") or + (CONFIG.OS == CONFIG.HOSTOS and CONFIG.PLUGIN.TESTSTRING != "RootString") + ): + log.fatal("Wrong subrepo option set: " + CONFIG.PLUGIN.TESTSTRING + " (in " + CONFIG.OS + ") with the host arch: " + CONFIG.HOSTARCH + "_" + CONFIG.HOSTOS) \ No newline at end of file From fd0fdd85e2bda1cb2e9c37439eb74394a67020ad Mon Sep 17 00:00:00 2001 From: cemeceme <26171877+cemeceme@users.noreply.github.com> Date: Wed, 5 Nov 2025 12:17:05 +0100 Subject: [PATCH 3/3] Fixed wrong comment character in test plugin definition This took me too long to notice, but also lead me to find that parsing errors get swallowed for subrepo configs. --- test/subrepo/arch_subrepo_config/test_repo/plugin/.plzconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/subrepo/arch_subrepo_config/test_repo/plugin/.plzconfig b/test/subrepo/arch_subrepo_config/test_repo/plugin/.plzconfig index 59344bf5b..e1148a3de 100644 --- a/test/subrepo/arch_subrepo_config/test_repo/plugin/.plzconfig +++ b/test/subrepo/arch_subrepo_config/test_repo/plugin/.plzconfig @@ -1,10 +1,10 @@ -:Define a simple plugin with an inherited string key to test with. +#Define a simple plugin with an inherited string key to test with. [PluginDefinition] name = plugin [PluginConfig "teststring"] ConfigKey = teststring DefaultValue = "DefaultString" -Inherit = true \ No newline at end of file +Inherit = true