Skip to content

Commit

Permalink
Merge branch 'polish-localization' of https://github.com/mavethee/UTM
Browse files Browse the repository at this point in the history
…into polish-localization
  • Loading branch information
mavethee committed Nov 25, 2022
2 parents 55c62da + d0b2d4e commit 5051d2f
Show file tree
Hide file tree
Showing 30 changed files with 1,707 additions and 176 deletions.
75 changes: 52 additions & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,50 @@ on:

env:
BUILD_XCODE_PATH: /Applications/Xcode_14.1.app
INSTALL_REQUIREMENTS: false
RUNNER_IMAGE: macos-12

jobs:
configuration:
name: Setup configuration
runs-on: ubuntu-latest
outputs:
runner: ${{ steps.checker.outputs.runners }}
github-runner: ${{ steps.checker.outputs.github-runner }}
steps:
- name: Check for hosted runners
id: checker
shell: bash
env:
IS_SELF_HOSTED_RUNNER: ${{ secrets.IS_SELF_HOSTED_RUNNER || (github.repository_owner == 'utmapp' && 'true') }}
run: |
echo "github-runner='$RUNNER_IMAGE'" >> $GITHUB_OUTPUT
if [ "$IS_SELF_HOSTED_RUNNER" == "true" ]; then
echo "runners=['self-hosted', 'macOS']" >> $GITHUB_OUTPUT
else
echo "runners='$RUNNER_IMAGE'" >> $GITHUB_OUTPUT
fi
build-sysroot:
name: Build Sysroot
runs-on: [self-hosted, macOS, large]
runs-on: ${{ matrix.runner == 'default' && fromJSON(needs.configuration.outputs.runner) || fromJSON(needs.configuration.outputs.github-runner) }}
needs: configuration
strategy:
matrix:
arch: [arm64, x86_64]
platform: [ios, ios_simulator, ios-tci, macos]
runner: [default, github]
exclude:
# x86_64 does not exist on iOS
- arch: x86_64
platform: ios
- arch: x86_64
# TCI does not exist for x86_64 and should not use default runner
- platform: ios-tci
# use default runner
- runner: github
include:
# always run iOS TCI build on GitHub Runner (Clang bug causes DOS on hosted runner)
- arch: arm64
platform: ios-tci
runner: github
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -60,7 +89,7 @@ jobs:
run: |
echo "/usr/local/opt/bison/bin:/opt/homebrew/opt/bison/bin" >> $GITHUB_PATH
- name: Install Requirements
if: (steps.cache-sysroot.outputs.cache-hit != 'true' || github.event.inputs.rebuild_sysroot == 'true') && env.INSTALL_REQUIREMENTS == 'true'
if: (steps.cache-sysroot.outputs.cache-hit != 'true' || github.event.inputs.rebuild_sysroot == 'true') && (matrix.runner == 'github' || needs.configuration.outputs.runner == env.RUNNER_IMAGE)
run: |
brew uninstall cmake
brew install bison pkg-config gettext glib-utils libgpg-error nasm make meson
Expand All @@ -70,7 +99,7 @@ jobs:
if: steps.cache-sysroot.outputs.cache-hit != 'true' || github.event.inputs.rebuild_sysroot == 'true'
run: ./scripts/build_dependencies.sh -p ${{ matrix.platform }} -a ${{ matrix.arch }}
env:
NCPU: ${{ matrix.platform == 'ios-tci' && '1' || '0' }} # limit 1 CPU for TCI build due to memory issues, 0 = unlimited for other builds
NCPU: ${{ matrix.platform == 'ios-tci' && '1' || '0' }} # limit 1 CPU for TCI build due to memory issues, 0 = unlimited for other builds
- name: Compress Sysroot
if: steps.cache-sysroot.outputs.cache-hit != 'true' || github.event_name == 'release' || github.event.inputs.test_release == 'true'
run: tar -acf sysroot.tgz sysroot*
Expand All @@ -82,8 +111,8 @@ jobs:
path: sysroot.tgz
build-sysroot-universal:
name: Build Sysroot (Universal Mac)
runs-on: macos-12
needs: build-sysroot
runs-on: ${{ fromJSON(needs.configuration.outputs.github-runner) }}
needs: [configuration, build-sysroot]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -127,8 +156,8 @@ jobs:
path: sysroot.tgz
build-utm:
name: Build UTM
runs-on: [self-hosted, macOS]
needs: build-sysroot
runs-on: ${{ fromJSON(needs.configuration.outputs.runner) }}
needs: [configuration, build-sysroot]
strategy:
matrix:
arch: [arm64, x86_64]
Expand Down Expand Up @@ -169,8 +198,8 @@ jobs:
path: UTM.xcarchive.tgz
build-universal:
name: Build UTM (Universal Mac)
runs-on: [self-hosted, macOS]
needs: build-sysroot-universal
runs-on: ${{ fromJSON(needs.configuration.outputs.runner) }}
needs: [configuration, build-sysroot-universal]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -204,8 +233,8 @@ jobs:
path: UTM.xcarchive.tgz
package-ipa:
name: Package (iOS IPA)
runs-on: macos-12
needs: build-utm
runs-on: ${{ fromJSON(needs.configuration.outputs.github-runner) }}
needs: [configuration, build-utm]
if: github.event_name == 'release' || github.event.inputs.test_release == 'true'
steps:
- name: Checkout
Expand Down Expand Up @@ -246,8 +275,8 @@ jobs:
event-type: new-release
package-ipa-se:
name: Package (iOS-TCI IPA)
runs-on: macos-12
needs: build-utm
runs-on: ${{ fromJSON(needs.configuration.outputs.github-runner) }}
needs: [configuration, build-utm]
if: github.event_name == 'release' || github.event.inputs.test_release == 'true'
steps:
- name: Checkout
Expand Down Expand Up @@ -288,8 +317,8 @@ jobs:
event-type: new-release
package-hv:
name: Package (iOS HV)
runs-on: macos-12
needs: build-utm
runs-on: ${{ fromJSON(needs.configuration.outputs.github-runner) }}
needs: [configuration, build-utm]
if: github.event_name == 'release' || github.event.inputs.test_release == 'true'
steps:
- name: Checkout
Expand Down Expand Up @@ -323,8 +352,8 @@ jobs:
asset_content_type: application/octet-stream
package-deb:
name: Package (iOS DEB)
runs-on: macos-12
needs: build-utm
runs-on: ${{ fromJSON(needs.configuration.outputs.github-runner) }}
needs: [configuration, build-utm]
if: github.event_name == 'release' || github.event.inputs.test_release == 'true'
steps:
- name: Checkout
Expand Down Expand Up @@ -365,8 +394,8 @@ jobs:
event-type: new-release
package-mac:
name: Package (macOS)
runs-on: macos-12
needs: build-universal
runs-on: ${{ fromJSON(needs.configuration.outputs.github-runner) }}
needs: [configuration, build-universal]
if: github.event_name == 'release' || github.event.inputs.test_release == 'true'
steps:
- name: Checkout
Expand Down Expand Up @@ -427,8 +456,8 @@ jobs:
asset_content_type: application/octet-stream
submit-mac:
name: Submit (macOS)
runs-on: macos-12
needs: build-universal
runs-on: ${{ fromJSON(needs.configuration.outputs.github-runner) }}
needs: [configuration, build-universal]
if: github.event_name == 'release' || github.event.inputs.test_release == 'true'
steps:
- name: Checkout
Expand Down
48 changes: 48 additions & 0 deletions Configuration/QEMUConstant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -390,3 +390,51 @@ enum QEMUPackageFileName: String {
case debugLog = "debug.log"
case efiVariables = "efi_vars.fd"
}

// MARK: Supported features

extension QEMUArchitecture {
var hasAgentSupport: Bool {
switch self {
case .sparc, .sparc64: return false
default: return true
}
}

var hasSharingSupport: Bool {
switch self {
case .sparc, .sparc64: return false
default: return true
}
}

var hasUsbSupport: Bool {
switch self {
case .s390x: return false
case .sparc, .sparc64: return false
default: return true
}
}

var hasHypervisorSupport: Bool {
guard jb_has_hypervisor() else {
return false
}
#if arch(arm64)
return self == .aarch64
#elseif arch(x86_64)
return self == .x86_64
#else
return false
#endif
}
}

extension QEMUTarget {
var hasUsbSupport: Bool {
switch self.rawValue {
case "isapc": return false
default: return true
}
}
}
41 changes: 11 additions & 30 deletions Configuration/UTMQemuConfiguration+Arguments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -269,38 +269,12 @@ import Foundation
#endif
}

private var isHypervisorSupported: Bool {
guard jb_has_hypervisor() else {
return false
}
#if arch(arm64)
return system.architecture == .aarch64
#elseif arch(x86_64)
return system.architecture == .x86_64
#else
return false
#endif
}

private var isHypervisorUsed: Bool {
isHypervisorSupported && qemu.hasHypervisor
}

private var isUsbSupported: Bool {
if system.target.rawValue == QEMUTarget_x86_64.isapc.rawValue {
return false
}
if system.architecture == .s390x {
return false
}
if system.architecture == .sparc || system.architecture == .sparc64 {
return false
}
return true
system.architecture.hasHypervisorSupport && qemu.hasHypervisor
}

private var isUsbUsed: Bool {
isUsbSupported && input.usbBusSupport != .disabled
system.architecture.hasUsbSupport && system.target.hasUsbSupport && input.usbBusSupport != .disabled
}

@QEMUArgumentBuilder private var machineArguments: [QEMUArgument] {
Expand Down Expand Up @@ -721,8 +695,15 @@ import Foundation
}
}

private var isAgentUsed: Bool {
guard system.architecture.hasAgentSupport else {
return false
}
return sharing.hasClipboardSharing || sharing.directoryShareMode == .webdav || displays.contains(where: { $0.isDynamicResolution })
}

@QEMUArgumentBuilder private var sharingArguments: [QEMUArgument] {
if sharing.hasClipboardSharing || sharing.directoryShareMode == .webdav || displays.contains(where: { $0.isDynamicResolution }) {
if isAgentUsed {
f("-device")
f("virtio-serial")
f("-device")
Expand All @@ -736,7 +717,7 @@ import Foundation
f("spiceport,name=org.spice-space.webdav.0,id=charchannel1")
}
}
if sharing.directoryShareMode == .virtfs, let url = sharing.directoryShareUrl {
if system.architecture.hasSharingSupport && sharing.directoryShareMode == .virtfs, let url = sharing.directoryShareUrl {
f("-fsdev")
"local"
"id=virtfs0"
Expand Down
3 changes: 3 additions & 0 deletions Configuration/UTMQemuConfigurationDisplay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ struct UTMQemuConfigurationDisplay: Codable, Identifiable {
extension UTMQemuConfigurationDisplay {
init?(forArchitecture architecture: QEMUArchitecture, target: any QEMUTarget) {
self.init()
if !architecture.hasAgentSupport {
isDynamicResolution = false
}
let rawTarget = target.rawValue
if rawTarget.hasPrefix("pc") || rawTarget.hasPrefix("q35") {
hardware = QEMUDisplayDevice_x86_64.virtio_vga
Expand Down
6 changes: 3 additions & 3 deletions Configuration/UTMQemuConfigurationInput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ extension UTMQemuConfigurationInput {
init(forArchitecture architecture: QEMUArchitecture, target: any QEMUTarget) {
self.init()
let rawTarget = target.rawValue
if rawTarget.hasPrefix("pc") || rawTarget.hasPrefix("q35") {
if !architecture.hasUsbSupport || !target.hasUsbSupport {
usbBusSupport = .disabled
} else if rawTarget.hasPrefix("pc") || rawTarget.hasPrefix("q35") {
usbBusSupport = .usb3_0
} else if (architecture == .arm || architecture == .aarch64) && (rawTarget.hasPrefix("virt-") || rawTarget == "virt") {
usbBusSupport = .usb3_0
} else if rawTarget == "isapc" {
usbBusSupport = .disabled
}
}
}
Expand Down
10 changes: 1 addition & 9 deletions Configuration/UTMQemuConfigurationQEMU.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,7 @@ extension UTMQemuConfigurationQEMU {
hasUefiBoot = true
hasRNGDevice = true
}
#if arch(arm64)
if architecture == .aarch64 {
hasHypervisor = jb_has_hypervisor()
}
#elseif arch(x86_64)
if architecture == .x86_64 {
hasHypervisor = jb_has_hypervisor()
}
#endif
hasHypervisor = architecture.hasHypervisorSupport
}
}

Expand Down
7 changes: 7 additions & 0 deletions Configuration/UTMQemuConfigurationSharing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ extension UTMQemuConfigurationSharing {
init(forArchitecture architecture: QEMUArchitecture, target: any QEMUTarget) {
self.init()
let rawTarget = target.rawValue
if !architecture.hasAgentSupport {
hasClipboardSharing = false
}
if !architecture.hasSharingSupport {
directoryShareMode = .none
}
// overrides for specific configurations
if rawTarget.hasPrefix("pc") || rawTarget.hasPrefix("q35") {
directoryShareMode = .webdav
hasClipboardSharing = true
Expand Down
1 change: 1 addition & 0 deletions Documentation/Release.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ Below is a summary of all the secrets used by GitHub Actions in the release proc
|`APP_STORE_HELPER_PROFILE_UUID` |UUID of provisioning profile above |
|`APP_STORE_LAUNCHER_PROFILE_DATA`|Base64 encoded provisioning profile of QEMULauncher for App Store submission |
|`APP_STORE_LAUNCHER_PROFILE_UUID`|UUID of provisioning profile above |
|`IS_SELF_HOSTED_RUNNER` |Set to `true` to use a self hosted macOS runner set up by the owner |

### Signing for release

Expand Down
Loading

0 comments on commit 5051d2f

Please sign in to comment.