Support cc_library_shared for mixed builds

Authors: cparsons, eakammer, jingwen

This CL also contains .toc file integration between Bazel and Make.

Fixes: b/190524879

Test: build/bazel/ci/mixed_droid.sh

Co-authored-by: Christopher Parsons <cparsons@google.com>
Co-authored-by: Liz Kammer <eakammer@google.com>
Co-authored-by: Jingwen Chen <jingwen@google.com>

Change-Id: If484042a58cb9f0db6d30a460f415f5684b4cbf6
This commit is contained in:
Chris Parsons
2021-06-04 15:03:47 -04:00
committed by Jingwen Chen
parent 79e04280ba
commit 94a0bba5a9
8 changed files with 208 additions and 60 deletions

View File

@@ -542,10 +542,13 @@ def get_arch(target):
platform_name = build_options(target)["//command_line_option:platforms"][0].name
if platform_name == "host":
return "HOST"
elif not platform_name.startswith("android_"):
fail("expected platform name of the form 'android_<arch>', but was " + str(platforms))
elif platform_name.startswith("android_"):
return platform_name[len("android_"):]
elif platform_name.startswith("linux_"):
return platform_name[len("linux_"):]
else:
fail("expected platform name of the form 'android_<arch>' or 'linux_<arch>', but was " + str(platforms))
return "UNKNOWN"
return platform_name[len("android_"):]
def format(target):
id_string = str(target.label) + "|" + get_arch(target)
@@ -742,8 +745,17 @@ func (c *bazelSingleton) GenerateBuildActions(ctx SingletonContext) {
}
rule := NewRuleBuilder(pctx, ctx)
cmd := rule.Command()
cmd.Text(fmt.Sprintf("cd %s/execroot/__main__ && %s",
ctx.Config().BazelContext.OutputBase(), buildStatement.Command))
// cd into Bazel's execution root, which is the action cwd.
cmd.Text(fmt.Sprintf("cd %s/execroot/__main__ && ", ctx.Config().BazelContext.OutputBase()))
for _, pair := range buildStatement.Env {
// Set per-action env variables, if any.
cmd.Flag(pair.Key + "=" + pair.Value)
}
// The actual Bazel action.
cmd.Text(" " + buildStatement.Command)
for _, outputPath := range buildStatement.OutputPaths {
cmd.ImplicitOutput(PathForBazelOut(ctx, outputPath))