-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes Android API level support in NDK crosstools.
NDK r19 crosstools incorrectly reported that it supports API level 29. NDK r21 crosstools was missing API level 30. Fixes #13421. PiperOrigin-RevId: 380800055
- Loading branch information
1 parent
640c3ef
commit b4c637c
Showing
13 changed files
with
280 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r20/ApiLevelR20.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright 2021 The Bazel Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.r20; | ||
|
||
import com.google.common.collect.ImmutableListMultimap; | ||
import com.google.common.collect.ImmutableMap; | ||
import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.ApiLevel; | ||
import com.google.devtools.build.lib.events.EventHandler; | ||
|
||
/** Class which encodes information from the Android NDK makefiles about API levels. */ | ||
final class ApiLevelR20 extends ApiLevel { | ||
/** This is the contents of {@code platforms/android-*} */ | ||
private static final ImmutableListMultimap<String, String> API_LEVEL_TO_ARCHITECTURES = | ||
ImmutableListMultimap.<String, String>builder() | ||
.putAll("16", "arm", "x86") | ||
.putAll("17", "arm", "x86") | ||
.putAll("18", "arm", "x86") | ||
.putAll("19", "arm", "x86") | ||
.putAll("21", "arm", "x86", "arm64", "x86_64") | ||
.putAll("22", "arm", "x86", "arm64", "x86_64") | ||
.putAll("23", "arm", "x86", "arm64", "x86_64") | ||
.putAll("24", "arm", "x86", "arm64", "x86_64") | ||
.putAll("26", "arm", "x86", "arm64", "x86_64") | ||
.putAll("27", "arm", "x86", "arm64", "x86_64") | ||
.putAll("28", "arm", "x86", "arm64", "x86_64") | ||
.putAll("29", "arm", "x86", "arm64", "x86_64") | ||
.build(); | ||
|
||
/** This map fill in the gaps of {@code API_LEVEL_TO_ARCHITECTURES}. */ | ||
private static final ImmutableMap<String, String> API_EQUIVALENCIES = | ||
ImmutableMap.<String, String>builder() | ||
.put("16", "16") | ||
.put("17", "16") | ||
.put("18", "18") | ||
.put("19", "19") | ||
.put("20", "19") | ||
.put("21", "21") | ||
.put("22", "22") | ||
.put("23", "23") | ||
.put("24", "24") | ||
.put("25", "24") | ||
.put("26", "26") | ||
.put("27", "27") | ||
.put("28", "28") | ||
.put("29", "29") | ||
.build(); | ||
|
||
ApiLevelR20(EventHandler eventHandler, String repositoryName, String apiLevel) { | ||
super(API_LEVEL_TO_ARCHITECTURES, API_EQUIVALENCIES, eventHandler, repositoryName, apiLevel); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r20/BUILD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
load("@rules_java//java:defs.bzl", "java_library") | ||
|
||
package( | ||
default_visibility = ["//src:__subpackages__"], | ||
) | ||
|
||
licenses(["notice"]) | ||
|
||
filegroup( | ||
name = "srcs", | ||
srcs = glob(["*"]), | ||
visibility = ["//src:__subpackages__"], | ||
) | ||
|
||
java_library( | ||
name = "r20", | ||
srcs = glob(["*.java"]), | ||
deps = [ | ||
"//src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools", | ||
"//src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r19", | ||
"//src/main/java/com/google/devtools/build/lib/events", | ||
"//src/main/protobuf:crosstool_config_java_proto", | ||
"//third_party:guava", | ||
], | ||
) |
44 changes: 44 additions & 0 deletions
44
.../google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r20/NdkMajorRevisionR20.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2021 The Bazel Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.r20; | ||
|
||
import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.ApiLevel; | ||
import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.NdkMajorRevision; | ||
import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.NdkPaths; | ||
import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.StlImpl; | ||
import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.r19.AndroidNdkCrosstoolsR19; | ||
import com.google.devtools.build.lib.events.EventHandler; | ||
import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CrosstoolRelease; | ||
|
||
/** Logic specific to Android NDK R20. */ | ||
public class NdkMajorRevisionR20 implements NdkMajorRevision { | ||
private final String clangVersion; | ||
|
||
public NdkMajorRevisionR20(String clangVersion) { | ||
this.clangVersion = clangVersion; | ||
} | ||
|
||
@Override | ||
public CrosstoolRelease crosstoolRelease( | ||
NdkPaths ndkPaths, StlImpl stlImpl, String hostPlatform) { | ||
// NDK r20 is the same as r19 for bazel, other than API level differences below. | ||
return AndroidNdkCrosstoolsR19.create(ndkPaths, stlImpl, hostPlatform, clangVersion); | ||
} | ||
|
||
@Override | ||
public ApiLevel apiLevel(EventHandler eventHandler, String name, String apiLevel) { | ||
return new ApiLevelR20(eventHandler, name, apiLevel); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
...java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r21/ApiLevelR21.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright 2021 The Bazel Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.r21; | ||
|
||
import com.google.common.collect.ImmutableListMultimap; | ||
import com.google.common.collect.ImmutableMap; | ||
import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.ApiLevel; | ||
import com.google.devtools.build.lib.events.EventHandler; | ||
|
||
/** Class which encodes information from the Android NDK makefiles about API levels. */ | ||
final class ApiLevelR21 extends ApiLevel { | ||
/** This is the contents of {@code platforms/android-*} */ | ||
private static final ImmutableListMultimap<String, String> API_LEVEL_TO_ARCHITECTURES = | ||
ImmutableListMultimap.<String, String>builder() | ||
.putAll("16", "arm", "x86") | ||
.putAll("17", "arm", "x86") | ||
.putAll("18", "arm", "x86") | ||
.putAll("19", "arm", "x86") | ||
.putAll("21", "arm", "x86", "arm64", "x86_64") | ||
.putAll("22", "arm", "x86", "arm64", "x86_64") | ||
.putAll("23", "arm", "x86", "arm64", "x86_64") | ||
.putAll("24", "arm", "x86", "arm64", "x86_64") | ||
.putAll("26", "arm", "x86", "arm64", "x86_64") | ||
.putAll("27", "arm", "x86", "arm64", "x86_64") | ||
.putAll("28", "arm", "x86", "arm64", "x86_64") | ||
.putAll("29", "arm", "x86", "arm64", "x86_64") | ||
.putAll("30", "arm", "x86", "arm64", "x86_64") | ||
.build(); | ||
|
||
/** This map fill in the gaps of {@code API_LEVEL_TO_ARCHITECTURES}. */ | ||
private static final ImmutableMap<String, String> API_EQUIVALENCIES = | ||
ImmutableMap.<String, String>builder() | ||
.put("16", "16") | ||
.put("17", "16") | ||
.put("18", "18") | ||
.put("19", "19") | ||
.put("20", "19") | ||
.put("21", "21") | ||
.put("22", "22") | ||
.put("23", "23") | ||
.put("24", "24") | ||
.put("25", "24") | ||
.put("26", "26") | ||
.put("27", "27") | ||
.put("28", "28") | ||
.put("29", "29") | ||
.put("30", "30") | ||
.build(); | ||
|
||
ApiLevelR21(EventHandler eventHandler, String repositoryName, String apiLevel) { | ||
super(API_LEVEL_TO_ARCHITECTURES, API_EQUIVALENCIES, eventHandler, repositoryName, apiLevel); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r21/BUILD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
load("@rules_java//java:defs.bzl", "java_library") | ||
|
||
package( | ||
default_visibility = ["//src:__subpackages__"], | ||
) | ||
|
||
licenses(["notice"]) | ||
|
||
filegroup( | ||
name = "srcs", | ||
srcs = glob(["*"]), | ||
visibility = ["//src:__subpackages__"], | ||
) | ||
|
||
java_library( | ||
name = "r21", | ||
srcs = glob(["*.java"]), | ||
deps = [ | ||
"//src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools", | ||
"//src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r19", | ||
"//src/main/java/com/google/devtools/build/lib/events", | ||
"//src/main/protobuf:crosstool_config_java_proto", | ||
"//third_party:guava", | ||
], | ||
) |
44 changes: 44 additions & 0 deletions
44
.../google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r21/NdkMajorRevisionR21.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2021 The Bazel Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.r21; | ||
|
||
import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.ApiLevel; | ||
import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.NdkMajorRevision; | ||
import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.NdkPaths; | ||
import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.StlImpl; | ||
import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.r19.AndroidNdkCrosstoolsR19; | ||
import com.google.devtools.build.lib.events.EventHandler; | ||
import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CrosstoolRelease; | ||
|
||
/** Logic specific to Android NDK R21. */ | ||
public class NdkMajorRevisionR21 implements NdkMajorRevision { | ||
private final String clangVersion; | ||
|
||
public NdkMajorRevisionR21(String clangVersion) { | ||
this.clangVersion = clangVersion; | ||
} | ||
|
||
@Override | ||
public CrosstoolRelease crosstoolRelease( | ||
NdkPaths ndkPaths, StlImpl stlImpl, String hostPlatform) { | ||
// NDK r21 is the same as r19 for bazel, other than API level differences below. | ||
return AndroidNdkCrosstoolsR19.create(ndkPaths, stlImpl, hostPlatform, clangVersion); | ||
} | ||
|
||
@Override | ||
public ApiLevel apiLevel(EventHandler eventHandler, String name, String apiLevel) { | ||
return new ApiLevelR21(eventHandler, name, apiLevel); | ||
} | ||
} |