diff --git a/cc/config/bp2build.go b/cc/config/bp2build.go index 4797acca1..982b43648 100644 --- a/cc/config/bp2build.go +++ b/cc/config/bp2build.go @@ -22,6 +22,7 @@ import ( "strings" "android/soong/android" + "github.com/google/blueprint" ) @@ -162,6 +163,10 @@ func exportStringListStaticVariable(name string, value []string) { exportedStringListVars.Set(name, value) } +func ExportStringList(name string, value []string) { + exportedStringListVars.Set(name, value) +} + type exportedStringListDictVariables map[string]map[string][]string func (m exportedStringListDictVariables) Set(k string, v map[string][]string) { diff --git a/cc/ndk_library.go b/cc/ndk_library.go index 7879a7d98..7efe134d2 100644 --- a/cc/ndk_library.go +++ b/cc/ndk_library.go @@ -25,6 +25,7 @@ import ( "github.com/google/blueprint/proptools" "android/soong/android" + "android/soong/cc/config" ) func init() { @@ -208,20 +209,26 @@ func (c *stubDecorator) compilerInit(ctx BaseModuleContext) { *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 { - flags.Global.CFlags = append(flags.Global.CFlags, - // 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", - ) + flags.Global.CFlags = append(flags.Global.CFlags, stubLibraryCompilerFlags...) // All symbols in the stubs library should be visible. if inList("-fvisibility=hidden", flags.Local.CFlags) { flags.Local.CFlags = append(flags.Local.CFlags, "-fvisibility=default")