diff options
Diffstat (limited to 'cc/cc.go')
-rw-r--r-- | cc/cc.go | 63 |
1 files changed, 52 insertions, 11 deletions
@@ -221,6 +221,7 @@ type Flags struct { SystemIncludeFlags []string Toolchain config.Toolchain + Sdclang bool Tidy bool // True if clang-tidy is enabled. GcovCoverage bool // True if coverage files should be generated. SAbiDump bool // True if header abi dumps should be generated. @@ -252,6 +253,9 @@ type BaseProperties struct { // Deprecated. true is the default, false is invalid. Clang *bool `android:"arch_variant"` + // compile module with SDLLVM instead of AOSP LLVM + Sdclang *bool `android:"arch_variant"` + // The API level that this module is built against. The APIs of this API level will be // visible at build time, but use of any APIs newer than min_sdk_version will render the // module unloadable on older devices. In the future it will be possible to weakly-link new @@ -299,10 +303,6 @@ type BaseProperties struct { Logtags []string // Make this module available when building for ramdisk. - // On device without a dedicated recovery partition, the module is only - // available after switching root into - // /first_stage_ramdisk. To expose the module before switching root, install - // the recovery variant instead. Ramdisk_available *bool // Make this module available when building for vendor ramdisk. @@ -332,6 +332,7 @@ type BaseProperties struct { // Used by vendor snapshot to record dependencies from snapshot modules. SnapshotSharedLibs []string `blueprint:"mutated"` + SnapshotStaticLibs []string `blueprint:"mutated"` SnapshotRuntimeLibs []string `blueprint:"mutated"` Installable *bool @@ -360,6 +361,13 @@ type BaseProperties struct { // framework module from the recovery snapshot. Exclude_from_recovery_snapshot *bool + // Normally Soong uses the directory structure to decide which modules + // should be included (framework) or excluded (non-framework) from the + // different snapshots (vendor, recovery, etc.), but this property + // allows a partner to exclude a module normally thought of as a + // framework module from the ramdisk snapshot. + Exclude_from_ramdisk_snapshot *bool + // List of APEXes that this module has private access to for testing purpose. The module // can depend on libraries that are not exported by the APEXes and use private symbols // from the exported libraries. @@ -1282,6 +1290,10 @@ func (c *Module) ExcludeFromRecoverySnapshot() bool { return Bool(c.Properties.Exclude_from_recovery_snapshot) } +func (c *Module) ExcludeFromRamdiskSnapshot() bool { + return Bool(c.Properties.Exclude_from_ramdisk_snapshot) +} + func isBionic(name string) bool { switch name { case "libc", "libm", "libdl", "libdl_android", "linker", "linkerconfig": @@ -1698,6 +1710,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { flags := Flags{ Toolchain: c.toolchain(ctx), EmitXrefs: ctx.Config().EmitXrefRules(), + Sdclang: c.sdclang(ctx), } if c.compiler != nil { flags = c.compiler.compilerFlags(ctx, flags, deps) @@ -1788,7 +1801,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { } // glob exported headers for snapshot, if BOARD_VNDK_VERSION is current or - // RECOVERY_SNAPSHOT_VERSION is current. + // RECOVERY_SNAPSHOT_VERSION is current or RAMDISK_SNAPSHOT_VERSION is current. if i, ok := c.linker.(snapshotLibraryInterface); ok { if ShouldCollectHeadersForSnapshot(ctx, c, apexInfo) { i.collectHeadersForSnapshot(ctx) @@ -2022,9 +2035,9 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { var snapshotInfo *SnapshotInfo getSnapshot := func() SnapshotInfo { - // Only modules with BOARD_VNDK_VERSION uses snapshot. Others use the zero value of + // Only device modules with BOARD_VNDK_VERSION uses snapshot. Others use the zero value of // SnapshotInfo, which provides no mappings. - if snapshotInfo == nil { + if snapshotInfo == nil && c.Device() { // Only retrieve the snapshot on demand in order to avoid circular dependencies // between the modules in the snapshot and the snapshot itself. var snapshotModule []blueprint.Module @@ -2032,17 +2045,19 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { snapshotModule = ctx.AddVariationDependencies(nil, nil, "vendor_snapshot") } else if recoverySnapshotVersion := actx.DeviceConfig().RecoverySnapshotVersion(); recoverySnapshotVersion != "current" && recoverySnapshotVersion != "" && c.InRecovery() { snapshotModule = ctx.AddVariationDependencies(nil, nil, "recovery_snapshot") + } else if ramdiskSnapshotVersion := actx.DeviceConfig().RamdiskSnapshotVersion(); ramdiskSnapshotVersion != "current" && ramdiskSnapshotVersion != "" && c.InRamdisk() { + snapshotModule = ctx.AddVariationDependencies(nil, nil, "ramdisk_snapshot") } - if len(snapshotModule) > 0 { + if len(snapshotModule) > 0 && snapshotModule[0] != nil { snapshot := ctx.OtherModuleProvider(snapshotModule[0], SnapshotInfoProvider).(SnapshotInfo) snapshotInfo = &snapshot // republish the snapshot for use in later mutators on this module ctx.SetProvider(SnapshotInfoProvider, snapshot) - } else { - snapshotInfo = &SnapshotInfo{} } } - + if snapshotInfo == nil { + snapshotInfo = &SnapshotInfo{} + } return *snapshotInfo } @@ -2080,6 +2095,8 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { name, _ := StubsLibNameAndVersion(entry) if c.InRecovery() { nonvariantLibs = append(nonvariantLibs, rewriteSnapshotLib(entry, getSnapshot().SharedLibs)) + } else if c.InRamdisk() { + nonvariantLibs = append(nonvariantLibs, rewriteSnapshotLib(entry, getSnapshot().SharedLibs)) } else if ctx.useSdk() && inList(name, *getNDKKnownLibs(ctx.Config())) { variantLibs = append(variantLibs, name+ndkLibrarySuffix) } else if ctx.useVndk() { @@ -2477,6 +2494,21 @@ func checkDoubleLoadableLibraries(ctx android.TopDownMutatorContext) { } } +func (c *Module) sdclang(ctx BaseModuleContext) bool { + sdclang := Bool(c.Properties.Sdclang) + + // SDLLVM is not for host build + if ctx.Host() || config.ForceSDClangOff { + return false + } + + if c.Properties.Sdclang == nil && config.SDClang { + return true + } + + return sdclang +} + // Convert dependencies to paths. Returns a PathDeps containing paths func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { var depPaths PathDeps @@ -2850,6 +2882,8 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { c.Properties.AndroidMkStaticLibs = append( c.Properties.AndroidMkStaticLibs, makeLibName) } + // Record BaseLibName for snapshots. + c.Properties.SnapshotStaticLibs = append(c.Properties.SnapshotStaticLibs, baseLibName(depName)) } } else if !c.IsStubs() { // Stubs lib doesn't link to the runtime lib, object, crt, etc. dependencies. @@ -3079,6 +3113,13 @@ func (c *Module) Binary() bool { return false } +func (c *Module) StaticExecutable() bool { + if b, ok := c.linker.(*binaryDecorator); ok { + return b.static() + } + return false +} + func (c *Module) Object() bool { if o, ok := c.linker.(interface { object() bool |