Loading cc/cc.go +7 −0 Original line number Diff line number Diff line Loading @@ -586,6 +586,13 @@ func (c *Module) GetDepsInLinkOrder() []android.Path { return c.depsInLinkOrder } func (c *Module) StubsSymbolFile() android.OptionalPath { if library, ok := c.linker.(*libraryDecorator); ok { return library.stubsSymbolFile } return android.OptionalPath{} } func (c *Module) StubsVersions() []string { if c.linker != nil { if library, ok := c.linker.(*libraryDecorator); ok { Loading cc/library.go +5 −1 Original line number Diff line number Diff line Loading @@ -367,6 +367,9 @@ type libraryDecorator struct { // Location of the file that should be copied to dist dir when requested distFile android.OptionalPath // stubs.symbol_file stubsSymbolFile android.OptionalPath versionScriptPath android.ModuleGenPath post_install_cmds []string Loading @@ -376,7 +379,7 @@ type libraryDecorator struct { useCoreVariant bool checkSameCoreVariant bool // Decorated interafaces // Decorated interfaces *baseCompiler *baseLinker *baseInstaller Loading Loading @@ -603,6 +606,7 @@ func (library *libraryDecorator) shouldCreateSourceAbiDump(ctx ModuleContext) bo func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects { if library.buildStubs() { library.stubsSymbolFile = android.OptionalPathForModuleSrc(ctx, library.Properties.Stubs.Symbol_file) objs, versionScript := compileStubLibrary(ctx, flags, String(library.Properties.Stubs.Symbol_file), library.MutatedProperties.StubsVersion, "--apex") library.versionScriptPath = versionScript return objs Loading cc/library_sdk_member.go +21 −0 Original line number Diff line number Diff line Loading @@ -269,12 +269,21 @@ func addPossiblyArchSpecificProperties(sdkModuleContext android.ModuleContext, b for property, dirs := range includeDirs { outputProperties.AddProperty(property, dirs) } if len(libInfo.StubsVersion) > 0 { symbolFilePath := filepath.Join(nativeEtcDir, libInfo.StubsSymbolFile.Path().Base()) builder.CopyToSnapshot(libInfo.StubsSymbolFile.Path(), symbolFilePath) stubsSet := outputProperties.AddPropertySet("stubs") stubsSet.AddProperty("symbol_file", symbolFilePath) stubsSet.AddProperty("versions", []string{libInfo.StubsVersion}) } } const ( nativeIncludeDir = "include" nativeGeneratedIncludeDir = "include_gen" nativeStubDir = "lib" nativeEtcDir = "etc" ) // path to the native library. Relative to <sdk_root>/<api_dir> Loading Loading @@ -335,6 +344,13 @@ type nativeLibInfoProperties struct { // This field is exported as its contents may not be arch specific. SystemSharedLibs []string // The specific stubs version for the lib variant, or empty string if stubs // are not in use. StubsVersion string // The stubs symbol file. StubsSymbolFile android.OptionalPath // outputFile is not exported as it is always arch specific. outputFile android.Path } Loading Loading @@ -370,6 +386,11 @@ func (p *nativeLibInfoProperties) PopulateFromVariant(ctx android.SdkMemberConte p.SystemSharedLibs = specifiedDeps.systemSharedLibs } p.exportedGeneratedHeaders = ccModule.ExportedGeneratedHeaders() if ccModule.HasStubsVariants() { p.StubsVersion = ccModule.StubsVersion() p.StubsSymbolFile = ccModule.StubsSymbolFile() } } func (p *nativeLibInfoProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) { Loading sdk/cc_sdk_test.go +63 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ func testSdkWithCc(t *testing.T, bp string) *testSdkResult { "arm64/include/Arm64Test.h": nil, "libfoo.so": nil, "aidl/foo/bar/Test.aidl": nil, "some/where/stubslib.map.txt": nil, } return testSdkWithFs(t, bp, fs) } Loading Loading @@ -1739,3 +1740,65 @@ sdk_snapshot { } `)) } func TestStubsLibrary(t *testing.T) { result := testSdkWithCc(t, ` sdk { name: "mysdk", native_shared_libs: ["stubslib"], } cc_library { name: "stubslib", stubs: { symbol_file: "some/where/stubslib.map.txt", versions: ["1", "2", "3"], }, } `) result.CheckSnapshot("mysdk", "", checkAndroidBpContents(` // This is auto-generated. DO NOT EDIT. cc_prebuilt_library_shared { name: "mysdk_stubslib@current", sdk_member_name: "stubslib", installable: false, stubs: { symbol_file: "etc/stubslib.map.txt", versions: ["3"], }, arch: { arm64: { srcs: ["arm64/lib/stubslib.so"], }, arm: { srcs: ["arm/lib/stubslib.so"], }, }, } cc_prebuilt_library_shared { name: "stubslib", prefer: false, stubs: { symbol_file: "etc/stubslib.map.txt", versions: ["3"], }, arch: { arm64: { srcs: ["arm64/lib/stubslib.so"], }, arm: { srcs: ["arm/lib/stubslib.so"], }, }, } sdk_snapshot { name: "mysdk@current", native_shared_libs: ["mysdk_stubslib@current"], } `)) } Loading
cc/cc.go +7 −0 Original line number Diff line number Diff line Loading @@ -586,6 +586,13 @@ func (c *Module) GetDepsInLinkOrder() []android.Path { return c.depsInLinkOrder } func (c *Module) StubsSymbolFile() android.OptionalPath { if library, ok := c.linker.(*libraryDecorator); ok { return library.stubsSymbolFile } return android.OptionalPath{} } func (c *Module) StubsVersions() []string { if c.linker != nil { if library, ok := c.linker.(*libraryDecorator); ok { Loading
cc/library.go +5 −1 Original line number Diff line number Diff line Loading @@ -367,6 +367,9 @@ type libraryDecorator struct { // Location of the file that should be copied to dist dir when requested distFile android.OptionalPath // stubs.symbol_file stubsSymbolFile android.OptionalPath versionScriptPath android.ModuleGenPath post_install_cmds []string Loading @@ -376,7 +379,7 @@ type libraryDecorator struct { useCoreVariant bool checkSameCoreVariant bool // Decorated interafaces // Decorated interfaces *baseCompiler *baseLinker *baseInstaller Loading Loading @@ -603,6 +606,7 @@ func (library *libraryDecorator) shouldCreateSourceAbiDump(ctx ModuleContext) bo func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects { if library.buildStubs() { library.stubsSymbolFile = android.OptionalPathForModuleSrc(ctx, library.Properties.Stubs.Symbol_file) objs, versionScript := compileStubLibrary(ctx, flags, String(library.Properties.Stubs.Symbol_file), library.MutatedProperties.StubsVersion, "--apex") library.versionScriptPath = versionScript return objs Loading
cc/library_sdk_member.go +21 −0 Original line number Diff line number Diff line Loading @@ -269,12 +269,21 @@ func addPossiblyArchSpecificProperties(sdkModuleContext android.ModuleContext, b for property, dirs := range includeDirs { outputProperties.AddProperty(property, dirs) } if len(libInfo.StubsVersion) > 0 { symbolFilePath := filepath.Join(nativeEtcDir, libInfo.StubsSymbolFile.Path().Base()) builder.CopyToSnapshot(libInfo.StubsSymbolFile.Path(), symbolFilePath) stubsSet := outputProperties.AddPropertySet("stubs") stubsSet.AddProperty("symbol_file", symbolFilePath) stubsSet.AddProperty("versions", []string{libInfo.StubsVersion}) } } const ( nativeIncludeDir = "include" nativeGeneratedIncludeDir = "include_gen" nativeStubDir = "lib" nativeEtcDir = "etc" ) // path to the native library. Relative to <sdk_root>/<api_dir> Loading Loading @@ -335,6 +344,13 @@ type nativeLibInfoProperties struct { // This field is exported as its contents may not be arch specific. SystemSharedLibs []string // The specific stubs version for the lib variant, or empty string if stubs // are not in use. StubsVersion string // The stubs symbol file. StubsSymbolFile android.OptionalPath // outputFile is not exported as it is always arch specific. outputFile android.Path } Loading Loading @@ -370,6 +386,11 @@ func (p *nativeLibInfoProperties) PopulateFromVariant(ctx android.SdkMemberConte p.SystemSharedLibs = specifiedDeps.systemSharedLibs } p.exportedGeneratedHeaders = ccModule.ExportedGeneratedHeaders() if ccModule.HasStubsVariants() { p.StubsVersion = ccModule.StubsVersion() p.StubsSymbolFile = ccModule.StubsSymbolFile() } } func (p *nativeLibInfoProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) { Loading
sdk/cc_sdk_test.go +63 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ func testSdkWithCc(t *testing.T, bp string) *testSdkResult { "arm64/include/Arm64Test.h": nil, "libfoo.so": nil, "aidl/foo/bar/Test.aidl": nil, "some/where/stubslib.map.txt": nil, } return testSdkWithFs(t, bp, fs) } Loading Loading @@ -1739,3 +1740,65 @@ sdk_snapshot { } `)) } func TestStubsLibrary(t *testing.T) { result := testSdkWithCc(t, ` sdk { name: "mysdk", native_shared_libs: ["stubslib"], } cc_library { name: "stubslib", stubs: { symbol_file: "some/where/stubslib.map.txt", versions: ["1", "2", "3"], }, } `) result.CheckSnapshot("mysdk", "", checkAndroidBpContents(` // This is auto-generated. DO NOT EDIT. cc_prebuilt_library_shared { name: "mysdk_stubslib@current", sdk_member_name: "stubslib", installable: false, stubs: { symbol_file: "etc/stubslib.map.txt", versions: ["3"], }, arch: { arm64: { srcs: ["arm64/lib/stubslib.so"], }, arm: { srcs: ["arm/lib/stubslib.so"], }, }, } cc_prebuilt_library_shared { name: "stubslib", prefer: false, stubs: { symbol_file: "etc/stubslib.map.txt", versions: ["3"], }, arch: { arm64: { srcs: ["arm64/lib/stubslib.so"], }, arm: { srcs: ["arm/lib/stubslib.so"], }, }, } sdk_snapshot { name: "mysdk@current", native_shared_libs: ["mysdk_stubslib@current"], } `)) }