This commit is contained in:
@@ -10,6 +10,8 @@ BIN_NAME="$APP_NAME"
|
||||
BIN_PATH="$REPO_ROOT/.build/release/$BIN_NAME"
|
||||
INFO_PLIST="$REPO_ROOT/sources/clipbored/resources/Info.plist"
|
||||
ICON_FILE="$REPO_ROOT/sources/clipbored/resources/AppIcon.icns"
|
||||
SIZE_LIMIT_BYTES=$((2 * 1024 * 1024))
|
||||
SIZE_LIMIT_LABEL="2 MiB"
|
||||
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
@@ -20,7 +22,8 @@ swift build -c release --product "$APP_NAME" \
|
||||
-Xswiftc -Xfrontend \
|
||||
-Xswiftc -disable-reflection-metadata \
|
||||
-Xlinker -dead_strip \
|
||||
-Xlinker -no_function_starts
|
||||
-Xlinker -no_function_starts \
|
||||
-Xlinker -no_compact_unwind
|
||||
rm -rf "$APP_BUNDLE"
|
||||
mkdir -p "$APP_BUNDLE/Contents/MacOS" "$APP_BUNDLE/Contents/Resources"
|
||||
cp "$INFO_PLIST" "$APP_BUNDLE/Contents/Info.plist"
|
||||
@@ -32,18 +35,17 @@ codesign --deep --force --options runtime --sign - "$APP_BUNDLE" >/dev/null 2>&1
|
||||
touch "$APP_BUNDLE"
|
||||
|
||||
APP_SIZE=$(stat -f%z "$APP_BUNDLE/Contents/MacOS/$APP_NAME")
|
||||
APP_SIZE_LIMIT=$((1024 * 1024))
|
||||
HUMAN_SIZE=$(du -h "$APP_BUNDLE/Contents/MacOS/$APP_NAME" | cut -f1)
|
||||
APP_BUNDLE_SIZE=$(du -sh "$APP_BUNDLE" | cut -f1)
|
||||
APP_BUNDLE_BYTES=$(du -sk "$APP_BUNDLE" | awk '{print $1*1024}')
|
||||
echo "Built $APP_BUNDLE"
|
||||
echo "Binary size: $HUMAN_SIZE ($APP_SIZE bytes)"
|
||||
echo "Bundle size: $APP_BUNDLE_SIZE"
|
||||
if [ "$APP_SIZE" -gt "$APP_SIZE_LIMIT" ]; then
|
||||
echo "FAIL: executable exceeds 1MiB target ($APP_SIZE bytes)"
|
||||
if [ "$APP_SIZE" -gt "$SIZE_LIMIT_BYTES" ]; then
|
||||
echo "FAIL: executable exceeds $SIZE_LIMIT_LABEL target ($APP_SIZE bytes)"
|
||||
exit 1
|
||||
fi
|
||||
if [ "$APP_BUNDLE_BYTES" -gt 1800000 ]; then
|
||||
echo "FAIL: bundle exceeds 1.8MB target ($APP_BUNDLE_BYTES bytes)"
|
||||
if [ "$APP_BUNDLE_BYTES" -gt "$SIZE_LIMIT_BYTES" ]; then
|
||||
echo "FAIL: bundle exceeds $SIZE_LIMIT_LABEL target ($APP_BUNDLE_BYTES bytes)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user