Use ndk_system STL header library

Soong currently adds -isystem
prebuilts/ndk/current/sources/cxx-stl/system/include to modules that
have ndk_system STL. This does not translate well to Bazel because of
its stricter sandboxing constraints.

In preparation for building sdk variants with Bazel, create an
indirection where sdk variants that use this STL depend on a
`ndk_system` header library module.

This should be a no-op in Soong, but the resultant ninja files are not
identical. (e.g diff https://diff.googleplex.com/#key=OOLtc1GFmDDF). The
-isystem now appears _before_ the local cflags. However, this should be
fine because we have a check in `CheckBadCompilerFlags` that bans use of
-I/-isystem in user-provided cflags.

Test: diff'd ninja file
Test: TH
Bug: 298258442
Change-Id: I8c4e2b66bb9ac25c44ceedd52298ba474a554a04
This commit is contained in:
Spandan Das 2023-09-05 23:02:27 +00:00
parent ca22dfb5d1
commit 72b8fcbbec

View file

@ -172,6 +172,7 @@ func (stl *stl) deps(ctx BaseModuleContext, deps Deps) Deps {
// The system STL doesn't have a prebuilt (it uses the system's libstdc++), but it does have
// its own includes. The includes are handled in CCBase.Flags().
deps.SharedLibs = append([]string{"libstdc++"}, deps.SharedLibs...)
deps.HeaderLibs = append([]string{"ndk_system"}, deps.HeaderLibs...)
case "ndk_libc++_shared", "ndk_libc++_static":
if stl.Properties.SelectedStl == "ndk_libc++_shared" {
deps.SharedLibs = append(deps.SharedLibs, stl.Properties.SelectedStl)
@ -219,8 +220,7 @@ func (stl *stl) flags(ctx ModuleContext, flags Flags) Flags {
case "libstdc++":
// Nothing
case "ndk_system":
ndkSrcRoot := android.PathForSource(ctx, "prebuilts/ndk/current/sources/cxx-stl/system/include")
flags.Local.CFlags = append(flags.Local.CFlags, "-isystem "+ndkSrcRoot.String())
// Nothing: The exports of ndk_system will be added automatically to the local cflags
case "ndk_libc++_shared", "ndk_libc++_static":
if ctx.Arch().ArchType == android.Arm {
// Make sure the _Unwind_XXX symbols are not re-exported.