Explorar o código

build: implement build for macOS (x86_64)

osy %!s(int64=5) %!d(string=hai) anos
pai
achega
c62fa79332

+ 27 - 22
.github/workflows/build.yml

@@ -3,6 +3,7 @@ on:
   push:
   push:
     branches:
     branches:
       - 'master'
       - 'master'
+      - 'dev'
     tags-ignore:
     tags-ignore:
       - '**'
       - '**'
     paths-ignore:
     paths-ignore:
@@ -19,25 +20,35 @@ jobs:
     strategy:
     strategy:
       matrix:
       matrix:
         arch: [arm64, x86_64]
         arch: [arm64, x86_64]
+        platform: [ios, macos]
+        target: [legacy, latest]
+        exclude:
+          - platform: macos
+            target: legacy
+          - platform: macos
+            arch: arm64 # not ready yet!
     steps:
     steps:
       - name: Checkout
       - name: Checkout
         uses: actions/checkout@v1
         uses: actions/checkout@v1
         with:
         with:
           submodules: recursive
           submodules: recursive
-      - name: Setup Xcode Path
+#      - name: Setup Xcode Path
+#        shell: bash
+#        run: |
+#          if [ ! -d "${{ secrets.XCODE_PATH }}" ]; then
+#            echo "WARNING: invalid XCODE_PATH specified in Github Secrets, using default Xcode version"
+#          else
+#            sudo xcode-select -switch "${{ secrets.XCODE_PATH }}"
+#          fi
+      - name: Setup Xcode Beta Path
         shell: bash
         shell: bash
-        run: |
-          if [ ! -d "${{ secrets.XCODE_PATH }}" ]; then
-            echo "WARNING: invalid XCODE_PATH specified in Github Secrets, using default Xcode version"
-          else
-            sudo xcode-select -switch "${{ secrets.XCODE_PATH }}"
-          fi
+        run: sudo xcode-select -switch /Applications/Xcode_12_beta.app
       - name: Cache Sysroot
       - name: Cache Sysroot
         id: cache-sysroot
         id: cache-sysroot
         uses: actions/cache@v1
         uses: actions/cache@v1
         with:
         with:
-          path: sysroot-${{ matrix.arch }}
-          key: ${{ matrix.arch }}-${{ hashFiles('scripts/build_dependencies.sh') }}-${{ hashFiles('patches/**') }}
+          path: sysroot-${{ matrix.platform }}-${{ matrix.arch }}
+          key: ${{ matrix.platform }}-${{ matrix.arch }}-${{ hashFiles('scripts/build_dependencies.sh') }}-${{ hashFiles('patches/**') }}
       - name: Setup Path
       - name: Setup Path
         shell: bash
         shell: bash
         run: |
         run: |
