Skip to content

Commit

Permalink
wrap for quickjs
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Razin committed Sep 8, 2024
1 parent 9834e8a commit 9d5ca26
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 3 deletions.
8 changes: 8 additions & 0 deletions releases.json
Original file line number Diff line number Diff line change
Expand Up @@ -2939,6 +2939,14 @@
"0.7.3-1"
]
},
"quickjs": {
"dependency_names": [
"quickjs"
],
"versions": [
"20240113-1"
]
},
"quill": {
"dependency_names": [
"quill"
Expand Down
79 changes: 79 additions & 0 deletions subprojects/packagefiles/quickjs/meson.build
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)
10 changes: 10 additions & 0 deletions subprojects/quickjs.wrap
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
6 changes: 3 additions & 3 deletions tools/sanity_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,6 @@ def check_source_url(self, name: str, wrap_section: configparser.SectionProxy, v
segs = version.split('.')
assert(len(segs) == 3)
version = segs[0] + segs[1] + '0' + segs[2]
elif name == 're2':
version = f'{version[:4]}-{version[4:6]}-{version[6:8]}'
elif name == 'netstring-c':
# There is no specific version for netstring-c
return True
Expand All @@ -332,7 +330,9 @@ def check_source_url(self, name: str, wrap_section: configparser.SectionProxy, v
version = segs[0] + segs[1] + segs[2]
source_url = wrap_section['source_url']
version_ = version.replace('.', '_')
self.assertTrue(version in source_url or version_ in source_url,
# re2 and quickjs use YYYY-MM-DD suffix in version names, we map it into YYYYMMDD
version_date = re.sub(r'^(\d\d\d\d)(\d\d)(\d\d)$', r'\1-\2-\3', version)
self.assertTrue(version in source_url or version_ in source_url or version_date in source_url,
f'Version {version} not found in {source_url}')

def check_new_release(self, name: str, builddir: str = '_build', deps=None, progs=None):
Expand Down

0 comments on commit 9d5ca26

Please sign in to comment.