GN: mac host and armv7 target
authormtklein <mtklein@chromium.org>
Fri, 26 Aug 2016 15:13:04 +0000 (08:13 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 26 Aug 2016 15:13:04 +0000 (08:13 -0700)
Just when I thought it wouldn't be useful to override ar...

Tested by building 32- and 64-bit DM on my MBP and running it on my N5x.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2279703003

Review-Url: https://codereview.chromium.org/2279703003

BUILD.gn
gn/BUILD.gn
gn/BUILDCONFIG.gn
third_party/libwebp/BUILD.gn

index 8c053cf..02cb350 100644 (file)
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -215,6 +215,12 @@ opts("avx") {
   cflags = [ "-mavx" ]
 }
 
+opts("dsp") {
+  enabled = current_cpu == "mipsel"
+  sources = opts_gypi.mips_dsp_sources
+  cflags = [ "-Wno-deprecated-register" ]  # FIXME
+}
+
 # Any feature of Skia that requires third-party code should be optional and use this template.
 template("optional") {
   if (invoker.enabled) {
@@ -334,6 +340,7 @@ component("skia") {
     ":armv7",
     ":avx",
     ":crc32",
+    ":dsp",
     ":gif",
     ":jpeg",
     ":none",
index 0a56fa2..fc518ff 100644 (file)
@@ -4,10 +4,12 @@
 # found in the LICENSE file.
 
 declare_args() {
+  ar = "ar"
   cc = "cc"
   cxx = "c++"
 
   if (is_android) {
+    ar = "$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin/ar"
     cc = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang"
     cxx = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang++"
   }
@@ -48,14 +50,27 @@ config("default") {
     "-Wnon-virtual-dtor",
   ]
   if (current_cpu == "arm") {
-    cflags += [ "-mfpu=neon" ]
+    cflags += [
+      "-march=armv7-a",
+      "-mfpu=neon",
+      "-mthumb",
+    ]
+  } else if (current_cpu == "mipsel") {
+    cflags += [
+      "-march=mips32r2",
+      "-mdspr2",
+    ]
   }
 
   if (is_android) {
-    asmflags = [ "--target=$ndk_target" ]
+    asmflags = [
+      "--target=$ndk_target",
+      "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
+    ]
     cflags += [
       "--sysroot=$ndk/platforms/$ndk_platform",
       "--target=$ndk_target",
+      "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
     ]
     cflags_cc += [
       "-isystem$ndk/sources/android/support/include",
@@ -64,12 +79,12 @@ config("default") {
     ldflags = [
       "--sysroot=$ndk/platforms/$ndk_platform",
       "--target=$ndk_target",
-      "-B$ndk/toolchains/$ndk_target-4.9/prebuilt/$ndk_host/$ndk_target/bin",
+      "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
       "-pie",
     ]
     lib_dirs = [
       "$ndk/sources/cxx-stl/llvm-libc++/libs/$ndk_stdlib",
-      "$ndk/toolchains/$ndk_target-4.9/prebuilt/$ndk_host/lib/gcc/$ndk_target/4.9.x",
+      "$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/lib/gcc/$ndk_target/4.9.x",
     ]
     libs = [
       # Order matters here!  Keep these three in exactly this order.
@@ -77,6 +92,9 @@ config("default") {
       "c++abi",
       "android_support",
     ]
+    if (target_cpu == "arm") {
+      libs += [ "unwind" ]
+    }
   }
 
   if (is_linux) {
@@ -136,13 +154,13 @@ toolchain("gcc_like") {
   }
 
   tool("alink") {
-    command = "rm -f {{output}} && ar rcs {{output}} {{inputs}}"
+    command = "rm -f {{output}} && $ar rcs {{output}} {{inputs}}"
     outputs = [
       "{{root_out_dir}}/{{target_output_name}}{{output_extension}}",
     ]
     default_output_extension = ".a"
     output_prefix = "lib"
-    description = "ar {{output}} ..."
+    description = "$ar {{output}} ..."
   }
 
   tool("solink") {
index 6aa4451..10f3244 100644 (file)
@@ -22,9 +22,16 @@ if (current_os == "") {
   current_os = target_os
 }
 
+is_android = current_os == "android"
+is_fuchsia = current_os == "fuchsia"
+is_ios = current_os == "ios"
+is_linux = current_os == "linux"
+is_mac = current_os == "mac"
+is_win = current_os == "win"
+
 if (target_cpu == "") {
   target_cpu = host_cpu
-  if (ndk != "") {
+  if (is_android) {
     target_cpu = "arm64"
   }
 }
@@ -32,28 +39,49 @@ if (current_cpu == "") {
   current_cpu = target_cpu
 }
 
-is_android = current_os == "android"
-is_fuchsia = current_os == "fuchsia"
-is_ios = current_os == "ios"
-is_linux = current_os == "linux"
-is_mac = current_os == "mac"
-is_win = current_os == "win"
-
-is_posix = !is_win
-
 if (is_android) {
   ndk_host = ""
   ndk_target = ""
   ndk_platform = ""
   ndk_stdlib = ""
+  nkd_gccdir = ""
 
-  if (host_os == "linux" && host_cpu == "x64") {
+  if (host_os == "linux") {
     ndk_host = "linux-x86_64"
+  } else if (host_os == "mac") {
+    ndk_host = "darwin-x86_64"
   }
+
   if (target_cpu == "arm64") {
     ndk_target = "aarch64-linux-android"
     ndk_platform = "android-21/arch-arm64"
     ndk_stdlib = "arm64-v8a"
+    ndk_gccdir = ndk_target
+  } else if (target_cpu == "arm") {
+    ndk_target = "arm-linux-androideabi"
+    ndk_platform = "android-18/arch-arm"
+    ndk_stdlib = "armeabi-v7a"
+    ndk_gccdir = ndk_target
+  } else if (target_cpu == "mips64el") {
+    ndk_target = "mips64el-linux-android"
+    ndk_platform = "android-21/arch-mips64"
+    ndk_stdlib = "mips64"
+    ndk_gccdir = ndk_target
+  } else if (target_cpu == "mipsel") {
+    ndk_target = "mipsel-linux-android"
+    ndk_platform = "android-18/arch-mips"
+    ndk_stdlib = "mips"
+    ndk_gccdir = ndk_target
+  } else if (target_cpu == "x64") {
+    ndk_target = "x86_64-linux-android"
+    ndk_platform = "android-21/arch-x86_64"
+    ndk_stdlib = "x86_64"
+    ndk_gccdir = ndk_stdlib
+  } else if (target_cpu == "x86") {
+    ndk_target = "i686-linux-android"
+    ndk_platform = "android-18/arch-x86"
+    ndk_stdlib = "x86"
+    ndk_gccdir = ndk_stdlib
   }
 }
 
index 7f7901e..ec51cd3 100644 (file)
@@ -11,6 +11,12 @@ import("../third_party.gni")
 third_party("libwebp") {
   public_include_dirs = [ "../externals/libwebp/src" ]
 
+  if (is_android) {
+    deps = [
+      "//third_party/cpu-features",
+    ]
+  }
+
   defines = [
     # WebP naturally decodes to RGB_565, and we work with BGR_565.
     # This makes WebP decode to BGR_565 when we ask for RGB_565.
@@ -32,39 +38,56 @@ third_party("libwebp") {
     "../externals/libwebp/src/dec/webp.c",
     "../externals/libwebp/src/demux/demux.c",
     "../externals/libwebp/src/dsp/alpha_processing.c",
+    "../externals/libwebp/src/dsp/alpha_processing_mips_dsp_r2.c",
     "../externals/libwebp/src/dsp/alpha_processing_sse2.c",
     "../externals/libwebp/src/dsp/alpha_processing_sse41.c",
     "../externals/libwebp/src/dsp/argb.c",
+    "../externals/libwebp/src/dsp/argb_mips_dsp_r2.c",
     "../externals/libwebp/src/dsp/argb_sse2.c",
     "../externals/libwebp/src/dsp/cost.c",
+    "../externals/libwebp/src/dsp/cost_mips32.c",
+    "../externals/libwebp/src/dsp/cost_mips_dsp_r2.c",
     "../externals/libwebp/src/dsp/cost_sse2.c",
     "../externals/libwebp/src/dsp/cpu.c",
     "../externals/libwebp/src/dsp/dec.c",
     "../externals/libwebp/src/dsp/dec_clip_tables.c",
+    "../externals/libwebp/src/dsp/dec_mips32.c",
+    "../externals/libwebp/src/dsp/dec_mips_dsp_r2.c",
     "../externals/libwebp/src/dsp/dec_neon.c",
     "../externals/libwebp/src/dsp/dec_sse2.c",
     "../externals/libwebp/src/dsp/dec_sse41.c",
     "../externals/libwebp/src/dsp/enc.c",
     "../externals/libwebp/src/dsp/enc_avx2.c",
+    "../externals/libwebp/src/dsp/enc_mips32.c",
+    "../externals/libwebp/src/dsp/enc_mips_dsp_r2.c",
     "../externals/libwebp/src/dsp/enc_neon.c",
     "../externals/libwebp/src/dsp/enc_sse2.c",
     "../externals/libwebp/src/dsp/enc_sse41.c",
     "../externals/libwebp/src/dsp/filters.c",
+    "../externals/libwebp/src/dsp/filters_mips_dsp_r2.c",
     "../externals/libwebp/src/dsp/filters_sse2.c",
     "../externals/libwebp/src/dsp/lossless.c",
     "../externals/libwebp/src/dsp/lossless_enc.c",
+    "../externals/libwebp/src/dsp/lossless_enc_mips32.c",
+    "../externals/libwebp/src/dsp/lossless_enc_mips_dsp_r2.c",
     "../externals/libwebp/src/dsp/lossless_enc_neon.c",
     "../externals/libwebp/src/dsp/lossless_enc_sse2.c",
     "../externals/libwebp/src/dsp/lossless_enc_sse41.c",
+    "../externals/libwebp/src/dsp/lossless_mips_dsp_r2.c",
     "../externals/libwebp/src/dsp/lossless_neon.c",
     "../externals/libwebp/src/dsp/lossless_sse2.c",
     "../externals/libwebp/src/dsp/rescaler.c",
+    "../externals/libwebp/src/dsp/rescaler_mips32.c",
+    "../externals/libwebp/src/dsp/rescaler_mips_dsp_r2.c",
     "../externals/libwebp/src/dsp/rescaler_neon.c",
     "../externals/libwebp/src/dsp/rescaler_sse2.c",
     "../externals/libwebp/src/dsp/upsampling.c",
+    "../externals/libwebp/src/dsp/upsampling_mips_dsp_r2.c",
     "../externals/libwebp/src/dsp/upsampling_neon.c",
     "../externals/libwebp/src/dsp/upsampling_sse2.c",
     "../externals/libwebp/src/dsp/yuv.c",
+    "../externals/libwebp/src/dsp/yuv_mips32.c",
+    "../externals/libwebp/src/dsp/yuv_mips_dsp_r2.c",
     "../externals/libwebp/src/dsp/yuv_sse2.c",
     "../externals/libwebp/src/enc/alpha.c",
     "../externals/libwebp/src/enc/analysis.c",