From 3958bf7a69acc2376987daa6056d1095c6044452 Mon Sep 17 00:00:00 2001 From: 813gan <813gan@protonmail.com> Date: Wed, 11 Sep 2024 02:25:19 +0200 Subject: [PATCH] Add Cask --- .github/workflows/test.yml | 15 +++++++++++++++ .gitignore | 1 + Cask | 5 +++++ Makefile | 34 +++++++++++++++++++++------------- 4 files changed, 42 insertions(+), 13 deletions(-) create mode 100644 Cask diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8a2b91f..945e5a4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,6 +25,21 @@ jobs: - uses: purcell/setup-emacs@master with: version: ${{ matrix.emacs_version }} + - uses: actions/cache@v2 + id: cache-cask-packages + with: + path: .cask + key: cache-cask-packages-000 + - uses: actions/cache@v2 + id: cache-cask-executable + with: + path: ~/.cask + key: cache-cask-executable-000 + - uses: cask/setup-cask@master + if: steps.cache-cask-executable.outputs.cache-hit != 'true' + with: + version: snapshot + - run: echo "$HOME/.cask/bin" >> $GITHUB_PATH - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python_version }} diff --git a/.gitignore b/.gitignore index 503f29b..a32324d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ .mypy_cache *.pyc /.valgrind-python.supp +/.cask diff --git a/Cask b/Cask new file mode 100644 index 0000000..0f86120 --- /dev/null +++ b/Cask @@ -0,0 +1,5 @@ +;; -*- mode: lisp-data -*- + +(source melpa) + +(package-file "emacspy.el") diff --git a/Makefile b/Makefile index c72d102..a146dec 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,10 @@ -PYTHON := "python3" -ifeq ("$(EMACS)","") -EMACS := emacs -endif +PYTHON ?= "python3" +export EMACS ?= $(shell command -v emacs 2>/dev/null) +CASK ?= $(shell which cask || echo ${HOME}/.local/bin/cask) CLANGFORMAT := clang-format +.PHONY: all clean clean_bin clean_cask test_module_assertions test test_ert test_formatting test_valgrind + HARDENING_FLAGS := -fstack-protector -fstack-clash-protection -fcf-protection \ -D_FORTIFY_SOURCE=2 -ftrapv -Wformat=2 -Wjump-misses-init OPTIMALISATION_FLAGS := -O2 @@ -21,12 +22,16 @@ ifeq (, $(shell which pkg-config)) $(error "No pkg-config found.") endif -IS_PYTHON_OLD := $(shell ${PYTHON} -c 'import platform;from packaging import version as v; \ -print("-DPYTHON311OLDER") if (v.parse(platform.python_version()) < v.parse("3.12.0")) else exit(0)') +all: emacspy-module.so -.PHONY: all clean test_module_assertions test test_ert test_formatting test_valgrind +CASK_DIR := $(shell ${CASK} package-directory) +$(CASK_DIR): Cask + ${CASK} install + @touch $(CASK_DIR) +cask: $(CASK_DIR) -all: emacspy-module.so +IS_PYTHON_OLD := $(shell ${PYTHON} -c 'import platform;from packaging import version as v; \ +print("-DPYTHON311OLDER") if (v.parse(platform.python_version()) < v.parse("3.12.0")) else exit(0)') emacspy.c: emacspy.pyx cython emacspy.pyx @@ -46,13 +51,16 @@ emacspy-module.so: emacspy.c stub.c subinterpreter.c -shared $(shell pkg-config --cflags --libs $(PKGCONFIG_PATH)"/python3-embed.pc") \ -o emacspy-module.so -clean: +clean_bin: rm -vf emacspy.c emacspy-module.so +clean_cask: + rm -vfr .cask +clean: clean_cask clean_bin test: test_ert test_formatting -test_ert: all - ulimit -c unlimited; ${EMACS} -batch -l tests/prepare-tests.el -l ert -l tests/test.el \ +test_ert: cask all + ulimit -c unlimited; ${CASK} emacs -batch -l tests/prepare-tests.el -l ert -l tests/test.el \ -f ert-run-tests-batch-and-exit # https://stackoverflow.com/questions/20112989/how-to-use-valgrind-with-python @@ -60,7 +68,7 @@ test_valgrind: OPTIMALISATION_FLAGS= test_valgrind: clean all .valgrind-python.supp PYTHONMALLOC=malloc valgrind --tool=memcheck --suppressions=.valgrind-python.supp \ --leak-check=full --show-leak-kinds=all \ - ${EMACS} -batch -l tests/prepare-tests.el -l ert -l tests/test.el \ + ${CASK} emacs -batch -l tests/prepare-tests.el -l ert -l tests/test.el \ -f ert-run-tests-batch-and-exit .valgrind-python.supp: @@ -73,5 +81,5 @@ test_formatting: ${CLANGFORMAT} --dry-run --Werror stub.c subinterpreter.c test_module_assertions: emacspy-module.so - ${EMACS} --batch --module-assertions --eval \ + ${CASK} emacs --batch --module-assertions --eval \ '(progn (add-to-list '\''load-path ".") (load "emacspy"))'