forked from IQ.Lvbs/IQ.Pilot
IQ.Pilot Prebuilt Release @ ab07000
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "60x60"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "60x60"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "1x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "1x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "1x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "1x",
|
||||
"size" : "76x76"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "76x76"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "83.5x83.5"
|
||||
},
|
||||
{
|
||||
"idiom" : "ios-marketing",
|
||||
"scale" : "1x",
|
||||
"size" : "1024x1024"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"scale" : "1x",
|
||||
"size" : "16x16"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"scale" : "2x",
|
||||
"size" : "16x16"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"scale" : "1x",
|
||||
"size" : "32x32"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"scale" : "2x",
|
||||
"size" : "32x32"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"scale" : "1x",
|
||||
"size" : "128x128"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"scale" : "2x",
|
||||
"size" : "128x128"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"scale" : "1x",
|
||||
"size" : "256x256"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"scale" : "2x",
|
||||
"size" : "256x256"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"scale" : "1x",
|
||||
"size" : "512x512"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"scale" : "2x",
|
||||
"size" : "512x512"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
import SwiftUI
|
||||
|
||||
private let dextID = "org.tinygrad.tinygpu.driver2"
|
||||
|
||||
@main
|
||||
struct TinyGPUApp: App {
|
||||
private static var runner: TinyGPUCLIRunner? // prevent dealloc before callback
|
||||
@State private var text = ""
|
||||
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
|
||||
|
||||
init() {
|
||||
guard CommandLine.arguments.count > 1 else { return }
|
||||
Self.runner = TinyGPUCLIRunner(dextID)
|
||||
Self.runner?.run(args: CommandLine.arguments) { exit($0.rawValue) }
|
||||
dispatchMain()
|
||||
}
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup("TinyGPU") {
|
||||
ScrollView {
|
||||
Text(text).font(.custom("Menlo", size: 11)).frame(maxWidth: .infinity, alignment: .leading).padding(8)
|
||||
}
|
||||
.frame(width: 500, height: 300).padding()
|
||||
.onAppear { setup() }
|
||||
}
|
||||
.commands { CommandGroup(replacing: .newItem) {} }
|
||||
}
|
||||
|
||||
func setup() {
|
||||
let bundlePath = Bundle.main.bundlePath
|
||||
guard bundlePath.hasPrefix("/Applications/") else {
|
||||
var error: NSDictionary?
|
||||
NSAppleScript(source: "do shell script \"mv '\(bundlePath)' '/Applications/'\" with administrator privileges")?.executeAndReturnError(&error)
|
||||
text = error == nil ? "Moved! Please reopen from /Applications/\n" : "Move TinyGPU to /Applications first.\n"
|
||||
return
|
||||
}
|
||||
let state = TinyGPUCLIRunner.queryDextState(dextID)
|
||||
if state == .unloaded || state == .activating {
|
||||
Self.runner = TinyGPUCLIRunner(dextID)
|
||||
Self.runner?.run(args: ["", "install"]) { _ in }
|
||||
}
|
||||
text = "TinyGPU - Remote PCI Device Server\n\n" + TinyGPUCLIRunner.statusText(state)
|
||||
}
|
||||
}
|
||||
|
||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { true }
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
import Foundation
|
||||
import SystemExtensions
|
||||
|
||||
enum TinyGPUCLIExit: Int32 { case ok = 0, usage = 2, failed = 3, needsApproval = 4 }
|
||||
enum DextState { case unloaded, activating, needsApproval, activated }
|
||||
|
||||
final class TinyGPUCLIRunner: NSObject, OSSystemExtensionRequestDelegate {
|
||||
private let dextID: String
|
||||
private var done: ((TinyGPUCLIExit) -> Void)?
|
||||
private var isInstall = true
|
||||
|
||||
init(_ dextID: String) { self.dextID = dextID }
|
||||
|
||||
static func queryDextState(_ bundleID: String) -> DextState {
|
||||
let p = Process()
|
||||
p.executableURL = URL(fileURLWithPath: "/usr/bin/systemextensionsctl")
|
||||
p.arguments = ["list"]
|
||||
let pipe = Pipe()
|
||||
p.standardOutput = pipe
|
||||
p.standardError = Pipe()
|
||||
guard (try? p.run()) != nil else { return .unloaded }
|
||||
p.waitUntilExit()
|
||||
|
||||
guard let output = String(data: pipe.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8),
|
||||
let line = output.split(separator: "\n").first(where: { $0.contains(bundleID) }) else { return .unloaded }
|
||||
if line.contains("[activated enabled]") { return .activated }
|
||||
if line.contains("[activated waiting for user]") { return .needsApproval }
|
||||
return line.contains("terminated waiting to uninstall") ? .unloaded : .activating
|
||||
}
|
||||
|
||||
private static let approvalHelp = """
|
||||
Please go to System Settings > Privacy & Security and allow the extension.
|
||||
|
||||
If previously disabled: System Settings > General > Login Items & Extensions > Driver Extensions > Toggle TinyGPU ON
|
||||
|
||||
"""
|
||||
|
||||
static func statusText(_ state: DextState) -> String {
|
||||
switch state {
|
||||
case .unloaded: return "Driver extension not installed.\n\n"
|
||||
case .activating: return "Extension is activating...\n\n"
|
||||
case .needsApproval: return "Extension awaiting approval.\n\n" + approvalHelp
|
||||
case .activated: return "Extension is ready! Run tinygrad to use your eGPU.\n\n"
|
||||
}
|
||||
}
|
||||
|
||||
func run(args: [String], done: @escaping (TinyGPUCLIExit) -> Void) {
|
||||
self.done = done
|
||||
guard args.count > 1 else { return usage() }
|
||||
|
||||
switch args[1] {
|
||||
case "status":
|
||||
print(Self.statusText(Self.queryDextState(dextID)))
|
||||
done(.ok)
|
||||
case "install":
|
||||
if Self.queryDextState(dextID) == .needsApproval { print(Self.statusText(.needsApproval)); return done(.needsApproval) }
|
||||
print("Installing TinyGPU driver extension...\nYou may need to approve in System Settings.\n")
|
||||
submitRequest(activate: true)
|
||||
case "uninstall":
|
||||
guard Self.queryDextState(dextID) != .unloaded else { print("Not installed.\n"); return done(.ok) }
|
||||
print("Uninstalling TinyGPU driver extension...\n")
|
||||
isInstall = false
|
||||
submitRequest(activate: false)
|
||||
case "server":
|
||||
guard args.count > 2 else { print("Error: server requires socket path\n"); return usage() }
|
||||
done(run_server(args[2]) == 0 ? .ok : .failed)
|
||||
case "help", "-h", "--help":
|
||||
usage(); done(.ok)
|
||||
default:
|
||||
print("Unknown command: \(args[1])\n"); usage()
|
||||
}
|
||||
}
|
||||
|
||||
private func usage() {
|
||||
print("""
|
||||
Usage: TinyGPU <command>
|
||||
status Show extension status
|
||||
install Install the driver extension
|
||||
uninstall Remove the driver extension
|
||||
server <path> Start server on Unix socket
|
||||
""")
|
||||
done?(.usage)
|
||||
}
|
||||
|
||||
private func submitRequest(activate: Bool) {
|
||||
let req = activate
|
||||
? OSSystemExtensionRequest.activationRequest(forExtensionWithIdentifier: dextID, queue: .main)
|
||||
: OSSystemExtensionRequest.deactivationRequest(forExtensionWithIdentifier: dextID, queue: .main)
|
||||
req.delegate = self
|
||||
OSSystemExtensionManager.shared.submitRequest(req)
|
||||
}
|
||||
|
||||
// MARK: - OSSystemExtensionRequestDelegate
|
||||
func requestNeedsUserApproval(_ request: OSSystemExtensionRequest) {
|
||||
print("\nUser approval required!\n\n\(Self.approvalHelp)After approval, connect the gpu and use it with tinygrad.\n")
|
||||
done?(.needsApproval)
|
||||
}
|
||||
|
||||
func request(_ request: OSSystemExtensionRequest, didFinishWithResult result: OSSystemExtensionRequest.Result) {
|
||||
switch result {
|
||||
case .completed: print("Driver extension \(isInstall ? "installed" : "uninstalled") successfully!\n")
|
||||
case .willCompleteAfterReboot: print("Will complete after reboot.\n")
|
||||
@unknown default: print("Completed: \(result)\n")
|
||||
}
|
||||
done?(.ok)
|
||||
}
|
||||
|
||||
func request(_ request: OSSystemExtensionRequest, didFailWithError error: Error) {
|
||||
print("\nError: \(error.localizedDescription)\n")
|
||||
let code = (error as NSError).code
|
||||
if code == 4 { print("Missing entitlements. Rebuild with proper signing.\n") }
|
||||
else if code == 8 { print("Extension not found in app bundle.\n") }
|
||||
else if code == 9 { print("Extension disabled by user.\n\n\(Self.approvalHelp)") }
|
||||
done?(.failed)
|
||||
}
|
||||
|
||||
func request(_ request: OSSystemExtensionRequest, actionForReplacingExtension existing: OSSystemExtensionProperties,
|
||||
withExtension ext: OSSystemExtensionProperties) -> OSSystemExtensionRequest.ReplacementAction {
|
||||
print("Updating v\(existing.bundleShortVersion) -> v\(ext.bundleShortVersion)...\n")
|
||||
return .replace
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<svg viewBox="0 0 130 50" xmlns="http://www.w3.org/2000/svg">
|
||||
<!-- t -->
|
||||
<rect x="10" y="0" width="10" height="40" fill="#000000"></rect>
|
||||
<rect x="0" y="10" width="30" height="10" fill="#000000"></rect>
|
||||
<rect x="10" y="30" width="20" height="10" fill="#000000"></rect>
|
||||
<!-- i -->
|
||||
<rect x="40" y="0" width="10" height="10" fill="#000000"></rect>
|
||||
<rect x="40" y="20" width="10" height="20" fill="#000000"></rect>
|
||||
<!-- n -->
|
||||
<rect x="60" y="10" width="10" height="30" fill="#000000"></rect>
|
||||
<rect x="60" y="10" width="20" height="10" fill="#000000"></rect>
|
||||
<rect x="80" y="20" width="10" height="20" fill="#000000"></rect>
|
||||
<!-- y -->
|
||||
<rect x="100" y="10" width="10" height="20" fill="#000000"></rect>
|
||||
<rect x="100" y="20" width="30" height="10" fill="#000000"></rect>
|
||||
<rect x="120" y="10" width="10" height="30" fill="#000000"></rect>
|
||||
<rect x="100" y="40" width="20" height="10" fill="#000000"></rect>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"fill" : "automatic",
|
||||
"groups" : [
|
||||
{
|
||||
"layers" : [
|
||||
{
|
||||
"fill-specializations" : [
|
||||
{
|
||||
"value" : "automatic"
|
||||
},
|
||||
{
|
||||
"appearance" : "dark",
|
||||
"value" : {
|
||||
"solid" : "display-p3:0.94011,0.96611,0.94301,1.00000"
|
||||
}
|
||||
},
|
||||
{
|
||||
"appearance" : "tinted",
|
||||
"value" : {
|
||||
"solid" : "display-p3:0.79528,0.79528,0.79528,1.00000"
|
||||
}
|
||||
}
|
||||
],
|
||||
"hidden" : false,
|
||||
"image-name" : "tiny.svg",
|
||||
"name" : "tiny_svg",
|
||||
"position" : {
|
||||
"scale" : 5,
|
||||
"translation-in-points" : [
|
||||
0,
|
||||
19
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"shadow" : {
|
||||
"kind" : "neutral",
|
||||
"opacity" : 0.5
|
||||
},
|
||||
"translucency" : {
|
||||
"enabled" : true,
|
||||
"value" : 0.5
|
||||
}
|
||||
}
|
||||
],
|
||||
"supported-platforms" : {
|
||||
"circles" : [
|
||||
"watchOS"
|
||||
],
|
||||
"squares" : "shared"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user