Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 0 additions & 73 deletions Makefile

This file was deleted.

1 change: 1 addition & 0 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Build-Depends:
debhelper (>= 11),
debhelper-compat (= 11),
cargo,
just,
libclang-dev,
libglib2.0-dev,
libegl-dev,
Expand Down
19 changes: 9 additions & 10 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
#!/usr/bin/make -f

DESTDIR = debian/xdg-desktop-portal-cosmic
CLEAN ?= 1
VENDOR ?= 1

%:
dh $@

override_dh_auto_clean:
ifeq ($(CLEAN),1)
make clean
endif
ifeq ($(VENDOR),1)
if ! ischroot; then \
make vendor; \
if test "${CLEAN}" = "1"; then \
cargo clean; \
fi

if ! ischroot && test "${VENDOR}" = "1"; then \
just vendor; \
fi
endif

override_dh_auto_build:
env CARGO_HOME="$$(pwd)/target/cargo" \
make all VENDOR=$(VENDOR) prefix=/usr
just build-vendored

override_dh_auto_install:
dh_auto_install -- prefix=/usr
just rootdir=$(DESTDIR) install
108 changes: 108 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name := 'xdg-desktop-portal-cosmic'
export APPID := 'org.freedesktop.impl.portal.desktop.cosmic'

rootdir := ''
prefix := '/usr'

# Paths for the final installed system (used in service files)
libexecdir := clean(prefix / 'libexec')

# Paths for staging installation (includes rootdir)
base-dir := absolute_path(clean(rootdir / prefix))

export INSTALL_DIR := base-dir / 'share'

bin-dir := base-dir / 'libexec'
data-dir := base-dir / 'share'
lib-dir := base-dir / 'lib'
icons-dir := data-dir / 'icons' / 'hicolor'

cargo-target-dir := env('CARGO_TARGET_DIR', 'target')
bin-src := cargo-target-dir / 'release' / name
bin-dst := bin-dir / name

# Default recipe which runs `just build-release`
[private]
default: build-release

# Runs `cargo clean`
clean:
cargo clean

# `cargo clean` and removes vendored dependencies
clean-dist: clean
rm -rf .cargo vendor vendor.tar

# Compiles with debug profile
build-debug *args:
cargo build {{args}}

# Compiles with release profile
build-release *args: (build-debug '--release' args)

# Compiles release profile with vendored dependencies
build-vendored *args: vendor-extract (build-release '--frozen --offline' args)

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

# Runs a clippy check with JSON message format
check-json: (check '--message-format=json')

# Run with debug logs
run *args:
env RUST_LOG=debug RUST_BACKTRACE=full cargo run --release {{args}}

# Installs files
install:
install -Dm0755 {{bin-src}} {{bin-dst}}
sed 's|@libexecdir@|{{libexecdir}}|' data/dbus-1/{{APPID}}.service.in \
| install -Dm0644 /dev/stdin {{data-dir}}/dbus-1/services/{{APPID}}.service
sed 's|@libexecdir@|{{libexecdir}}|' data/{{APPID}}.service.in \
| install -Dm0644 /dev/stdin {{lib-dir}}/systemd/user/{{APPID}}.service
install -Dm0644 data/cosmic.portal {{data-dir}}/xdg-desktop-portal/portals/cosmic.portal
install -Dm0644 data/cosmic-portals.conf {{data-dir}}/xdg-desktop-portal/cosmic-portals.conf
find 'data'/'icons' -type f -exec echo {} \; \
| rev \
| cut -d'/' -f-3 \
| rev \
| xargs -d '\n' -I {} install -Dm0644 'data'/'icons'/{} {{icons-dir}}/{}
-pkill -f 'xdg-desktop-portal-cosmic'

# Uninstalls installed files
uninstall:
rm -f {{bin-dst}}
rm -f {{data-dir}}/dbus-1/services/{{APPID}}.service
rm -f {{lib-dir}}/systemd/user/{{APPID}}.service
rm -f {{data-dir}}/xdg-desktop-portal/portals/cosmic.portal
rm -f {{data-dir}}/xdg-desktop-portal/cosmic-portals.conf
find 'data'/'icons' -type f -exec echo {} \; \
| rev \
| cut -d'/' -f-3 \
| rev \
| xargs -d '\n' -I {} rm -f {{icons-dir}}/{}

# Vendor dependencies locally
vendor:
rm -rf .cargo
mkdir -p .cargo
cargo vendor | head -n -1 > .cargo/config.toml
echo 'directory = "vendor"' >> .cargo/config.toml
echo >> .cargo/config.toml
echo '[env]' >> .cargo/config.toml
if [ -n "$${SOURCE_DATE_EPOCH}" ]; then \
source_date="$$(date -d "@$${SOURCE_DATE_EPOCH}" "+%Y-%m-%d")"; \
echo "VERGEN_GIT_COMMIT_DATE = \"$${source_date}\"" >> .cargo/config.toml; \
fi
if [ -n "$${SOURCE_GIT_HASH}" ]; then \
echo "VERGEN_GIT_SHA = \"$${SOURCE_GIT_HASH}\"" >> .cargo/config.toml; \
fi
tar pcf vendor.tar .cargo vendor
rm -rf .cargo vendor

# Extracts vendored dependencies
[private]
vendor-extract:
rm -rf vendor
tar pxf vendor.tar