build: migrate from make to just
This commit is contained in:
parent
d8e4683be8
commit
af025856c7
5 changed files with 157 additions and 70 deletions
67
Makefile
67
Makefile
|
|
@ -1,67 +0,0 @@
|
||||||
export prefix ?= /usr
|
|
||||||
sysconfdir ?= /etc
|
|
||||||
bindir = $(prefix)/bin
|
|
||||||
libdir = $(prefix)/lib
|
|
||||||
sharedir = $(prefix)/share
|
|
||||||
|
|
||||||
BINARY = cosmic-comp
|
|
||||||
CARGO_TARGET_DIR ?= target
|
|
||||||
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)"
|
|
||||||
|
|
||||||
KEYBINDINGS_CONF="$(DESTDIR)$(sharedir)/cosmic/com.system76.CosmicSettings.Shortcuts/v1/defaults"
|
|
||||||
TILING_EXCEPTIONS_CONF="$(DESTDIR)$(sharedir)/cosmic/com.system76.CosmicSettings.WindowRules/v1/tiling_exception_defaults"
|
|
||||||
|
|
||||||
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
|
|
||||||
[ -n "$(SOURCE_GIT_HASH)" ] && printf '\n[env]\nGIT_HASH = "%s"\n' "$(SOURCE_GIT_HASH)" >> .cargo/config || true
|
|
||||||
tar pcf vendor.tar vendor
|
|
||||||
rm -rf vendor
|
|
||||||
|
|
||||||
extract-vendor:
|
|
||||||
ifeq ($(VENDOR),1)
|
|
||||||
rm -rf vendor; tar pxf vendor.tar
|
|
||||||
endif
|
|
||||||
|
|
||||||
install:
|
|
||||||
install -Dm0755 "$(CARGO_TARGET_DIR)/$(TARGET)/$(BINARY)" "$(TARGET_BIN)"
|
|
||||||
install -Dm0644 "data/keybindings.ron" "$(KEYBINDINGS_CONF)"
|
|
||||||
install -Dm0644 "data/tiling-exceptions.ron" "$(TILING_EXCEPTIONS_CONF)"
|
|
||||||
|
|
||||||
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)" "$(KEYBINDINGS_CONF)"
|
|
||||||
|
|
||||||
uninstall-bare-session:
|
|
||||||
rm "$(DESTDIR)$(sharedir)/wayland-sessions/cosmic.desktop"
|
|
||||||
31
README.md
Normal file
31
README.md
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
# cosmic-comp
|
||||||
|
Compositor for the COSMIC desktop environment
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
This project uses [just](https://github.com/casey/just) as a command runner.
|
||||||
|
|
||||||
|
### Available Commands
|
||||||
|
|
||||||
|
#### Building
|
||||||
|
- `just build-debug` - Compile with debug profile
|
||||||
|
- `just build-release` - Compile with release profile (default)
|
||||||
|
- `just build-vendored` - Compile release profile with vendored dependencies
|
||||||
|
- Requires vendoring first, which can be done with `just vendor`
|
||||||
|
|
||||||
|
#### Code Quality
|
||||||
|
- `just check` - Run clippy linter with pedantic warnings
|
||||||
|
|
||||||
|
#### Installation
|
||||||
|
- `just install` - Install binary and configuration files
|
||||||
|
- `just install-bare-session` - Install with bare session files (wayland session, systemd units)
|
||||||
|
- `just uninstall` - Remove installed files
|
||||||
|
- `just uninstall-bare-session` - Remove installed files including bare session files
|
||||||
|
|
||||||
|
#### Cleanup
|
||||||
|
- `just clean` - Run `cargo clean`
|
||||||
|
- `just clean-dist` - Run `cargo clean` and remove vendored dependencies
|
||||||
|
|
||||||
|
#### Vendoring
|
||||||
|
- `just vendor` - Vendor dependencies locally and create vendor.tar
|
||||||
|
- `just vendor-extract` - Extract vendored dependencies from vendor.tar
|
||||||
53
cargo.just
Normal file
53
cargo.just
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
cargo-target-dir := env('CARGO_TARGET_DIR', 'target')
|
||||||
|
|
||||||
|
# Compile with debug profile
|
||||||
|
build-debug *args:
|
||||||
|
cargo build {{ args }}
|
||||||
|
|
||||||
|
# Compile with release profile
|
||||||
|
build-release *args: (build-debug '--release' args)
|
||||||
|
|
||||||
|
# Compile with a vendored tarball
|
||||||
|
build-vendored *args: vendor-extract (build-release '--frozen --offline' args)
|
||||||
|
|
||||||
|
# Check for errors and linter warnings
|
||||||
|
check *args:
|
||||||
|
cargo clippy --all-features {{ args }} -- -W clippy::pedantic
|
||||||
|
|
||||||
|
# Remove Cargo build artifacts
|
||||||
|
[no-cd]
|
||||||
|
clean:
|
||||||
|
cargo clean
|
||||||
|
|
||||||
|
# Also remove .cargo and vendored dependencies
|
||||||
|
[no-cd]
|
||||||
|
clean-dist: clean
|
||||||
|
rm -rf .cargo vendor vendor.tar
|
||||||
|
|
||||||
|
# Vendor Cargo dependencies locally
|
||||||
|
[no-cd]
|
||||||
|
vendor:
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
mkdir -p .cargo
|
||||||
|
cargo vendor --sync Cargo.toml | 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 "GIT_HASH = \"${SOURCE_GIT_HASH}\"" >> .cargo/config.toml
|
||||||
|
fi
|
||||||
|
tar pcf vendor.tar .cargo vendor
|
||||||
|
rm -rf .cargo vendor
|
||||||
|
|
||||||
|
# Extracts vendored dependencies
|
||||||
|
[no-cd]
|
||||||
|
[private]
|
||||||
|
vendor-extract:
|
||||||
|
rm -rf vendor
|
||||||
|
tar pxf vendor.tar
|
||||||
12
debian/rules
vendored
12
debian/rules
vendored
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/make -f
|
#!/usr/bin/make -f
|
||||||
|
|
||||||
export sysconfdir = "/usr/share"
|
DESTDIR = debian/cosmic-comp
|
||||||
export VENDOR ?= 1
|
export VENDOR ?= 1
|
||||||
CLEAN ?= 1
|
CLEAN ?= 1
|
||||||
|
|
||||||
|
|
@ -9,12 +9,18 @@ CLEAN ?= 1
|
||||||
|
|
||||||
override_dh_auto_clean:
|
override_dh_auto_clean:
|
||||||
ifeq ($(CLEAN),1)
|
ifeq ($(CLEAN),1)
|
||||||
ischroot && make clean || make distclean
|
ischroot && just clean || just clean-dist
|
||||||
endif
|
endif
|
||||||
ifeq ($(VENDOR),1)
|
ifeq ($(VENDOR),1)
|
||||||
ischroot || make vendor
|
ischroot || just vendor
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
override_dh_auto_build:
|
||||||
|
just build-vendored
|
||||||
|
|
||||||
|
override_dh_auto_install:
|
||||||
|
just rootdir=$(DESTDIR) install
|
||||||
|
|
||||||
override_dh_installinit:
|
override_dh_installinit:
|
||||||
dh_installinit -r
|
dh_installinit -r
|
||||||
|
|
||||||
|
|
|
||||||
64
justfile
Normal file
64
justfile
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
name := 'cosmic-comp'
|
||||||
|
|
||||||
|
rootdir := ''
|
||||||
|
prefix := '/usr'
|
||||||
|
sysconfdir := '/etc'
|
||||||
|
|
||||||
|
base-dir := absolute_path(clean(rootdir / prefix))
|
||||||
|
sysconfdir-dir := absolute_path(clean(rootdir / sysconfdir))
|
||||||
|
|
||||||
|
bin-dir := base-dir / 'bin'
|
||||||
|
lib-dir := base-dir / 'lib'
|
||||||
|
share-dir := base-dir / 'share'
|
||||||
|
|
||||||
|
bin-src := cargo-target-dir / 'release' / name
|
||||||
|
bin-dst := bin-dir / name
|
||||||
|
|
||||||
|
keybindings-src := 'data' / 'keybindings.ron'
|
||||||
|
keybindings-dst := share-dir / 'cosmic' / 'com.system76.CosmicSettings.Shortcuts' / 'v1' / 'defaults'
|
||||||
|
|
||||||
|
tiling-exceptions-src := 'data' / 'tiling-exceptions.ron'
|
||||||
|
tiling-exceptions-dst := share-dir / 'cosmic' / 'com.system76.CosmicSettings.WindowRules' / 'v1' / 'tiling_exception_defaults'
|
||||||
|
|
||||||
|
session-desktop-src := 'data' / 'cosmic.desktop'
|
||||||
|
session-desktop-dst := share-dir / 'wayland-sessions' / 'cosmic.desktop'
|
||||||
|
|
||||||
|
systemd-session-target-src := 'data' / 'cosmic-session.target'
|
||||||
|
systemd-session-target-dst := lib-dir / 'systemd' / 'user' / 'cosmic-session.target'
|
||||||
|
|
||||||
|
systemd-session-pre-target-src := 'data' / 'cosmic-session-pre.target'
|
||||||
|
systemd-session-pre-target-dst := lib-dir / 'systemd' / 'user' / 'cosmic-session-pre.target'
|
||||||
|
|
||||||
|
systemd-comp-service-src := 'data' / 'cosmic-comp.service'
|
||||||
|
systemd-comp-service-dst := lib-dir / 'systemd' / 'user' / 'cosmic-comp.service'
|
||||||
|
|
||||||
|
cosmic-service-src := 'data' / 'cosmic-service'
|
||||||
|
cosmic-service-dst := bin-dir / 'cosmic-service'
|
||||||
|
|
||||||
|
import 'cargo.just'
|
||||||
|
|
||||||
|
# Default recipe which runs `just build-release`
|
||||||
|
[private]
|
||||||
|
default: build-release
|
||||||
|
|
||||||
|
# Installs files
|
||||||
|
install:
|
||||||
|
install -Dm0755 {{bin-src}} {{bin-dst}}
|
||||||
|
install -Dm0644 {{keybindings-src}} {{keybindings-dst}}
|
||||||
|
install -Dm0644 {{tiling-exceptions-src}} {{tiling-exceptions-dst}}
|
||||||
|
|
||||||
|
# Installs files including bare session files
|
||||||
|
install-bare-session: install
|
||||||
|
install -Dm0644 {{session-desktop-src}} {{session-desktop-dst}}
|
||||||
|
install -Dm0644 {{systemd-session-target-src}} {{systemd-session-target-dst}}
|
||||||
|
install -Dm0644 {{systemd-session-pre-target-src}} {{systemd-session-pre-target-dst}}
|
||||||
|
install -Dm0644 {{systemd-comp-service-src}} {{systemd-comp-service-dst}}
|
||||||
|
install -Dm0755 {{cosmic-service-src}} {{cosmic-service-dst}}
|
||||||
|
|
||||||
|
# Uninstalls installed files
|
||||||
|
uninstall:
|
||||||
|
rm {{bin-dst}} {{keybindings-dst}} {{tiling-exceptions-dst}}
|
||||||
|
|
||||||
|
# Uninstalls installed files including bare session files
|
||||||
|
uninstall-bare-session: uninstall
|
||||||
|
rm {{session-desktop-dst}} {{systemd-session-target-dst}} {{systemd-session-pre-target-dst}} {{systemd-comp-service-dst}} {{cosmic-service-dst}}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue