Loading cc/binary_sdk_member.go +25 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import ( "android/soong/android" "github.com/google/blueprint" "github.com/google/blueprint/proptools" ) func init() { Loading Loading @@ -65,7 +66,15 @@ func (mt *binarySdkMemberType) IsInstance(module android.Module) bool { } func (mt *binarySdkMemberType) AddPrebuiltModule(ctx android.SdkMemberContext, member android.SdkMember) android.BpModule { return ctx.SnapshotBuilder().AddPrebuiltModule(member, "cc_prebuilt_binary") pbm := ctx.SnapshotBuilder().AddPrebuiltModule(member, "cc_prebuilt_binary") ccModule := member.Variants()[0].(*Module) if stl := ccModule.stl.Properties.Stl; stl != nil { pbm.AddProperty("stl", proptools.String(stl)) } return pbm } func (mt *binarySdkMemberType) CreateVariantPropertiesStruct() android.SdkMemberProperties { Loading Loading @@ -105,6 +114,10 @@ type nativeBinaryInfoProperties struct { // // This field is exported as its contents may not be arch specific. SystemSharedLibs []string // Arch specific flags. StaticExecutable bool Nocrt bool } func (p *nativeBinaryInfoProperties) PopulateFromVariant(ctx android.SdkMemberContext, variant android.Module) { Loading @@ -113,6 +126,10 @@ func (p *nativeBinaryInfoProperties) PopulateFromVariant(ctx android.SdkMemberCo p.archType = ccModule.Target().Arch.ArchType.String() p.outputFile = getRequiredMemberOutputFile(ctx, ccModule) binaryLinker := ccModule.linker.(*binaryDecorator) p.StaticExecutable = binaryLinker.static() p.Nocrt = Bool(binaryLinker.baseLinker.Properties.Nocrt) if ccModule.linker != nil { specifiedDeps := specifiedDeps{} specifiedDeps = ccModule.linker.linkerSpecifiedDeps(specifiedDeps) Loading Loading @@ -143,4 +160,11 @@ func (p *nativeBinaryInfoProperties) AddToPropertySet(ctx android.SdkMemberConte if p.SystemSharedLibs != nil { propertySet.AddPropertyWithTag("system_shared_libs", p.SystemSharedLibs, builder.SdkMemberReferencePropertyTag(false)) } if p.StaticExecutable { propertySet.AddProperty("static_executable", p.StaticExecutable) } if p.Nocrt { propertySet.AddProperty("nocrt", p.Nocrt) } } sdk/cc_sdk_test.go +86 −1 Original line number Diff line number Diff line Loading @@ -401,7 +401,6 @@ func TestSnapshotWithCcBinary(t *testing.T) { "Test.cpp", ], compile_multilib: "both", stl: "none", } `) Loading Loading @@ -494,6 +493,7 @@ cc_prebuilt_binary { device_supported: false, host_supported: true, installable: false, stl: "none", target: { linux_glibc: { compile_multilib: "both", Loading @@ -518,6 +518,7 @@ cc_prebuilt_binary { prefer: false, device_supported: false, host_supported: true, stl: "none", target: { linux_glibc: { compile_multilib: "both", Loading Loading @@ -557,6 +558,90 @@ module_exports_snapshot { ) } // Test that we support the necessary flags for the linker binary, which is // special in several ways. func TestSnapshotWithCcStaticNocrtBinary(t *testing.T) { // b/145598135 - Generating host snapshots for anything other than linux is not supported. SkipIfNotLinux(t) result := testSdkWithCc(t, ` module_exports { name: "mymodule_exports", host_supported: true, device_supported: false, native_binaries: ["linker"], } cc_binary { name: "linker", host_supported: true, static_executable: true, nocrt: true, stl: "none", srcs: [ "Test.cpp", ], compile_multilib: "both", } `) result.CheckSnapshot("mymodule_exports", "", checkAndroidBpContents(` // This is auto-generated. DO NOT EDIT. cc_prebuilt_binary { name: "mymodule_exports_linker@current", sdk_member_name: "linker", device_supported: false, host_supported: true, installable: false, stl: "none", static_executable: true, nocrt: true, compile_multilib: "both", arch: { x86_64: { srcs: ["x86_64/bin/linker"], }, x86: { srcs: ["x86/bin/linker"], }, }, } cc_prebuilt_binary { name: "linker", prefer: false, device_supported: false, host_supported: true, stl: "none", static_executable: true, nocrt: true, compile_multilib: "both", arch: { x86_64: { srcs: ["x86_64/bin/linker"], }, x86: { srcs: ["x86/bin/linker"], }, }, } module_exports_snapshot { name: "mymodule_exports@current", device_supported: false, host_supported: true, native_binaries: ["mymodule_exports_linker@current"], } `), checkAllCopyRules(` .intermediates/linker/linux_glibc_x86_64/linker -> x86_64/bin/linker .intermediates/linker/linux_glibc_x86/linker -> x86/bin/linker `), ) } func TestSnapshotWithCcSharedLibrary(t *testing.T) { result := testSdkWithCc(t, ` sdk { Loading Loading
cc/binary_sdk_member.go +25 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import ( "android/soong/android" "github.com/google/blueprint" "github.com/google/blueprint/proptools" ) func init() { Loading Loading @@ -65,7 +66,15 @@ func (mt *binarySdkMemberType) IsInstance(module android.Module) bool { } func (mt *binarySdkMemberType) AddPrebuiltModule(ctx android.SdkMemberContext, member android.SdkMember) android.BpModule { return ctx.SnapshotBuilder().AddPrebuiltModule(member, "cc_prebuilt_binary") pbm := ctx.SnapshotBuilder().AddPrebuiltModule(member, "cc_prebuilt_binary") ccModule := member.Variants()[0].(*Module) if stl := ccModule.stl.Properties.Stl; stl != nil { pbm.AddProperty("stl", proptools.String(stl)) } return pbm } func (mt *binarySdkMemberType) CreateVariantPropertiesStruct() android.SdkMemberProperties { Loading Loading @@ -105,6 +114,10 @@ type nativeBinaryInfoProperties struct { // // This field is exported as its contents may not be arch specific. SystemSharedLibs []string // Arch specific flags. StaticExecutable bool Nocrt bool } func (p *nativeBinaryInfoProperties) PopulateFromVariant(ctx android.SdkMemberContext, variant android.Module) { Loading @@ -113,6 +126,10 @@ func (p *nativeBinaryInfoProperties) PopulateFromVariant(ctx android.SdkMemberCo p.archType = ccModule.Target().Arch.ArchType.String() p.outputFile = getRequiredMemberOutputFile(ctx, ccModule) binaryLinker := ccModule.linker.(*binaryDecorator) p.StaticExecutable = binaryLinker.static() p.Nocrt = Bool(binaryLinker.baseLinker.Properties.Nocrt) if ccModule.linker != nil { specifiedDeps := specifiedDeps{} specifiedDeps = ccModule.linker.linkerSpecifiedDeps(specifiedDeps) Loading Loading @@ -143,4 +160,11 @@ func (p *nativeBinaryInfoProperties) AddToPropertySet(ctx android.SdkMemberConte if p.SystemSharedLibs != nil { propertySet.AddPropertyWithTag("system_shared_libs", p.SystemSharedLibs, builder.SdkMemberReferencePropertyTag(false)) } if p.StaticExecutable { propertySet.AddProperty("static_executable", p.StaticExecutable) } if p.Nocrt { propertySet.AddProperty("nocrt", p.Nocrt) } }
sdk/cc_sdk_test.go +86 −1 Original line number Diff line number Diff line Loading @@ -401,7 +401,6 @@ func TestSnapshotWithCcBinary(t *testing.T) { "Test.cpp", ], compile_multilib: "both", stl: "none", } `) Loading Loading @@ -494,6 +493,7 @@ cc_prebuilt_binary { device_supported: false, host_supported: true, installable: false, stl: "none", target: { linux_glibc: { compile_multilib: "both", Loading @@ -518,6 +518,7 @@ cc_prebuilt_binary { prefer: false, device_supported: false, host_supported: true, stl: "none", target: { linux_glibc: { compile_multilib: "both", Loading Loading @@ -557,6 +558,90 @@ module_exports_snapshot { ) } // Test that we support the necessary flags for the linker binary, which is // special in several ways. func TestSnapshotWithCcStaticNocrtBinary(t *testing.T) { // b/145598135 - Generating host snapshots for anything other than linux is not supported. SkipIfNotLinux(t) result := testSdkWithCc(t, ` module_exports { name: "mymodule_exports", host_supported: true, device_supported: false, native_binaries: ["linker"], } cc_binary { name: "linker", host_supported: true, static_executable: true, nocrt: true, stl: "none", srcs: [ "Test.cpp", ], compile_multilib: "both", } `) result.CheckSnapshot("mymodule_exports", "", checkAndroidBpContents(` // This is auto-generated. DO NOT EDIT. cc_prebuilt_binary { name: "mymodule_exports_linker@current", sdk_member_name: "linker", device_supported: false, host_supported: true, installable: false, stl: "none", static_executable: true, nocrt: true, compile_multilib: "both", arch: { x86_64: { srcs: ["x86_64/bin/linker"], }, x86: { srcs: ["x86/bin/linker"], }, }, } cc_prebuilt_binary { name: "linker", prefer: false, device_supported: false, host_supported: true, stl: "none", static_executable: true, nocrt: true, compile_multilib: "both", arch: { x86_64: { srcs: ["x86_64/bin/linker"], }, x86: { srcs: ["x86/bin/linker"], }, }, } module_exports_snapshot { name: "mymodule_exports@current", device_supported: false, host_supported: true, native_binaries: ["mymodule_exports_linker@current"], } `), checkAllCopyRules(` .intermediates/linker/linux_glibc_x86_64/linker -> x86_64/bin/linker .intermediates/linker/linux_glibc_x86/linker -> x86/bin/linker `), ) } func TestSnapshotWithCcSharedLibrary(t *testing.T) { result := testSdkWithCc(t, ` sdk { Loading