mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 06:45:37 +08:00
feat: Build xswiftbus for Apple Silicon
This commit is contained in:
7
.github/workflows/build.yml
vendored
7
.github/workflows/build.yml
vendored
@@ -22,7 +22,7 @@ env:
|
||||
bitrock_version: qt-professional-24.7.0
|
||||
bitrock_url: https://releases.installbuilder.com/installbuilder
|
||||
externals: swift-project/externals
|
||||
externals_sha: dfe49bbeb8f0ca664afa293ad3f454cffe751acf
|
||||
externals_sha: e1f1743ba159e11b0c065ea8f1ae1a0e91e3bf39
|
||||
use_externals: ${{ secrets.EXTERNALS_PAT != '' }}
|
||||
|
||||
jobs:
|
||||
@@ -384,11 +384,16 @@ jobs:
|
||||
ARTIFACTORY_USER: ${{ secrets.ARTIFACTORY_USER }}
|
||||
ARTIFACTORY_TOKEN: ${{ secrets.ARTIFACTORY_TOKEN }}
|
||||
run: |
|
||||
# Empty presets to avoid autogenerated config from Conan
|
||||
echo "{\"version\": 6}" > CMakeUserPresets.json
|
||||
conan profile detect
|
||||
conan remote disable conancenter
|
||||
conan remote add swift https://artifactory.swift-project.org/artifactory/api/conan/conan-local
|
||||
conan remote login swift "$ARTIFACTORY_USER" --password "$ARTIFACTORY_TOKEN"
|
||||
conan install . --output-folder=build_conan --deployer=full_deploy -pr=ci/profile_mac
|
||||
conan install . --output-folder=build_conan_arm --deployer=full_deploy -pr=ci/profile_mac_arm
|
||||
# https://doc.qt.io/qt-6/macos-issues.html#d-bus-and-macos
|
||||
conan install --requires=dbus/1.15.8 --output-folder build_conan_dbus_shared --deployer=full_deploy -o "dbus/*:shared=True" -o "dbus/*:message_bus=True" -pr=ci/profile_mac
|
||||
- name: Create Vatsim key file
|
||||
if: ${{ env.do_vatsim_key == 'true' }}
|
||||
run: |
|
||||
|
||||
@@ -6,8 +6,16 @@ cmake_policy(VERSION 3.21)
|
||||
cmake_minimum_required(VERSION 3.26)
|
||||
|
||||
if(APPLE)
|
||||
set(CMAKE_OSX_ARCHITECTURES "x86_64")
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15")
|
||||
if (NOT DEFINED CMAKE_OSX_ARCHITECTURES)
|
||||
# by default use x86 as currently only xswiftbus works on ARM/Apple Silicon
|
||||
set(CMAKE_OSX_ARCHITECTURES "x86_64")
|
||||
endif()
|
||||
if(CMAKE_OSX_ARCHITECTURES MATCHES "arm64")
|
||||
# arm64 only supported since 11.0
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0")
|
||||
else()
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(SWIFT_LANGUAGES C CXX)
|
||||
@@ -48,9 +56,27 @@ option(SWIFT_BUILD_EMULATED_PLUGIN "Build Emulated plugin" ON)
|
||||
cmake_dependent_option(SWIFT_BUILD_MSFS_PLUGIN "Build MSFS plugin" ON WIN32 OFF)
|
||||
cmake_dependent_option(SWIFT_BUILD_MSFS2024_PLUGIN "Build MSFS2024 plugin" ON WIN32 OFF)
|
||||
option(SWIFT_MINIFY_DEBUG_SYMBOLS "Minify debug symbols" OFF)
|
||||
option(SWIFT_ONLY_XSWIFTBUS_WORKAROUND "Only build xswiftbus (useful when compiling on ARM)" OFF)
|
||||
|
||||
option(SWIFT_USE_CRASHPAD "Use crashpad" OFF)
|
||||
|
||||
|
||||
# Shortcut to only build xswiftbus
|
||||
if (SWIFT_ONLY_XSWIFTBUS_WORKAROUND)
|
||||
set(CMAKE_AUTOMOC OFF)
|
||||
set(CMAKE_AUTORCC OFF)
|
||||
set(CMAKE_AUTOUIC OFF)
|
||||
|
||||
find_package(DBus1 REQUIRED)
|
||||
find_package(XPSDK REQUIRED)
|
||||
find_package(Libevent REQUIRED)
|
||||
find_package(nlohmann_json REQUIRED)
|
||||
|
||||
add_subdirectory(src/xswiftbus)
|
||||
return()
|
||||
endif()
|
||||
|
||||
|
||||
# VATSIM related options
|
||||
option(SWIFT_VATSIM_SUPPORT "Build with VATSIM support" ON)
|
||||
set(VATSIM_KEY_JSON "" CACHE STRING "Path to JSON containing VATSIM key")
|
||||
|
||||
@@ -41,7 +41,26 @@
|
||||
"rhs": "Darwin"
|
||||
},
|
||||
"cacheVariables": {
|
||||
"SWIFT_USE_CRASHPAD": "OFF"
|
||||
"SWIFT_USE_CRASHPAD": "OFF",
|
||||
"CMAKE_OSX_ARCHITECTURES": "x86_64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "ci-build-macos-xswiftbus-arm",
|
||||
"displayName": "CI Build macOS xswiftbus ARM",
|
||||
"inherits": "ci-base",
|
||||
"toolchainFile": "build_conan_arm/build/RelWithDebInfo/generators/conan_toolchain.cmake",
|
||||
"generator": "Unix Makefiles",
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Darwin"
|
||||
},
|
||||
"cacheVariables": {
|
||||
"SWIFT_USE_CRASHPAD": "OFF",
|
||||
"SWIFT_ONLY_XSWIFTBUS_WORKAROUND": "ON",
|
||||
"CMAKE_OSX_ARCHITECTURES": "arm64",
|
||||
"CMAKE_INSTALL_PREFIX": "${sourceDir}/dist_arm"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
11
ci/profile_mac_arm
Normal file
11
ci/profile_mac_arm
Normal file
@@ -0,0 +1,11 @@
|
||||
# SPDX-FileCopyrightText: Copyright (C) swift Project Community / Contributors
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
[settings]
|
||||
arch=armv8
|
||||
build_type=RelWithDebInfo
|
||||
compiler=apple-clang
|
||||
compiler.cppstd=gnu17
|
||||
compiler.libcxx=libc++
|
||||
compiler.version=15
|
||||
os=Macos
|
||||
@@ -225,29 +225,16 @@ elseif (APPLE)
|
||||
install(FILES ${SODIUM_PATH}/lib/${LIB} DESTINATION lib)
|
||||
endforeach ()
|
||||
|
||||
# libevent
|
||||
if(SWIFT_BUILD_XSWIFTBUS)
|
||||
set(EVENT_LIBS
|
||||
libevent_core-2.1.7.dylib
|
||||
libevent_core.dylib
|
||||
)
|
||||
CheckPathExists(${EVENT_PATH}/lib ${EVENT_LIBS})
|
||||
foreach (LIB IN LISTS EVENT_LIBS)
|
||||
install(FILES ${EVENT_PATH}/lib/${LIB} DESTINATION xswiftbus/64)
|
||||
endforeach ()
|
||||
endif()
|
||||
|
||||
# DBus
|
||||
set(CONAN_DEPLOY_DIR_DBUS_SHARED ${PROJECT_SOURCE_DIR}/build_conan_dbus_shared/full_deploy/host)
|
||||
set(DBUS_PATH_SHARED ${CONAN_DEPLOY_DIR_DBUS_SHARED}/dbus/1.15.8/${CMAKE_BUILD_TYPE}/${SWIFT_SYSTEM_PROCESSOR})
|
||||
set(DBUS_LIBS libdbus-1.3.dylib libdbus-1.dylib)
|
||||
CheckPathExists(${DBUS_PATH}/lib ${DBUS_LIBS})
|
||||
CheckPathExists(${DBUS_PATH_SHARED}/lib ${DBUS_LIBS})
|
||||
foreach (LIB IN LISTS DBUS_LIBS)
|
||||
install(FILES ${DBUS_PATH}/lib/${LIB} DESTINATION lib)
|
||||
if(SWIFT_BUILD_XSWIFTBUS)
|
||||
install(FILES ${DBUS_PATH}/lib/${LIB} DESTINATION xswiftbus/64)
|
||||
endif()
|
||||
install(FILES ${DBUS_PATH_SHARED}/lib/${LIB} DESTINATION lib)
|
||||
endforeach ()
|
||||
install(FILES ${DBUS_PATH}/bin/dbus-daemon DESTINATION bin)
|
||||
install(FILES ${DBUS_PATH}/bin/dbus-uuidgen DESTINATION bin)
|
||||
install(FILES ${DBUS_PATH_SHARED}/bin/dbus-daemon DESTINATION bin)
|
||||
install(FILES ${DBUS_PATH_SHARED}/bin/dbus-uuidgen DESTINATION bin)
|
||||
|
||||
elseif (SWIFT_WIN64)
|
||||
# Opus
|
||||
|
||||
@@ -36,6 +36,10 @@ class SwiftRecipe(ConanFile):
|
||||
if self.settings.os != "Linux":
|
||||
self.options["dbus"].shared = True
|
||||
self.options["dbus"].message_bus = True
|
||||
if self.settings.os == "Macos":
|
||||
# use static libraries on macOS for a universal plugin binary
|
||||
self.options["libevent"].shared = False
|
||||
self.options["dbus"].shared = False
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self)
|
||||
|
||||
@@ -95,6 +95,24 @@ class Builder:
|
||||
os.chdir(build_path)
|
||||
subprocess.check_call(["cmake", "--install", "."], env=dict(os.environ))
|
||||
|
||||
# Build xswiftbus for ARM/Apple Silicon
|
||||
# Workaround to do this here. Should be moved when refactoring the build script
|
||||
if self.__class__.__name__ == 'MacOSBuilder':
|
||||
arm_build_path = path.abspath(path.join(utils.get_swift_source_path(), "build_arm"))
|
||||
if not os.path.isdir(arm_build_path):
|
||||
os.makedirs(arm_build_path)
|
||||
os.chdir(arm_build_path)
|
||||
subprocess.check_call(["cmake", "..", "--preset=ci-build-macos-xswiftbus-arm"], env=dict(os.environ))
|
||||
subprocess.check_call(["cmake", "--build", ".", "-j4"], env=dict(os.environ))
|
||||
subprocess.check_call(["cmake", "--install", "."], env=dict(os.environ))
|
||||
|
||||
os.chdir(utils.get_swift_source_path())
|
||||
os.rename("dist/xswiftbus/64/mac.xpl", "dist/xswiftbus/64/mac_x86.xpl")
|
||||
|
||||
subprocess.check_call(["lipo", "-create", "dist_arm/xswiftbus/64/mac.xpl", "dist/xswiftbus/64/mac_x86.xpl", "-output", "dist/xswiftbus/64/mac.xpl"], env=dict(os.environ))
|
||||
os.remove("dist/xswiftbus/64/mac_x86.xpl")
|
||||
os.chdir(build_path)
|
||||
|
||||
if self._should_publish():
|
||||
self._strip_debug()
|
||||
self.create_installer()
|
||||
|
||||
Reference in New Issue
Block a user