Fixed iOS / tvOS support
authorMatthew Leibowitz <mattleibow@live.com>
Tue, 14 Mar 2017 02:06:48 +0000 (23:06 -0300)
committerMatthew Leibowitz <mattleibow@live.com>
Tue, 14 Mar 2017 02:06:48 +0000 (23:06 -0300)
gn/BUILD.gn
gn/BUILDCONFIG.gn
gn/find_ios_sysroot.py
third_party/libjpeg-turbo/BUILD.gn

index 97e5368..a393928 100644 (file)
@@ -50,7 +50,19 @@ if (!is_clang && !is_win) {
 }
 
 if (is_ios) {
-  ios_sysroot = exec_script("find_ios_sysroot.py", [], "trim string")
+  if (is_tvos) {
+    sdk = "appletvos"
+    if (target_cpu == "x86" || target_cpu == "x64") {
+      sdk = "appletvsimulator"
+    }
+    ios_sysroot = exec_script("find_ios_sysroot.py", [ sdk ], "trim string")
+  } else {
+    sdk = "iphoneos"
+    if (target_cpu == "x86" || target_cpu == "x64") {
+      sdk = "iphonesimulator"
+    }
+    ios_sysroot = exec_script("find_ios_sysroot.py", [ sdk ], "trim string")
+  }
 }
 
 config("default") {
@@ -186,18 +198,31 @@ config("default") {
   }
 
   if (is_ios) {
+    _target = target_cpu
+    if (target_cpu == "arm") {
+      _target = "armv7"
+    } else if (target_cpu == "x86") {
+      _target = "i386"
+    } else if (target_cpu == "x64") {
+      _target = "x86_64"
+    }
     cflags += [
       "-isysroot",
       ios_sysroot,
       "-arch",
-      target_cpu,
+      _target,
     ]
+    if (is_tvos) {
+      cflags += [
+        "-fembed-bitcode"
+      ]
+    }
     cflags_cc += [ "-stdlib=libc++" ]
     ldflags += [
       "-isysroot",
       ios_sysroot,
       "-arch",
-      target_cpu,
+      _target,
       "-stdlib=libc++",
     ]
     libs += [ "objc" ]
@@ -399,7 +424,7 @@ config("release") {
     ]
   } else {
     cflags = [
-      "-O3",
+      "-Os",
       "-momit-leaf-frame-pointer",
     ]
   }
index 23e5288..4a99df3 100644 (file)
@@ -37,7 +37,8 @@ if (current_os == "") {
 
 is_android = current_os == "android"
 is_fuchsia = current_os == "fuchsia"
-is_ios = current_os == "ios"
+is_ios = current_os == "ios" || current_os == "tvos"
+is_tvos = current_os == "tvos"
 is_linux = current_os == "linux"
 is_mac = current_os == "mac"
 is_win = current_os == "win"
index 2d9f8d6..b4af2ac 100644 (file)
@@ -6,5 +6,8 @@
 # found in the LICENSE file.
 
 import subprocess
+import sys
 
-print subprocess.check_output('xcrun --sdk iphoneos --show-sdk-path'.split())
+sdk = sys.argv[1:]
+
+print subprocess.check_output(['xcrun', '--sdk', '%s' % sdk[0], '--show-sdk-path'])
index 6825b6b..655c5f2 100644 (file)
@@ -64,12 +64,12 @@ if (skia_use_system_libjpeg_turbo) {
       "../externals/libjpeg-turbo/jutils.c",
     ]
 
-    if (current_cpu == "arm" && current_os != "ios") {
+    if (current_cpu == "arm" && !is_ios) {
       sources += [
         "../externals/libjpeg-turbo/simd/jsimd_arm.c",
         "../externals/libjpeg-turbo/simd/jsimd_arm_neon.S",
       ]
-    } else if (current_cpu == "arm64" && current_os != "ios") {
+    } else if (current_cpu == "arm64" && !is_ios) {
       sources += [
         "../externals/libjpeg-turbo/simd/jsimd_arm64.c",
         "../externals/libjpeg-turbo/simd/jsimd_arm64_neon.S",