diff options
author | sternenseemann <sternenseemann@systemli.org> | 2022-05-01 14:07:17 +0200 |
---|---|---|
committer | sternenseemann <sternenseemann@systemli.org> | 2022-05-01 14:57:22 +0200 |
commit | 5f8564a784b51b953c27dde4146f1b4a1ce991b4 (patch) | |
tree | 4ca4a31d0365ba32083ef0b5854c148c80890584 | |
parent | 0431d78fa421b6d9d6b221a1b796018c50a95af8 (diff) |
chore: port to meson
This means that we can finally build a shared library correctly without to much hassle and will be able to use pkgsStatic as well (provided we fix the dependencies upstream). redo is nice, but, while its dependency tracking is better, you end up scripting a lot in a lot of different places.
-rw-r--r-- | .gitignore | 8 | ||||
-rw-r--r-- | Makefile | 25 | ||||
-rw-r--r-- | README.md | 23 | ||||
-rw-r--r-- | build_config | 7 | ||||
-rw-r--r-- | default.exe.do | 9 | ||||
-rw-r--r-- | default.o.do | 30 | ||||
-rw-r--r-- | libbuchstabensuppe.a.do | 14 | ||||
-rw-r--r-- | meson.build | 52 | ||||
-rw-r--r-- | overlay.nix | 10 |
9 files changed, 70 insertions, 108 deletions
diff --git a/.gitignore b/.gitignore index 4ca41ba..f919254 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,5 @@ result* -*.o -*.a -/*.exe - -.dep** -.target.* -.lock.* +/build # directory used to store fonts for testing /fonts diff --git a/Makefile b/Makefile deleted file mode 100644 index 57a1289..0000000 --- a/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -PREFIX ?= /usr/local -BINDIR ?= $(PREFIX)/bin -LIBDIR ?= $(PREFIX)/lib -INCDIR ?= $(PREFIX)/include -MANDIR ?= $(PREFIX)/share/man - -.PHONY: all clean install check -all: - redo bs-renderflipdot.exe libbuchstabensuppe.a - -clean: - rm -f *.o *.a *.exe - rm -rf doc/html - -check: - redo test.exe - ./test.exe - -install: - install -Dm755 bs-renderflipdot.exe $(BINDIR)/bs-renderflipdot - install -Dm644 include/buchstabensuppe.h -t $(INCDIR) - install -Dm644 include/buchstabensuppe/bitmap.h -t $(INCDIR)/buchstabensuppe - install -Dm644 include/buchstabensuppe/flipdot.h -t $(INCDIR)/buchstabensuppe - install -Dm644 libbuchstabensuppe.a -t $(LIBDIR) - install -Dm644 doc/man/bs-renderflipdot.1 -t $(MANDIR)/man1 diff --git a/README.md b/README.md index d88df8b..5786e98 100644 --- a/README.md +++ b/README.md @@ -30,23 +30,20 @@ i. e. [openlab's flipdot display](https://wiki.openlab-augsburg.de/Flipdots). requirements: -* [redo-c](https://github.com/leahneukirchen/redo-c) -* Optionally `make` for install script and such +* [meson](https://mesonbuild.com) +* [ninja](https://ninja-build.org/) * [utf8proc](https://juliastrings.github.io/utf8proc) -* [harfbuzz](harfbuzz.github.io/) +* [harfbuzz](https://harfbuzz.github.io/) * [libschrift](https://github.com/tomolt/libschrift) == 0.10.1 ``` # run inside nix-shell if you have nix! -# static library -$ redo libbuchstabensuppe.a +$ meson build -# demo binary -$ redo bs-renderflipdot.exe +$ cd build -# tests -$ redo test.exe && ./test.exe +$ ninja ``` alternatively you can just run `nix-build` @@ -54,14 +51,14 @@ alternatively you can just run `nix-build` ## demo if you want to play around with the font rendering in binary -mode you can use the dry run mode of the supplied `./bs-renderflipdot.exe` +mode you can use the dry run mode of the supplied `./bs-renderflipdot` (or `./result/bin/bs-renderflipdot` if you use nix) binary. -Run `./bs-renderflipdot.exe -?` for usage instructions and don't forget `-n` +Run `./bs-renderflipdot -?` for usage instructions and don't forget `-n` for dry running! ``` -$ ./bs-renderflipdot.exe -f fonts/unifont.ttf -f fonts/unifont_upper.ttf -n "Greetings ❣️" 2>/dev/null +$ ./bs-renderflipdot -f /path/to/unifont.ttf -f /path/to/unifont_upper.ttf -n "Greetings ❣️" 2>/dev/null ███ ███ █████████ @@ -112,7 +109,7 @@ See [bs-renderflipdot(1)](https://sternenseemann.github.io/buchstabensuppe/bs-re for more usage details. ``` -./bs-renderflipdot.exe -f /path/to/unifont.ttf -f /path/to/unifont_upper.ttf -i "Hello World" +./bs-renderflipdot -f /path/to/unifont.ttf -f /path/to/unifont_upper.ttf -i "Hello World" ``` ## caveats diff --git a/build_config b/build_config deleted file mode 100644 index 4f83f34..0000000 --- a/build_config +++ /dev/null @@ -1,7 +0,0 @@ -AR=ar -RANLIB=ranlib -CC=cc -CFLAGS="-W -Wall -Wextra -pedantic -Os -std=c99 -g" -CFLAGS="$CFLAGS -Iinclude" - -# vim: ft=sh diff --git a/default.exe.do b/default.exe.do deleted file mode 100644 index f5efa96..0000000 --- a/default.exe.do +++ /dev/null @@ -1,9 +0,0 @@ -redo-ifchange build_config -source ./build_config - -DEPS="$2.o libbuchstabensuppe.a" -redo-ifchange $DEPS - -$CC $CFLAGS -o "$3" "$2.o" -L. -lm -lharfbuzz -lutf8proc -lbuchstabensuppe -lschrift - -# vim: ft=sh diff --git a/default.o.do b/default.o.do deleted file mode 100644 index c36bd86..0000000 --- a/default.o.do +++ /dev/null @@ -1,30 +0,0 @@ -redo-ifchange build_config -source ./build_config - -redo-ifchange "$2.c" - -possible_headers="include/$2.h include/buchstabensuppe/$2.h" - -for h in $possible_headers; do - if test -e "$h"; then - redo-ifchange "$h" - fi -done - -case "$2" in - buchstabensuppe) - redo-ifchange bitmap.o - ;; - bs-renderflipdot) - redo-ifchange bitmap.o - redo-ifchange buchstabensuppe.o - redo-ifchange flipdot.o - ;; - flipdot) - redo-ifchange bitmap.o - ;; - *) -esac - - -$CC $CFLAGS -o "$3" -c "$2.c" diff --git a/libbuchstabensuppe.a.do b/libbuchstabensuppe.a.do deleted file mode 100644 index d813554..0000000 --- a/libbuchstabensuppe.a.do +++ /dev/null @@ -1,14 +0,0 @@ -source ./build_config -redo-ifchange ./build_config - -OBJS="bitmap.o buchstabensuppe.o flipdot.o" -redo-ifchange $OBJS - -tmp_dir="$(mktemp -d)" -tmp_archive="$tmp_dir/$1" - -$AR rc "$tmp_archive" $OBJS -$RANLIB "$tmp_archive" -mv "$tmp_archive" "$3" - -rm -r "$tmp_dir" diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..93fbe37 --- /dev/null +++ b/meson.build @@ -0,0 +1,52 @@ +project( + 'buchstabensuppe', 'c', + version : '0.0.0', + license : 'BSD-3-Clause', + default_options: ['c_std=c99'], +) + +cc = meson.get_compiler('c') +pc = import('pkgconfig') + +# TODO: version constraints +utf8proc = dependency('libutf8proc') +harfbuzz = dependency('harfbuzz') +# TODO: no pkg-config upstream, maybe ask for it? +schrift = cc.find_library('schrift') +math = cc.find_library('m') + +incdir = include_directories('include') +lib = library( + 'buchstabensuppe', + 'bitmap.c', + 'buchstabensuppe.c', + 'flipdot.c', + soversion : '0', + include_directories : incdir, + dependencies : [ utf8proc, harfbuzz, schrift, math ], + install : true, +) +install_headers('include/buchstabensuppe.h') +install_headers( + 'include/buchstabensuppe/flipdot.h', + 'include/buchstabensuppe/bitmap.h', + subdir : 'buchstabensuppe', +) + +executable( + 'bs-renderflipdot', + 'bs-renderflipdot.c', + link_with : lib, + include_directories : incdir, + install : true, +) + +install_man('doc/man/bs-renderflipdot.1') + +unittests = executable( + 'unittests', + 'test.c', + include_directories : incdir, + link_with : lib, +) +test('unit test suite', unittests) diff --git a/overlay.nix b/overlay.nix index d516527..72e97a1 100644 --- a/overlay.nix +++ b/overlay.nix @@ -3,7 +3,8 @@ self: super: let gi = self.nix-gitignore; - buchstabensuppe = { stdenv, utf8proc, harfbuzz, libschrift, redo-c }: + buchstabensuppe = + { stdenv, utf8proc, harfbuzz, libschrift, meson, ninja, pkg-config }: stdenv.mkDerivation rec { pname = "buchstabensuppe"; version = "unstable"; @@ -14,9 +15,12 @@ let "bindings/" # bindings we don't need for compilation ] ./.; - makeFlags = [ "PREFIX=${placeholder "out"}" ]; + nativeBuildInputs = [ + meson + ninja + pkg-config + ]; - nativeBuildInputs = [ redo-c ]; buildInputs = [ utf8proc harfbuzz libschrift ]; doCheck = true; |