cc: fix version macro for stubs
When a cc module is built against a stub, compiler passes version macro of the stub lib. Version macro should be numeric, so codenames or "current" should be mapped to numbers just like how ndkstubgen maps to. * "current" -> future (10000) * codenames -> look up api_level.json * otherwise -> cast to int Bug: 179329813 Test: m / soong test / manually check the output build.ninja Change-Id: Ic0e1dd904984e161694a0b77fad5559c06a4462f
This commit is contained in:
@@ -19,6 +19,7 @@ import (
|
||||
"io"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
@@ -1362,8 +1363,11 @@ func (library *libraryDecorator) link(ctx ModuleContext,
|
||||
func (library *libraryDecorator) exportVersioningMacroIfNeeded(ctx android.BaseModuleContext) {
|
||||
if library.buildStubs() && library.stubsVersion() != "" && !library.skipAPIDefine {
|
||||
name := versioningMacroName(ctx.Module().(*Module).ImplementationModuleName(ctx))
|
||||
ver := library.stubsVersion()
|
||||
library.reexportFlags("-D" + name + "=" + ver)
|
||||
apiLevel, err := android.ApiLevelFromUser(ctx, library.stubsVersion())
|
||||
if err != nil {
|
||||
ctx.ModuleErrorf("Can't export version macro: %s", err.Error())
|
||||
}
|
||||
library.reexportFlags("-D" + name + "=" + strconv.Itoa(apiLevel.FinalOrPreviewInt()))
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user