logo

deblob

remove binary executables from a directory git clone https://hacktivis.me/git/deblob.git
commit: 8823d6461ed16d8e353a9b84d707ff79f53dc802
parent 0cd963770cf121365bc9ba0fa0908240a9a34b6c
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Wed, 23 Nov 2022 01:03:22 +0100

Add OCaml support

Diffstat:

M.reuse/dep52+-
Mdeblob.12++
Mmain.ha14++++++++++++--
Mtest/fixtures/Makefile18++++++++++++++++--
Mtest/fixtures/README.md1+
Atest/fixtures/hello-ocaml.a0
Atest/fixtures/hello-ocaml.cma0
Atest/fixtures/hello-ocaml.cmi0
Atest/fixtures/hello-ocaml.cmo0
Atest/fixtures/hello-ocaml.cmx0
Atest/fixtures/hello-ocaml.cmxa0
Atest/fixtures/hello-ocaml.ml5+++++
Atest/fixtures/hello-ocaml.o0
13 files changed, 37 insertions(+), 5 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/pickle/*.pickle test/fixtures/hello.luac* 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 test/fixtures/hello-chez.so +Files: test/fixtures/pyc/*.pyc test/fixtures/pickle/*.pickle test/fixtures/hello.luac* 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 test/fixtures/hello-chez.so test/fixtures/hello.n test/fixtures/hello-ocaml.* Copyright: 2019-2022 deblob Authors <https://hacktivis.me/projects/deblob> License: BSD-3-Clause diff --git a/deblob.1 b/deblob.1 @@ -75,6 +75,8 @@ Device Tree Blob, typically Chez Scheme bytecode .It NekoVM bytecode +.It +OCaml bytecode and native binaries .El .Sh EXAMPLES The following code block shows how it can be used in Gentoo's diff --git a/main.ha b/main.ha @@ -46,6 +46,8 @@ const magic: [_][]u8 = [ ['p', 's', 't', '0'], // Perl Storable(v0.7) [0x00, 0x00, 0x00, 0x00, 'c', 'h', 'e', 'z'], // Chez Scheme bytecode ['N', 'E', 'K', 'O'], // NekoVM Bytecode + + ['C', 'a', 'm', 'l', '1', '9', '9', '9'] // OCaml ]; const dos_magic: []u8 = ['M', 'Z']; const pe_magic: []u8 = ['P', 'E', 0x00, 0x00]; @@ -95,6 +97,7 @@ fn is_blob(filename: str) (bool | fs::error | io::error) = { (false, "test/fixtures/hello.pir"), (false, "test/fixtures/hello.py"), (false, "test/fixtures/hello.wat"), + (false, "test/fixtures/hello-ocaml.ml"), (false, "test/fixtures/perl_storage.pm"), (true, "test/fixtures/empty.dtb"), (true, "test/fixtures/hello"), @@ -110,6 +113,13 @@ fn is_blob(filename: str) (bool | fs::error | io::error) = { (true, "test/fixtures/hello.pir.pbc"), (true, "test/fixtures/hello.wasm"), (true, "test/fixtures/monodx.dll"), + (true, "test/fixtures/hello-ocaml.a"), + (true, "test/fixtures/hello-ocaml.cma"), + (true, "test/fixtures/hello-ocaml.cmi"), + (true, "test/fixtures/hello-ocaml.cmo"), + (true, "test/fixtures/hello-ocaml.cmx"), + (true, "test/fixtures/hello-ocaml.cmxa"), + (true, "test/fixtures/hello-ocaml.o"), //(true, "test/fixtures/option.rom"), (true, "test/fixtures/perl_storage.pst"), (true, "test/fixtures/pickle/hello.4.pickle"), @@ -215,7 +225,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) == 42); + assert(len(files_before) == 50); const ret = check_dir(dirname); assert(ret is void); @@ -226,7 +236,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) == 25); + assert(len(files_after) == 26); }; export fn main() void = { diff --git a/test/fixtures/Makefile b/test/fixtures/Makefile @@ -12,9 +12,11 @@ PERL ?= perl ERLC ?= erlc DTC ?= dtc CHEZ ?= chezscheme +OCAMLC ?= ocamlc +OCAMLOPT ?= ocamlopt 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 hello-chez.so hello.n +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 hello-chez.so hello.n hello-ocaml.cmo hello-ocaml.cma hello-ocaml.cmx hello-ocaml.cmxa base: $(NONBUNDLED_BLOBS) @@ -22,7 +24,7 @@ all: $(TEST_BLOBS) .PHONY: clean clean: - rm -f $(NONBUNDLED_BLOBS) + rm -f $(NONBUNDLED_BLOBS) hello-ocaml.o hello-ocaml.a hello-ocaml.cmi .PHONY: cleanall cleanall: @@ -72,3 +74,15 @@ hello-chez.so: hello-chez.ss hello.n: hello.neko nekoc hello.neko + +hello-ocaml.cmo: hello-ocaml.ml + $(OCAMLC) -c hello-ocaml.ml + +hello-ocaml.cma: hello-ocaml.cmo + $(OCAMLC) -a -o hello-ocaml.cma hello-ocaml.cmo + +hello-ocaml.cmx: hello-ocaml.ml + $(OCAMLOPT) -c hello-ocaml.ml + +hello-ocaml.cmxa: hello-ocaml.cmx + $(OCAMLOPT) -a -o hello-ocaml.cmxa hello-ocaml.cmx diff --git a/test/fixtures/README.md b/test/fixtures/README.md @@ -13,6 +13,7 @@ Dependencies: - Erlang - Device Tree Compiler, default one is [dtc](https://git.kernel.org/cgit/utils/dtc/dtc.git/) - [NekoVM Compiler](https://nekovm.org/) +- OCaml bytecode(ocamlc) and native(ocamlopt) compilers Rebuilding: ``` diff --git a/test/fixtures/hello-ocaml.a b/test/fixtures/hello-ocaml.a Binary files differ. diff --git a/test/fixtures/hello-ocaml.cma b/test/fixtures/hello-ocaml.cma Binary files differ. diff --git a/test/fixtures/hello-ocaml.cmi b/test/fixtures/hello-ocaml.cmi Binary files differ. diff --git a/test/fixtures/hello-ocaml.cmo b/test/fixtures/hello-ocaml.cmo Binary files differ. diff --git a/test/fixtures/hello-ocaml.cmx b/test/fixtures/hello-ocaml.cmx Binary files differ. diff --git a/test/fixtures/hello-ocaml.cmxa b/test/fixtures/hello-ocaml.cmxa Binary files differ. diff --git a/test/fixtures/hello-ocaml.ml b/test/fixtures/hello-ocaml.ml @@ -0,0 +1,5 @@ +(* SPDX-FileCopyrightText: 2019-2022 deblob Authors <https://hacktivis.me/projects/deblob> + * SPDX-License-Identifier: BSD-3-Clause + *) + +print_endline "Hello, World!" diff --git a/test/fixtures/hello-ocaml.o b/test/fixtures/hello-ocaml.o Binary files differ.