Skip to content

Commit d3c2bac

Browse files
committed
Add script to create amalgamated build
Fixes: #688
1 parent 9c0dca7 commit d3c2bac

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

amalgam.js

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import {loadFile, writeFile} from "qjs:std"
2+
3+
const cutils_c = loadFile("cutils.c")
4+
const cutils_h = loadFile("cutils.h")
5+
const libbf_c = loadFile("libbf.c")
6+
const libbf_h = loadFile("libbf.h")
7+
const libregexp_c = loadFile("libregexp.c")
8+
const libregexp_h = loadFile("libregexp.h")
9+
const libregexp_opcode_h = loadFile("libregexp-opcode.h")
10+
const libunicode_c = loadFile("libunicode.c")
11+
const libunicode_h = loadFile("libunicode.h")
12+
const libunicode_table_h = loadFile("libunicode-table.h")
13+
const list_h = loadFile("list.h")
14+
const quickjs_atom_h = loadFile("quickjs-atom.h")
15+
const quickjs_c = loadFile("quickjs.c")
16+
const quickjs_c_atomics_h = loadFile("quickjs-c-atomics.h")
17+
const quickjs_h = loadFile("quickjs.h")
18+
const quickjs_libc_c = loadFile("quickjs-libc.c")
19+
const quickjs_libc_h = loadFile("quickjs-libc.h")
20+
const quickjs_opcode_h = loadFile("quickjs-opcode.h")
21+
22+
let source = "#if defined(CONFIG_QUICKJS_LIBC) && defined(__linux__) && !defined(_GNU_SOURCE)\n"
23+
+ "#define _GNU_SOURCE\n"
24+
+ "#endif\n"
25+
+ quickjs_c_atomics_h
26+
+ cutils_h
27+
+ list_h
28+
+ libbf_h
29+
+ libunicode_h // exports lre_is_id_start, used by libregexp.h
30+
+ libregexp_h
31+
+ libunicode_table_h
32+
+ quickjs_h
33+
+ quickjs_c
34+
+ cutils_c
35+
+ libbf_c
36+
+ libregexp_c
37+
+ libunicode_c
38+
+ "#ifdef CONFIG_QUICKJS_LIBC\n"
39+
+ quickjs_libc_h
40+
+ quickjs_libc_c
41+
+ "#endif // CONFIG_QUICKJS_LIBC\n"
42+
source = source.replace(/#include "quickjs-atom.h"/g, quickjs_atom_h)
43+
source = source.replace(/#include "quickjs-opcode.h"/g, quickjs_opcode_h)
44+
source = source.replace(/#include "libregexp-opcode.h"/g, libregexp_opcode_h)
45+
source = source.replace(/#include "[^"]+"/g, "")
46+
writeFile("quickjs-amalgam.c", source)

quickjs-libc.c

+2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ extern char **environ;
9494
#include "list.h"
9595
#include "quickjs-libc.h"
9696

97+
#ifndef MAX_SAFE_INTEGER // already defined in amalgamation builds
9798
#define MAX_SAFE_INTEGER (((int64_t) 1 << 53) - 1)
99+
#endif
98100

99101
#ifndef QJS_NATIVE_MODULE_SUFFIX
100102
#ifdef _WIN32

0 commit comments

Comments
 (0)