diff options
Diffstat (limited to 'cc/api_level.go')
-rw-r--r-- | cc/api_level.go | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/cc/api_level.go b/cc/api_level.go index 69a0d3ae4..3dac571a9 100644 --- a/cc/api_level.go +++ b/cc/api_level.go @@ -41,12 +41,25 @@ func MinApiForArch(ctx android.EarlyModuleContext, } } +// Native API levels cannot be less than the MinApiLevelForArch. This function +// sets the lower bound of the API level with the MinApiLevelForArch. +func nativeClampedApiLevel(ctx android.BaseModuleContext, + apiLevel android.ApiLevel) android.ApiLevel { + + min := MinApiForArch(ctx, ctx.Arch().ArchType) + + if apiLevel.LessThan(min) { + return min + } + + return apiLevel +} + func nativeApiLevelFromUser(ctx android.BaseModuleContext, raw string) (android.ApiLevel, error) { - min := MinApiForArch(ctx, ctx.Arch().ArchType) if raw == "minimum" { - return min, nil + return MinApiForArch(ctx, ctx.Arch().ArchType), nil } value, err := android.ApiLevelFromUser(ctx, raw) @@ -54,15 +67,12 @@ func nativeApiLevelFromUser(ctx android.BaseModuleContext, return android.NoneApiLevel, err } - if value.LessThan(min) { - return min, nil - } - - return value, nil + return nativeClampedApiLevel(ctx, value), nil } func nativeApiLevelOrPanic(ctx android.BaseModuleContext, raw string) android.ApiLevel { + value, err := nativeApiLevelFromUser(ctx, raw) if err != nil { panic(err.Error()) |