Refine macOS app bundle creation process
Simplified the macOS app bundling instructions in `Installation.md` and streamlined the app bundle script.
This commit is contained in:
parent
17d1fc25f2
commit
a0e17d89a0
|
@ -79,25 +79,12 @@ Sadly this doesn't work for all users, so feel free to update this part of docum
|
||||||
|
|
||||||
To generate an app bundle on macOS, you can use the provided script `./misc/create_app_bundle.sh`. This script will create an `.app` bundle with the necessary structure and copy the executable and icon files into the correct locations.
|
To generate an app bundle on macOS, you can use the provided script `./misc/create_app_bundle.sh`. This script will create an `.app` bundle with the necessary structure and copy the executable and icon files into the correct locations.
|
||||||
|
|
||||||
Before running the script, make sure you have the `librsvg` library installed, which is used to convert SVG icons to PNG format. You can install it using Homebrew:
|
1. Install `librsvg` with Homebrew: `brew install librsvg`
|
||||||
|
2. Run the script: `./misc/create_app_bundle.sh`
|
||||||
|
3. The `.app` bundle will be in `./target/release`
|
||||||
|
4. Move the bundle to Applications: `mv ./target/release/Czkawka.app /Applications`
|
||||||
|
|
||||||
```shellscript
|
Now, you can launch Czkawka from your Applications folder or via Spotlight search.
|
||||||
brew install librsvg
|
|
||||||
```
|
|
||||||
Then, you can run the script with the following command:
|
|
||||||
|
|
||||||
```shellscript
|
|
||||||
./misc/create_app_bundle.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
After running the script, you will find the generated `.app` bundle in the `./target/release` directory.
|
|
||||||
|
|
||||||
You can move this bundle to your Applications folder to install the app:
|
|
||||||
|
|
||||||
```shellscript
|
|
||||||
mv ./target/release/Czkawka.app /Applications
|
|
||||||
```
|
|
||||||
Now, you should be able to launch Czkawka from your Applications folder or via Spotlight search.
|
|
||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
By default, all needed libraries are bundled with the app except libheif library which allows to scan/use heif files, inside `windows_czkawka_gui.zip`, but if you compile the app or just move `czkawka_gui.exe`, then you will need to install the `GTK 4`
|
By default, all needed libraries are bundled with the app except libheif library which allows to scan/use heif files, inside `windows_czkawka_gui.zip`, but if you compile the app or just move `czkawka_gui.exe`, then you will need to install the `GTK 4`
|
||||||
|
|
|
@ -1,54 +1,38 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Define bundle ID
|
# Define bundle ID and paths
|
||||||
BUNDLE_ID="com.github.qarmin.czkawka"
|
BUNDLE_ID="com.github.qarmin.czkawka"
|
||||||
|
|
||||||
# Get the directory of the current script (works even if the script is called from another location)
|
|
||||||
DIR="$(dirname "$0")"
|
DIR="$(dirname "$0")"
|
||||||
PARENT_DIR="$(dirname "$DIR")"
|
PARENT_DIR="$(dirname "$DIR")"
|
||||||
BUNDLE_NAME="Czkawka.app"
|
BUNDLE_NAME="Czkawka.app"
|
||||||
BUNDLE_PATH="$PARENT_DIR/target/release/$BUNDLE_NAME"
|
BUNDLE_PATH="$PARENT_DIR/target/release/$BUNDLE_NAME"
|
||||||
|
|
||||||
BINARY_NAME="czkawka_gui"
|
BINARY_NAME="czkawka_gui"
|
||||||
# Extract version from Cargo.toml
|
|
||||||
VERSION=$(grep '^version = ' "$PARENT_DIR/$BINARY_NAME/Cargo.toml" | head -n 1 | cut -d '"' -f 2)
|
VERSION=$(grep '^version = ' "$PARENT_DIR/$BINARY_NAME/Cargo.toml" | head -n 1 | cut -d '"' -f 2)
|
||||||
|
|
||||||
# Step 1: Build the project
|
|
||||||
cargo build --release --manifest-path="$DIR/../Cargo.toml" --bin $BINARY_NAME
|
|
||||||
|
|
||||||
# Step 2: Create the application bundle structure
|
|
||||||
mkdir -p "$BUNDLE_PATH/Contents/MacOS"
|
|
||||||
mkdir -p "$BUNDLE_PATH/Contents/Resources"
|
|
||||||
|
|
||||||
# Step 3: Copy the binary
|
|
||||||
cp "$PARENT_DIR/target/release/$BINARY_NAME" "$BUNDLE_PATH/Contents/MacOS/"
|
|
||||||
|
|
||||||
# Step 4: Generate the icon from SVG and copy it to the bundle
|
|
||||||
SVG_PATH="$PARENT_DIR/data/icons/${BUNDLE_ID}.svg"
|
SVG_PATH="$PARENT_DIR/data/icons/${BUNDLE_ID}.svg"
|
||||||
ICONSET_DIR="${PARENT_DIR}/data/icons/${BUNDLE_ID}.iconset"
|
ICONSET_DIR="${PARENT_DIR}/data/icons/${BUNDLE_ID}.iconset"
|
||||||
|
|
||||||
# Create iconset directory
|
|
||||||
mkdir -p "$ICONSET_DIR"
|
|
||||||
|
|
||||||
# Generate icon sizes and populate the iconset
|
|
||||||
ICON_SIZES="16 32 64 128 256 512"
|
ICON_SIZES="16 32 64 128 256 512"
|
||||||
SRC_ICON="$SVG_PATH"
|
SRC_ICON="$SVG_PATH"
|
||||||
|
|
||||||
|
# Build the project
|
||||||
|
cargo build --release --manifest-path="$DIR/../Cargo.toml" --bin $BINARY_NAME
|
||||||
|
|
||||||
|
# Create the application bundle structure and copy the binary
|
||||||
|
mkdir -p "$BUNDLE_PATH/Contents/MacOS" "$BUNDLE_PATH/Contents/Resources"
|
||||||
|
cp "$PARENT_DIR/target/release/$BINARY_NAME" "$BUNDLE_PATH/Contents/MacOS/"
|
||||||
|
|
||||||
|
# Create iconset directory and generate icon sizes
|
||||||
|
mkdir -p "$ICONSET_DIR"
|
||||||
for SIZE in $ICON_SIZES; do
|
for SIZE in $ICON_SIZES; do
|
||||||
rsvg-convert -w $SIZE -h $SIZE $SRC_ICON -o "${ICONSET_DIR}/icon_${SIZE}x${SIZE}.png"
|
rsvg-convert -w $SIZE -h $SIZE $SRC_ICON -o "${ICONSET_DIR}/icon_${SIZE}x${SIZE}.png"
|
||||||
if [ $SIZE -ne 512 ]; then
|
[ $SIZE -ne 512 ] && rsvg-convert -w $((SIZE*2)) -h $((SIZE*2)) $SRC_ICON -o "${ICONSET_DIR}/icon_${SIZE}x${SIZE}@2x.png"
|
||||||
SIZE_2X=$((SIZE*2))
|
|
||||||
rsvg-convert -w $SIZE_2X -h $SIZE_2X $SRC_ICON -o "${ICONSET_DIR}/icon_${SIZE}x${SIZE}@2x.png"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Convert the iconset to an icns file
|
# Convert the iconset to an icns file and clean up the iconset directory
|
||||||
iconutil -c icns "$ICONSET_DIR" -o "$BUNDLE_PATH/Contents/Resources/${BUNDLE_ID}.icns"
|
iconutil -c icns "$ICONSET_DIR" -o "$BUNDLE_PATH/Contents/Resources/${BUNDLE_ID}.icns"
|
||||||
|
|
||||||
# Clean up the iconset directory
|
|
||||||
rm -rf "$ICONSET_DIR"
|
rm -rf "$ICONSET_DIR"
|
||||||
|
|
||||||
# Step 5: Create the Info.plist file
|
# Create the Info.plist file
|
||||||
cat <<EOF >"$BUNDLE_PATH/Contents/Info.plist"
|
cat <<EOF >"$BUNDLE_PATH/Contents/Info.plist"
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
@ -70,4 +54,4 @@ cat <<EOF >"$BUNDLE_PATH/Contents/Info.plist"
|
||||||
</plist>
|
</plist>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo "Application bundle created at: $BUNDLE_PATH"
|
echo "Application bundle created at: $BUNDLE_PATH"
|
Loading…
Reference in a new issue