diff --git a/Makefile b/Makefile deleted file mode 100644 index 76d3b4d4..00000000 --- a/Makefile +++ /dev/null @@ -1,61 +0,0 @@ -export prefix ?= /usr -sysconfdir ?= /etc -bindir = $(prefix)/bin -libdir = $(prefix)/lib -sharedir = $(prefix)/share - -BINARY = cosmic-comp -ID = com.pop-os.Compositor -TARGET = debug -DEBUG ?= 0 - -.PHONY = all clean install uninstall vendor - -ifeq ($(DEBUG),0) - TARGET = release - ARGS += --release -endif - -VENDOR ?= 0 -ifneq ($(VENDOR),0) - ARGS += --offline --locked -endif - -TARGET_BIN="$(DESTDIR)$(bindir)/$(BINARY)" - -all: extract-vendor - cargo build $(ARGS) - -clean: - cargo clean - -distclean: - rm -rf .cargo vendor vendor.tar target - -vendor: - mkdir -p .cargo - cargo vendor | head -n -1 > .cargo/config - echo 'directory = "vendor"' >> .cargo/config - tar pcf vendor.tar vendor - rm -rf vendor - -extract-vendor: -ifeq ($(VENDOR),1) - rm -rf vendor; tar pxf vendor.tar -endif - -install: - install -Dm0755 "target/$(TARGET)/$(BINARY)" "$(TARGET_BIN)" - -install-bare-session: install - install -Dm0644 "data/cosmic.desktop" "$(DESTDIR)$(sharedir)/wayland-sessions/cosmic.desktop" - install -Dm0644 "data/cosmic-session.target" "$(DESTDIR)$(libdir)/systemd/user/cosmic-session.target" - install -Dm0644 "data/cosmic-session-pre.target" "$(DESTDIR)$(libdir)/systemd/user/cosmic-session-pre.target" - install -Dm0644 "data/cosmic-comp.service" "$(DESTDIR)$(libdir)/systemd/user/cosmic-comp.service" - install -Dm0755 "data/cosmic-service" "$(DESTDIR)/$(bindir)/cosmic-service" - -uninstall: - rm "$(TARGET_BIN)" - -uninstall-bare-session: - rm "$(DESTDIR)$(sharedir)/wayland-sessions/cosmic.desktop" \ No newline at end of file diff --git a/data/justfile b/data/justfile new file mode 100644 index 00000000..5c13d72b --- /dev/null +++ b/data/justfile @@ -0,0 +1,29 @@ +appid := env_var('APPID') +share-dir := env_var('SHARE_DIR') +lib-dir := env_var('LIB_DIR') +bin-dir := env_var('BIN_DIR') + +desktop-src := 'cosmic' + '.desktop' +desktop-dst := share-dir / 'wayland-sessions' / desktop-src + +ccservice-src := 'cosmic-comp' + '.service' +ccservice-dst := lib-dir / 'systemd' / 'user' / ccservice-src + +session-target-src := 'cosmic-session' + '.target' +session-target-dst := lib-dir / 'systemd' / 'user' / session-pretarget-src + +session-pretarget-src := 'cosmic-session-pre' + '.target' +session-pretarget-dst := lib-dir / 'systemd' / 'user' / session-pretarget-src + +cosmic-service-src := 'cosmic-service' +cosmic-service-dst := bin-dir / cosmic-service-src + +install-bare-session: + install -Dm0644 {{desktop-src}} {{desktop-dst}} + install -Dm0644 {{ccservice-src}} {{ccservice-dst}} + install -Dm0644 {{session-pretarget-src}} {{session-pretarget-dst}} + install -Dm0644 {{session-target-src}} {{session-target-dst}} + install -Dm0755 {{cosmic-service-src}} {{cosmic-service-dst}} + +uninstall-bare-session: + rm {{desktop-dst}} {{ccservice-dst}} {{session-pretarget-dst}} {{session-target-dst}} {{cosmic-service-dst}} \ No newline at end of file diff --git a/debian/rules b/debian/rules index 5a266947..2d8a6b32 100755 --- a/debian/rules +++ b/debian/rules @@ -9,10 +9,10 @@ CLEAN ?= 1 override_dh_auto_clean: ifeq ($(CLEAN),1) - ischroot && make clean || make distclean + ischroot && just clean || just clean-dist endif ifeq ($(VENDOR),1) - ischroot || make vendor + ischroot || just vendor endif override_dh_installinit: diff --git a/justfile b/justfile new file mode 100644 index 00000000..d076a7f1 --- /dev/null +++ b/justfile @@ -0,0 +1,74 @@ +name := 'cosmic-comp' +export APPID := 'com.system76.CosmicComp' + +rootdir := '' +prefix := '/usr' + +base-dir := absolute_path(clean(rootdir / prefix)) + +export SHARE_DIR := sharedir +export BIN_DIR := base-dir / 'bin' +export LIB_DIR := libdir + +bin-src := 'target' / 'release' / name +bin-dst := base-dir / 'bin' / name + +libdir := base-dir / 'lib' +sharedir := base-dir / 'share' + +# Default recipe which runs `just build-release` +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') + +# Installs files +install: + install -Dm0755 {{bin-src}} {{bin-dst}} + +install-bare-session: install + @just data/install-bare-session + +# Uninstalls installed files +uninstall: + rm {{bin-dst}} + +uninstall-bare-session: uninstall + @just data/uninstall-bare-session + +# Vendor dependencies locally +vendor: + mkdir -p .cargo + cargo vendor --sync Cargo.toml \ + | head -n -1 > .cargo/config + echo 'directory = "vendor"' >> .cargo/config + tar pcf vendor.tar vendor + rm -rf vendor + +# Extracts vendored dependencies +vendor-extract: + #!/usr/bin/env sh + rm -rf vendor + tar pxf vendor.tar \ No newline at end of file