Allow compilation of Dawn on Android
BUG=dawn:286
Change-Id: Ia65b57fde12a1260d29913f61f9b24eded7dbc30
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13822
Reviewed-by: David Turner <digit@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/scripts/dawn_component.gni b/scripts/dawn_component.gni
index 3e854da..2a85c78 100644
--- a/scripts/dawn_component.gni
+++ b/scripts/dawn_component.gni
@@ -12,8 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import("dawn_overrides_with_defaults.gni")
+import("//build_overrides/build.gni")
import("dawn_features.gni")
+import("dawn_overrides_with_defaults.gni")
###############################################################################
# Template to produce a component for one of Dawn's libraries.
@@ -95,6 +96,14 @@
defines = []
}
defines += [ "${invoker.DEFINE_PREFIX}_IMPLEMENTATION" ]
+
+ # Chromium adds a config that uses a special linker script that removes
+ # all symbols except JNI ones. Remove this config so that our
+ # shared_library symbols are visible. This matches what Chromium's
+ # component template does.
+ if (build_with_chromium && is_android) {
+ configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
+ }
}
static_library("${libname}_static") {
diff --git a/scripts/dawn_features.gni b/scripts/dawn_features.gni
index 2de3260..ab1d595 100644
--- a/scripts/dawn_features.gni
+++ b/scripts/dawn_features.gni
@@ -36,7 +36,7 @@
dawn_enable_opengl = is_linux && !is_chromeos
# Enables the compilation of Dawn's Vulkan backend
- dawn_enable_vulkan = is_linux || is_win || is_fuchsia
+ dawn_enable_vulkan = is_linux || is_win || is_fuchsia || is_android
# Enable use of reflection compiler in spirv-cross. This is needed
# if performing reflection on systems that the platform language
diff --git a/src/common/BUILD.gn b/src/common/BUILD.gn
index fdc4377..585876d 100644
--- a/src/common/BUILD.gn
+++ b/src/common/BUILD.gn
@@ -79,7 +79,7 @@
# This GN file is discovered by all Chromium builds, but common doesn't support
# all of Chromium's OSes so we explicitly make the target visible only on
# systems we know Dawn is able to compile on.
-if (is_win || is_linux || is_mac || is_fuchsia) {
+if (is_win || is_linux || is_mac || is_fuchsia || is_android) {
static_library("common") {
sources = [
"Assert.cpp",
diff --git a/src/common/Platform.h b/src/common/Platform.h
index f6d7fc5..bc64db2 100644
--- a/src/common/Platform.h
+++ b/src/common/Platform.h
@@ -21,6 +21,9 @@
#elif defined(__linux__)
# define DAWN_PLATFORM_LINUX 1
# define DAWN_PLATFORM_POSIX 1
+# if defined(__ANDROID__)
+# define DAWN_PLATFORM_ANDROID 1
+# endif
#elif defined(__APPLE__)
# define DAWN_PLATFORM_APPLE 1