bp2build: export some cc toolchain flags into Starlark.

This CL exports common/global/device/host clang/ld/ldd flags
from their Ninja variable initialization locations in
cc/config/global.go and cc/config/clang.go to make Bazel's cc_toolchain
and Soong's cc actions more consistent with each other.

This does not handle env-dependent or arch-specific toolchain flags
yet (logic in compiler.go and linker.go).

Test: TH
Bug: 187086342
Bug: 187084737
Bug: 186628704
Bug: 187857770
Change-Id: Ie403d7cd23f35160897b9dd902c799cbf1bd7f0c
This commit is contained in:
Jingwen Chen
2021-05-06 13:31:18 +00:00
parent 3950cd6ed4
commit bf61afb7f7
10 changed files with 336 additions and 46 deletions

View File

@@ -79,9 +79,33 @@ func TestCreateBazelFiles_QueryView_AddsTopLevelFiles(t *testing.T) {
}
}
func TestCreateBazelFiles_Bp2Build_CreatesNoFilesWithNoTargets(t *testing.T) {
files := CreateBazelFiles(map[string]RuleShim{}, map[string]BazelTargets{}, Bp2Build)
if len(files) != 0 {
t.Errorf("Expected no files, got %d", len(files))
func TestCreateBazelFiles_Bp2Build_CreatesDefaultFiles(t *testing.T) {
files := CreateSoongInjectionFiles()
expectedFilePaths := []bazelFilepath{
{
dir: "cc_toolchain",
basename: "BUILD",
},
{
dir: "cc_toolchain",
basename: "constants.bzl",
},
}
if len(files) != len(expectedFilePaths) {
t.Errorf("Expected %d file, got %d", len(expectedFilePaths), len(files))
}
for i := range files {
actualFile, expectedFile := files[i], expectedFilePaths[i]
if actualFile.Dir != expectedFile.dir || actualFile.Basename != expectedFile.basename {
t.Errorf("Did not find expected file %s/%s", actualFile.Dir, actualFile.Basename)
}
if expectedFile.basename != "BUILD" && actualFile.Contents == "" {
t.Errorf("Contents of %s unexpected empty.", actualFile)
}
}
}