Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/core/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down
9 changes: 9 additions & 0 deletions test/subrepo/arch_subrepo_config/BUILD
Original file line number Diff line number Diff line change
@@ -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"
)
4 changes: 4 additions & 0 deletions test/subrepo/arch_subrepo_config/test_repo/.plzconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

[Plugin "plugin"]
Target = //:plugin
teststring = "RootString"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

[Plugin "plugin"]
Target = //:plugin
teststring = "RootArchString"
33 changes: 33 additions & 0 deletions test/subrepo/arch_subrepo_config/test_repo/BUILD_FILE
Original file line number Diff line number Diff line change
@@ -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)
10 changes: 10 additions & 0 deletions test/subrepo/arch_subrepo_config/test_repo/plugin/.plzconfig
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions test/subrepo/arch_subrepo_config/test_repo/plugin/BUILD_FILE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

# Empty plugin to load config.
filegroup(
name = "plugin",
srcs = [],
visibility = ["PUBLIC"]
)
4 changes: 4 additions & 0 deletions test/subrepo/arch_subrepo_config/test_repo/subrepo/.plzconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

[Plugin "plugin"]
Target = //:plugin
teststring = "subrepoString"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

[Plugin "plugin"]
Target = //:plugin
teststring = "subrepoArchString"
16 changes: 16 additions & 0 deletions test/subrepo/arch_subrepo_config/test_repo/subrepo/BUILD_FILE
Original file line number Diff line number Diff line change
@@ -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)