logo

deblob

remove binary executables from a directory git clone https://hacktivis.me/git/deblob.git
commit: 66d79e14a5a977b31045dbde6a5828d2873f9c9b
parent f8d362849d0be824487c4da45922d395342cdd57
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Thu, 13 Oct 2022 00:54:26 +0200

Add support for MoarVM bytecode

Diffstat:

M.reuse/dep52+-
MMakefile6+++++-
MREADME.md1+
Mdeblob.12++
Mmain.ha8++++++--
Atest/fixtures/hello.nqp5+++++
Atest/fixtures/hello.nqp.moarvm0
7 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/.reuse/dep5 b/.reuse/dep5 @@ -3,6 +3,6 @@ Upstream-Name: deblob Upstream-Contact: deblob Authors <https://hacktivis.me/projects/deblob> Source: https://hacktivis.me/projects/deblob -Files: test/fixtures/pyc/*.pyc test/fixtures/hello.luac* test/fixtures/hello.class +Files: test/fixtures/pyc/*.pyc test/fixtures/hello.luac* test/fixtures/hello.class test/fixtures/hello.nqp.moarvm Copyright: 2019-2022 deblob Authors <https://hacktivis.me/projects/deblob> License: BSD-3-Clause diff --git a/Makefile b/Makefile @@ -14,9 +14,10 @@ CFLAGS ?= -Os -s MANDOC ?= mandoc REUSE ?= reuse JAVAC ?= javac +NQP ?= nqp 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_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 all: $(EXE) @@ -51,6 +52,9 @@ test/fixtures/hello.wasm: 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 + .PHONY: test test: all $(TEST_BLOBS) rm -fr test/check_dir-fixtures diff --git a/README.md b/README.md @@ -26,6 +26,7 @@ Dependencies: - `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 Rebuilding: ``` diff --git a/deblob.1 b/deblob.1 @@ -60,6 +60,8 @@ Lua bytecode WASM (Web Assembly) .It Apple Preferred Executable Format +.It +MoarVM bytecode .El .Sh EXAMPLES The following code block shows how it can be used in Gentoo's diff --git a/main.ha b/main.ha @@ -31,6 +31,8 @@ const magic: [_][]u8 = [ [0x55, 0x0D, '\r', '\n'], // (3413i litte-endian) Python 3.8 [0x61, 0x0D, '\r', '\n'], // (3425i litte-endian) Python 3.9 [0x6F, 0x0D, '\r', '\n'], // (3439i litte-endian) Python 3.10 + // MoarVM bytecode https://github.com/MoarVM/MoarVM/blob/master/docs/bytecode.markdown + ['M', 'O', 'A', 'R', 'V', 'M', '\r', '\n'], ]; const dos_magic: []u8 = ['M', 'Z']; const pe_magic: []u8 = ['P', 'E', 0x00, 0x00]; @@ -74,6 +76,7 @@ fn is_blob(filename: str) (bool | fs::error | io::error) = { ("test/fixtures/hello.wat", false), ("test/fixtures/hello.py", false), ("test/fixtures/hello.java", false), + ("test/fixtures/hello.nqp", false), ("test/fixtures/hello", true), ("test/fixtures/hello.luac53", true), ("test/fixtures/hello.luac54", true), @@ -86,6 +89,7 @@ fn is_blob(filename: str) (bool | fs::error | io::error) = { ("test/fixtures/Elixir.Hex.API.Auth.beam", true), //("test/fixtures/option.rom", true), ("test/fixtures/qemu_vga.ndrv", true), + ("test/fixtures/hello.nqp.moarvm", true), ("test/fixtures/empty", false), ]; @@ -187,7 +191,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) == 27); + assert(len(files_before) == 29); const ret = check_dir(dirname); assert(ret is void); @@ -198,7 +202,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) == 16); + assert(len(files_after) == 17); }; export fn main() void = { diff --git a/test/fixtures/hello.nqp b/test/fixtures/hello.nqp @@ -0,0 +1,5 @@ +#!/usr/bin/env nqp +# SPDX-FileCopyrightText: 2019-2022 deblob Authors <https://hacktivis.me/projects/deblob> +# SPDX-License-Identifier: BSD-3-Clause + +say("Hello, World!") diff --git a/test/fixtures/hello.nqp.moarvm b/test/fixtures/hello.nqp.moarvm Binary files differ.