Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added dependency check after post_build step. #3174

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
10 changes: 10 additions & 0 deletions src/build/build_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,16 @@ func buildTarget(state *core.BuildState, target *core.BuildTarget, runRemotely b
return err
}

// Wait for any new dependencies added by post-build commands before continuing.
for _, dep := range target.Dependencies() {
dep.WaitForBuild()
if dep.State() >= core.DependencyFailed { // Either the target failed or its dependencies failed
// Give up and set the original target as dependency failed
target.SetState(core.DependencyFailed)
return fmt.Errorf("error in post-rule dependency for %s: %s", target.Label, dep.Label)
}
}

if runRemotely && len(outs) != len(target.Outputs()) {
// postBuildFunction has changed the target - must rebuild it
log.Info("Rebuilding %s after post-build function", target)
Expand Down
10 changes: 10 additions & 0 deletions src/core/build_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -1653,6 +1653,16 @@ func (target *BuildTarget) AddMaybeExportedDependency(dep BuildLabel, exported,
}
}

// RegisterDependencyTarget registers a build target to be used for a dependency label on the given target.
func (target *BuildTarget) RegisterDependencyTarget(dep BuildLabel, deptarget *BuildTarget) {
info := target.dependencyInfo(dep)
if info == nil {
log.Fatalf("Target %s doesn't contain dependency %s.\n", target.Label, dep)
} else {
info.deps = append(info.deps, deptarget)
}
}

// IsTool returns true if the given build label is a tool used by this target.
func (target *BuildTarget) IsTool(tool BuildLabel) bool {
for _, t := range target.Tools {
Expand Down
1 change: 1 addition & 0 deletions src/parse/asp/builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,7 @@ func addDep(s *scope, args []pyObject) pyObject {
dep := s.parseLabelInPackage(string(args[1].(pyString)), s.pkg)
exported := args[2].IsTruthy()
target.AddMaybeExportedDependency(dep, exported, false, false)
target.RegisterDependencyTarget(dep, s.state.Graph.Target(dep))
// Queue this dependency if it'll be needed.
if target.State() > core.Inactive {
err := s.state.QueueTarget(dep, target.Label, false, core.ParseModeNormal)
Expand Down
Loading