logo

deblob

remove binary executables from a directory git clone https://hacktivis.me/git/deblob.git
commit: 7e63f750d8063b34b573a2974effe23d68ee8a1e
parent 31f026fdf874d6445da94173234ed82b40f81002
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Mon, 17 Oct 2022 12:09:23 +0200

Makefile: move fixtures targets to test/fixtures/Makefile

This also fixes a nasty bug with GNU make where it would rebuild files
like `hello.class` (while bundled) when running `make test`.

Diffstat:

MMakefile58++++++----------------------------------------------------
MREADME.md26+-------------------------
Mmain.ha4++--
Atest/fixtures/Makefile67+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atest/fixtures/README.md32++++++++++++++++++++++++++++++++
5 files changed, 108 insertions(+), 79 deletions(-)

diff --git a/Makefile b/Makefile @@ -5,23 +5,12 @@ PREFIX ?= /usr/local BINDIR ?= $(PREFIX)/bin MANDIR ?= $(PREFIX)/share/man -AR ?= ar -CC ?= cc -MCS ?= mcs # Mono C Sharp compiler HARE ?= hare HAREFLAGS ?= -CFLAGS ?= -Os -s MANDOC ?= mandoc REUSE ?= reuse -JAVAC ?= javac -NQP ?= nqp -PARROT ?= parrot -PERL ?= perl -ERLC ?= erlc -DTC ?= dtc EXE = deblob -TEST_BLOBS = test/fixtures/hello test/fixtures/hello.a test/fixtures/hello.o test/fixtures/hello.exe test/fixtures/hello.luac53 test/fixtures/hello.luac54 test/fixtures/hello.wasm test/fixtures/hello.class test/fixtures/hello.nqp.moarvm test/fixtures/hello.pir.pbc test/fixtures/perl_storage.pst test/fixtures/hello.beam test/fixtures/empty.dtb all: $(EXE) @@ -30,49 +19,14 @@ $(EXE): main.ha .PHONY: clean clean: - rm -f $(EXE) $(TEST_BLOBS) - -test/fixtures/hello.a: test/fixtures/hello - $(AR) -rc $@ test/fixtures/hello - -test/fixtures/hello.o: test/fixtures/hello.c - $(CC) $(CFLAGS) -c -o $@ test/fixtures/hello.c - -test/fixtures/hello: test/fixtures/hello.c - $(CC) $(CFLAGS) -o $@ test/fixtures/hello.c - -test/fixtures/hello.exe: test/fixtures/hello.cs - $(MCS) test/fixtures/hello.cs - -test/fixtures/hello.luac53: test/fixtures/hello.lua - luac5.3 -o $@ test/fixtures/hello.lua - -test/fixtures/hello.luac54: test/fixtures/hello.lua - luac5.4 -o $@ test/fixtures/hello.lua - -test/fixtures/hello.wasm: test/fixtures/hello.wat - wat2wasm -o $@ test/fixtures/hello.wat - -test/fixtures/hello.class: test/fixtures/hello.java - $(JAVAC) test/fixtures/hello.java - -test/fixtures/hello.nqp.moarvm: test/fixtures/hello.nqp - $(NQP) --target mbc --output=$@ test/fixtures/hello.nqp - -test/fixtures/hello.pir.pbc: test/fixtures/hello.pir - $(PARROT) -o $@ test/fixtures/hello.pir - -test/fixtures/perl_storage.pst: test/fixtures/perl_storage.pm - $(PERL) test/fixtures/perl_storage.pm - -test/fixtures/hello.beam: test/fixtures/hello.erl - $(ERLC) -o test/fixtures +deterministic test/fixtures/hello.erl - -test/fixtures/empty.dtb: test/fixtures/empty.dts - $(DTC) -o $@ -O dtb test/fixtures/empty.dts + rm -f $(EXE) + $(MAKE) -C test/fixtures clean .PHONY: test -test: all $(TEST_BLOBS) +test: all + @if $(MAKE) --version | grep -q GNU; then echo 'GNU Make is not my favorite make implementation'; fi + $(MAKE) -C test/fixtures + rm -fr test/check_dir-fixtures cp -r test/fixtures test/check_dir-fixtures $(HARE) $(HAREFLAGS) test diff --git a/README.md b/README.md @@ -18,31 +18,7 @@ Those are only needed during development. - [black](https://pypi.org/project/black/) for re-formatting python files ### rebuilding fixtures -Note: This part is entirely optionnal and reproducibility of those binaries isn't guaranteed. - -Dependencies: -- C Sharp Compiler, default one is `msc` from [Mono](https://mono-project.com) -- `luac5.3` from Lua 5.3 -- `luac5.4` from Lua 5.4 -- wasm assembler, default one is `wat2wasm` from [wabt](https://github.com/WebAssembly/wabt) -- Java Development Kit, defaults to `javac`. Any version should work, including early bootstrap with jamvm 1.5+ -- [NQP](https://github.com/Raku/nqp) aka Not Quite Perl -- [Parrot](http://www.parrot.org/) -- Perl5 -- Erlang -- Device Tree Compiler, default one is [dtc](https://git.kernel.org/cgit/utils/dtc/dtc.git/) - -Rebuilding: -``` -make clean -make -``` - -#### manual fixtures -The following fixtures are either manually built or copied from another project and aren't removed with `make clean`: -- Files in `test/fixtures/pyc/` are made via running `./test/python_compile.py` -- `monodx.dll` is `lib/x86/monodx.dll` from wine-mono 7.0.0 -- `qemu_vga.ndrv` is `pc-bios/qemu_vga.ndrv` from QEMU 7.0.0 +See <./test/fixtures/README.md>. <!-- SPDX-FileCopyrightText: 2019-2022 deblob Authors <https://hacktivis.me/projects/deblob> diff --git a/main.ha b/main.ha @@ -203,7 +203,7 @@ fn check_dir(dirname: str) (void | errors::invalid) = { case let e: fs::error => fmt::fatalf("os::readdir({}): {}", dirname, fs::strerror(e)); }; - assert(len(files_before) == 35); + assert(len(files_before) == 37); const ret = check_dir(dirname); assert(ret is void); @@ -214,7 +214,7 @@ fn check_dir(dirname: str) (void | errors::invalid) = { case let e: fs::error => fmt::fatalf("os::readdir({}): {}", dirname, fs::strerror(e)); }; - assert(len(files_after) == 20); + assert(len(files_after) == 22); }; export fn main() void = { diff --git a/test/fixtures/Makefile b/test/fixtures/Makefile @@ -0,0 +1,67 @@ +# SPDX-FileCopyrightText: 2019-2022 deblob Authors <https://hacktivis.me/projects/deblob> +# SPDX-License-Identifier: BSD-3-Clause + +AR ?= ar +CC ?= cc +MCS ?= mcs # Mono C Sharp compiler +CFLAGS ?= -Os -s +JAVAC ?= javac +NQP ?= nqp +PARROT ?= parrot +PERL ?= perl +ERLC ?= erlc +DTC ?= dtc + +NONBUNDLED_BLOBS = hello hello.a hello.o +TEST_BLOBS = $(NONBUNDLED_BLOBS) hello.exe hello.luac53 hello.luac54 hello.wasm hello.class hello.nqp.moarvm hello.pir.pbc perl_storage.pst hello.beam empty.dtb + +base: $(NONBUNDLED_BLOBS) + +all: $(TEST_BLOBS) + +.PHONY: clean +clean: + rm -f $(NONBUNDLED_BLOBS) + +.PHONY: cleanall +cleanall: + rm -f $(TEST_BLOBS) + +hello.a: hello + $(AR) -rc $@ hello + +hello.o: hello.c + $(CC) $(CFLAGS) -c -o $@ hello.c + +hello: hello.c + $(CC) $(CFLAGS) -o $@ hello.c + +hello.exe: hello.cs + $(MCS) hello.cs + +hello.luac53: hello.lua + luac5.3 -o $@ hello.lua + +hello.luac54: hello.lua + luac5.4 -o $@ hello.lua + +hello.wasm: hello.wat + wat2wasm -o $@ hello.wat + +hello.class: hello.java + $(JAVAC) hello.java + +hello.nqp.moarvm: hello.nqp + $(NQP) --target mbc --output=$@ hello.nqp + +hello.pir.pbc: hello.pir + $(PARROT) -o $@ hello.pir + +perl_storage.pst: perl_storage.pm + $(PERL) perl_storage.pm + +hello.beam: hello.erl + $(ERLC) -o test/fixtures +deterministic hello.erl + +empty.dtb: empty.dts + $(DTC) -o $@ -O dtb empty.dts diff --git a/test/fixtures/README.md b/test/fixtures/README.md @@ -0,0 +1,32 @@ +# Rebuilding fixtures +Note: This part is entirely optionnal and reproducibility of those binaries isn't guaranteed. + +Dependencies: +- C Sharp Compiler, default one is `msc` from [Mono](https://mono-project.com) +- `luac5.3` from Lua 5.3 +- `luac5.4` from Lua 5.4 +- wasm assembler, default one is `wat2wasm` from [wabt](https://github.com/WebAssembly/wabt) +- Java Development Kit, defaults to `javac`. Any version should work, including early bootstrap with jamvm 1.5+ +- [NQP](https://github.com/Raku/nqp) aka Not Quite Perl +- [Parrot](http://www.parrot.org/) +- Perl5 +- Erlang +- Device Tree Compiler, default one is [dtc](https://git.kernel.org/cgit/utils/dtc/dtc.git/) + +Rebuilding: +``` +# in test/fixtures directory +make cleanall +make all +``` + +## manual fixtures +The following fixtures are either manually built or copied from another project and aren't removed with `make clean`: +- Files in `./pyc/` are made via running `../python_compile.py` +- `monodx.dll` is `lib/x86/monodx.dll` from wine-mono 7.0.0 +- `qemu_vga.ndrv` is `pc-bios/qemu_vga.ndrv` from QEMU 7.0.0 + +<!-- +SPDX-FileCopyrightText: 2019-2022 deblob Authors <https://hacktivis.me/projects/deblob> +SPDX-License-Identifier: BSD-3-Clause +-->