浏览代码

build: support dependency build for visionOS

osy 2 年之前
父节点
当前提交
7611a46831
共有 5 个文件被更改,包括 218 次插入19 次删除
  1. 119 0
      patches/angle-toolchain.patch
  2. 31 5
      patches/openssl-1.1.1b.patch
  3. 1 1
      patches/sources
  4. 26 0
      patches/spice-gtk-0.40.patch
  5. 41 13
      scripts/build_dependencies.sh

+ 119 - 0
patches/angle-toolchain.patch

@@ -0,0 +1,119 @@
+From 0287d27a409fb257bdfa6fe1eb38fcba30d7ac70 Mon Sep 17 00:00:00 2001
+From: osy <osy@turing.llc>
+Date: Sat, 5 Aug 2023 18:38:51 -0700
+Subject: [PATCH] Add xrOS support
+
+---
+ config/apple/sdk_info.py |  2 +-
+ config/compiler/BUILD.gn |  2 +-
+ config/ios/BUILD.gn      |  5 +----
+ config/ios/codesign.py   |  2 ++
+ config/ios/config.gni    |  3 +++
+ config/ios/ios_sdk.gni   | 18 ++++++++++++++----
+ 6 files changed, 22 insertions(+), 10 deletions(-)
+
+diff --git a/config/apple/sdk_info.py b/config/apple/sdk_info.py
+index 81b06d438..94b260971 100755
+--- a/config/apple/sdk_info.py
++++ b/config/apple/sdk_info.py
+@@ -134,7 +134,7 @@ def main():
+                       default='.',
+                       help='Value of gn $root_build_dir')
+   parser.add_argument('platform',
+-                      choices=['iphoneos', 'iphonesimulator', 'macosx'])
++                      choices=['iphoneos', 'iphonesimulator', 'macosx', 'xros', 'xrsimulator'])
+   args = parser.parse_args()
+   if args.developer_dir:
+     os.environ['DEVELOPER_DIR'] = args.developer_dir
+diff --git a/config/compiler/BUILD.gn b/config/compiler/BUILD.gn
+index 944a039d0..685f79da4 100644
+--- a/config/compiler/BUILD.gn
++++ b/config/compiler/BUILD.gn
+@@ -1592,7 +1592,7 @@ config("default_warnings") {
+ 
+   if (is_clang) {
+     cflags += [
+-      "-Wloop-analysis",
++      "-Wloop-analysis", "-Wno-deprecated-declarations",
+ 
+       # TODO(thakis): This used to be implied by -Wno-unused-function,
+       # which we no longer use. Check if it makes sense to remove
+diff --git a/config/ios/BUILD.gn b/config/ios/BUILD.gn
+index f0b85cc65..9a31fa30d 100644
+--- a/config/ios/BUILD.gn
++++ b/config/ios/BUILD.gn
+@@ -39,13 +39,10 @@ config("compiler") {
+     assert(false, "unsupported environment: $target_environment")
+   }
+ 
+-  # OS.
+-  triplet_os = "apple-ios"
+-
+   # Set target.
+   common_flags = [
+     "-target",
+-    "$triplet_cpu-$triplet_os$ios_deployment_target$triplet_environment",
++    "$triplet_cpu-apple-$target_platform$ios_deployment_target$triplet_environment",
+   ]
+ 
+   # This is here so that all files get recompiled after an Xcode update.
+diff --git a/config/ios/codesign.py b/config/ios/codesign.py
+index a475302e8..ca1cb05ca 100644
+--- a/config/ios/codesign.py
++++ b/config/ios/codesign.py
+@@ -92,6 +92,8 @@ class Bundle(object):
+   def Kind(platform, extension):
+     if platform == 'iphonesimulator' or platform == 'iphoneos':
+       return 'ios'
++    if platform == 'xrsimulator' or platform == 'xros':
++      return 'xros'
+     if platform == 'macosx':
+       if extension == '.framework':
+         return 'mac_framework'
+diff --git a/config/ios/config.gni b/config/ios/config.gni
+index 74d064532..5f3f25ad5 100644
+--- a/config/ios/config.gni
++++ b/config/ios/config.gni
+@@ -14,6 +14,9 @@ declare_args() {
+   # components/cronet/tools/cr_cronet.py as cronet requires specific
+   # gn args to build correctly).
+   is_cronet_build = false
++
++  # Platform to build (ios,xros,tvos,watchos)
++  target_platform = "ios"
+ }
+ 
+ if (target_environment == "") {
+diff --git a/config/ios/ios_sdk.gni b/config/ios/ios_sdk.gni
+index af498ced8..1faab75f3 100644
+--- a/config/ios/ios_sdk.gni
++++ b/config/ios/ios_sdk.gni
+@@ -118,11 +118,21 @@ if (additional_target_cpus != [] && !is_fat_secondary_toolchain) {
+ if (ios_sdk_path == "") {
+   # Compute default target.
+   if (target_environment == "simulator") {
+-    ios_sdk_name = "iphonesimulator"
+-    ios_sdk_platform = "iPhoneSimulator"
++    if (target_platform == "xros") {
++      ios_sdk_name = "xrsimulator"
++      ios_sdk_platform = "XRSimulator"
++    } else {
++      ios_sdk_name = "iphonesimulator"
++      ios_sdk_platform = "iPhoneSimulator"
++    }
+   } else if (target_environment == "device") {
+-    ios_sdk_name = "iphoneos"
+-    ios_sdk_platform = "iPhoneOS"
++    if (target_platform == "xros") {
++      ios_sdk_name = "xros"
++      ios_sdk_platform = "XROS"
++    } else {
++      ios_sdk_name = "iphoneos"
++      ios_sdk_platform = "iPhoneOS"
++    }
+   } else if (target_environment == "catalyst") {
+     ios_sdk_name = "macosx"
+     ios_sdk_platform = "MacOSX"
+-- 
+2.41.0
+

+ 31 - 5
patches/openssl-1.1.1b.patch

@@ -16,9 +16,9 @@ diff -urN a/Configurations/10-main.conf b/Configurations/10-main.conf
  
  ##### GNU Hurd
      "hurd-x86" => {
-diff -urN a/Configurations/15-ios.conf b/Configurations/15-ios.conf
---- a/Configurations/15-ios.conf	2019-02-26 06:15:30.000000000 -0800
-+++ b/Configurations/15-ios.conf	2020-11-03 19:00:27.000000000 -0800
+diff --color -Naur a/Configurations/15-ios.conf b/Configurations/15-ios.conf
+--- a/Configurations/15-ios.conf	2019-02-26 06:15:30
++++ b/Configurations/15-ios.conf	2023-08-07 19:53:43
 @@ -32,6 +32,13 @@
          inherit_from     => [ "ios-common" ],
          CC               => "xcrun -sdk iphonesimulator cc",
@@ -33,13 +33,39 @@ diff -urN a/Configurations/15-ios.conf b/Configurations/15-ios.conf
  # It takes three prior-set environment variables to make it work:
  #
  # CROSS_COMPILE=/where/toolchain/is/usr/bin/ [note ending slash]
-@@ -59,4 +66,9 @@
+@@ -58,5 +65,35 @@
+         inherit_from     => [ "ios64-xcrun" ],
          CC               => "cc",
          cflags           => add("-isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK)"),
-     },
++    },
 +    "iossimulator64-cross" => {
 +        inherit_from     => [ "iossimulator64-xcrun" ],
 +        CC               => "cc",
 +        cflags           => add("-isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK)"),
 +    },
++## Apple visionOS
++    "visionos-common" => {
++        template         => 1,
++        inherit_from     => [ "darwin-common" ],
++        sys_id           => "visionOS",
++        disable          => [ "engine", "async" ],
++    },
++    "visionos-cross-arm64" => {
++        inherit_from     => [ "visionos-common", asm("aarch64_asm") ],
++        CC               => "xcrun -sdk xros cc",
++        cflags           => add("-arch arm64"),
++        bn_ops           => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
++        perlasm_scheme   => "ios64",
++    },
++    "visionos-sim-cross-arm64" => {
++        inherit_from     => [ "visionos-common" ],
++        CC               => "xcrun -sdk xrsimulator cc",
++    },
++    "visionos-sim-cross-x86_64" => {
++        inherit_from     => [ "visionos-common", asm("x86_64_asm") ],
++        CC               => "xcrun -sdk xrsimulator cc",
++        cflags           => add("-arch x86_64"),
++        bn_ops           => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
++        perlasm_scheme   => "macosx",
+     },
  );

+ 1 - 1
patches/sources

@@ -39,7 +39,7 @@ SPICE_CLIENT_SRC="https://www.spice-space.org/download/gtk/spice-gtk-0.40.tar.xz
 DEPOT_TOOLS_REPO="https://chromium.googlesource.com/chromium/tools/depot_tools.git"
 DEPOT_TOOLS_COMMIT="5da65ec20db9b17b03420d928240092e5955a769"
 ANGLE_REPO="https://github.com/utmapp/angle.git"
-ANGLE_COMMIT="13630ff5d3afef80ea50c3bc67b3ab95887220fe"
+ANGLE_COMMIT="18e942b3e66d45d0ac5404eb3cfc89390788e11f"
 EPOXY_REPO="https://github.com/utmapp/libepoxy.git"
 EPOXY_COMMIT="266d2290a437c655f7419e85af06bfbb73a720c4"
 VIRGLRENDERER_REPO="https://github.com/utmapp/virglrenderer.git"

+ 26 - 0
patches/spice-gtk-0.40.patch

@@ -1434,3 +1434,29 @@ index eb9416b..6d263aa 100644
 -- 
 GitLab
 
+From d5dc89146697d075178fa916253e2a69a25964b8 Mon Sep 17 00:00:00 2001
+From: osy <osy@turing.llc>
+Date: Sun, 6 Aug 2023 01:11:31 -0700
+Subject: [PATCH] meson: disable version script
+
+Fails to build on Xcode 15
+---
+ src/meson.build | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/meson.build b/src/meson.build
+index 961779f..5ef1e0d 100644
+--- a/src/meson.build
++++ b/src/meson.build
+@@ -205,7 +205,7 @@ spice_client_glib_lib = library('spice-client-glib-2.0', spice_client_glib_sourc
+                                 version : spice_client_glib_so_version,
+                                 install : true,
+                                 include_directories : spice_gtk_include,
+-                                link_args : [spice_gtk_version_script],
++#                                link_args : [spice_gtk_version_script],
+                                 link_depends : spice_client_glib_syms,
+                                 dependencies : spice_glib_deps)
+ 
+-- 
+2.41.0
+

+ 41 - 13
scripts/build_dependencies.sh

@@ -23,6 +23,7 @@ NC='\033[0m'
 # Knobs
 IOS_SDKMINVER="11.0"
 MAC_SDKMINVER="10.11"
+VISIONOS_SDKMINVER="1.0"
 
 # Build environment
 PLATFORM=
@@ -41,7 +42,7 @@ version_check() {
 usage () {
     echo "Usage: [VARIABLE...] $(basename $0) [-p platform] [-a architecture] [-q qemu_path] [-d] [-r]"
     echo ""
-    echo "  -p platform      Target platform. Default ios. [ios|ios_simulator|ios-tci|ios_simulator-tci|macos]"
+    echo "  -p platform      Target platform. Default ios. [ios|ios_simulator|ios-tci|ios_simulator-tci|macos|visionos|visionos_simulator]"
     echo "  -a architecture  Target architecture. Default arm64. [armv7|armv7s|arm64|i386|x86_64]"
     echo "  -q qemu_path     Do not download QEMU, use qemu_path instead."
     echo "  -d, --download   Force re-download of source even if already downloaded."
@@ -217,7 +218,7 @@ generate_meson_cross() {
     echo "python = ['$(which python3)']" >> $cross
     echo "[host_machine]" >> $cross
     case $PLATFORM in
-    ios* )
+    ios* | visionos* )
         echo "system = 'ios'" >> $cross
         ;;
     macos )
@@ -323,6 +324,12 @@ build_openssl() {
             ;;
         esac
         ;;
+    visionos_simulator )
+        OPENSSL_CROSS=visionos-sim-cross-$ARCH
+        ;;
+    visionos* )
+        OPENSSL_CROSS=visionos-cross-$ARCH
+        ;;
     esac
     if [ -z "$OPENSSL_CROSS" ]; then
         echo "${RED}Unsupported configuration for OpenSSL $PLATFORM, $ARCH${NC}"
@@ -412,6 +419,16 @@ build_angle () {
             IOS_BUILD_ARGS="$IOS_BUILD_ARGS target_environment=\"device\""
         fi
         ;;
+    visionos* )
+        TARGET_OS="ios"
+        CLANG_BASE_PATH="$(dirname $(dirname $OBJCC))"
+        IOS_BUILD_ARGS="ios_enable_code_signing=false ios_deployment_target=\"$VISIONOS_SDKMINVER\" angle_enable_gl=false angle_enable_glsl=true target_platform=\"xros\" clang_base_path=\"$CLANG_BASE_PATH\" clang_use_chrome_plugins=false use_lld=false"
+        if [ "$PLATFORM" == "visionos_simulator" ]; then
+            IOS_BUILD_ARGS="$IOS_BUILD_ARGS target_environment=\"simulator\""
+        else
+            IOS_BUILD_ARGS="$IOS_BUILD_ARGS target_environment=\"device\""
+        fi
+        ;;
     macos )
         TARGET_OS="mac"
         ;;
@@ -430,8 +447,7 @@ build_angle () {
         TARGET_CPU="x64"
         ;;
     esac
-    # FIXME: remove this hack when SwiftShader is fixed
-    sed -i.old 's/"-Wloop-analysis"/"-Wloop-analysis", "-Wno-deprecated-declarations"/g' "build/config/compiler/BUILD.gn"
+    git -C build am "$PATCHES_DIR/angle-toolchain.patch"
     gn gen "--args=is_debug=false angle_build_all=false angle_enable_metal=true $IOS_BUILD_ARGS target_os=\"$TARGET_OS\" target_cpu=\"$TARGET_CPU\"" utm_build
     ninja -C utm_build -j $NCPU
     if [ "$TARGET_OS" == "ios" ]; then
@@ -441,8 +457,6 @@ build_angle () {
         cp -a "utm_build/libEGL.dylib" "$PREFIX/lib/libEGL.dylib"
         cp -a "utm_build/libGLESv2.dylib" "$PREFIX/lib/libGLESv2.dylib"
     fi
-    # FIXME: above
-    mv "build/config/compiler/BUILD.gn.old" "build/config/compiler/BUILD.gn"
     # -headerpad_max_install_names is broken and these still fail on long paths so we just make sure they run at the end with a short path
     #install_name_tool -id "$PREFIX/lib/libEGL.dylib" "$PREFIX/lib/libEGL.dylib"
     #install_name_tool -id "$PREFIX/lib/libGLESv2.dylib" "$PREFIX/lib/libGLESv2.dylib"
@@ -492,7 +506,7 @@ build_qemu_dependencies () {
     ZSTD_BASENAME="$(basename $ZSTD_SRC)"
     meson_build "$BUILD_DIR/${ZSTD_BASENAME%.tar.*}/build/meson"
     meson_build $GST_SRC -Dtests=disabled -Ddefault_library=both -Dregistry=false
-    meson_build $GST_BASE_SRC -Dtests=disabled -Ddefault_library=both
+    meson_build $GST_BASE_SRC -Dtests=disabled -Ddefault_library=both -Dgl=disabled
     meson_build $GST_GOOD_SRC -Dtests=disabled -Ddefault_library=both
     meson_build $SPICE_PROTOCOL_SRC
     meson_build $SPICE_SERVER_SRC -Dlz4=false -Dsasl=false
@@ -652,23 +666,38 @@ CHOST=$CPU-apple-darwin
 export CHOST
 
 case $PLATFORM in
-ios* )
+ios* | visionos* )
     if [ -z "$SDKMINVER" ]; then
-        SDKMINVER="$IOS_SDKMINVER"
+        case $PLATFORM in
+        ios* )
+            SDKMINVER="$IOS_SDKMINVER"
+            ;;
+        visionos* )
+            SDKMINVER="$VISIONOS_SDKMINVER"
+            ;;
+        esac
     fi
+    HVF_FLAGS="--disable-hvf"
     case $PLATFORM in
-    *simulator* )
+    ios_simulator* )
         SDK=iphonesimulator
         CFLAGS_MINVER="-mios-simulator-version-min=$SDKMINVER"
         PLATFORM_FAMILY_PREFIX="iOS_Simulator"
-        HVF_FLAGS="--disable-hvf"
         ;;
-    * )
+    ios* )
         SDK=iphoneos
         CFLAGS_MINVER="-miphoneos-version-min=$SDKMINVER"
         PLATFORM_FAMILY_PREFIX="iOS"
         HVF_FLAGS="--enable-hvf-private"
         ;;
+    visionos_simulator* )
+        SDK=xrsimulator
+        PLATFORM_FAMILY_PREFIX="visionOS_Simulator"
+        ;;
+    visionos* )
+        SDK=xros
+        PLATFORM_FAMILY_PREFIX="visionOS"
+        ;;
     esac
     CFLAGS_TARGET=
     case $PLATFORM in
@@ -680,7 +709,6 @@ ios* )
         fi
         PLATFORM_FAMILY_NAME="$PLATFORM_FAMILY_PREFIX-TCI"
         SKIP_USB_BUILD=1
-        HVF_FLAGS="--disable-hvf"
         ;;
     * )
         PLATFORM_FAMILY_NAME="$PLATFORM_FAMILY_PREFIX"