Skip to content

Commit a0cd3a1

Browse files
committed
feature 'tools'
When disabled do not build qjs and qjsc.
1 parent d31c087 commit a0cd3a1

2 files changed

Lines changed: 29 additions & 34 deletions

File tree

meson.build

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ if host_system != 'dos'
134134
qjs_sys_deps += dependency('threads', required: false)
135135
qjs_sys_deps += dependency('dl', required: false)
136136
endif
137+
tools = get_option('tools')
137138

138139
qjs_srcs = files(
139140
'dtoa.c',
@@ -145,7 +146,6 @@ qjs_hdrs = files(
145146
'quickjs.h',
146147
)
147148

148-
lib_only = get_option('libonly')
149149
qjs_libc = get_option('libc')
150150
qjs_libc_srcs = files('quickjs-libc.c')
151151
qjs_libc_hdrs = files('quickjs-libc.h')
@@ -223,7 +223,9 @@ if qjs_libc
223223
include_directories: include_directories('.'),
224224
dependencies: qjs_dep,
225225
)
226-
elif not lib_only
226+
elif not tools.allowed()
227+
qjs_libc_dep = []
228+
else
227229
qjs_libc_lib = static_library(
228230
'quickjs-libc',
229231
qjs_libc_srcs,
@@ -308,18 +310,15 @@ qjsc_srcs = files(
308310
'qjsc.c',
309311
)
310312

311-
if lib_only
312-
qjsc_exe = '/bin/true'
313-
else
314-
qjsc_exe = executable(
315-
'qjsc',
316-
qjsc_srcs,
313+
qjsc_exe = executable(
314+
'qjsc',
315+
qjsc_srcs,
317316

318-
c_args: qjs_c_args,
319-
dependencies: [qjs_dep, qjs_libc_dep],
320-
install: true,
321-
)
322-
endif
317+
c_args: qjs_c_args,
318+
dependencies: [qjs_dep, qjs_libc_dep],
319+
build_by_default: tools.allowed(),
320+
install: tools.allowed(),
321+
)
323322

324323
mimalloc_dep = []
325324
mimalloc_sys_dep = dependency('mimalloc', required: get_option('cli_mimalloc'))
@@ -337,20 +336,16 @@ qjs_exe_srcs = files(
337336
'qjs.c',
338337
)
339338

340-
if lib_only
341-
qjs_exe = '/bin/true'
342-
else
343-
qjs_exe = executable(
344-
'qjs',
345-
qjs_exe_srcs,
346-
347-
c_args: qjs_c_args,
348-
dependencies: [qjs_dep, qjs_libc_dep, mimalloc_dep],
349-
export_dynamic: true,
339+
qjs_exe = executable(
340+
'qjs',
341+
qjs_exe_srcs,
350342

351-
install: true,
352-
)
353-
endif
343+
c_args: qjs_c_args,
344+
dependencies: [qjs_dep, qjs_libc_dep, mimalloc_dep],
345+
export_dynamic: true,
346+
build_by_default: tools.allowed(),
347+
install: tools.allowed(),
348+
)
354349

355350
if meson.is_cross_build()
356351
mimalloc_native_dep = []
@@ -571,7 +566,7 @@ alias_target('codegen',
571566
run_target(
572567
'codegen_repl.c',
573568
command: [
574-
qjsc_exe,
569+
'qjsc',
575570
'-ss',
576571
'-o', files('gen/repl.c'),
577572
'-m',
@@ -582,7 +577,7 @@ alias_target('codegen',
582577
run_target(
583578
'codegen_standalone.c',
584579
command: [
585-
qjsc_exe,
580+
'qjsc',
586581
'-ss',
587582
'-o', files('gen/standalone.c'),
588583
'-m',
@@ -593,7 +588,7 @@ alias_target('codegen',
593588
run_target(
594589
'codegen_function_source.c',
595590
command: [
596-
qjsc_exe,
591+
'qjsc',
597592
'-e',
598593
'-o', files('gen/function_source.c'),
599594
'-n', 'tests/function_source.js',
@@ -603,7 +598,7 @@ alias_target('codegen',
603598
run_target(
604599
'codegen_hello.c',
605600
command: [
606-
qjsc_exe,
601+
'qjsc',
607602
'-e',
608603
'-o', files('gen/hello.c'),
609604
'-n', 'examples/hello.js',
@@ -613,7 +608,7 @@ alias_target('codegen',
613608
run_target(
614609
'codegen_hello_module.c',
615610
command: [
616-
qjsc_exe,
611+
'qjsc',
617612
'-e',
618613
'-o', files('gen/hello_module.c'),
619614
'-m',
@@ -624,7 +619,7 @@ alias_target('codegen',
624619
run_target(
625620
'codegen_test_fib.c',
626621
command: [
627-
qjsc_exe,
622+
'qjsc',
628623
'-e',
629624
'-o', files('gen/test_fib.c'),
630625
'-m',
@@ -635,7 +630,7 @@ alias_target('codegen',
635630
run_target(
636631
'codegen_builtin-array-fromasync.h',
637632
command: [
638-
qjsc_exe,
633+
'qjsc',
639634
'-C',
640635
'-ss',
641636
'-o', files('builtin-array-fromasync.h'),

meson_options.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ option('libc', type: 'boolean', value: false, description: 'build qjs standard l
44
option('cli_mimalloc', type: 'feature', value: 'disabled', description: 'build qjs cli with mimalloc')
55
option('docdir', type: 'string', description: 'documentation directory')
66
option('parser', type: 'boolean', value: true, description: 'Enable JS source code parser')
7-
option('libonly', type: 'boolean', value: false, description: 'Build qjs library only')
7+
option('tools', type: 'feature', description: 'build tools like qjs and qjsc')

0 commit comments

Comments
 (0)