Use aquery to declare bazel actions in the ninja file.

This effectively moves execution of Bazel actions outside of soong_build
and alongside ninja execution of the actual ninja files, whether that be
by ninja or by Bazel itself.

This almost allows for mixed builds and Bazel-as-Ninja-executor to
coexist, but requires hacks explained in b/175307058.

Test: Treehugger
Test: lunch aosp_flame && USE_BAZEL_ANALYSIS=1 m libc
Test: lunch aosp_flame && USE_BAZEL=1 USE_BAZEL_ANALYSIS=1 m libc,
though this requires a hack of the main BUILD file. See b/175307058

Change-Id: Ia2f6b0f1057e8cea3809de66d8287f13d84b510c
This commit is contained in:
Chris Parsons
2020-12-10 17:19:18 -05:00
parent fde77e02f3
commit dbcb1ff469
6 changed files with 268 additions and 19 deletions

View File

@@ -1154,6 +1154,17 @@ func pathForModule(ctx ModuleContext) OutputPath {
return PathForOutput(ctx, ".intermediates", ctx.ModuleDir(), ctx.ModuleName(), ctx.ModuleSubDir())
}
type BazelOutPath struct {
OutputPath
}
var _ Path = BazelOutPath{}
var _ objPathProvider = BazelOutPath{}
func (p BazelOutPath) objPathWithExt(ctx ModuleContext, subdir, ext string) ModuleObjPath {
return PathForModuleObj(ctx, subdir, pathtools.ReplaceExtension(p.path, ext))
}
// PathForVndkRefAbiDump returns an OptionalPath representing the path of the
// reference abi dump for the given module. This is not guaranteed to be valid.
func PathForVndkRefAbiDump(ctx ModuleContext, version, fileName string,
@@ -1192,6 +1203,24 @@ func PathForVndkRefAbiDump(ctx ModuleContext, version, fileName string,
fileName+ext)
}
// PathForBazelOut returns a Path representing the paths... under an output directory dedicated to
// bazel-owned outputs.
func PathForBazelOut(ctx PathContext, paths ...string) BazelOutPath {
execRootPathComponents := append([]string{"execroot", "__main__"}, paths...)
execRootPath := filepath.Join(execRootPathComponents...)
validatedExecRootPath, err := validatePath(execRootPath)
if err != nil {
reportPathError(ctx, err)
}
outputPath := OutputPath{basePath{"", ctx.Config(), ""},
ctx.Config().BazelContext.OutputBase()}
return BazelOutPath{
OutputPath: outputPath.withRel(validatedExecRootPath),
}
}
// PathForModuleOut returns a Path representing the paths... under the module's
// output directory.
func PathForModuleOut(ctx ModuleContext, paths ...string) ModuleOutPath {