diff options
author | Dan Albert <danalbert@google.com> | 2017-01-03 15:16:29 -0800 |
---|---|---|
committer | Dan Albert <danalbert@google.com> | 2017-01-03 15:16:29 -0800 |
commit | 98dbb3bc2dda9633222fc66786cc122d79b4b33d (patch) | |
tree | 8228d84b22d6901d0e7706e1eb23c3dfca4c826a /cc | |
parent | ae452ccb7f61405917a4eb3eb82a2f28f9e0de14 (diff) | |
download | build_soong-98dbb3bc2dda9633222fc66786cc122d79b4b33d.tar.gz build_soong-98dbb3bc2dda9633222fc66786cc122d79b4b33d.tar.bz2 build_soong-98dbb3bc2dda9633222fc66786cc122d79b4b33d.zip |
Add unversioned_until to ndk_library.
This defaults to the value of first_version, and should almost never
be used. This is only needed to work around platform bugs like
https://github.com/android-ndk/ndk/issues/265.
Test: Set `unversioned_until: "24"` for libGLESv3.ndk, readelf on the
android-23 and android-24 outputs to check for version info.
Bug: https://github.com/android-ndk/ndk/issues/265
Change-Id: Ie44b170daad692fdc98e7d7c5f10f9077930b8a9
Diffstat (limited to 'cc')
-rw-r--r-- | cc/ndk_library.go | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/cc/ndk_library.go b/cc/ndk_library.go index afa7927e..aea0d52f 100644 --- a/cc/ndk_library.go +++ b/cc/ndk_library.go @@ -87,6 +87,12 @@ type libraryProperties struct { // for every API level beginning with this one. First_version string + // The first API level that library should have the version script applied. + // This defaults to the value of first_version, and should almost never be + // used. This is only needed to work around platform bugs like + // https://github.com/android-ndk/ndk/issues/265. + Unversioned_until string + // Private property for use by the mutator that splits per-API level. ApiLevel string `blueprint:"mutated"` } @@ -150,6 +156,29 @@ func getFirstGeneratedVersion(firstSupportedVersion string, platformVersion int) return strconv.Atoi(firstSupportedVersion) } +func shouldUseVersionScript(stub *stubDecorator) (bool, error) { + // unversioned_until is normally empty, in which case we should use the version script. + if stub.properties.Unversioned_until == "" { + return true, nil + } + + if stub.properties.ApiLevel == "current" { + return true, nil + } + + unversionedUntil, err := strconv.Atoi(stub.properties.Unversioned_until) + if err != nil { + return true, err + } + + version, err := strconv.Atoi(stub.properties.ApiLevel) + if err != nil { + return true, err + } + + return version >= unversionedUntil, nil +} + func generateStubApiVariants(mctx android.BottomUpMutatorContext, c *stubDecorator) { platformVersion := mctx.AConfig().PlatformSdkVersionInt() @@ -255,8 +284,16 @@ func (stub *stubDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags { func (stub *stubDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path { - linkerScriptFlag := "-Wl,--version-script," + stub.versionScriptPath.String() - flags.LdFlags = append(flags.LdFlags, linkerScriptFlag) + useVersionScript, err := shouldUseVersionScript(stub) + if err != nil { + ctx.ModuleErrorf(err.Error()) + } + + if useVersionScript { + linkerScriptFlag := "-Wl,--version-script," + stub.versionScriptPath.String() + flags.LdFlags = append(flags.LdFlags, linkerScriptFlag) + } + return stub.libraryDecorator.link(ctx, flags, deps, objs) } |