From 1e7495d973f8fb846d82025be11853031ab1057b Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Thu, 10 Aug 2017 13:33:27 +0900 Subject: cflags for vendor variants cflags that are only applied when building the vendor variant of a lib is now supported. This will be particularily useful when existing macro should be turned off for the vendor variant: cflags: ["-DENABLE_FEATURE_X"], target: { vendor: { cflags: ["-UENABLE_FEATURE_X"], }, }, Without this, the library author has to undef the macro inside the source code using __ANDROID_VNDK__, which is not desired especially for external projects. Bug: 64514237 Test: BOARD_VNDK_VERSION=current m -j libsqlite libsqlite.vendor Change-Id: Ib484b5b12e14ab776276a30ed2763dffadc9d642 --- cc/compiler.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cc/compiler.go b/cc/compiler.go index cec527bf..c7fcca79 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -134,6 +134,10 @@ type BaseCompilerProperties struct { // list of source files that should not be used to // build the vendor variant of the C/C++ module. Exclude_srcs []string + + // List of additional cflags that should be used to build the vendor + // variant of the C/C++ module. + Cflags []string } } @@ -392,6 +396,10 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag flags.CppFlags = append([]string{"-std=" + cppStd}, flags.CppFlags...) } + if ctx.vndk() { + flags.CFlags = append(flags.CFlags, esc(compiler.Properties.Target.Vendor.Cflags)...) + } + // We can enforce some rules more strictly in the code we own. strict // indicates if this is code that we can be stricter with. If we have // rules that we want to apply to *our* code (but maybe can't for -- cgit v1.2.3