From 2c7af23323f533cdcec252fc02ea35b80f8df428 Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy Date: Sat, 26 Mar 2022 01:12:11 +0100 Subject: [PATCH] chore: Switch from Makefile to justfile --- Makefile | 103 --------------------------------------------------- debian/rules | 27 ++++++++++---- justfile | 100 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+), 111 deletions(-) delete mode 100644 Makefile create mode 100644 justfile diff --git a/Makefile b/Makefile deleted file mode 100644 index e352b1b..0000000 --- a/Makefile +++ /dev/null @@ -1,103 +0,0 @@ -TARGET = debug -DEBUG ?= 0 - -ifeq ($(DESTDIR),) -BASE_PATH = $(HOME)/.local -LIB_PATH = $(BASE_PATH)/share -else -BASE_PATH = $(DESTDIR)/usr -LIB_PATH = $(BASE_PATH)/lib -endif - -LAUNCHER_DIR = $(LIB_PATH)/pop-launcher -SCRIPTS_DIR = $(LAUNCHER_DIR)/scripts -PLUGIN_DIR = $(LAUNCHER_DIR)/plugins -BIN_DIR = $(BASE_PATH)/bin -BIN = $(BIN_DIR)/pop-launcher - -PLUGINS=calc desktop_entries files find pop_shell pulse recent scripts terminal web - -.PHONY = all clean install uninstall vendor - -ifeq ($(DEBUG),0) - TARGET = release - ARGS += --release -endif - -VENDOR ?= 0 -ifneq ($(VENDOR),0) - ARGS += --frozen --offline -endif - -all: extract-vendor - cargo build -p pop-launcher-bin $(ARGS) - -clean: - cargo clean - -distclean: - rm -rf .cargo vendor vendor.tar target - -vendor: - mkdir -p .cargo - cargo vendor --sync plugins/Cargo.toml --sync service/Cargo.toml | 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: - for plugin in $(PLUGINS); do \ - dest=$(PLUGIN_DIR)/$${plugin}; \ - mkdir -p $${dest}; \ - install -Dm0644 plugins/src/$${plugin}/*.ron $${dest}; \ - done - - install -Dm0755 target/$(TARGET)/pop-launcher-bin $(BIN) - - # Pop Shell Windows plugin - ln -sf $(BIN) $(PLUGIN_DIR)/pop_shell/pop-shell - - # Desktop Entries plugin - ln -sf $(BIN) $(PLUGIN_DIR)/desktop_entries/desktop-entries - - # Find plugin - ln -sf $(BIN) $(PLUGIN_DIR)/find/find - - # Scripts plugin - ln -sf $(BIN) $(PLUGIN_DIR)/scripts/scripts - - # Web plugin - ln -sf $(BIN) $(PLUGIN_DIR)/web/web - - # Calculator plugin - ln -sf $(BIN) $(PLUGIN_DIR)/calc/calc - - # Files plugin - ln -sf $(BIN) $(PLUGIN_DIR)/files/files - - # Recent plugin - ln -sf $(BIN) $(PLUGIN_DIR)/recent/recent - - # Pulse plugin - ln -sf $(BIN) $(PLUGIN_DIR)/pulse/pulse - - # Terminal plugin - ln -sf $(BIN) $(PLUGIN_DIR)/terminal/terminal - - # Scripts - mkdir -p $(SCRIPTS_DIR) - for script in $(PWD)/scripts/*; do \ - cp -r $${script} $(SCRIPTS_DIR); \ - done - -release: - sed -i "s/^version.*/version = \"${RELEASE}\"/g" Cargo.toml - sed -i "s/^version.*/version = \"${RELEASE}\"/g" bin/Cargo.toml - sed -i "s/^version.*/version = \"${RELEASE}\"/g" plugins/Cargo.toml - sed -i "s/^version.*/version= \"${RELEASE}\"/g" service/Cargo.toml - cargo update diff --git a/debian/rules b/debian/rules index ea7901f..2e0ee35 100755 --- a/debian/rules +++ b/debian/rules @@ -1,6 +1,6 @@ #!/usr/bin/make -f -export VENDOR ?= 1 +VENDOR ?= 1 CLEAN ?= 1 DESTDIR=debian/tmp @@ -8,15 +8,26 @@ DESTDIR=debian/tmp dh $@ --with=systemd override_dh_auto_clean: -ifeq ($(CLEAN),1) - ischroot && make clean || make distclean -endif -ifeq ($(VENDOR),1) - ischroot || make vendor -endif + if test "${CLEAN}" = "1"; then \ + cargo clean; \ + fi + + if ! ischroot && test "${VENDOR}" = "1"; then \ + mkdir -p .cargo; \ + cargo vendor --sync plugins/Cargo.toml \ + --sync bin/Cargo.toml \ + --sync service/Cargo.toml \ + | head -n -1 > .cargo/config; \ + echo 'directory = "vendor"' >> .cargo/config; \ + tar pcf vendor.tar vendor; \ + rm -rf vendor; \ + fi override_dh_auto_build: - CARGO_HOME="$$(pwd)/target/cargo" make DESTDIR=$(DESTDIR) + env CARGO_HOME="$$(pwd)/target/cargo" just rootdir=$(DESTDIR) debug=$(DEBUG) vendor=$(VENDOR) + +override_dh_auto_install: + just rootdir=$(DESTDIR) install override_dh_fixperms: dh_fixperms diff --git a/justfile b/justfile new file mode 100644 index 0000000..32f9195 --- /dev/null +++ b/justfile @@ -0,0 +1,100 @@ +debug := '0' +vendor := '0' + +target := if debug == '1' { 'debug' } else { 'release' } +vendor_args := if vendor == '1' { '--frozen --offline' } else { '' } +debug_args := if debug == '1' { '' } else { '--release' } +cargo_args := vendor_args + ' ' + debug_args + +plugins := 'calc desktop_entries files find pop_shell pulse recent scripts terminal web' + +ID := 'pop-launcher' + +rootdir := '' + +base_dir := if rootdir == '' { + env_var('HOME') + '/.local/' +} else { + rootdir + '/usr/' +} + +lib_dir := if rootdir == '' { + base_dir + 'share/' +} else { + base_dir + 'lib/' +} + +bin_dir := base_dir + 'bin/' +bin_path := bin_dir + ID + +launcher_dir := lib_dir + ID + '/' +scripts_dir := launcher_dir + 'scripts/' +plugin_dir := launcher_dir + 'plugins/' + +version := '0.0.0' + +# Compile pop-launcher +all: _extract_vendor + cargo build -p pop-launcher-bin {{cargo_args}} + +# Remove Cargo build artifacts +clean: + cargo clean + +# Also remove .cargo and vendored dependencies +distclean: + rm -rf .cargo vendor vendor.tar target + +# Install everything +install: install_bin install_plugins install_scripts + +# Install pop-launcher binary +install_bin: + install -Dm0755 target/{{target}}/pop-launcher-bin {{bin_path}} + +# Install pop-launcher plugins +install_plugins: + #!/usr/bin/env sh + set -ex + for plugin in {{plugins}}; do + dest={{plugin_dir}}${plugin} + mkdir -p ${dest} + install -Dm0644 plugins/src/${plugin}/*.ron ${dest} + ln -sf {{bin_path}} {{plugin_dir}}${plugin}/${plugin} + done + +# Install pop-launcher scripts +install_scripts: + #!/usr/bin/env sh + set -ex + mkdir -p {{scripts_dir}} + for script in {{justfile_directory()}}/scripts/*; do + cp -r ${script} {{scripts_dir}} + done + +# Increment version across workspace +release: + sed -i "s/^version.*/version = \"{{version}}\"/g" Cargo.toml + sed -i "s/^version.*/version = \"{{version}}\"/g" bin/Cargo.toml + sed -i "s/^version.*/version = \"{{version}}\"/g" plugins/Cargo.toml + sed -i "s/^version.*/version= \"{{version}}\"/g" service/Cargo.toml + cargo update + +# Vendor Cargo dependencies locally +vendor: + mkdir -p .cargo + cargo vendor --sync bin/Cargo.toml \ + --sync plugins/Cargo.toml \ + --sync service/Cargo.toml \ + | head -n -1 > .cargo/config + echo 'directory = "vendor"' >> .cargo/config + tar pcf vendor.tar vendor + rm -rf vendor + +# Extracts vendored dependencies if vendor=1 +_extract_vendor: + #!/usr/bin/env sh + if test {{vendor}} = 1; then + rm -rf vendor + tar pxf vendor.tar + fi \ No newline at end of file