diff options
Diffstat (limited to 'cc')
-rw-r--r-- | cc/androidmk.go | 38 | ||||
-rw-r--r-- | cc/cc.go | 59 | ||||
-rw-r--r-- | cc/config/global.go | 2 | ||||
-rw-r--r-- | cc/installer.go | 11 | ||||
-rw-r--r-- | cc/library.go | 15 | ||||
-rw-r--r-- | cc/makevars.go | 10 | ||||
-rw-r--r-- | cc/sabi.go | 2 | ||||
-rw-r--r-- | cc/sanitize.go | 4 | ||||
-rw-r--r-- | cc/test.go | 7 | ||||
-rw-r--r-- | cc/test_data_test.go | 23 | ||||
-rw-r--r-- | cc/vndk.go | 98 |
11 files changed, 218 insertions, 51 deletions
diff --git a/cc/androidmk.go b/cc/androidmk.go index 2a3b344f..a92a95c0 100644 --- a/cc/androidmk.go +++ b/cc/androidmk.go @@ -88,6 +88,25 @@ func (c *Module) AndroidMk() (ret android.AndroidMkData, err error) { return ret, nil } +func androidMkWriteTestData(data android.Paths, ctx AndroidMkContext, ret *android.AndroidMkData) { + var testFiles []string + for _, d := range data { + rel := d.Rel() + path := d.String() + if !strings.HasSuffix(path, rel) { + panic(fmt.Errorf("path %q does not end with %q", path, rel)) + } + path = strings.TrimSuffix(path, rel) + testFiles = append(testFiles, path+":"+rel) + } + if len(testFiles) > 0 { + ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { + fmt.Fprintln(w, "LOCAL_TEST_DATA := "+strings.Join(testFiles, " ")) + return nil + }) + } +} + func (library *libraryDecorator) androidMkWriteExportedFlags(w io.Writer) { exportedFlags := library.exportedFlags() if len(exportedFlags) > 0 { @@ -212,6 +231,8 @@ func (benchmark *benchmarkDecorator) AndroidMk(ctx AndroidMkContext, ret *androi } return nil }) + + androidMkWriteTestData(benchmark.data, ctx, ret) } func (test *testBinary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { @@ -229,22 +250,7 @@ func (test *testBinary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkDa return nil }) - var testFiles []string - for _, d := range test.data { - rel := d.Rel() - path := d.String() - if !strings.HasSuffix(path, rel) { - panic(fmt.Errorf("path %q does not end with %q", path, rel)) - } - path = strings.TrimSuffix(path, rel) - testFiles = append(testFiles, path+":"+rel) - } - if len(testFiles) > 0 { - ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { - fmt.Fprintln(w, "LOCAL_TEST_DATA := "+strings.Join(testFiles, " ")) - return nil - }) - } + androidMkWriteTestData(test.data, ctx, ret) } func (test *testLibrary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { @@ -183,6 +183,8 @@ type ModuleContextIntf interface { sdk() bool sdkVersion() string vndk() bool + isVndk() bool + isVndkSp() bool createVndkSourceAbiDump() bool selectedStl() string baseModuleName() string @@ -291,6 +293,7 @@ type Module struct { sanitize *sanitize coverage *coverage sabi *sabi + vndkdep *vndkdep androidMkSharedLibDeps []string @@ -327,6 +330,9 @@ func (c *Module) Init() android.Module { if c.sabi != nil { c.AddProperties(c.sabi.props()...) } + if c.vndkdep != nil { + c.AddProperties(c.vndkdep.props()...) + } for _, feature := range c.features { c.AddProperties(feature.props()...) } @@ -353,6 +359,13 @@ func (c *Module) vndk() bool { return c.Properties.UseVndk } +func (c *Module) isVndk() bool { + if c.vndkdep != nil { + return c.vndkdep.isVndk() + } + return false +} + type baseModuleContext struct { android.BaseContext moduleContextImpl @@ -368,10 +381,10 @@ type moduleContext struct { moduleContextImpl } -// Vendor returns true for vendor modules so that they get installed onto the -// correct partition +// Vendor returns true for vendor modules excluding VNDK libraries so that +// they get installed onto the correct partition func (ctx *moduleContext) Vendor() bool { - return ctx.ModuleContext.Vendor() || ctx.moduleContextImpl.mod.Properties.UseVndk + return ctx.ModuleContext.Vendor() || (ctx.mod.vndk() && !ctx.mod.isVndk()) } type moduleContextImpl struct { @@ -431,9 +444,20 @@ func (ctx *moduleContextImpl) vndk() bool { return ctx.mod.vndk() } +func (ctx *moduleContextImpl) isVndk() bool { + return ctx.mod.isVndk() +} + +func (ctx *moduleContextImpl) isVndkSp() bool { + if vndk := ctx.mod.vndkdep; vndk != nil { + return vndk.isVndkSp() + } + return false +} + // Create source abi dumps if the module belongs to the list of VndkLibraries. func (ctx *moduleContextImpl) createVndkSourceAbiDump() bool { - return ctx.ctx.Device() && ((Bool(ctx.mod.Properties.Vendor_available)) || (inList(ctx.baseModuleName(), config.LLndkLibraries()))) + return ctx.ctx.Device() && (ctx.mod.isVndk() || inList(ctx.baseModuleName(), config.LLndkLibraries())) } func (ctx *moduleContextImpl) selectedStl() string { @@ -463,6 +487,7 @@ func newModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Mo module.sanitize = &sanitize{} module.coverage = &coverage{} module.sabi = &sabi{} + module.vndkdep = &vndkdep{} return module } @@ -591,6 +616,9 @@ func (c *Module) begin(ctx BaseModuleContext) { if c.sabi != nil { c.sabi.begin(ctx) } + if c.vndkdep != nil { + c.vndkdep.begin(ctx) + } for _, feature := range c.features { feature.begin(ctx) } @@ -624,6 +652,9 @@ func (c *Module) deps(ctx DepsContext) Deps { if c.sabi != nil { deps = c.sabi.deps(ctx, deps) } + if c.vndkdep != nil { + deps = c.vndkdep.deps(ctx, deps) + } for _, feature := range c.features { deps = feature.deps(ctx, deps) } @@ -828,7 +859,12 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { return } if from.Properties.UseVndk { - // Vendor code is already limited by the vendor mutator + // Though vendor code is limited by the vendor mutator, + // each vendor-available module needs to check + // link-type for VNDK. + if from.vndkdep != nil { + from.vndkdep.vndkCheckLinkType(ctx, to) + } return } if from.Properties.Sdk_version == "" { @@ -1169,6 +1205,18 @@ func vendorMutator(mctx android.BottomUpMutatorContext) { "doesn't make sense at the same time as `vendor: true` or `proprietary: true`") return } + if vndk := m.vndkdep; vndk != nil { + if vndk.isVndk() && !Bool(m.Properties.Vendor_available) { + mctx.PropertyErrorf("vndk", + "has to define `vendor_available: true` to enable vndk") + return + } + if !vndk.isVndk() && vndk.isVndkSp() { + mctx.PropertyErrorf("vndk", + "must set `enabled: true` to set `support_system_process: true`") + return + } + } if !mctx.DeviceConfig().CompileVndk() { // If the device isn't compiling against the VNDK, we always @@ -1180,6 +1228,7 @@ func vendorMutator(mctx android.BottomUpMutatorContext) { mctx.CreateVariations(vendorMode) } else if Bool(m.Properties.Vendor_available) { // This will be available in both /system and /vendor + // or a /system directory that is available to vendor. mod := mctx.CreateVariations(coreMode, vendorMode) mod[1].(*Module).Properties.UseVndk = true } else if mctx.Vendor() && m.Properties.Sdk_version == "" { diff --git a/cc/config/global.go b/cc/config/global.go index 4ae22c95..f4a12302 100644 --- a/cc/config/global.go +++ b/cc/config/global.go @@ -124,7 +124,7 @@ func init() { // This is used by non-NDK modules to get jni.h. export_include_dirs doesn't help // with this, since there is no associated library. pctx.PrefixedExistentPathsForSourcesVariable("CommonNativehelperInclude", "-I", - []string{"libnativehelper/include/nativehelper"}) + []string{"libnativehelper/include_deprecated"}) pctx.SourcePathVariable("ClangDefaultBase", ClangDefaultBase) pctx.VariableFunc("ClangBase", func(config interface{}) (string, error) { diff --git a/cc/installer.go b/cc/installer.go index 112a7ea6..7bedc564 100644 --- a/cc/installer.go +++ b/cc/installer.go @@ -48,6 +48,7 @@ type baseInstaller struct { dir string dir64 string + subDir string relative string location installLocation @@ -61,17 +62,17 @@ func (installer *baseInstaller) installerProps() []interface{} { } func (installer *baseInstaller) installDir(ctx ModuleContext) android.OutputPath { - subDir := installer.dir + dir := installer.dir if ctx.toolchain().Is64Bit() && installer.dir64 != "" { - subDir = installer.dir64 + dir = installer.dir64 } if !ctx.Host() && !ctx.Arch().Native { - subDir = filepath.Join(subDir, ctx.Arch().ArchType.String()) + dir = filepath.Join(dir, ctx.Arch().ArchType.String()) } if installer.location == InstallInData && ctx.vndk() { - subDir = filepath.Join(subDir, "vendor") + dir = filepath.Join(dir, "vendor") } - return android.PathForModuleInstall(ctx, subDir, installer.Properties.Relative_install_path, installer.relative) + return android.PathForModuleInstall(ctx, dir, installer.subDir, installer.Properties.Relative_install_path, installer.relative) } func (installer *baseInstaller) install(ctx ModuleContext, file android.Path) { diff --git a/cc/library.go b/cc/library.go index c7c11426..3d463bdb 100644 --- a/cc/library.go +++ b/cc/library.go @@ -156,7 +156,7 @@ type flagExporter struct { } func (f *flagExporter) exportedIncludes(ctx ModuleContext) android.Paths { - if ctx.Vendor() && f.Properties.Target.Vendor.Export_include_dirs != nil { + if ctx.vndk() && f.Properties.Target.Vendor.Export_include_dirs != nil { return android.PathsForModuleSrc(ctx, f.Properties.Target.Vendor.Export_include_dirs) } else { return android.PathsForModuleSrc(ctx, f.Properties.Export_include_dirs) @@ -351,7 +351,7 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa } return Objects{} } - if (ctx.createVndkSourceAbiDump() || (library.sabi.Properties.CreateSAbiDumps && ctx.Device())) && !ctx.Vendor() { + if ctx.createVndkSourceAbiDump() { exportIncludeDirs := android.PathsForModuleSrc(ctx, library.flagExporter.Properties.Export_include_dirs) var SourceAbiFlags []string for _, dir := range exportIncludeDirs.Strings() { @@ -596,7 +596,7 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext, func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objects, fileName string, soFile android.Path) { //Also take into account object re-use. - if len(objs.sAbiDumpFiles) > 0 && ctx.createVndkSourceAbiDump() && !ctx.Vendor() { + if len(objs.sAbiDumpFiles) > 0 && ctx.createVndkSourceAbiDump() { refSourceDumpFile := android.PathForVndkRefAbiDump(ctx, "current", fileName, vndkVsNdk(ctx), true) versionScript := android.OptionalPathForModuleSrc(ctx, library.Properties.Version_script) var symbolFile android.OptionalPath @@ -699,6 +699,15 @@ func (library *libraryDecorator) toc() android.OptionalPath { func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) { if library.shared() { + if ctx.Device() { + if ctx.vndk() { + if ctx.isVndkSp() { + library.baseInstaller.subDir = "vndk-sp" + } else if ctx.isVndk() { + library.baseInstaller.subDir = "vndk" + } + } + } library.baseInstaller.install(ctx, file) } } diff --git a/cc/makevars.go b/cc/makevars.go index 11c31622..294f3e65 100644 --- a/cc/makevars.go +++ b/cc/makevars.go @@ -82,6 +82,16 @@ func makeVarsProvider(ctx android.MakeVarsContext) { ctx.Strict("RS_GLOBAL_INCLUDES", "${config.RsGlobalIncludes}") + nativeHelperIncludeFlags, err := ctx.Eval("${config.CommonNativehelperInclude}") + if err != nil { + panic(err) + } + nativeHelperIncludes, nativeHelperSystemIncludes := splitSystemIncludes(ctx, nativeHelperIncludeFlags) + if len(nativeHelperSystemIncludes) > 0 { + panic("native helper may not have any system includes") + } + ctx.Strict("JNI_H_INCLUDE", strings.Join(nativeHelperIncludes, " ")) + includeFlags, err := ctx.Eval("${config.CommonGlobalIncludes}") if err != nil { panic(err) @@ -72,7 +72,7 @@ func (sabimod *sabi) flags(ctx ModuleContext, flags Flags) Flags { func sabiDepsMutator(mctx android.TopDownMutatorContext) { if c, ok := mctx.Module().(*Module); ok && - (Bool(c.Properties.Vendor_available) || (inList(c.Name(), config.LLndkLibraries())) || + (c.isVndk() || inList(c.Name(), config.LLndkLibraries()) || (c.sabi != nil && c.sabi.Properties.CreateSAbiDumps)) { mctx.VisitDirectDeps(func(m blueprint.Module) { tag := mctx.OtherModuleDependencyTag(m) diff --git a/cc/sanitize.go b/cc/sanitize.go index 49bd0f31..eccd2558 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -188,7 +188,9 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) { } if found, globalSanitizers = removeFromList("integer_overflow", globalSanitizers); found && s.Integer_overflow == nil { - s.Integer_overflow = boolPtr(true) + if !ctx.AConfig().IntegerOverflowDisabledForPath(ctx.ModuleDir()) { + s.Integer_overflow = boolPtr(true) + } } if len(globalSanitizers) > 0 { @@ -298,6 +298,10 @@ func NewTestLibrary(hod android.HostOrDeviceSupported) *Module { } type BenchmarkProperties struct { + // list of files or filegroup modules that provide data that should be installed alongside + // the test + Data []string + // list of compatibility suites (for example "cts", "vts") that the module should be // installed into. Test_suites []string @@ -306,6 +310,7 @@ type BenchmarkProperties struct { type benchmarkDecorator struct { *binaryDecorator Properties BenchmarkProperties + data android.Paths } func (benchmark *benchmarkDecorator) linkerInit(ctx BaseModuleContext) { @@ -324,12 +329,14 @@ func (benchmark *benchmarkDecorator) linkerProps() []interface{} { } func (benchmark *benchmarkDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps { + android.ExtractSourcesDeps(ctx, benchmark.Properties.Data) deps = benchmark.binaryDecorator.linkerDeps(ctx, deps) deps.StaticLibs = append(deps.StaticLibs, "libgoogle-benchmark") return deps } func (benchmark *benchmarkDecorator) install(ctx ModuleContext, file android.Path) { + benchmark.data = ctx.ExpandSources(benchmark.Properties.Data, nil) benchmark.binaryDecorator.baseInstaller.dir = filepath.Join("nativetest", ctx.ModuleName()) benchmark.binaryDecorator.baseInstaller.dir64 = filepath.Join("nativetest64", ctx.ModuleName()) benchmark.binaryDecorator.baseInstaller.install(ctx, file) diff --git a/cc/test_data_test.go b/cc/test_data_test.go index a798919f..962bde5b 100644 --- a/cc/test_data_test.go +++ b/cc/test_data_test.go @@ -23,8 +23,6 @@ import ( "android/soong/android" "android/soong/genrule" - - "github.com/google/blueprint" ) type dataFile struct { @@ -123,8 +121,7 @@ func TestDataTests(t *testing.T) { for _, test := range testDataTests { t.Run(test.name, func(t *testing.T) { - ctx := blueprint.NewContext() - android.RegisterTestMutators(ctx) + ctx := android.NewTestContext() ctx.MockFileSystem(map[string][]byte{ "Blueprints": []byte(`subdirs = ["dir"]`), "dir/Blueprints": []byte(test.modules), @@ -135,18 +132,16 @@ func TestDataTests(t *testing.T) { android.ModuleFactoryAdaptor(genrule.FileGroupFactory)) ctx.RegisterModuleType("test", android.ModuleFactoryAdaptor(newTest)) + ctx.Register() _, errs := ctx.ParseBlueprintsFiles("Blueprints") fail(t, errs) _, errs = ctx.PrepareBuildActions(config) fail(t, errs) - foo := findModule(ctx, "foo") - if foo == nil { - t.Fatalf("failed to find module foo") - } + foo := ctx.ModuleForTests("foo", "") - got := foo.(*testDataTest).data + got := foo.Module().(*testDataTest).data if len(got) != len(test.data) { t.Errorf("expected %d data files, got %d", len(test.data), len(got)) @@ -192,16 +187,6 @@ func (test *testDataTest) GenerateAndroidBuildActions(ctx android.ModuleContext) test.data = ctx.ExpandSources(test.Properties.Data, nil) } -func findModule(ctx *blueprint.Context, name string) blueprint.Module { - var ret blueprint.Module - ctx.VisitAllModules(func(m blueprint.Module) { - if ctx.ModuleName(m) == name { - ret = m - } - }) - return ret -} - func fail(t *testing.T, errs []error) { if len(errs) > 0 { for _, err := range errs { diff --git a/cc/vndk.go b/cc/vndk.go new file mode 100644 index 00000000..fd1bdcb5 --- /dev/null +++ b/cc/vndk.go @@ -0,0 +1,98 @@ +// Copyright 2017 Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cc + +import ( + "android/soong/android" +) + +type VndkProperties struct { + Vndk struct { + // declared as a VNDK or VNDK-SP module. The vendor variant + // will be installed in /system instead of /vendor partition. + // + // `vendor_available: true` must set to together for VNDK + // modules. + Enabled *bool + + // declared as a VNDK-SP module, which is a subset of VNDK. + // + // `vndk: { enabled: true }` must set together. + // + // All these modules are allowed to link to VNDK-SP or LL-NDK + // modules only. Other dependency will cause link-type errors. + // + // If `support_system_process` is not set or set to false, + // the module is VNDK-core and can link to other VNDK-core, + // VNDK-SP or LL-NDK modules only. + Support_system_process *bool + } +} + +type vndkdep struct { + Properties VndkProperties +} + +func (vndk *vndkdep) props() []interface{} { + return []interface{}{&vndk.Properties} +} + +func (vndk *vndkdep) begin(ctx BaseModuleContext) {} + +func (vndk *vndkdep) deps(ctx BaseModuleContext, deps Deps) Deps { + return deps +} + +func (vndk *vndkdep) isVndk() bool { + return Bool(vndk.Properties.Vndk.Enabled) +} + +func (vndk *vndkdep) isVndkSp() bool { + return Bool(vndk.Properties.Vndk.Support_system_process) +} + +func (vndk *vndkdep) typeName() string { + if !vndk.isVndk() { + return "native:vendor" + } + if !vndk.isVndkSp() { + return "native:vendor:vndk" + } + return "native:vendor:vndksp" +} + +func (vndk *vndkdep) vndkCheckLinkType(ctx android.ModuleContext, to *Module) { + if to.linker == nil { + return + } + if lib, ok := to.linker.(*libraryDecorator); !ok || !lib.shared() { + // Check only shared libraries. + // Other (static and LL-NDK) libraries are allowed to link. + return + } + if !to.Properties.UseVndk { + ctx.ModuleErrorf("(%s) should not link to %q which is not a vendor-available library", + vndk.typeName(), to.Name()) + return + } + if to.vndkdep == nil { + return + } + if (vndk.isVndk() && !to.vndkdep.isVndk()) || (vndk.isVndkSp() && !to.vndkdep.isVndkSp()) { + ctx.ModuleErrorf("(%s) should not link to %q(%s)", + vndk.typeName(), to.Name(), to.vndkdep.typeName()) + return + } +} |