-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.command
More file actions
executable file
·70 lines (60 loc) · 2.46 KB
/
build.command
File metadata and controls
executable file
·70 lines (60 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env swift
import Foundation
let dir = (CommandLine.arguments[0] as NSString)
.deletingLastPathComponent
.isEmpty
? FileManager.default.currentDirectoryPath
: ((CommandLine.arguments[0] as NSString).deletingLastPathComponent as NSString).standardizingPath
let scriptDir = URL(fileURLWithPath: dir, isDirectory: true).standardizedFileURL.path
let app = "\(scriptDir)/ClaudeRootHelper.app"
func run(_ tool: String, _ args: [String]) {
let p = Process()
p.executableURL = URL(fileURLWithPath: tool)
p.arguments = args
do {
try p.run()
p.waitUntilExit()
if p.terminationStatus != 0 {
FileHandle.standardError.write(Data("\(tool) \(args.joined(separator: " ")) exited \(p.terminationStatus)\n".utf8))
exit(p.terminationStatus)
}
} catch {
FileHandle.standardError.write(Data("Failed to run \(tool): \(error)\n".utf8))
exit(1)
}
}
print("Building ClaudeRootHelper...")
// Clean
try? FileManager.default.removeItem(atPath: app)
// Compile app
run("/usr/bin/env", [
"swiftc", "\(scriptDir)/ClaudeRootHelper.swift",
"-o", "\(scriptDir)/ClaudeRootHelper_bin",
"-framework", "Cocoa",
"-O"
])
// Compile client
run("/usr/bin/env", [
"swiftc", "\(scriptDir)/claude-root-cmd.swift",
"-o", "\(scriptDir)/claude-root-cmd_bin",
"-O"
])
// Create .app bundle
let macOS = "\(app)/Contents/MacOS"
let resources = "\(app)/Contents/Resources"
try? FileManager.default.createDirectory(atPath: macOS, withIntermediateDirectories: true)
try? FileManager.default.createDirectory(atPath: resources, withIntermediateDirectories: true)
try? FileManager.default.moveItem(atPath: "\(scriptDir)/ClaudeRootHelper_bin", toPath: "\(macOS)/ClaudeRootHelper")
try? FileManager.default.moveItem(atPath: "\(scriptDir)/claude-root-cmd_bin", toPath: "\(resources)/claude-root-cmd")
try? FileManager.default.copyItem(atPath: "\(scriptDir)/Info.plist", toPath: "\(app)/Contents/Info.plist")
try? FileManager.default.copyItem(atPath: "\(scriptDir)/AppIcon.icns", toPath: "\(resources)/AppIcon.icns")
// Ad-hoc sign
run("/usr/bin/codesign", ["--force", "--deep", "--sign", "-", app])
print("")
print("Built: \(app)")
print("")
print("To use:")
print(" 1. Double-click ClaudeRootHelper.app (it will ask for your password once)")
print(" 2. The app window shows it's running")
print(" 3. Claude can now use: claude-root-cmd <command>")
print(" 4. Quit the app when done — the helper stops automatically")