Export stub library compiler flags to soong_injection.

These are used by the "stub_library" cc toolchain feature.

Test: CI
Bug: 207812332
Change-Id: I392e51f32c92b30b30e85658e7627e16190bdbad
This commit is contained in:
Jingwen Chen
2022-01-11 05:42:49 +00:00
parent d1227b20aa
commit 341f73550d
2 changed files with 25 additions and 13 deletions

View File

@@ -22,6 +22,7 @@ import (
"strings" "strings"
"android/soong/android" "android/soong/android"
"github.com/google/blueprint" "github.com/google/blueprint"
) )
@@ -162,6 +163,10 @@ func exportStringListStaticVariable(name string, value []string) {
exportedStringListVars.Set(name, value) exportedStringListVars.Set(name, value)
} }
func ExportStringList(name string, value []string) {
exportedStringListVars.Set(name, value)
}
type exportedStringListDictVariables map[string]map[string][]string type exportedStringListDictVariables map[string]map[string][]string
func (m exportedStringListDictVariables) Set(k string, v map[string][]string) { func (m exportedStringListDictVariables) Set(k string, v map[string][]string) {

View File

@@ -25,6 +25,7 @@ import (
"github.com/google/blueprint/proptools" "github.com/google/blueprint/proptools"
"android/soong/android" "android/soong/android"
"android/soong/cc/config"
) )
func init() { func init() {
@@ -208,20 +209,26 @@ func (c *stubDecorator) compilerInit(ctx BaseModuleContext) {
*ndkKnownLibs = append(*ndkKnownLibs, name) *ndkKnownLibs = append(*ndkKnownLibs, name)
} }
var stubLibraryCompilerFlags = []string{
// We're knowingly doing some otherwise unsightly things with builtin
// functions here. We're just generating stub libraries, so ignore it.
"-Wno-incompatible-library-redeclaration",
"-Wno-incomplete-setjmp-declaration",
"-Wno-builtin-requires-header",
"-Wno-invalid-noreturn",
"-Wall",
"-Werror",
// These libraries aren't actually used. Don't worry about unwinding
// (avoids the need to link an unwinder into a fake library).
"-fno-unwind-tables",
}
func init() {
config.ExportStringList("StubLibraryCompilerFlags", stubLibraryCompilerFlags)
}
func addStubLibraryCompilerFlags(flags Flags) Flags { func addStubLibraryCompilerFlags(flags Flags) Flags {
flags.Global.CFlags = append(flags.Global.CFlags, flags.Global.CFlags = append(flags.Global.CFlags, stubLibraryCompilerFlags...)
// We're knowingly doing some otherwise unsightly things with builtin
// functions here. We're just generating stub libraries, so ignore it.
"-Wno-incompatible-library-redeclaration",
"-Wno-incomplete-setjmp-declaration",
"-Wno-builtin-requires-header",
"-Wno-invalid-noreturn",
"-Wall",
"-Werror",
// These libraries aren't actually used. Don't worry about unwinding
// (avoids the need to link an unwinder into a fake library).
"-fno-unwind-tables",
)
// All symbols in the stubs library should be visible. // All symbols in the stubs library should be visible.
if inList("-fvisibility=hidden", flags.Local.CFlags) { if inList("-fvisibility=hidden", flags.Local.CFlags) {
flags.Local.CFlags = append(flags.Local.CFlags, "-fvisibility=default") flags.Local.CFlags = append(flags.Local.CFlags, "-fvisibility=default")