-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Maxim Razin
committed
Sep 8, 2024
1 parent
9834e8a
commit 9d5ca26
Showing
4 changed files
with
100 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
project('quickjs', 'c') | ||
|
||
cc = meson.get_compiler('c') | ||
dep_m = cc.find_library('m', required: false) | ||
dep_threads = dependency('threads') | ||
deps = [ | ||
dep_m, | ||
dep_threads, | ||
dependency('dl') | ||
] | ||
|
||
lib_src = [ | ||
'quickjs.c', | ||
'libregexp.c', | ||
'libunicode.c', | ||
'cutils.c', | ||
'quickjs-libc.c', | ||
'libbf.c' | ||
] | ||
config_version = run_command('cat', 'VERSION', check: true).stdout().strip() | ||
# WARNING: current version (2024-01-23) does not compile without bignum | ||
# TODO: support shared libs | ||
c_defines = [ | ||
'-funsigned-char', | ||
'-D_GNU_SOURCE', | ||
'-DCONFIG_VERSION="'+config_version+'"', | ||
'-DCONFIG_BIGNUM', | ||
] | ||
|
||
add_project_arguments(c_defines, language: 'c') | ||
|
||
qjsc = executable('qjsc', | ||
'qjsc.c', | ||
lib_src, | ||
dependencies: deps) | ||
|
||
repl_c = custom_target('repl_c', | ||
input: 'repl.js', | ||
output: 'repl.c', | ||
command: [qjsc, '-c', '-o', '@OUTPUT@', '-m', '@INPUT@'] | ||
) | ||
|
||
qjscalc_c = custom_target('qjscalc_c', | ||
input: 'qjscalc.js', | ||
output: 'qjscalc.c', | ||
command: [qjsc, '-fbignum', '-c', '-o', '@OUTPUT@', '@INPUT@'] | ||
) | ||
|
||
quickjs_lib = static_library('quickjs', | ||
lib_src, | ||
qjscalc_c, | ||
dependencies : deps | ||
) | ||
|
||
qjs = executable('qjs', | ||
'qjs.c', | ||
repl_c, | ||
link_with: [quickjs_lib], | ||
dependencies: deps) | ||
|
||
# TODO: add more tests and examples | ||
|
||
test_root = join_paths(meson.project_source_root(), 'tests') | ||
|
||
test('closure', qjs, args: ['test_closure.js'], workdir: test_root) | ||
test('language', qjs, args: ['test_language.js'], workdir: test_root) | ||
test('builtin', qjs, args: ['test_builtin.js'], workdir: test_root) | ||
test('loop', qjs, args: ['test_loop.js'], workdir: test_root) | ||
test('std', qjs, args: ['test_std.js'], workdir: test_root) | ||
test('worker', qjs, args: ['test_worker.js'], workdir: test_root) | ||
|
||
test('op_overloading', qjs, args: ['--bignum', 'test_op_overloading.js'], workdir: test_root) | ||
test('bignum', qjs, args: ['--bignum', 'test_bignum.js'], workdir: test_root) | ||
test('qjscalc', qjs, args: ['--qjscalc', 'test_qjscalc.js'], workdir: test_root) | ||
|
||
quickjs_lib_dep = declare_dependency( | ||
include_directories: include_directories('.'), | ||
link_with: quickjs_lib, | ||
dependencies: deps) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[wrap-file] | ||
directory=quickjs-2024-01-13 | ||
source_url=https://bellard.org/quickjs/quickjs-2024-01-13.tar.xz | ||
source_filename=quickjs-2024-01-13.tar.xz | ||
source_hash=3c4bf8f895bfa54beb486c8d1218112771ecfc5ac3be1036851ef41568212e03 | ||
patch_directory=quickjs | ||
method=meson | ||
|
||
[provide] | ||
quickjs=quickjs_lib_dep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters