-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support building for architectures other than x86_64 on macOS (Apple …
…Silicon) (#185) * Add and test new 'ProfileInfo.machineHardwareName' property * Update 'Mint.install(package:executable:beforeOtherCommand:force:link:noInstall:)' method to construct 'swift build' command that specifies the correct target architecture in order to support building on Apple Silicon * Remove use of XCTSkipIf to preserve support for Xcode 10.2 * Update CHANGELOG.md * Clean up ProcessInfoExtensionTests by removing print for skipped tests
- Loading branch information
1 parent
7b9920f
commit 06f3914
Showing
4 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Foundation | ||
|
||
extension ProcessInfo { | ||
/// Returns a `String` representing the machine hardware name or nil if there was an error invoking `uname(_:)` or decoding the response. | ||
/// | ||
/// Return value is the equivalent to running `$ uname -m` in shell. | ||
var machineHardwareName: String? { | ||
var sysinfo = utsname() | ||
let result = uname(&sysinfo) | ||
guard result == EXIT_SUCCESS else { return nil } | ||
|
||
let data = Data(bytes: &sysinfo.machine, count: Int(_SYS_NAMELEN)) | ||
|
||
guard let identifier = String(bytes: data, encoding: .ascii) else { return nil } | ||
return identifier.trimmingCharacters(in: .controlCharacters) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@testable import MintKit | ||
import XCTest | ||
|
||
final class ProcessInfoExtensionTests: XCTestCase { | ||
#if arch(x86_64) | ||
func testMachineHardwareName_Intel() { | ||
XCTAssertEqual(ProcessInfo.processInfo.machineHardwareName, "x86_64") | ||
} | ||
#endif | ||
|
||
#if arch(arm64) | ||
func testMachineHardwareName_AppleSilicone() { | ||
XCTAssertEqual(ProcessInfo.processInfo.machineHardwareName, "arm64") | ||
} | ||
#endif | ||
} |