From 956187966fb18b34482c96397ad0d6b2a8f8416b Mon Sep 17 00:00:00 2001 From: Zephyr Lykos Date: Sat, 11 Oct 2025 21:05:24 +0800 Subject: [PATCH 01/12] Update meson.build version number --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 533267791..3bccf1573 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project( 'quickjs-ng', 'c', - version: '0.8.0', + version: '0.10.1', default_options: [ 'c_std=gnu11,c11', 'warning_level=3', From b61106e6bd885c943e38217066a58b0698006efa Mon Sep 17 00:00:00 2001 From: Zephyr Lykos Date: Sat, 11 Oct 2025 21:08:11 +0800 Subject: [PATCH 02/12] build/meson: Set _WIN32_WINNT=0x0601 fixup: 5a949ca758ea3cad38ac6988db953c2bc0b94925 ("CMake: Set _WIN32_WINNT=0x0601", #900) --- meson.build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 3bccf1573..d8f77204f 100644 --- a/meson.build +++ b/meson.build @@ -158,7 +158,8 @@ endif qjs_c_args = ['-D_GNU_SOURCE'] if host_system == 'windows' - qjs_c_args += ['-DWIN32_LEAN_AND_MEAN', '-D_WIN32_WINNT=0x0602'] + qjs_c_args += ['-DWIN32_LEAN_AND_MEAN', '-D_WIN32_WINNT=0x0601'] +endif endif qjs_libc_lib = static_library( From 8b35169d54e04182f07ef991822708ede4ace32d Mon Sep 17 00:00:00 2001 From: Zephyr Lykos Date: Sat, 11 Oct 2025 21:16:47 +0800 Subject: [PATCH 03/12] build/meson: rename parserless builds to -Dparser the original is -Ddisable_parser, invert that to make it less confusing --- meson.build | 9 +++------ meson_options.txt | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/meson.build b/meson.build index d8f77204f..7696829c6 100644 --- a/meson.build +++ b/meson.build @@ -122,12 +122,6 @@ if get_option('debug') language: 'c', ) endif -if get_option('disable_parser') - add_project_arguments( - ['-DQJS_DISABLE_PARSER'], - language: 'c', - ) -endif qjs_sys_deps = [] @@ -160,6 +154,9 @@ qjs_c_args = ['-D_GNU_SOURCE'] if host_system == 'windows' qjs_c_args += ['-DWIN32_LEAN_AND_MEAN', '-D_WIN32_WINNT=0x0601'] endif + +if not get_option('parser') + qjs_c_args += ['-DQJS_DISABLE_PARSER'] endif qjs_libc_lib = static_library( diff --git a/meson_options.txt b/meson_options.txt index eec8afd3e..20e661e1a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -3,4 +3,4 @@ option('examples', type: 'feature', description: 'build examples') option('libc', type: 'boolean', value: false, description: 'build qjs standard library modules as part of the library') option('cli_mimalloc', type: 'feature', value: 'disabled', description: 'build qjs cli with mimalloc') option('docdir', type: 'string', description: 'documentation directory') -option('disable_parser', type: 'boolean', value: false, description: 'Disable JS source code parser') +option('parser', type: 'boolean', value: true, description: 'Enable JS source code parser') From 083cb29ecf048aa67d03b56c898e8d92a685d513 Mon Sep 17 00:00:00 2001 From: Zephyr Lykos Date: Sat, 11 Oct 2025 21:18:11 +0800 Subject: [PATCH 04/12] build/meson: added Map/WeakMap in microbench fixup: 8dda2a033030873e1062dd437f35119f462470d2 ("fixed hash_map_resize() - added Map/WeakMap in microbench") --- meson.build | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 7696829c6..5ac98ae4d 100644 --- a/meson.build +++ b/meson.build @@ -413,7 +413,10 @@ if tests.allowed() 'int_arith', 'float_arith', - 'set_collection_add', + 'map_set', + 'map_delete', + 'weak_map_set', + 'weak_map_delete', 'array_for', 'array_for_in', From 891f4644dbb85ee320622794f7bb4114500d187c Mon Sep 17 00:00:00 2001 From: Zephyr Lykos Date: Sat, 11 Oct 2025 21:19:19 +0800 Subject: [PATCH 05/12] build/meson: added object_null in microbench fixup: 0a00011d2a8bff8ec4ff831d619c9ac6e7da47f0 ("Optimize {__proto__:null} object literal creation", #1118) --- meson.build | 2 ++ 1 file changed, 2 insertions(+) diff --git a/meson.build b/meson.build index 5ac98ae4d..90d0b0aed 100644 --- a/meson.build +++ b/meson.build @@ -424,6 +424,8 @@ if tests.allowed() 'math_min', + 'object_null', + 'regexp_ascii', 'regexp_utf16', From 07384922ca0db97ad84e20b79f33ad58e775eabb Mon Sep 17 00:00:00 2001 From: Zephyr Lykos Date: Sat, 11 Oct 2025 21:20:05 +0800 Subject: [PATCH 06/12] build/meson: add string_slice in microbench fixup: 08db51a73a9ce3948e9e7ac8142689fe4c83d46f ("Add ref-counted string slices", #1175) --- meson.build | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/meson.build b/meson.build index 90d0b0aed..f4b764dd1 100644 --- a/meson.build +++ b/meson.build @@ -432,6 +432,10 @@ if tests.allowed() 'string_build1', 'string_build2', + 'string_slice1', + 'string_slice2', + 'string_slice3', + 'sort_bench', 'int_to_string', From 339f24b9c85c8839dc3d4099954e36c3e31c8af2 Mon Sep 17 00:00:00 2001 From: Zephyr Lykos Date: Sat, 11 Oct 2025 22:40:13 +0800 Subject: [PATCH 07/12] build/meson: export have_parser in dependency --- meson.build | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index f4b764dd1..884d4184e 100644 --- a/meson.build +++ b/meson.build @@ -149,13 +149,15 @@ if qjs_libc qjs_hdrs += qjs_libc_hdrs endif +qjs_parser = get_option('parser') + qjs_c_args = ['-D_GNU_SOURCE'] if host_system == 'windows' qjs_c_args += ['-DWIN32_LEAN_AND_MEAN', '-D_WIN32_WINNT=0x0601'] endif -if not get_option('parser') +if not qjs_parser qjs_c_args += ['-DQJS_DISABLE_PARSER'] endif @@ -188,10 +190,15 @@ qjs_lib = library( version: meson.project_version(), ) +qjs_export_variables = [ + f'have_parser=@qjs_parser@' +] + qjs_dep = declare_dependency( link_with: qjs_lib, dependencies: qjs_sys_deps, include_directories: qjs_lib.private_dir_include(), + variables: qjs_export_variables, ) if host_system == 'emscripten' @@ -249,6 +256,7 @@ import('pkgconfig').generate( description: 'QuickJS, the Next Generation: a mighty JavaScript engine', url: 'https://github.com/quickjs-ng/quickjs', version: meson.project_version(), + variables: qjs_export_variables, ) # QuickJS bytecode compiler From d1aed541593135a3021f0e0afbbe7bc53f064e60 Mon Sep 17 00:00:00 2001 From: Zephyr Lykos Date: Sat, 11 Oct 2025 22:55:59 +0800 Subject: [PATCH 08/12] build/meson: guard many features for parserless builds skips building: qjs/qjsc cli, examples, tests, codegen --- meson.build | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/meson.build b/meson.build index 884d4184e..a5e7731a2 100644 --- a/meson.build +++ b/meson.build @@ -259,6 +259,10 @@ import('pkgconfig').generate( variables: qjs_export_variables, ) +if not qjs_parser + subdir_done() +endif + # QuickJS bytecode compiler qjsc_srcs = files( 'qjsc.c', From 5f176a3b6a32771e0bc09af8f26bf68e05df73f8 Mon Sep 17 00:00:00 2001 From: Zephyr Lykos Date: Sun, 12 Oct 2025 02:21:38 +0800 Subject: [PATCH 09/12] build/meson: move function_source into tests --- meson.build | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/meson.build b/meson.build index a5e7731a2..689a73c80 100644 --- a/meson.build +++ b/meson.build @@ -482,6 +482,21 @@ if tests.allowed() c_args: qjs_c_args, dependencies: qjs_dep, + build_by_default: false, + ), + ) + + # Function.toString() test + test( + 'function_source', + executable( + 'function_source', + 'gen/function_source.c', + qjs_libc_srcs, + + c_args: qjs_c_args, + dependencies: qjs_dep, + build_by_default: false, ), ) endif @@ -497,14 +512,6 @@ executable( build_by_default: false, ) -executable( - 'function_source', - 'gen/function_source.c', - qjs_libc_srcs, - - c_args: qjs_c_args, - dependencies: qjs_dep, -) if examples.allowed() executable( From 3bfc3ca8d6f735fbc735429a09ebae74b3222b82 Mon Sep 17 00:00:00 2001 From: Zephyr Lykos Date: Sun, 12 Oct 2025 04:27:52 +0800 Subject: [PATCH 10/12] build/meson: support running codegen also removed -M during the test_fib.c codegen: 902cc2cf0eb1fdda5095c9b5a1b6a7127f35e30d ("Add native module support on Windows") switched examples to dynamic import() instead of static import statement and the lookup was deferred to runtime, thus we don't need to hint qjsc this is a declared module and exclude it from bundling. --- Makefile | 2 +- meson.build | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 89 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 596ef0526..4ff8ca17e 100644 --- a/Makefile +++ b/Makefile @@ -79,7 +79,7 @@ codegen: $(QJSC) $(QJSC) -e -o gen/function_source.c tests/function_source.js $(QJSC) -e -o gen/hello.c examples/hello.js $(QJSC) -e -o gen/hello_module.c -m examples/hello_module.js - $(QJSC) -e -o gen/test_fib.c -M examples/fib.so,fib -m examples/test_fib.js + $(QJSC) -e -o gen/test_fib.c -m examples/test_fib.js $(QJSC) -C -ss -o builtin-array-fromasync.h builtin-array-fromasync.js debug: diff --git a/meson.build b/meson.build index 689a73c80..f96ceb5a9 100644 --- a/meson.build +++ b/meson.build @@ -502,7 +502,7 @@ if tests.allowed() endif # Unicode generator -executable( +unicode_gen = executable( 'unicode_gen', 'cutils.c', 'libunicode.c', @@ -512,6 +512,93 @@ executable( build_by_default: false, ) +run_target( + 'libunicode-table.h', + command: [ + unicode_gen, + meson.current_source_dir() / 'unicode', + files('libunicode-table.h'), + ], +) + +# bytecode to c source code for builtin and examples +alias_target('codegen', + run_target( + 'codegen_repl.c', + command: [ + qjsc_exe, + '-ss', + '-o', files('gen/repl.c'), + '-m', + '-n', 'repl.js', + files('repl.js'), + ], + ), + run_target( + 'codegen_standalone.c', + command: [ + qjsc_exe, + '-ss', + '-o', files('gen/standalone.c'), + '-m', + '-n', 'standalone.js', + files('standalone.js'), + ], + ), + run_target( + 'codegen_function_source.c', + command: [ + qjsc_exe, + '-e', + '-o', files('gen/function_source.c'), + '-n', 'tests/function_source.js', + files('tests/function_source.js'), + ], + ), + run_target( + 'codegen_hello.c', + command: [ + qjsc_exe, + '-e', + '-o', files('gen/hello.c'), + '-n', 'examples/hello.js', + files('examples/hello.js'), + ], + ), + run_target( + 'codegen_hello_module.c', + command: [ + qjsc_exe, + '-e', + '-o', files('gen/hello_module.c'), + '-m', + '-n', 'examples/hello_module.js', + files('examples/hello_module.js'), + ], + ), + run_target( + 'codegen_test_fib.c', + command: [ + qjsc_exe, + '-e', + '-o', files('gen/test_fib.c'), + '-m', + '-n', 'examples/test_fib.js', + files('examples/test_fib.js'), + ], + ), + run_target( + 'codegen_builtin-array-fromasync.h', + command: [ + qjsc_exe, + '-C', + '-ss', + '-o', files('builtin-array-fromasync.h'), + '-n', 'builtin-array-fromasync.js', + files('builtin-array-fromasync.js'), + ], + ), +) if examples.allowed() executable( From d6f0527d5cd79fd774ac2f82dbba8a20ad8a2e51 Mon Sep 17 00:00:00 2001 From: Zephyr Lykos Date: Sun, 12 Oct 2025 04:32:01 +0800 Subject: [PATCH 11/12] build/meson: export dynamic symbols on qjs cli Fix unable to `import {fib} from './fib.so';` using qjs cli --- meson.build | 2 ++ 1 file changed, 2 insertions(+) diff --git a/meson.build b/meson.build index f96ceb5a9..1121d8c1f 100644 --- a/meson.build +++ b/meson.build @@ -300,6 +300,7 @@ qjs_exe = executable( c_args: qjs_c_args, link_with: qjs_libc ? [] : qjs_libc_lib, dependencies: [qjs_dep, mimalloc_dep], + export_dynamic: true, install: true, ) @@ -357,6 +358,7 @@ if meson.is_cross_build() c_args: qjs_c_args, link_with: qjs_native_lib, dependencies: [qjs_sys_native_deps, mimalloc_native_dep], + export_dynamic: true, build_by_default: false, native: true, From f2aead8d927ea6c038aa0c72f7907269812842d0 Mon Sep 17 00:00:00 2001 From: Zephyr Lykos Date: Sun, 12 Oct 2025 05:56:04 +0800 Subject: [PATCH 12/12] build/meson: remove not required libunicode.c for unicode_gen --- meson.build | 1 - 1 file changed, 1 deletion(-) diff --git a/meson.build b/meson.build index 1121d8c1f..88cbc7ca9 100644 --- a/meson.build +++ b/meson.build @@ -507,7 +507,6 @@ endif unicode_gen = executable( 'unicode_gen', 'cutils.c', - 'libunicode.c', 'unicode_gen.c', c_args: qjs_c_args,