From 62f23d9a24e349f57e8857c75bdf2c0ca32c4f70 Mon Sep 17 00:00:00 2001 From: euxane Date: Sat, 30 Nov 2024 12:16:50 +0100 Subject: makefile: add --- .gitignore | 1 + flake.nix | 18 +++++++----------- makefile | 39 +++++++++++++++++++++++++++++++++++++++ readme.md | 7 +++---- 4 files changed, 50 insertions(+), 15 deletions(-) create mode 100644 makefile diff --git a/.gitignore b/.gitignore index 41bcc3d..f07dd37 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # ignore binaries * !*.* +!makefile !*/ nimcache/ diff --git a/flake.nix b/flake.nix index bbfd8f0..2118e42 100644 --- a/flake.nix +++ b/flake.nix @@ -39,18 +39,14 @@ version = "SNAPSHOT"; src = ./.; buildInputs = [ pkgs.nim ]; - buildPhase = '' - export VERSION=${final.version} - nim c --nimcache:. -d:release main.nim - ''; doCheck = true; - checkPhase = '' - nim r --nimcache:. -d:test main.nim - ''; - installPhase = '' - mkdir -p $out/bin - mv main $out/bin/${final.meta.mainProgram} - ''; + makeFlags = [ + "NIM_FLAGS=--nimcache:." + "VERSION=${final.version}" + ]; + installFlags = [ + "DESTDIR=$(out)" + ]; }); }); } diff --git a/makefile b/makefile new file mode 100644 index 0000000..8ab718e --- /dev/null +++ b/makefile @@ -0,0 +1,39 @@ +# tickwatch +# Author: Euxane TRAN-GIRARD +# Licence: EUPL-1.2 + + +tickwatch: $(wildcard *.nim) + nim c \ + ${NIM_FLAGS} \ + -d:release \ + -o:tickwatch \ + main.nim + +.PHONY: clean +clean: + rm -f tickwatch + +.PHONY: check +check: + nim r \ + ${NIM_FLAGS} \ + -d:test \ + main.nim + +.PHONY: check-loop +check-loop: + watchexec -cclear -r \ + nim r \ + ${NIM_FLAGS} \ + -d:test \ + main.nim + +.PHONY: install +install: + nim c \ + ${NIM_FLAGS} \ + -d:release \ + -o:tickwatch \ + --outdir=${DESTDIR}/bin \ + main.nim diff --git a/readme.md b/readme.md index 52c8a9e..7e0424b 100644 --- a/readme.md +++ b/readme.md @@ -68,12 +68,11 @@ Contributions Issues and patches: email the author. -Development commands --------------------- +Development +----------- * Enter the development shell: `nix develop` -* Run tests in loop: `watchexec -cclear -r nim r -d:test main.nim` -* Build executable: `nim c -d:release main.nim` +* Make targets: `tickwatch`, `check`, `check-loop`, `install`, `clean` Copyright and Licence -- cgit v1.2.3