Skip to content

Commit

Permalink
chore: Adding Initial macOS Build Support
Browse files Browse the repository at this point in the history
Adding a just target `build-macos` which creates an application bundle for
macOS.
First draft of multi platform release.
  • Loading branch information
vkhitrin committed Dec 25, 2024
1 parent 01581b0 commit 67ac926
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 5 deletions.
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<img alt="cosmicding logo" src="./res/icons/hicolor/256x256/apps/com.vkhitrin.cosmicding.png" alt="Logo" height="192px" width="192px">
<img alt="cosmicding logo" src="./res/linux/icons/hicolor/256x256/apps/com.vkhitrin.cosmicding.png" alt="Logo" height="192px" width="192px">
</p>

<p align="center">
Expand Down Expand Up @@ -33,7 +33,9 @@ cosmicding was tested against linkding releases `1.31.0`, and `1.36.0`.

## Installation

### Local
cosmicding is not distributed at the moment, and has to be built manually.

### Local (Linux)

```shell
# Clone the repository
Expand All @@ -49,6 +51,22 @@ just build-release
sudo just install
```

### Local (macOS)

```shell
# Clone the repository
git clone https://github.com/vkhitrin/cosmicding

# Change directory to the project folder
cd cosmicding

# Build Release version
just build-macos

# Install globally (for all users)
cp -r target/release/macos/cosmicding.app /Applications
```

## Roadmap

### Future
Expand Down
32 changes: 29 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,27 @@ bin-src := 'target' / 'release' / name
bin-dst := base-dir / 'bin' / name

desktop := appid + '.desktop'
desktop-src := 'res' / desktop
desktop-src := 'res' / 'linux' / desktop
desktop-dst := clean(rootdir / prefix) / 'share' / 'applications' / desktop

icons-src := 'res' / 'icons' / 'hicolor'
icons-src := 'res' / 'linux' / 'icons' / 'hicolor'
icons-dst := clean(rootdir / prefix) / 'share' / 'icons' / 'hicolor'

# NOTE: macOS related, should be consolidated
assets-dir := 'res' / 'macOS'
release-dir := 'target' / 'release'
app-name := name + '.app'
app-template := assets-dir / app-name
app-template-plist := app-template / 'Contents' / 'Info.plist'
app-dir := release-dir / 'macos'
app-binary := release-dir / name
app-binary-dir := app-dir / app-name / 'Contents' / 'MacOS'
app-extras-dir := app-dir / app-name / 'Contents' / 'Resources'
dmg-name := name + '.dmg'
dmg-release := release-dir / 'macos'
version := '0.1.0'
build := 'test'

default: build-release

clean:
Expand All @@ -34,6 +49,17 @@ build-release *args: (build-debug '--release' args)

build-vendored *args: vendor-extract (build-release '--frozen --offline' args)

build-macos:
cargo build --release --target=aarch64-apple-darwin
lipo "target/aarch64-apple-darwin/release/{{name}}" -create -output "{{app-binary}}"

mkdir -p "{{app-binary-dir}}"
mkdir -p "{{app-extras-dir}}"
cp -fRp "{{app-template}}" "{{app-dir}}"
cp -fp "{{app-binary}}" "{{app-binary-dir}}"
touch -r "{{app-binary}}" "{{app-dir}}/{{app-name}}"
echo "Created '{{app-name}}' in '{{app-dir}}'"

check *args:
cargo clippy --all-features {{args}} -- -W clippy::pedantic

Expand All @@ -44,7 +70,7 @@ run *args:

install: install-migrations
install -Dm0755 {{bin-src}} {{bin-dst}}
install -Dm0644 res/app.desktop {{desktop-dst}}
install -Dm0644 res/linux/app.desktop {{desktop-dst}}
for size in `ls {{icons-src}}`; do \
install -Dm0644 "{{icons-src}}/$size/apps/{{appid}}.png" "{{icons-dst}}/$size/apps/{{appid}}.png"; \
done
Expand Down
File renamed without changes.
39 changes: 39 additions & 0 deletions res/macOS/cosmicding.app/Contents/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?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>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>cosmicding</string>
<key>CFBundleIdentifier</key>
<string>com.vkhitrin.cosmicding</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>cosmicding</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>{{ VERSION }}</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>{{ BUILD }}</string>
<key>CFBundleIconFile</key>
<string>cosmicding.icns</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSMainNibFile</key>
<string></string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
<key>CFBundleDisplayName</key>
<string>cosmicding</string>
<key>NSRequiresAquaSystemAppearance</key>
<string>NO</string>
<key>CFBundleURLTypes</key>
</dict>
</plist>
Binary file not shown.

0 comments on commit 67ac926

Please sign in to comment.