-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·83 lines (72 loc) · 2.32 KB
/
build.sh
File metadata and controls
executable file
·83 lines (72 loc) · 2.32 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
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
set -e
echo "Building ChargeControl..."
BUILD_DIR="build"
APP_NAME="ChargeControl.app"
APP_DIR="$BUILD_DIR/$APP_NAME"
CONTENTS_DIR="$APP_DIR/Contents"
MACOS_DIR="$CONTENTS_DIR/MacOS"
RESOURCES_DIR="$CONTENTS_DIR/Resources"
DAEMONS_DIR="$CONTENTS_DIR/Library/LaunchDaemons"
rm -rf "$BUILD_DIR"
mkdir -p "$MACOS_DIR"
mkdir -p "$RESOURCES_DIR"
mkdir -p "$DAEMONS_DIR"
# Build Daemon
echo "Compiling Daemon..."
swiftc -o "$MACOS_DIR/ChargeControlDaemon" \
-import-objc-header Daemon/SMCParamStruct.h \
Daemon/*.swift Shared/*.swift \
-lsqlite3 \
-framework Foundation -framework IOKit
# Build CLI
echo "Compiling CLI..."
swiftc -o "$MACOS_DIR/cc" \
CLI/*.swift Shared/*.swift \
-framework Foundation
# Build App
echo "Compiling App..."
swiftc -o "$MACOS_DIR/ChargeControl" \
App/AppDelegate.swift App/BatteryState.swift App/SettingsView.swift App/Components.swift App/AppIntents.swift Shared/ChargeControlCommProtocol.swift \
-framework AppKit -framework SwiftUI -framework ServiceManagement -framework Charts -framework AppIntents
# Copy Resources
echo "Copying resources..."
if [ -d "App/Resources" ]; then
cp App/Resources/* "$RESOURCES_DIR/"
fi
# Copy plist
cp Daemon/launchd.plist "$DAEMONS_DIR/com.chargecontrol.daemon.plist"
# Create Info.plist for App
cat << 'PLIST' > "$CONTENTS_DIR/Info.plist"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>ChargeControl</string>
<key>CFBundleIdentifier</key>
<string>com.chargecontrol.app</string>
<key>CFBundleName</key>
<string>ChargeControl</string>
<key>CFBundleShortVersionString</key>
<string>1.0.3</string>
<key>CFBundleVersion</key>
<string>4</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>LSUIElement</key>
<true/>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
PLIST
echo "Signing binaries..."
codesign -s - --force --deep "$MACOS_DIR/ChargeControlDaemon"
codesign -s - --force --deep "$MACOS_DIR/cc"
codesign -s - --force --deep "$APP_DIR"
echo "Build complete at $APP_DIR"