Skip to content

Commit

Permalink
Add Cask
Browse files Browse the repository at this point in the history
  • Loading branch information
813gan committed Sep 11, 2024
1 parent a33c81d commit 3958bf7
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 13 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
.mypy_cache
*.pyc
/.valgrind-python.supp
/.cask
5 changes: 5 additions & 0 deletions Cask
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
;; -*- mode: lisp-data -*-

(source melpa)

(package-file "emacspy.el")
34 changes: 21 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -46,21 +51,24 @@ 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
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:
Expand All @@ -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"))'

0 comments on commit 3958bf7

Please sign in to comment.