summaryrefslogtreecommitdiff
path: root/bazel/aquery.go
diff options
context:
space:
mode:
Diffstat (limited to 'bazel/aquery.go')
-rw-r--r--bazel/aquery.go32
1 files changed, 31 insertions, 1 deletions
diff --git a/bazel/aquery.go b/bazel/aquery.go
index 480158c11..186a4945b 100644
--- a/bazel/aquery.go
+++ b/bazel/aquery.go
@@ -115,7 +115,11 @@ type BuildStatement struct {
// input path string, but not both.
InputDepsetHashes []string
InputPaths []string
+ OrderOnlyInputs []string
FileContents string
+ // If ShouldRunInSbox is true, Soong will use sbox to created an isolated environment
+ // and run the mixed build action there
+ ShouldRunInSbox bool
}
// A helper type for aquery processing which facilitates retrieval of path IDs from their
@@ -134,6 +138,8 @@ type aqueryArtifactHandler struct {
depsetHashToArtifactPathsCache sync.Map
// Maps artifact ids to fully expanded paths.
artifactIdToPath map[artifactId]string
+
+ extraBuildStatements []*BuildStatement
}
// The tokens should be substituted with the value specified here, instead of the
@@ -163,13 +169,29 @@ func newAqueryHandler(aqueryResult *analysis_v2_proto.ActionGraphContainer) (*aq
return pathFragmentId(pf.Id)
})
+ var extraBuildStatements []*BuildStatement
artifactIdToPath := make(map[artifactId]string, len(aqueryResult.Artifacts))
for _, artifact := range aqueryResult.Artifacts {
artifactPath, err := expandPathFragment(pathFragmentId(artifact.PathFragmentId), pathFragments)
if err != nil {
return nil, err
}
- artifactIdToPath[artifactId(artifact.Id)] = artifactPath
+ if strings.HasSuffix(artifactPath, "DumpPlatformClassPath.java") {
+ // TODO(b/291828210): This is a workaround for the fact that DumpPlatformClassPath.java
+ // has a timestamp in 2033. We'll copy it to a new file using a order-only dep, so that
+ // the file is not recopied every build. Technically the order-only dep would produce
+ // incremental build issues if this was a regular file produced as part of the build,
+ // but this file is actually created by bazel during analysis, so it's not an issue.
+ outputPath := "hack_for_b291828210/DumpPlatformClassPath.java"
+ extraBuildStatements = append(extraBuildStatements, &BuildStatement{
+ Command: fmt.Sprintf("cp %s %s", artifactPath, outputPath),
+ OutputPaths: []string{outputPath},
+ OrderOnlyInputs: []string{artifactPath},
+ })
+ artifactIdToPath[artifactId(artifact.Id)] = outputPath
+ } else {
+ artifactIdToPath[artifactId(artifact.Id)] = artifactPath
+ }
}
// Map middleman artifact ContentHash to input artifact depset ID.
@@ -196,6 +218,7 @@ func newAqueryHandler(aqueryResult *analysis_v2_proto.ActionGraphContainer) (*aq
depsetHashToArtifactPathsCache: sync.Map{},
emptyDepsetIds: make(map[depsetId]struct{}, 0),
artifactIdToPath: artifactIdToPath,
+ extraBuildStatements: extraBuildStatements,
}
// Validate and adjust aqueryResult.DepSetOfFiles values.
@@ -369,6 +392,7 @@ func AqueryBuildStatements(aqueryJsonProto []byte, eventHandler *metrics.EventHa
if err != nil {
return nil, nil, err
}
+ buildStatements = append(buildStatements, aqueryHandler.extraBuildStatements...)
depsetsByHash := map[string]AqueryDepset{}
depsets := make([]AqueryDepset, 0, len(aqueryHandler.depsetIdToAqueryDepset))
@@ -496,6 +520,12 @@ func (a *aqueryArtifactHandler) normalActionBuildStatement(actionEntry *analysis
Env: actionEntry.EnvironmentVariables,
Mnemonic: actionEntry.Mnemonic,
}
+ if buildStatement.Mnemonic == "GoToolchainBinaryBuild" {
+ // Unlike b's execution root, mixed build execution root contains a symlink to prebuilts/go
+ // This causes issues for `GOCACHE=$(mktemp -d) go build ...`
+ // To prevent this, sandbox this action in mixed builds as well
+ buildStatement.ShouldRunInSbox = true
+ }
return buildStatement, nil
}