commit: 114a21559c4060c73b3824e9b54a0e545a501c64
parent 418640113513f4e3df3eef52fa6b286f063de40f
Author: lauren n. liberda <lauren@selfisekai.rocks>
Date: Tue, 24 Oct 2023 02:57:11 +0200
add support for Dart Kernel and JIT snapshots
Diffstat:
7 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/deblob.1 b/deblob.1
@@ -89,6 +89,8 @@ Squirrel bytecode
Pre-Compiled Headers: Clang, GCC
.It
GCC Rust Metadata, typically
+.It
+Dart Kernel and JIT snapshots
.Sq *.rox
.El
.Sh EXAMPLES
diff --git a/main.ha b/main.ha
@@ -71,7 +71,13 @@ const magic: [_][]u8 = [
// Excluded from fixtures (1.2MB+), test with:
// echo > empty.h && gcc empty.h
- ['G', 'R', 'S', 'T'] // GCC Rust Metadata (*.rox)
+ ['G', 'R', 'S', 'T'], // GCC Rust Metadata (*.rox)
+
+ [0x90, 0xab, 0xcd, 0xef], // Dart Kernel snapshot
+ // why are these 2 different, and is the C one still in use?
+ // no clue, but both are in the sdk repo.
+ [0xdc, 0xdc, 0xf5, 0xf5], // Dart JIT snapshot, if done from the C code.
+ [0xdc, 0xdc, 0xf6, 0xf6], // Dart JIT snapshot, if done from the Dart code.
];
const dos_magic: []u8 = ['M', 'Z'];
const pe_magic: []u8 = ['P', 'E', 0x00, 0x00];
@@ -163,6 +169,7 @@ fn is_blob(filename: str) (bool | fs::error | io::error) = {
const tests = [
(false, "test/fixtures/empty"),
(false, "test/fixtures/empty.dts"),
+ (false, "test/fixtures/hello-dart.dart"),
(false, "test/fixtures/hello-ocaml.ml"),
(false, "test/fixtures/hello-racket.rkt"),
(false, "test/fixtures/hello.1"),
@@ -183,6 +190,8 @@ fn is_blob(filename: str) (bool | fs::error | io::error) = {
(true, "test/fixtures/compiled/hello-racket_rkt.zo"),
(true, "test/fixtures/empty.dtb"),
(true, "test/fixtures/hello"),
+ (true, "test/fixtures/hello-dart.dill"),
+ (true, "test/fixtures/hello-dart.jit"),
(true, "test/fixtures/hello-ocaml.a"),
(true, "test/fixtures/hello-ocaml.cma"),
(true, "test/fixtures/hello-ocaml.cmi"),
@@ -310,7 +319,7 @@ fn check_dir(dirname: str) (void | errors::invalid | io::error) = {
case let e: fs::error =>
fmt::fatalf("deblob: os::readdir({}): {}", dirname, fs::strerror(e));
};
- assert(len(files_before) == 57);
+ assert(len(files_before) == 60);
const ret = check_dir(dirname);
assert(ret is void);
@@ -321,7 +330,7 @@ fn check_dir(dirname: str) (void | errors::invalid | io::error) = {
case let e: fs::error =>
fmt::fatalf("deblob: os::readdir({}): {}", dirname, fs::strerror(e));
};
- assert(len(files_after) == 29);
+ assert(len(files_after) == 30);
};
export fn main() void = {
diff --git a/test/fixtures/Makefile b/test/fixtures/Makefile
@@ -17,9 +17,10 @@ OCAMLC ?= ocamlc
OCAMLOPT ?= ocamlopt
EMACS ?= emacs
SQUIRREL ?= squirrel3
+DART ?= dart
NONBUNDLED_BLOBS = hello hello.a hello.o hello.erl.escript hello.beam.escript
-TEST_BLOBS = $(NONBUNDLED_BLOBS) hello.exe hello.luac53 hello.luac54 hello.wasm hello.class hello.jar 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 compiled/hello-racket_rkt.zo hello.elc hello.cnut
+TEST_BLOBS = $(NONBUNDLED_BLOBS) hello.exe hello.luac53 hello.luac54 hello.wasm hello.class hello.jar 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 compiled/hello-racket_rkt.zo hello.elc hello.cnut hello-dart.dill hello-dart.jit
base: $(NONBUNDLED_BLOBS)
@@ -109,3 +110,9 @@ hello.elc: hello.el
hello.cnut: hello.nut
$(SQUIRREL) -c -o $@ hello.nut
+
+hello-dart.dill:
+ $(DART) compile kernel hello-dart.dart
+
+hello-dart.jit:
+ $(DART) compile jit-snapshot hello-dart.dart
diff --git a/test/fixtures/README.md b/test/fixtures/README.md
@@ -17,6 +17,7 @@ Dependencies:
- OCaml bytecode(ocamlc) and native(ocamlopt) compilers
- Racket
- Squirrel
+- Dart
Rebuilding:
```
diff --git a/test/fixtures/hello-dart.dart b/test/fixtures/hello-dart.dart
@@ -0,0 +1,6 @@
+// SPDX-FileCopyrightText: 2019-2022 deblob Authors <https://hacktivis.me/projects/deblob>
+// SPDX-License-Identifier: BSD-3-Clause
+
+void main(List<String> arguments) {
+ print('Hello, world!');
+}
diff --git a/test/fixtures/hello-dart.dill b/test/fixtures/hello-dart.dill
Binary files differ.
diff --git a/test/fixtures/hello-dart.jit b/test/fixtures/hello-dart.jit
Binary files differ.