diff --git a/src/core/state.go b/src/core/state.go index 3596885b51..ab1f0b4582 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 } diff --git a/test/subrepo/arch_subrepo_config/BUILD b/test/subrepo/arch_subrepo_config/BUILD new file mode 100644 index 0000000000..dff19e15ac --- /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 0000000000..4e552569cd --- /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 0000000000..b91e826117 --- /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 0000000000..665976cdce --- /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 0000000000..e1148a3dee --- /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 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 0000000000..e057d25557 --- /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 0000000000..98168cc32a --- /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 0000000000..3d22881344 --- /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 0000000000..6164df7a0d --- /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