Skip to content

Commit 2d680a9

Browse files
authored
Update meson.build
1 parent 8c526f6 commit 2d680a9

File tree

3 files changed

+133
-19
lines changed

3 files changed

+133
-19
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ codegen: $(QJSC)
7979
$(QJSC) -e -o gen/function_source.c tests/function_source.js
8080
$(QJSC) -e -o gen/hello.c examples/hello.js
8181
$(QJSC) -e -o gen/hello_module.c -m examples/hello_module.js
82-
$(QJSC) -e -o gen/test_fib.c -M examples/fib.so,fib -m examples/test_fib.js
82+
$(QJSC) -e -o gen/test_fib.c -m examples/test_fib.js
8383
$(QJSC) -C -ss -o builtin-array-fromasync.h builtin-array-fromasync.js
8484

8585
debug:

meson.build

Lines changed: 131 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
project(
22
'quickjs-ng',
33
'c',
4-
version: '0.8.0',
4+
version: '0.10.1',
55
default_options: [
66
'c_std=gnu11,c11',
77
'warning_level=3',
@@ -122,12 +122,6 @@ if get_option('debug')
122122
language: 'c',
123123
)
124124
endif
125-
if get_option('disable_parser')
126-
add_project_arguments(
127-
['-DQJS_DISABLE_PARSER'],
128-
language: 'c',
129-
)
130-
endif
131125

132126
qjs_sys_deps = []
133127

@@ -155,10 +149,16 @@ if qjs_libc
155149
qjs_hdrs += qjs_libc_hdrs
156150
endif
157151

152+
qjs_parser = get_option('parser')
153+
158154
qjs_c_args = ['-D_GNU_SOURCE']
159155

160156
if host_system == 'windows'
161-
qjs_c_args += ['-DWIN32_LEAN_AND_MEAN', '-D_WIN32_WINNT=0x0602']
157+
qjs_c_args += ['-DWIN32_LEAN_AND_MEAN', '-D_WIN32_WINNT=0x0601']
158+
endif
159+
160+
if not qjs_parser
161+
qjs_c_args += ['-DQJS_DISABLE_PARSER']
162162
endif
163163

164164
qjs_libc_lib = static_library(
@@ -190,10 +190,15 @@ qjs_lib = library(
190190
version: meson.project_version(),
191191
)
192192

193+
qjs_export_variables = [
194+
f'have_parser=@qjs_parser@'
195+
]
196+
193197
qjs_dep = declare_dependency(
194198
link_with: qjs_lib,
195199
dependencies: qjs_sys_deps,
196200
include_directories: qjs_lib.private_dir_include(),
201+
variables: qjs_export_variables,
197202
)
198203

199204
if host_system == 'emscripten'
@@ -251,8 +256,13 @@ import('pkgconfig').generate(
251256
description: 'QuickJS, the Next Generation: a mighty JavaScript engine',
252257
url: 'https://github.com/quickjs-ng/quickjs',
253258
version: meson.project_version(),
259+
variables: qjs_export_variables,
254260
)
255261

262+
if not qjs_parser
263+
subdir_done()
264+
endif
265+
256266
# QuickJS bytecode compiler
257267
qjsc_srcs = files(
258268
'qjsc.c',
@@ -290,6 +300,7 @@ qjs_exe = executable(
290300
c_args: qjs_c_args,
291301
link_with: qjs_libc ? [] : qjs_libc_lib,
292302
dependencies: [qjs_dep, mimalloc_dep],
303+
export_dynamic: true,
293304

294305
install: true,
295306
)
@@ -347,6 +358,7 @@ if meson.is_cross_build()
347358
c_args: qjs_c_args,
348359
link_with: qjs_native_lib,
349360
dependencies: [qjs_sys_native_deps, mimalloc_native_dep],
361+
export_dynamic: true,
350362

351363
build_by_default: false,
352364
native: true,
@@ -415,20 +427,29 @@ if tests.allowed()
415427
'int_arith',
416428
'float_arith',
417429

418-
'set_collection_add',
430+
'map_set',
431+
'map_delete',
432+
'weak_map_set',
433+
'weak_map_delete',
419434

420435
'array_for',
421436
'array_for_in',
422437
'array_for_of',
423438

424439
'math_min',
425440

441+
'object_null',
442+
426443
'regexp_ascii',
427444
'regexp_utf16',
428445

429446
'string_build1',
430447
'string_build2',
431448

449+
'string_slice1',
450+
'string_slice2',
451+
'string_slice3',
452+
432453
'sort_bench',
433454

434455
'int_to_string',
@@ -463,28 +484,121 @@ if tests.allowed()
463484

464485
c_args: qjs_c_args,
465486
dependencies: qjs_dep,
487+
build_by_default: false,
488+
),
489+
)
490+
491+
# Function.toString() test
492+
test(
493+
'function_source',
494+
executable(
495+
'function_source',
496+
'gen/function_source.c',
497+
qjs_libc_srcs,
498+
499+
c_args: qjs_c_args,
500+
dependencies: qjs_dep,
501+
build_by_default: false,
466502
),
467503
)
468504
endif
469505

470506
# Unicode generator
471-
executable(
507+
unicode_gen = executable(
472508
'unicode_gen',
473509
'cutils.c',
474-
'libunicode.c',
475510
'unicode_gen.c',
476511

477512
c_args: qjs_c_args,
478513
build_by_default: false,
479514
)
480515

481-
executable(
482-
'function_source',
483-
'gen/function_source.c',
484-
qjs_libc_srcs,
516+
run_target(
517+
'libunicode-table.h',
518+
command: [
519+
unicode_gen,
520+
meson.current_source_dir() / 'unicode',
521+
files('libunicode-table.h'),
522+
],
523+
)
485524

486-
c_args: qjs_c_args,
487-
dependencies: qjs_dep,
525+
# bytecode to c source code for builtin and examples
526+
alias_target('codegen',
527+
run_target(
528+
'codegen_repl.c',
529+
command: [
530+
qjsc_exe,
531+
'-ss',
532+
'-o', files('gen/repl.c'),
533+
'-m',
534+
'-n', 'repl.js',
535+
files('repl.js'),
536+
],
537+
),
538+
run_target(
539+
'codegen_standalone.c',
540+
command: [
541+
qjsc_exe,
542+
'-ss',
543+
'-o', files('gen/standalone.c'),
544+
'-m',
545+
'-n', 'standalone.js',
546+
files('standalone.js'),
547+
],
548+
),
549+
run_target(
550+
'codegen_function_source.c',
551+
command: [
552+
qjsc_exe,
553+
'-e',
554+
'-o', files('gen/function_source.c'),
555+
'-n', 'tests/function_source.js',
556+
files('tests/function_source.js'),
557+
],
558+
),
559+
run_target(
560+
'codegen_hello.c',
561+
command: [
562+
qjsc_exe,
563+
'-e',
564+
'-o', files('gen/hello.c'),
565+
'-n', 'examples/hello.js',
566+
files('examples/hello.js'),
567+
],
568+
),
569+
run_target(
570+
'codegen_hello_module.c',
571+
command: [
572+
qjsc_exe,
573+
'-e',
574+
'-o', files('gen/hello_module.c'),
575+
'-m',
576+
'-n', 'examples/hello_module.js',
577+
files('examples/hello_module.js'),
578+
],
579+
),
580+
run_target(
581+
'codegen_test_fib.c',
582+
command: [
583+
qjsc_exe,
584+
'-e',
585+
'-o', files('gen/test_fib.c'),
586+
'-m',
587+
'-n', 'examples/test_fib.js',
588+
files('examples/test_fib.js'),
589+
],
590+
),
591+
run_target(
592+
'codegen_builtin-array-fromasync.h',
593+
command: [
594+
qjsc_exe,
595+
'-C',
596+
'-ss',
597+
'-o', files('builtin-array-fromasync.h'),
598+
'-n', 'builtin-array-fromasync.js',
599+
files('builtin-array-fromasync.js'),
600+
],
601+
),
488602
)
489603

490604
if examples.allowed()

meson_options.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ option('examples', type: 'feature', description: 'build examples')
33
option('libc', type: 'boolean', value: false, description: 'build qjs standard library modules as part of the library')
44
option('cli_mimalloc', type: 'feature', value: 'disabled', description: 'build qjs cli with mimalloc')
55
option('docdir', type: 'string', description: 'documentation directory')
6-
option('disable_parser', type: 'boolean', value: false, description: 'Disable JS source code parser')
6+
option('parser', type: 'boolean', value: true, description: 'Enable JS source code parser')

0 commit comments

Comments
 (0)