Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this change depend on the other PR changing qjsc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

$(QJSC) -C -ss -o builtin-array-fromasync.h builtin-array-fromasync.js

debug:
Expand Down
148 changes: 131 additions & 17 deletions meson.build
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -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 = []

Expand Down Expand Up @@ -155,10 +149,16 @@ 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=0x0602']
qjs_c_args += ['-DWIN32_LEAN_AND_MEAN', '-D_WIN32_WINNT=0x0601']
endif

if not qjs_parser
qjs_c_args += ['-DQJS_DISABLE_PARSER']
endif

qjs_libc_lib = static_library(
Expand Down Expand Up @@ -190,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'
Expand Down Expand Up @@ -251,8 +256,13 @@ 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,
)

if not qjs_parser
subdir_done()
endif

# QuickJS bytecode compiler
qjsc_srcs = files(
'qjsc.c',
Expand Down Expand Up @@ -290,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,
)
Expand Down Expand Up @@ -347,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,
Expand Down Expand Up @@ -415,20 +427,29 @@ 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',
'array_for_of',

'math_min',

'object_null',

'regexp_ascii',
'regexp_utf16',

'string_build1',
'string_build2',

'string_slice1',
'string_slice2',
'string_slice3',

'sort_bench',

'int_to_string',
Expand Down Expand Up @@ -463,28 +484,121 @@ 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

# Unicode generator
executable(
unicode_gen = executable(
'unicode_gen',
'cutils.c',
'libunicode.c',
'unicode_gen.c',

c_args: qjs_c_args,
build_by_default: false,
)

executable(
'function_source',
'gen/function_source.c',
qjs_libc_srcs,
run_target(
'libunicode-table.h',
command: [
unicode_gen,
meson.current_source_dir() / 'unicode',
files('libunicode-table.h'),
],
)

c_args: qjs_c_args,
dependencies: qjs_dep,
# 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()
Expand Down
2 changes: 1 addition & 1 deletion meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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')