adds first version of the app

This commit is contained in:
2026-10-17 14:33:43 +02:00
parent ab1abadcd1
commit 7b891819b0
3066 changed files with 29585 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
# Usage: scripts/build.sh [--release]
set -euo pipefail
source "$(dirname "$0")/env.sh"
config=debug
for arg in "$@"; do
case "$arg" in
--release) config=release ;;
*) echo "unknown option: $arg" >&2; exit 2 ;;
esac
done
swift build -c "$config"
+75
View File
@@ -0,0 +1,75 @@
#!/usr/bin/env bash
# Usage: scripts/bundle.sh [--install] [--force]
# --install copy "build/Plak.app" to ~/Applications
# --force let --install replace an app that has a different bundle id
set -euo pipefail
source "$(dirname "$0")/env.sh"
install=false
force=false
for arg in "$@"; do
case "$arg" in
--install) install=true ;;
--force) force=true ;;
*) echo "unknown option: $arg" >&2; exit 2 ;;
esac
done
BUNDLE_ID=nl.blijnder.plak
VERSION=0.1.0
APP="build/Plak.app"
swift build -c release --product Plak
BIN="$(swift build -c release --show-bin-path)"
rm -rf "$APP"
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
cp "$BIN/Plak" "$APP/Contents/MacOS/Plak"
# SwiftPM resource bundles go in Contents/Resources: the .app root would break
# the code signature.
for bundle in "$BIN"/*.bundle; do
[[ -e "$bundle" ]] || continue
cp -R "$bundle" "$APP/Contents/Resources/"
done
cat > "$APP/Contents/Info.plist" <<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>Plak</string>
<key>CFBundleIdentifier</key><string>$BUNDLE_ID</string>
<key>CFBundleName</key><string>Plak</string>
<key>CFBundleDisplayName</key><string>Plak</string>
<key>CFBundlePackageType</key><string>APPL</string>
<key>CFBundleShortVersionString</key><string>$VERSION</string>
<key>CFBundleVersion</key><string>$VERSION</string>
<key>CFBundleInfoDictionaryVersion</key><string>6.0</string>
<key>LSMinimumSystemVersion</key><string>14.0</string>
<key>LSApplicationCategoryType</key><string>public.app-category.productivity</string>
<key>LSUIElement</key><true/>
<key>NSHighResolutionCapable</key><true/>
<key>NSPrincipalClass</key><string>NSApplication</string>
</dict>
</plist>
PLIST
codesign --force --deep -s - "$APP"
codesign --verify --deep --strict "$APP"
echo "built $APP"
if $install; then
target="$HOME/Applications/Plak.app"
if [[ -d "$target" ]]; then
existing="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleIdentifier' "$target/Contents/Info.plist" 2>/dev/null || true)"
if [[ "$existing" != "$BUNDLE_ID" && "$force" != true ]]; then
echo "refusing to replace $target (bundle id '$existing'); pass --force to overwrite it" >&2
exit 1
fi
rm -rf "$target"
fi
mkdir -p "$HOME/Applications"
cp -R "$APP" "$target"
echo "installed $target"
fi
Executable
+13
View File
@@ -0,0 +1,13 @@
# Sourced by the other scripts. The Command Line Tools swift is broken on this
# machine and so is xcodebuild, so we compile with Xcode's toolchain directly.
XCODE_DEV=/Applications/Xcode.app/Contents/Developer
export PATH=$XCODE_DEV/Toolchains/XcodeDefault.xctoolchain/usr/bin:$PATH
export SDKROOT=$XCODE_DEV/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
# DEVELOPER_DIR points at the Command Line Tools on purpose: with Xcode's
# developer dir, /usr/bin/xcrun and /usr/bin/git ask the broken xcodebuild for
# every lookup. SwiftPM then cannot read the manifest API's deployment target,
# falls back to macOS 11, and fails to compile swift-argument-parser's plugin.
export DEVELOPER_DIR=/Library/Developer/CommandLineTools
PLATFORM_DEV=$XCODE_DEV/Platforms/MacOSX.platform/Developer
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"
Executable
+7
View File
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# Usage: scripts/run.sh
set -euo pipefail
source "$(dirname "$0")/env.sh"
swift build
exec "$(swift build --show-bin-path)/Plak"
+15
View File
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
# Usage: scripts/test.sh [swift test args...], e.g. scripts/test.sh --filter MarkdownParserTests
set -euo pipefail
source "$(dirname "$0")/env.sh"
# Swift Testing lives in the platform developer dir, which the Xcode toolchain
# does not search on its own when invoked outside xcodebuild.
swift test \
-Xswiftc -F -Xswiftc "$PLATFORM_DEV/Library/Frameworks" \
-Xswiftc -I -Xswiftc "$PLATFORM_DEV/usr/lib" \
-Xlinker -F -Xlinker "$PLATFORM_DEV/Library/Frameworks" \
-Xlinker -rpath -Xlinker "$PLATFORM_DEV/Library/Frameworks" \
-Xlinker -L -Xlinker "$PLATFORM_DEV/usr/lib" \
-Xlinker -rpath -Xlinker "$PLATFORM_DEV/usr/lib" \
"$@"