diff options
| -rw-r--r-- | OWNERS | 2 | ||||
| -rw-r--r-- | android/arch.go | 36 | ||||
| -rw-r--r-- | android/config.go | 2 | ||||
| -rw-r--r-- | apex/apex.go | 8 | ||||
| -rw-r--r-- | cc/cc.go | 21 | ||||
| -rw-r--r-- | cc/config/global.go | 4 | ||||
| -rw-r--r-- | cc/config/x86_64_device.go | 2 | ||||
| -rw-r--r-- | cc/prebuilt.go | 8 | ||||
| -rw-r--r-- | cc/sanitize.go | 295 | ||||
| -rw-r--r-- | java/sdk_library.go | 75 | ||||
| -rw-r--r-- | ui/build/paths/config.go | 6 |
11 files changed, 244 insertions, 215 deletions
@@ -1,4 +1,4 @@ -per-file * = ccross@android.com,dwillemsen@google.com,nanzhang@google.com,jungjw@google.com +per-file * = ccross@android.com,dwillemsen@google.com,jungjw@google.com per-file ndk_*.go, *gen_stub_libs.py = danalbert@google.com per-file clang.go,global.go = srhines@google.com, chh@google.com, pirama@google.com, yikong@google.com per-file tidy.go = srhines@google.com, chh@google.com diff --git a/android/arch.go b/android/arch.go index bee09b02d..e8d9c6eeb 100644 --- a/android/arch.go +++ b/android/arch.go @@ -106,6 +106,7 @@ module { var archVariants = map[ArchType][]string{} var archFeatures = map[ArchType][]string{} var archFeatureMap = map[ArchType]map[string][]string{} +var defaultArchFeatureMap = map[OsType]map[ArchType][]string{} func RegisterArchVariants(arch ArchType, variants ...string) { checkCalledFromInit() @@ -117,9 +118,24 @@ func RegisterArchFeatures(arch ArchType, features ...string) { archFeatures[arch] = append(archFeatures[arch], features...) } +func RegisterDefaultArchVariantFeatures(os OsType, arch ArchType, features ...string) { + checkCalledFromInit() + + for _, feature := range features { + if !InList(feature, archFeatures[arch]) { + panic(fmt.Errorf("Invalid feature %q for arch %q variant \"\"", feature, arch)) + } + } + + if defaultArchFeatureMap[os] == nil { + defaultArchFeatureMap[os] = make(map[ArchType][]string) + } + defaultArchFeatureMap[os][arch] = features +} + func RegisterArchVariantFeatures(arch ArchType, variant string, features ...string) { checkCalledFromInit() - if variant != "" && !InList(variant, archVariants[arch]) { + if !InList(variant, archVariants[arch]) { panic(fmt.Errorf("Invalid variant %q for arch %q", variant, arch)) } @@ -952,7 +968,7 @@ func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) { return } - arch, err := decodeArch(archName, archVariant, cpuVariant, abi) + arch, err := decodeArch(os, archName, archVariant, cpuVariant, abi) if err != nil { targetErr = err return @@ -1127,11 +1143,11 @@ func getNdkAbisConfig() []archConfig { } } -func decodeArchSettings(archConfigs []archConfig) ([]Target, error) { +func decodeArchSettings(os OsType, archConfigs []archConfig) ([]Target, error) { var ret []Target for _, config := range archConfigs { - arch, err := decodeArch(config.arch, &config.archVariant, + arch, err := decodeArch(os, config.arch, &config.archVariant, &config.cpuVariant, &config.abi) if err != nil { return nil, err @@ -1147,7 +1163,7 @@ func decodeArchSettings(archConfigs []archConfig) ([]Target, error) { } // Convert a set of strings from product variables into a single Arch struct -func decodeArch(arch string, archVariant, cpuVariant *string, abi *[]string) (Arch, error) { +func decodeArch(os OsType, arch string, archVariant, cpuVariant *string, abi *[]string) (Arch, error) { stringPtr := func(p *string) string { if p != nil { return *p @@ -1190,8 +1206,14 @@ func decodeArch(arch string, archVariant, cpuVariant *string, abi *[]string) (Ar } } - if featureMap, ok := archFeatureMap[archType]; ok { - a.ArchFeatures = featureMap[a.ArchVariant] + if a.ArchVariant == "" { + if featureMap, ok := defaultArchFeatureMap[os]; ok { + a.ArchFeatures = featureMap[archType] + } + } else { + if featureMap, ok := archFeatureMap[archType]; ok { + a.ArchFeatures = featureMap[a.ArchVariant] + } } return a, nil diff --git a/android/config.go b/android/config.go index f5ea38133..925ca9440 100644 --- a/android/config.go +++ b/android/config.go @@ -303,7 +303,7 @@ func NewConfig(srcDir, buildDir string) (Config, error) { } if archConfig != nil { - androidTargets, err := decodeArchSettings(archConfig) + androidTargets, err := decodeArchSettings(Android, archConfig) if err != nil { return Config{}, err } diff --git a/apex/apex.go b/apex/apex.go index e711c8bb2..62698681b 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -482,6 +482,11 @@ func (a *apexBundle) getImageVariation(config android.DeviceConfig) string { } } +func (a *apexBundle) IsSanitizerEnabled() bool { + // APEX can be mutated for sanitizers + return true +} + func getCopyManifestForNativeLibrary(cc *cc.Module) (fileToCopy android.Path, dirInApex string) { // Decide the APEX-local directory by the multilib of the library // In the future, we may query this to the module. @@ -903,6 +908,9 @@ func (a *apexBundle) androidMkForType(apexType apexPackaging) android.AndroidMkD fmt.Fprintln(w, "include $(BUILD_PHONY_PACKAGE)") for _, fi := range a.filesInfo { + if cc, ok := fi.module.(*cc.Module); ok && cc.Properties.HideFromMake { + continue + } fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)") fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir) fmt.Fprintln(w, "LOCAL_MODULE :=", fi.moduleName) @@ -60,6 +60,7 @@ func init() { ctx.BottomUp("tsan", sanitizerMutator(tsan)).Parallel() ctx.TopDown("sanitize_runtime_deps", sanitizerRuntimeDepsMutator) + ctx.BottomUp("sanitize_runtime", sanitizerRuntimeMutator).Parallel() ctx.BottomUp("coverage", coverageLinkingMutator).Parallel() ctx.TopDown("vndk_deps", sabiDepsMutator) @@ -524,6 +525,8 @@ func (c *Module) onlyInRecovery() bool { func (c *Module) IsStubs() bool { if library, ok := c.linker.(*libraryDecorator); ok { return library.buildStubs() + } else if _, ok := c.linker.(*llndkStubDecorator); ok { + return true } return false } @@ -569,12 +572,7 @@ func (ctx *moduleContextImpl) static() bool { } func (ctx *moduleContextImpl) staticBinary() bool { - if static, ok := ctx.mod.linker.(interface { - staticBinary() bool - }); ok { - return static.staticBinary() - } - return false + return ctx.mod.staticBinary() } func (ctx *moduleContextImpl) useSdk() bool { @@ -891,7 +889,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { } } -func (c *Module) toolchain(ctx BaseModuleContext) config.Toolchain { +func (c *Module) toolchain(ctx android.BaseContext) config.Toolchain { if c.cachedToolchain == nil { c.cachedToolchain = config.FindToolchain(ctx.Os(), ctx.Arch()) } @@ -1708,6 +1706,15 @@ func (c *Module) static() bool { return false } +func (c *Module) staticBinary() bool { + if static, ok := c.linker.(interface { + staticBinary() bool + }); ok { + return static.staticBinary() + } + return false +} + func (c *Module) getMakeLinkType() string { if c.useVndk() { if inList(c.Name(), vndkCoreLibraries) || inList(c.Name(), vndkSpLibraries) || inList(c.Name(), llndkLibraries) { diff --git a/cc/config/global.go b/cc/config/global.go index 13ad27cd5..5d98d67bc 100644 --- a/cc/config/global.go +++ b/cc/config/global.go @@ -120,8 +120,8 @@ var ( // prebuilts/clang default settings. ClangDefaultBase = "prebuilts/clang/host" - ClangDefaultVersion = "clang-r346389b" - ClangDefaultShortVersion = "8.0.6" + ClangDefaultVersion = "clang-r346389c" + ClangDefaultShortVersion = "8.0.7" // Directories with warnings from Android.bp files. WarningAllowedProjects = []string{ diff --git a/cc/config/x86_64_device.go b/cc/config/x86_64_device.go index ff8a6da73..381f7e7d1 100644 --- a/cc/config/x86_64_device.go +++ b/cc/config/x86_64_device.go @@ -81,7 +81,7 @@ func init() { "aes_ni", "avx", "popcnt") - android.RegisterArchVariantFeatures(android.X86_64, "", + android.RegisterDefaultArchVariantFeatures(android.Android, android.X86_64, "ssse3", "sse4", "sse4_1", diff --git a/cc/prebuilt.go b/cc/prebuilt.go index 47994a8ca..ffeeb697b 100644 --- a/cc/prebuilt.go +++ b/cc/prebuilt.go @@ -103,6 +103,10 @@ func (p *prebuiltLibraryLinker) link(ctx ModuleContext, return nil } +func (p *prebuiltLibraryLinker) shared() bool { + return p.libraryDecorator.shared() +} + func prebuiltSharedLibraryFactory() android.Module { module, _ := NewPrebuiltSharedLibrary(android.HostAndDeviceSupported) return module.Init() @@ -121,6 +125,10 @@ func NewPrebuiltSharedLibrary(hod android.HostOrDeviceSupported) (*Module, *libr module.AddProperties(&prebuilt.properties) android.InitPrebuiltModule(module, &prebuilt.properties.Srcs) + + // Prebuilt libraries can be included in APEXes + android.InitApexModule(module) + return module, library } diff --git a/cc/sanitize.go b/cc/sanitize.go index 8d33de53d..d19e54a34 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -16,7 +16,6 @@ package cc import ( "fmt" - "io" "sort" "strings" "sync" @@ -138,18 +137,17 @@ type SanitizeProperties struct { Blacklist *string } `android:"arch_variant"` - SanitizerEnabled bool `blueprint:"mutated"` - SanitizeDep bool `blueprint:"mutated"` - MinimalRuntimeDep bool `blueprint:"mutated"` - UbsanRuntimeDep bool `blueprint:"mutated"` - InSanitizerDir bool `blueprint:"mutated"` + SanitizerEnabled bool `blueprint:"mutated"` + SanitizeDep bool `blueprint:"mutated"` + MinimalRuntimeDep bool `blueprint:"mutated"` + UbsanRuntimeDep bool `blueprint:"mutated"` + InSanitizerDir bool `blueprint:"mutated"` + Sanitizers []string `blueprint:"mutated"` + DiagSanitizers []string `blueprint:"mutated"` } type sanitize struct { Properties SanitizeProperties - - runtimeLibrary string - androidMkRuntimeLibrary string } func init() { @@ -405,46 +403,6 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags { return flags } - var sanitizers []string - var diagSanitizers []string - - if Bool(sanitize.Properties.Sanitize.All_undefined) { - sanitizers = append(sanitizers, "undefined") - } else { - if Bool(sanitize.Properties.Sanitize.Undefined) { - sanitizers = append(sanitizers, - "bool", - "integer-divide-by-zero", - "return", - "returns-nonnull-attribute", - "shift-exponent", - "unreachable", - "vla-bound", - // TODO(danalbert): The following checks currently have compiler performance issues. - //"alignment", - //"bounds", - //"enum", - //"float-cast-overflow", - //"float-divide-by-zero", - //"nonnull-attribute", - //"null", - //"shift-base", - //"signed-integer-overflow", - // TODO(danalbert): Fix UB in libc++'s __tree so we can turn this on. - // https://llvm.org/PR19302 - // http://reviews.llvm.org/D6974 - // "object-size", - ) - } - sanitizers = append(sanitizers, sanitize.Properties.Sanitize.Misc_undefined...) - } - - if Bool(sanitize.Properties.Sanitize.Diag.Undefined) { - diagSanitizers = append(diagSanitizers, "undefined") - } - - diagSanitizers = append(diagSanitizers, sanitize.Properties.Sanitize.Diag.Misc_undefined...) - if Bool(sanitize.Properties.Sanitize.Address) { if ctx.Arch().ArchType == android.Arm { // Frame pointer based unwinder in ASan requires ARM frame setup. @@ -465,34 +423,22 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags { flags.DynamicLinker += "64" } } - sanitizers = append(sanitizers, "address") - diagSanitizers = append(diagSanitizers, "address") } if Bool(sanitize.Properties.Sanitize.Hwaddress) { flags.CFlags = append(flags.CFlags, hwasanCflags...) - sanitizers = append(sanitizers, "hwaddress") - } - - if Bool(sanitize.Properties.Sanitize.Thread) { - sanitizers = append(sanitizers, "thread") } if Bool(sanitize.Properties.Sanitize.Coverage) { flags.CFlags = append(flags.CFlags, "-fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp") } - if Bool(sanitize.Properties.Sanitize.Safestack) { - sanitizers = append(sanitizers, "safe-stack") - } - if Bool(sanitize.Properties.Sanitize.Cfi) { if ctx.Arch().ArchType == android.Arm { // __cfi_check needs to be built as Thumb (see the code in linker_cfi.cpp). LLVM is not set up // to do this on a function basis, so force Thumb on the entire module. flags.RequiredInstructionSet = "thumb" } - sanitizers = append(sanitizers, "cfi") flags.CFlags = append(flags.CFlags, cfiCflags...) flags.AsFlags = append(flags.AsFlags, cfiAsflags...) @@ -502,9 +448,6 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags { flags.CFlags = append(flags.CFlags, "-fvisibility=default") } flags.LdFlags = append(flags.LdFlags, cfiLdflags...) - if Bool(sanitize.Properties.Sanitize.Diag.Cfi) { - diagSanitizers = append(diagSanitizers, "cfi") - } if ctx.staticBinary() { _, flags.CFlags = removeFromList("-fsanitize-cfi-cross-dso", flags.CFlags) @@ -513,25 +456,11 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags { } if Bool(sanitize.Properties.Sanitize.Integer_overflow) { - sanitizers = append(sanitizers, "unsigned-integer-overflow") - sanitizers = append(sanitizers, "signed-integer-overflow") flags.CFlags = append(flags.CFlags, intOverflowCflags...) - if Bool(sanitize.Properties.Sanitize.Diag.Integer_overflow) { - diagSanitizers = append(diagSanitizers, "unsigned-integer-overflow") - diagSanitizers = append(diagSanitizers, "signed-integer-overflow") - } } - if Bool(sanitize.Properties.Sanitize.Scudo) { - sanitizers = append(sanitizers, "scudo") - } - - if Bool(sanitize.Properties.Sanitize.Scs) { - sanitizers = append(sanitizers, "shadow-call-stack") - } - - if len(sanitizers) > 0 { - sanitizeArg := "-fsanitize=" + strings.Join(sanitizers, ",") + if len(sanitize.Properties.Sanitizers) > 0 { + sanitizeArg := "-fsanitize=" + strings.Join(sanitize.Properties.Sanitizers, ",") flags.CFlags = append(flags.CFlags, sanitizeArg) flags.AsFlags = append(flags.AsFlags, sanitizeArg) @@ -556,8 +485,8 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags { } } - if len(diagSanitizers) > 0 { - flags.CFlags = append(flags.CFlags, "-fno-sanitize-trap="+strings.Join(diagSanitizers, ",")) + if len(sanitize.Properties.DiagSanitizers) > 0 { + flags.CFlags = append(flags.CFlags, "-fno-sanitize-trap="+strings.Join(sanitize.Properties.DiagSanitizers, ",")) } // FIXME: enable RTTI if diag + (cfi or vptr) @@ -571,46 +500,6 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags { strings.Join(sanitize.Properties.Sanitize.Diag.No_recover, ",")) } - // Link a runtime library if needed. - runtimeLibrary := "" - if Bool(sanitize.Properties.Sanitize.Address) { - runtimeLibrary = config.AddressSanitizerRuntimeLibrary(ctx.toolchain()) - } else if Bool(sanitize.Properties.Sanitize.Hwaddress) { - runtimeLibrary = config.HWAddressSanitizerRuntimeLibrary(ctx.toolchain()) - } else if Bool(sanitize.Properties.Sanitize.Thread) { - runtimeLibrary = config.ThreadSanitizerRuntimeLibrary(ctx.toolchain()) - } else if Bool(sanitize.Properties.Sanitize.Scudo) { - if len(diagSanitizers) == 0 && !sanitize.Properties.UbsanRuntimeDep { - runtimeLibrary = config.ScudoMinimalRuntimeLibrary(ctx.toolchain()) - } else { - runtimeLibrary = config.ScudoRuntimeLibrary(ctx.toolchain()) - } - } else if len(diagSanitizers) > 0 || sanitize.Properties.UbsanRuntimeDep { - runtimeLibrary = config.UndefinedBehaviorSanitizerRuntimeLibrary(ctx.toolchain()) - } - - if runtimeLibrary != "" { - runtimeLibraryPath := "${config.ClangAsanLibDir}/" + runtimeLibrary - if !ctx.static() { - runtimeLibraryPath = runtimeLibraryPath + ctx.toolchain().ShlibSuffix() - } else { - runtimeLibraryPath = runtimeLibraryPath + ".a" - } - - // ASan runtime library must be the first in the link order. - flags.libFlags = append([]string{runtimeLibraryPath}, flags.libFlags...) - sanitize.runtimeLibrary = runtimeLibrary - - // When linking against VNDK, use the vendor variant of the runtime lib - if ctx.useVndk() { - sanitize.androidMkRuntimeLibrary = sanitize.runtimeLibrary + vendorSuffix - } else if ctx.inRecovery() { - sanitize.androidMkRuntimeLibrary = sanitize.runtimeLibrary + recoverySuffix - } else { - sanitize.androidMkRuntimeLibrary = sanitize.runtimeLibrary - } - } - blacklist := android.OptionalPathForModuleSrc(ctx, sanitize.Properties.Sanitize.Blacklist) if blacklist.Valid() { flags.CFlags = append(flags.CFlags, "-fsanitize-blacklist="+blacklist.String()) @@ -621,12 +510,6 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags { } func (sanitize *sanitize) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { - ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { - if sanitize.androidMkRuntimeLibrary != "" { - fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES += "+sanitize.androidMkRuntimeLibrary) - } - }) - // Add a suffix for CFI-enabled static libraries to allow surfacing both to make without a // name conflict. if ret.Class == "STATIC_LIBRARIES" && Bool(sanitize.Properties.Sanitize.Cfi) { @@ -782,6 +665,159 @@ func sanitizerRuntimeDepsMutator(mctx android.TopDownMutatorContext) { } } +// Add the dependency to the runtime library for each of the sanitizer variants +func sanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) { + if mctx.Os() != android.Android { + return + } + if c, ok := mctx.Module().(*Module); ok && c.sanitize != nil { + var sanitizers []string + var diagSanitizers []string + + if Bool(c.sanitize.Properties.Sanitize.All_undefined) { + sanitizers = append(sanitizers, "undefined") + } else { + if Bool(c.sanitize.Properties.Sanitize.Undefined) { + sanitizers = append(sanitizers, + "bool", + "integer-divide-by-zero", + "return", + "returns-nonnull-attribute", + "shift-exponent", + "unreachable", + "vla-bound", + // TODO(danalbert): The following checks currently have compiler performance issues. + //"alignment", + //"bounds", + //"enum", + //"float-cast-overflow", + //"float-divide-by-zero", + //"nonnull-attribute", + //"null", + //"shift-base", + //"signed-integer-overflow", + // TODO(danalbert): Fix UB in libc++'s __tree so we can turn this on. + // https://llvm.org/PR19302 + // http://reviews.llvm.org/D6974 + // "object-size", + ) + } + sanitizers = append(sanitizers, c.sanitize.Properties.Sanitize.Misc_undefined...) + } + + if Bool(c.sanitize.Properties.Sanitize.Diag.Undefined) { + diagSanitizers = append(diagSanitizers, "undefined") + } + + diagSanitizers = append(diagSanitizers, c.sanitize.Properties.Sanitize.Diag.Misc_undefined...) + + if Bool(c.sanitize.Properties.Sanitize.Address) { + sanitizers = append(sanitizers, "address") + diagSanitizers = append(diagSanitizers, "address") + } + + if Bool(c.sanitize.Properties.Sanitize.Hwaddress) { + sanitizers = append(sanitizers, "hwaddress") + } + + if Bool(c.sanitize.Properties.Sanitize.Thread) { + sanitizers = append(sanitizers, "thread") + } + + if Bool(c.sanitize.Properties.Sanitize.Safestack) { + sanitizers = append(sanitizers, "safe-stack") + } + + if Bool(c.sanitize.Properties.Sanitize.Cfi) { + sanitizers = append(sanitizers, "cfi") + + if Bool(c.sanitize.Properties.Sanitize.Diag.Cfi) { + diagSanitizers = append(diagSanitizers, "cfi") + } + } + + if Bool(c.sanitize.Properties.Sanitize.Integer_overflow) { + sanitizers = append(sanitizers, "unsigned-integer-overflow") + sanitizers = append(sanitizers, "signed-integer-overflow") + if Bool(c.sanitize.Properties.Sanitize.Diag.Integer_overflow) { + diagSanitizers = append(diagSanitizers, "unsigned-integer-overflow") + diagSanitizers = append(diagSanitizers, "signed-integer-overflow") + } + } + + if Bool(c.sanitize.Properties.Sanitize.Scudo) { + sanitizers = append(sanitizers, "scudo") + } + + if Bool(c.sanitize.Properties.Sanitize.Scs) { + sanitizers = append(sanitizers, "shadow-call-stack") + } + + // Save the list of sanitizers. These will be used again when generating + // the build rules (for Cflags, etc.) + c.sanitize.Properties.Sanitizers = sanitizers + c.sanitize.Properties.DiagSanitizers = diagSanitizers + + // Determine the runtime library required + runtimeLibrary := "" + toolchain := c.toolchain(mctx) + if Bool(c.sanitize.Properties.Sanitize.Address) { + runtimeLibrary = config.AddressSanitizerRuntimeLibrary(toolchain) + } else if Bool(c.sanitize.Properties.Sanitize.Hwaddress) { + if c.staticBinary() { + runtimeLibrary = config.HWAddressSanitizerStaticLibrary(toolchain) + } else { + runtimeLibrary = config.HWAddressSanitizerRuntimeLibrary(toolchain) + } + } else if Bool(c.sanitize.Properties.Sanitize.Thread) { + runtimeLibrary = config.ThreadSanitizerRuntimeLibrary(toolchain) + } else if Bool(c.sanitize.Properties.Sanitize.Scudo) { + if len(diagSanitizers) == 0 && !c.sanitize.Properties.UbsanRuntimeDep { + runtimeLibrary = config.ScudoMinimalRuntimeLibrary(toolchain) + } else { + runtimeLibrary = config.ScudoRuntimeLibrary(toolchain) + } + } else if len(diagSanitizers) > 0 || c.sanitize.Properties.UbsanRuntimeDep { + runtimeLibrary = config.UndefinedBehaviorSanitizerRuntimeLibrary(toolchain) + } + + if mctx.Device() && runtimeLibrary != "" { + if inList(runtimeLibrary, llndkLibraries) && !c.static() { + runtimeLibrary = runtimeLibrary + llndkLibrarySuffix + } + + // Adding dependency to the runtime library. We are using *FarVariation* + // because the runtime libraries themselves are not mutated by sanitizer + // mutators and thus don't have sanitizer variants whereas this module + // has been already mutated. + // + // Note that by adding dependency with {static|shared}DepTag, the lib is + // added to libFlags and LOCAL_SHARED_LIBRARIES by cc.Module + if c.staticBinary() { + // static executable gets static runtime libs + mctx.AddFarVariationDependencies([]blueprint.Variation{ + {Mutator: "link", Variation: "static"}, + {Mutator: "arch", Variation: mctx.Target().String()}, + }, staticDepTag, runtimeLibrary) + } else if !c.static() { + // dynamic executable andshared libs get shared runtime libs + mctx.AddFarVariationDependencies([]blueprint.Variation{ + {Mutator: "link", Variation: "shared"}, + {Mutator: "arch", Variation: mctx.Target().String()}, + }, sharedDepTag, runtimeLibrary) + } + // static lib does not have dependency to the runtime library. The + // dependency will be added to the executables or shared libs using + // the static lib. + } + } +} + +type Sanitizeable interface { + android.Module + IsSanitizerEnabled() bool +} + // Create sanitized variants for modules that need them func sanitizerMutator(t sanitizerType) func(android.BottomUpMutatorContext) { return func(mctx android.BottomUpMutatorContext) { @@ -883,6 +919,9 @@ func sanitizerMutator(t sanitizerType) func(android.BottomUpMutatorContext) { } } c.sanitize.Properties.SanitizeDep = false + } else if sanitizeable, ok := mctx.Module().(Sanitizeable); ok && sanitizeable.IsSanitizerEnabled() { + // APEX modules fall here + mctx.CreateVariations(t.String()) } } } diff --git a/java/sdk_library.go b/java/sdk_library.go index 55a959036..941e66594 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -134,11 +134,6 @@ type sdkLibraryProperties struct { // Defaults to "android.annotation". Srcs_lib_whitelist_pkgs []string - // if set to true, create stubs through Metalava instead of Doclava. Javadoc/Doclava is - // currently still used for documentation generation, and will be replaced by Dokka soon. - // Defaults to true. - Metalava_enabled *bool - // TODO: determines whether to create HTML doc or not //Html_doc *bool } @@ -447,9 +442,6 @@ func (module *sdkLibrary) createDocs(mctx android.TopDownMutatorContext, apiScop Local_include_dirs []string } }{} - droiddocProps := struct { - Custom_template *string - }{} props.Name = proptools.StringPtr(module.docsName(apiScope)) props.Srcs = append(props.Srcs, module.properties.Srcs...) @@ -462,25 +454,12 @@ func (module *sdkLibrary) createDocs(mctx android.TopDownMutatorContext, apiScop props.Aidl.Include_dirs = module.deviceProperties.Aidl.Include_dirs props.Aidl.Local_include_dirs = module.deviceProperties.Aidl.Local_include_dirs - if module.properties.Metalava_enabled == nil { - module.properties.Metalava_enabled = proptools.BoolPtr(true) - } - - droiddocArgs := "" - if Bool(module.properties.Metalava_enabled) == true { - droiddocArgs = " --stub-packages " + strings.Join(module.properties.Api_packages, ":") + - " " + android.JoinWithPrefix(module.properties.Hidden_api_packages, " --hide-package ") + - " " + android.JoinWithPrefix(module.properties.Droiddoc_options, " ") + - " --hide MissingPermission --hide BroadcastBehavior " + - "--hide HiddenSuperclass --hide DeprecationMismatch --hide UnavailableSymbol " + - "--hide SdkConstant --hide HiddenTypeParameter --hide Todo --hide Typo" - } else { - droiddocProps.Custom_template = proptools.StringPtr("droiddoc-templates-sdk") - droiddocArgs = " -stubpackages " + strings.Join(module.properties.Api_packages, ":") + - " " + android.JoinWithPrefix(module.properties.Hidden_api_packages, " -hidePackage ") + - " " + android.JoinWithPrefix(module.properties.Droiddoc_options, " ") + - " -hide 110 -hide 111 -hide 113 -hide 121 -hide 125 -hide 126 -hide 127 -hide 128 -nodocs" - } + droiddocArgs := " --stub-packages " + strings.Join(module.properties.Api_packages, ":") + + " " + android.JoinWithPrefix(module.properties.Hidden_api_packages, " --hide-package ") + + " " + android.JoinWithPrefix(module.properties.Droiddoc_options, " ") + + " --hide MissingPermission --hide BroadcastBehavior " + + "--hide HiddenSuperclass --hide DeprecationMismatch --hide UnavailableSymbol " + + "--hide SdkConstant --hide HiddenTypeParameter --hide Todo --hide Typo" switch apiScope { case apiScopeSystem: @@ -519,45 +498,11 @@ func (module *sdkLibrary) createDocs(mctx android.TopDownMutatorContext, apiScop module.latestApiFilegroupName(apiScope)) props.Check_api.Last_released.Removed_api_file = proptools.StringPtr( module.latestRemovedApiFilegroupName(apiScope)) - if Bool(module.properties.Metalava_enabled) == false { - // any change is reported as error - props.Check_api.Current.Args = proptools.StringPtr("-error 2 -error 3 -error 4 -error 5 " + - "-error 6 -error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 " + - "-error 14 -error 15 -error 16 -error 17 -error 18 -error 19 -error 20 " + - "-error 21 -error 23 -error 24 -error 25 -error 26 -error 27") - - // backward incompatible changes are reported as error - props.Check_api.Last_released.Args = proptools.StringPtr("-hide 2 -hide 3 -hide 4 -hide 5 " + - "-hide 6 -hide 24 -hide 25 -hide 26 -hide 27 " + - "-error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 " + - "-error 15 -error 16 -error 17 -error 18") - - // Include the part of the framework source. This is required for the case when - // API class is extending from the framework class. In that case, doclava needs - // to know whether the base class is hidden or not. Since that information is - // encoded as @hide string in the comment, we need source files for the classes, - // not the compiled ones. - props.Srcs_lib = proptools.StringPtr("framework") - props.Srcs_lib_whitelist_dirs = []string{"core/java"} - - // Add android.annotation package to give access to the framework-defined - // annotations such as SystemApi, NonNull, etc. - if module.properties.Srcs_lib_whitelist_pkgs != nil { - props.Srcs_lib_whitelist_pkgs = module.properties.Srcs_lib_whitelist_pkgs - } else { - props.Srcs_lib_whitelist_pkgs = []string{"android.annotation"} - } - } else { - props.Srcs_lib = module.properties.Srcs_lib - props.Srcs_lib_whitelist_dirs = module.properties.Srcs_lib_whitelist_dirs - props.Srcs_lib_whitelist_pkgs = module.properties.Srcs_lib_whitelist_pkgs - } + props.Srcs_lib = module.properties.Srcs_lib + props.Srcs_lib_whitelist_dirs = module.properties.Srcs_lib_whitelist_dirs + props.Srcs_lib_whitelist_pkgs = module.properties.Srcs_lib_whitelist_pkgs - if Bool(module.properties.Metalava_enabled) == true { - mctx.CreateModule(android.ModuleFactoryAdaptor(DroidstubsFactory), &props) - } else { - mctx.CreateModule(android.ModuleFactoryAdaptor(DroiddocFactory), &props, &droiddocProps) - } + mctx.CreateModule(android.ModuleFactoryAdaptor(DroidstubsFactory), &props) } // Creates the runtime library. This is not directly linkable from other modules. diff --git a/ui/build/paths/config.go b/ui/build/paths/config.go index fdd291ea9..f4ef03427 100644 --- a/ui/build/paths/config.go +++ b/ui/build/paths/config.go @@ -107,7 +107,6 @@ var Configuration = map[string]PathConfig{ "python": Allowed, "python2.7": Allowed, "python3": Allowed, - "readlink": Allowed, "realpath": Allowed, "rm": Allowed, "rsync": Allowed, @@ -116,14 +115,12 @@ var Configuration = map[string]PathConfig{ "sha1sum": Allowed, "sha256sum": Allowed, "sha512sum": Allowed, - "sort": Allowed, "tar": Allowed, "timeout": Allowed, "tr": Allowed, "unzip": Allowed, "wc": Allowed, "which": Allowed, - "xargs": Allowed, "xz": Allowed, "zip": Allowed, "zipinfo": Allowed, @@ -164,9 +161,11 @@ var Configuration = map[string]PathConfig{ "od": Toybox, "paste": Toybox, "pwd": Toybox, + "readlink": Toybox, "rmdir": Toybox, "setsid": Toybox, "sleep": Toybox, + "sort": Toybox, "stat": Toybox, "tail": Toybox, "tee": Toybox, @@ -176,6 +175,7 @@ var Configuration = map[string]PathConfig{ "uniq": Toybox, "unix2dos": Toybox, "whoami": Toybox, + "xargs": Toybox, "xxd": Toybox, } |