@@ -48,30 +59,24 @@ jobs:
         run: |
         run: |
           brew install bison pkg-config nasm
           brew install bison pkg-config nasm
           rm -f /usr/local/lib/pkgconfig/*.pc
           rm -f /usr/local/lib/pkgconfig/*.pc
-          ./scripts/build_dependencies.sh -a ${{ matrix.arch }}
+          ./scripts/build_dependencies.sh -p ${{ matrix.platform }} -a ${{ matrix.arch }}
       - name: Compress Sysroot
       - name: Compress Sysroot
         if: steps.cache-sysroot.outputs.cache-hit != 'true'
         if: steps.cache-sysroot.outputs.cache-hit != 'true'
         run: |
         run: |
           mkdir sysroot_tar
           mkdir sysroot_tar
-          tar cf sysroot_tar/sysroot.tgz sysroot-${{ matrix.arch }}
+          tar cf sysroot_tar/sysroot.tgz sysroot*
       - name: Upload Sysroot
       - name: Upload Sysroot
         if: steps.cache-sysroot.outputs.cache-hit != 'true'
         if: steps.cache-sysroot.outputs.cache-hit != 'true'
         uses: actions/upload-artifact@v1
         uses: actions/upload-artifact@v1
         with:
         with:
-          name: Sysroot-${{ matrix.arch }}
+          name: Sysroot-${{ matrix.platform }}-${{ matrix.arch }}
           path: sysroot_tar
           path: sysroot_tar
-      - name: Build UTM (Simulator)
-        if: matrix.arch == 'x86_64'
-        run: |
-          xcodebuild archive -archivePath build-utm/UTM -scheme UTM -sdk iphonesimulator -configuration Release
-      - name: Build UTM (iOS)
-        if: matrix.arch == 'arm64'
-        run: |
-          xcodebuild archive -archivePath build-utm/UTM -scheme UTM -sdk iphoneos -configuration Release CODE_SIGNING_ALLOWED=NO
+      - name: Build UTM
+        run: ./scripts/build_utm.sh -p ${{ matrix.platform }} -a ${{ matrix.arch }} -t ${{ matrix.target }} -o build-utm/UTM
       - name: Upload UTM
       - name: Upload UTM
         uses: actions/upload-artifact@v1
         uses: actions/upload-artifact@v1
         with:
         with:
-          name: UTM-${{ matrix.arch }}
+          name: UTM-${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.target }}
           path: build-utm
           path: build-utm
   package:
   package:
     name: Package
     name: Package
@@ -84,7 +89,7 @@ jobs:
       - name: Download Artifact
       - name: Download Artifact
         uses: actions/download-artifact@v1
         uses: actions/download-artifact@v1
         with:
         with:
-          name: UTM-arm64
+          name: UTM-ios-arm64-legacy
       - name: Install ldid
       - name: Install ldid
         run: |
         run: |
           brew install ldid
           brew install ldid

+ 1 - 0
CocoaSpice/CSDisplayMetal.m

@@ -14,6 +14,7 @@
 // limitations under the License.
 // limitations under the License.
 //
 //
 
 
+#import "TargetConditionals.h"
 #import "UTMScreenshot.h"
 #import "UTMScreenshot.h"
 #import "UTMShaderTypes.h"
 #import "UTMShaderTypes.h"
 #import "CocoaSpice.h"
 #import "CocoaSpice.h"

+ 1 - 0
Managers/UTMScreenshot.h

@@ -14,6 +14,7 @@
 // limitations under the License.
 // limitations under the License.
 //
 //
 
 
+#import "TargetConditionals.h"
 #if TARGET_OS_IPHONE
 #if TARGET_OS_IPHONE
 #include <UIKit/UIKit.h>
 #include <UIKit/UIKit.h>
 #else
 #else

+ 3 - 2
Managers/UTMScreenshot.m

@@ -14,6 +14,7 @@
 // limitations under the License.
 // limitations under the License.
 //
 //
 
 
+#import "TargetConditionals.h"
 #import "UTMScreenshot.h"
 #import "UTMScreenshot.h"
 
 
 @implementation UTMScreenshot
 @implementation UTMScreenshot
@@ -41,7 +42,7 @@
 
 
 - (instancetype)initWithContentsOfURL:(NSURL *)url {
 - (instancetype)initWithContentsOfURL:(NSURL *)url {
     if (self = [self init]) {
     if (self = [self init]) {
-        _image = [[UIImage alloc] initWithContentsOfURL:url];
+        _image = [[UIImage alloc] initWithContentsOfFile:url.path];
         if (_image == nil) {
         if (_image == nil) {
             self = nil;
             self = nil;
         }
         }
@@ -50,7 +51,7 @@
 }
 }
 
 
 - (void)writeToURL:(NSURL *)url atomically:(BOOL)atomically {
 - (void)writeToURL:(NSURL *)url atomically:(BOOL)atomically {
-    [UIImagePNGRepresentation(_screenshot) writeToURL:url atomically:atomically];
+    [UIImagePNGRepresentation(_image) writeToURL:url atomically:atomically];
 }
 }
 #else
 #else
 - (instancetype)initWithImage:(NSImage *)image {
 - (instancetype)initWithImage:(NSImage *)image {

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 367 - 367
UTM.xcodeproj/project.pbxproj


+ 2 - 2
gstreamer/gst_ios_init.m

@@ -138,7 +138,7 @@ GST_PLUGIN_STATIC_DECLARE(osxaudio);
 //GST_PLUGIN_STATIC_DECLARE(shm);
 //GST_PLUGIN_STATIC_DECLARE(shm);
 #endif
 #endif
 #if defined(GST_IOS_PLUGIN_OPENGL) || defined(GST_IOS_PLUGINS_SYS)
 #if defined(GST_IOS_PLUGIN_OPENGL) || defined(GST_IOS_PLUGINS_SYS)
-GST_PLUGIN_STATIC_DECLARE(opengl);
+//GST_PLUGIN_STATIC_DECLARE(opengl);
 #endif
 #endif
 #if defined(GST_IOS_PLUGIN_LIBVISUAL) || defined(GST_IOS_PLUGINS_VIS)
 #if defined(GST_IOS_PLUGIN_LIBVISUAL) || defined(GST_IOS_PLUGINS_VIS)
 GST_PLUGIN_STATIC_DECLARE(libvisual);
 GST_PLUGIN_STATIC_DECLARE(libvisual);
@@ -644,7 +644,7 @@ gst_ios_init (void)
 //    GST_PLUGIN_STATIC_REGISTER(shm);
 //    GST_PLUGIN_STATIC_REGISTER(shm);
 #endif
 #endif
 #if defined(GST_IOS_PLUGIN_OPENGL) || defined(GST_IOS_PLUGINS_SYS)
 #if defined(GST_IOS_PLUGIN_OPENGL) || defined(GST_IOS_PLUGINS_SYS)
-    GST_PLUGIN_STATIC_REGISTER(opengl);
+//    GST_PLUGIN_STATIC_REGISTER(opengl);
 #endif
 #endif
 #if defined(GST_IOS_PLUGIN_LIBVISUAL) || defined(GST_IOS_PLUGINS_VIS)
 #if defined(GST_IOS_PLUGIN_LIBVISUAL) || defined(GST_IOS_PLUGINS_VIS)
     GST_PLUGIN_STATIC_REGISTER(libvisual);
     GST_PLUGIN_STATIC_REGISTER(libvisual);

+ 27 - 0
patches/qemu-4.2.0.patch

@@ -5339,3 +5339,30 @@ index 1492c3b288..7497b5b1c5 100755
 -- 
 -- 
 2.24.1 (Apple Git-126)
 2.24.1 (Apple Git-126)
 
 
+From 210cdec6b981f82b48c2bc0f2154830576da7945 Mon Sep 17 00:00:00 2001
+From: osy <osy86@users.noreply.github.com>
+Date: Wed, 1 Jul 2020 22:39:02 -0700
+Subject: [PATCH] build: use -dynamiclib instead of -bundle for OSX
+
+For building QEMU as a shared lib, it must be loaded as a dylib. This breaks
+compatibility with OSX < 10.4.
+---
+ configure | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/configure b/configure
+index 7497b5b1c5..97cea5b663 100755
+--- a/configure
++++ b/configure
+@@ -861,7 +861,7 @@ Darwin)
+   hax="yes"
+   hvf="yes"
+   DSOSUF=".dylib"
+-  LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
++  LDFLAGS_SHARED="-dynamiclib -undefined dynamic_lookup"
+   if [ "$cpu" = "x86_64" ] ; then
+     QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
+     LDFLAGS="-arch x86_64 $LDFLAGS"
+-- 
+2.24.3 (Apple Git-128)
+

+ 58 - 20
scripts/build_dependencies.sh

@@ -23,10 +23,15 @@ GREEN='\033[0;32m'
 RED='\033[0;31m'
 RED='\033[0;31m'
 NC='\033[0m'
 NC='\033[0m'
 
 
+# Knobs
+IOS_SDKMINVER="9.0"
+MAC_SDKMINVER="10.11"
+
 # Build environment
 # Build environment
+PLATFORM=
 CHOST=
 CHOST=
 SDK=
 SDK=
-SDKMINVER="9.0"
+SDKMINVER=
 NCPU=$(sysctl -n hw.ncpu)
 NCPU=$(sysctl -n hw.ncpu)
 
 
 command -v realpath >/dev/null 2>&1 || realpath() {
 command -v realpath >/dev/null 2>&1 || realpath() {
@@ -34,8 +39,9 @@ command -v realpath >/dev/null 2>&1 || realpath() {
 }
 }
 
 
 usage () {
 usage () {
-    echo "Usage: [VARIABLE...] $(basename $0) [-a architecture] [-d] [-r] [-q]"
+    echo "Usage: [VARIABLE...] $(basename $0) [-p platform] [-a architecture] [-d] [-r] [-q]"
     echo ""
     echo ""
+    echo "  -p platform      Target platform. Default ios. [ios|macos]"
     echo "  -a architecture  Target architecture. Default arm64. [armv7|armv7s|arm64|i386|x86_64]"
     echo "  -a architecture  Target architecture. Default arm64. [armv7|armv7s|arm64|i386|x86_64]"
     echo "  -d, --download   Force re-download of source even if already downloaded."
     echo "  -d, --download   Force re-download of source even if already downloaded."
     echo "  -r, --rebuild    Build only. Do not download, patch, configure."
     echo "  -r, --rebuild    Build only. Do not download, patch, configure."
@@ -44,7 +50,6 @@ usage () {
     echo "  VARIABLEs are:"
     echo "  VARIABLEs are:"
     echo "    SDKVERSION     Target a specific SDK version."
     echo "    SDKVERSION     Target a specific SDK version."
     echo "    CHOST          Configure host, set if not deducable by ARCH."
     echo "    CHOST          Configure host, set if not deducable by ARCH."
-    echo "    SDK            SDK target, set if not deducable by ARCH. [iphoneos|iphonesimulator]"
     echo ""
     echo ""
     echo "    CFLAGS CPPFLAGS CXXFLAGS LDFLAGS PKG_CONFIG_PATH"
     echo "    CFLAGS CPPFLAGS CXXFLAGS LDFLAGS PKG_CONFIG_PATH"
     echo ""
     echo ""
@@ -209,7 +214,7 @@ build_qemu () {
     CFLAGS=
     CFLAGS=
     CXXFLAGS=
     CXXFLAGS=
     LDFLAGS=
     LDFLAGS=
-    build $QEMU_SRC --enable-shared-lib
+    build $QEMU_SRC --enable-shared-lib --with-coroutine=libucontext
     CFLAGS="$QEMU_CFLAGS"
     CFLAGS="$QEMU_CFLAGS"
     CXXFLAGS="$QEMU_CXXFLAGS"
     CXXFLAGS="$QEMU_CXXFLAGS"
     LDFLAGS="$QEMU_LDFLAGS"
     LDFLAGS="$QEMU_LDFLAGS"
@@ -226,10 +231,10 @@ steal_libucontext () {
 build_spice_client () {
 build_spice_client () {
     build $JSON_GLIB_SRC
     build $JSON_GLIB_SRC
     build $GST_SRC --enable-static --enable-static-plugins --disable-registry
     build $GST_SRC --enable-static --enable-static-plugins --disable-registry
-    build $GST_BASE_SRC --enable-static --disable-fatal-warnings
-    build $GST_GOOD_SRC --enable-static
+    build $GST_BASE_SRC --enable-static --disable-fatal-warnings --disable-cocoa
+    build $GST_GOOD_SRC --enable-static --disable-osx_video
     build $XML2_SRC --enable-shared=no --without-python
     build $XML2_SRC --enable-shared=no --without-python
-    build $SOUP_SRC --without-gnome --without-krb5-config --enable-shared=no
+    build $SOUP_SRC --without-gnome --without-krb5-config --enable-shared=no --disable-tls-check
     build $PHODAV_SRC
     build $PHODAV_SRC
     build $SPICE_CLIENT_SRC --with-gtk=no
     build $SPICE_CLIENT_SRC --with-gtk=no
 }
 }
@@ -240,13 +245,21 @@ fixup () {
     OLDIFS=$IFS
     OLDIFS=$IFS
     IFS=$'\n'
     IFS=$'\n'
     echo "${GREEN}Fixing up $FILE...${NC}"
     echo "${GREEN}Fixing up $FILE...${NC}"
-    install_name_tool -id "@executable_path/Frameworks/$(basename "$FILE")" "$FILE"
+    newname="@executable_path/Frameworks/$(basename "$FILE")"
+    if [ "x$PLATFORM" == "xmacos" ]; then
+        newname="@executable_path/../Frameworks/$(basename "$FILE")"
+    fi
+    install_name_tool -id "$newname" "$FILE"
     for f in $LIST
     for f in $LIST
     do
     do
         base=$(basename "$f")
         base=$(basename "$f")
         dir=$(dirname "$f")
         dir=$(dirname "$f")
         if [ "$dir" == "$PREFIX/lib" ]; then
         if [ "$dir" == "$PREFIX/lib" ]; then
-            install_name_tool -change "$f" "@executable_path/Frameworks/$base" "$FILE"
+            newname="@executable_path/Frameworks/$base"
+            if [ "x$PLATFORM" == "xmacos" ]; then
+                newname="@executable_path/../Frameworks/$base"
+            fi
+            install_name_tool -change "$f" "$newname" "$FILE"
         fi
         fi
     done
     done
     IFS=$OLDIFS
     IFS=$OLDIFS
@@ -282,6 +295,7 @@ ARCH=
 REBUILD=
 REBUILD=
 QEMU_ONLY=
 QEMU_ONLY=
 REDOWNLOAD=
 REDOWNLOAD=
+PLATFORM_FAMILY_NAME=
 while [ "x$1" != "x" ]; do
 while [ "x$1" != "x" ]; do
     case $1 in
     case $1 in
     -a )
     -a )
@@ -297,6 +311,10 @@ while [ "x$1" != "x" ]; do
     -q | --qemu )
     -q | --qemu )
         QEMU_ONLY=y
         QEMU_ONLY=y
         ;;
         ;;
+    -p )
+        PLATFORM=$2
+        shift
+        ;;
     * )
     * )
         usage
         usage
         ;;
         ;;
@@ -309,6 +327,10 @@ if [ "x$ARCH" == "x" ]; then
 fi
 fi
 export ARCH
 export ARCH
 
 
+if [ "x$PLATFORM" == "x" ]; then
+    PLATFORM=ios
+fi
+
 # Export supplied CHOST or deduce by ARCH
 # Export supplied CHOST or deduce by ARCH
 if [ -z "$CHOST" ]; then
 if [ -z "$CHOST" ]; then
     case $ARCH in
     case $ARCH in
@@ -328,25 +350,41 @@ if [ -z "$CHOST" ]; then
 fi
 fi
 export CHOST
 export CHOST
 
 
-# Export supplied SDK or deduce by ARCH
-if [ -z "$SDK" ]; then
+case $PLATFORM in
+ios )
+    if [ -z "$SDKMINVER" ]; then
+        SDKMINVER="$IOS_SDKMINVER"
+        CFLAGS_MINVER="-miphoneos-version-min=$SDKMINVER"
+    fi
     case $ARCH in
     case $ARCH in
-    armv7 | armv7s | arm64 )
+    arm* )
         SDK=iphoneos
         SDK=iphoneos
         ;;
         ;;
     i386 | x86_64 )
     i386 | x86_64 )
         SDK=iphonesimulator
         SDK=iphonesimulator
         ;;
         ;;
-    * )
-        usage
-        ;;
     esac
     esac
-fi
+    PLATFORM_FAMILY_NAME="iOS"
+    ;;
+macos )
+    if [ -z "$SDKMINVER" ]; then
+        SDKMINVER="$MAC_SDKMINVER"
+        CFLAGS_MINVER="-mmacos-version-min=$SDKMINVER"
+    fi
+    SDK=macosx
+    PLATFORM_FAMILY_NAME="macOS"
+    ;;
+* )
+    usage
+    ;;
+esac
+export SDK
+export SDKMINVER
 
 
 # Setup directories
 # Setup directories
-BUILD_DIR="build-$ARCH"
+BUILD_DIR="build-$PLATFORM_FAMILY_NAME-$ARCH"
 PATCHES_DIR="patches"
 PATCHES_DIR="patches"
-SYSROOT_DIR="sysroot-$ARCH"
+SYSROOT_DIR="sysroot-$PLATFORM_FAMILY_NAME-$ARCH"
 
 
 [ -d "$SYSROOT_DIR" ] || mkdir -p "$SYSROOT_DIR"
 [ -d "$SYSROOT_DIR" ] || mkdir -p "$SYSROOT_DIR"
 PREFIX="$(realpath "$SYSROOT_DIR")"
 PREFIX="$(realpath "$SYSROOT_DIR")"
@@ -377,8 +415,8 @@ export LD
 export PREFIX
 export PREFIX
 
 
 # Flags
 # Flags
-CFLAGS="$CFLAGS -arch $ARCH -isysroot $SDKROOT -I$PREFIX/include -miphoneos-version-min=$SDKMINVER"
-CPPFLAGS="$CPPFLAGS -arch $ARCH -isysroot $SDKROOT -I$PREFIX/include -miphoneos-version-min=$SDKMINVER"
+CFLAGS="$CFLAGS -arch $ARCH -isysroot $SDKROOT -I$PREFIX/include $CFLAGS_MINVER"
+CPPFLAGS="$CPPFLAGS -arch $ARCH -isysroot $SDKROOT -I$PREFIX/include $CFLAGS_MINVER"
 CXXFLAGS="$CXXFLAGS -arch $ARCH -isysroot $SDKROOT -I$PREFIX/include"
 CXXFLAGS="$CXXFLAGS -arch $ARCH -isysroot $SDKROOT -I$PREFIX/include"
 LDFLAGS="$LDFLAGS -arch $ARCH -isysroot $SDKROOT -L$PREFIX/lib"
 LDFLAGS="$LDFLAGS -arch $ARCH -isysroot $SDKROOT -L$PREFIX/lib"
 MAKEFLAGS="-j$NCPU"
 MAKEFLAGS="-j$NCPU"

+ 93 - 0
scripts/build_utm.sh

@@ -0,0 +1,93 @@
+#!/bin/sh
+set -e
+
+usage () {
+    echo "Usage: $(basename $0) [-p platform] [-a architecture] [-t targetversion] [-o output]"
+    echo ""
+    echo "  -p platform      Target platform. Default ios. [ios|macos]"
+    echo "  -a architecture  Target architecture. Default arm64. [armv7|armv7s|arm64|i386|x86_64]"
+    echo "  -t targetversion Target version. Default 'latest'. [legacy|latest]"
+    echo "  -o output        Output archive path. Default is current directory."
+    echo ""
+    exit 1
+}
+
+ARCH=arm64
+PLATFORM=ios
+TARGET=latest
+OUTPUT=$PWD
+SDK=
+SCHEME=
+
+while [ "x$1" != "x" ]; do
+    case $1 in
+    -a )
+        ARCH=$2
+        shift
+        ;;
+    -p )
+        PLATFORM=$2
+        shift
+        ;;
+    -t )
+        TARGET=$2
+        shift
+        ;;
+    -o )
+        OUTPUT=$2
+        shift
+        ;;
+    * )
+        usage
+        ;;
+    esac
+    shift
+done
+
+case $TARGET in
+legacy )
+    SCHEME="Legacy"
+    ;;
+latest )
+    case $PLATFORM in
+    ios )
+        SCHEME="iOS"
+        ;;
+    macos )
+        SCHEME="macOS"
+        ;;
+    * )
+        usage
+        ;;
+    esac
+    ;;
+* )
+    usage
+    ;;
+esac
+
+case $PLATFORM in
+ios )
+    case $ARCH in
+    arm* )
+        SDK=iphoneos
+        ;;
+    i386 | x86_64 )
+        SDK=iphonesimulator
+        ;;
+    * )
+        usage
+        ;;
+    esac
+    PLATFORM_FAMILY_NAME="iOS"
+    ;;
+macos )
+    SDK=macosx
+    PLATFORM_FAMILY_NAME="macOS"
+    ;;
+* )
+    usage
+    ;;
+esac
+
+xcodebuild archive -archivePath "$OUTPUT" -scheme "$SCHEME" -sdk "$SDK" -arch "$ARCH" -configuration Release CODE_SIGNING_ALLOWED=NO

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio