-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
Summary
Make mcs build and run on Linux. The codebase is already well-structured with Environment and ShellRunner as natural abstraction points, so most changes are conditional compilation guards and constant swaps.
Effort Estimate
Moderate — ~15-20 focused changes, no architectural rewrite needed.
Required Changes
Build Configuration
- Remove or conditionalize
.macOS(.v13)inPackage.swift(line 7-8) — currently blocks compilation entirely
Conditional Compilation Guards
-
Darwin.read()→Glibc.read()inCLIOutput.swift:523— use#if canImport(Darwin)/#if canImport(Glibc) -
termiosVMIN/VTIME indices inCLIOutput.swift:236-237— macOS uses tuple indices 16/17, Linux uses 6/5. Replace magic numbers with platform-conditional named constants -
CryptoKit→ add#if canImport(CryptoKit)withimport Cryptofallback (fromapple/swift-crypto) in:FileHasher.swift:1SettingsHasher.swift:1SectionValidator.swift:1PackTrustManager.swift:1
-
OSAllocatedUnfairLockinScriptRunner.swift:174— Apple-only (osframework). Replace with Swift 6Mutex(Synchronization module) orNSLockwrapper
Homebrew on Linux
- Add Linuxbrew prefix
/home/linuxbrew/.linuxbrewtoHomebrew.allPrefixes(Homebrew.swift:6) - Update
Environment.swift:59-63brew prefix fallback to include Linux default path
Verification
- Foundation
Process,FileManager,NSString,ObjCBool— these work on Linux via swift-corelibs-foundation (verified in audit) - Hardcoded POSIX paths (
/usr/bin/env,/usr/bin/which,/bin/bashinConstants.swift:36-42) — exist on all standard Linux distros, no change needed - POSIX APIs (
flock,ioctl+TIOCGWINSZ,isatty,open/close,.posixPermissions) — all available on Linux, no change needed
Files Affected
| File | Change |
|---|---|
Package.swift |
Remove/conditionalize macOS platform restriction |
Sources/mcs/Core/CLIOutput.swift |
#if canImport(Darwin/Glibc) for read(), fix termios indices |
Sources/mcs/Core/FileHasher.swift |
CryptoKit conditional import |
Sources/mcs/Core/SettingsHasher.swift |
CryptoKit conditional import |
Sources/mcs/Doctor/SectionValidator.swift |
CryptoKit conditional import |
Sources/mcs/ExternalPack/PackTrustManager.swift |
CryptoKit conditional import |
Sources/mcs/ExternalPack/ScriptRunner.swift |
Replace OSAllocatedUnfairLock |
Sources/mcs/Core/Homebrew.swift |
Add Linuxbrew prefix |
Sources/mcs/Core/Environment.swift |
Add Linux brew prefix fallback |
Notes
- Distribution remains Homebrew-only (Linuxbrew is officially supported)
- All Foundation bridging types (
NSString,ObjCBool,NSNumber,NSHomeDirectory) work via swift-corelibs-foundation - POSIX APIs (
flock,ioctl,termios,isatty) are all available on Linux - No architectural changes required — just conditional compilation
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels