@@ -123,9 +123,11 @@ if get_option('debug')
123123 )
124124endif
125125
126- copy = find_program (' cp' , ' xcopy' )
126+ copy = find_program (' cp' , ' xcopy' , required : true )
127+ fs = import (' fs' )
127128
128129qjs_parser = get_option (' parser' )
130+ qjs_codegen = get_option (' codegen' ).enable_auto_if(fs.is_dir(' unicode/' ))
129131
130132qjs_c_args = [' -D_GNU_SOURCE' ]
131133
@@ -146,38 +148,44 @@ unicode_gen = executable(
146148 build_by_default : false ,
147149)
148150
149- unicode_table = custom_target (
150- ' codegen_libunicode-table.h' ,
151- command : [
152- unicode_gen,
153- ' @CURRENT_SOURCE_DIR@/unicode' ,
154- ' @OUTPUT@' ,
155- ],
156- depend_files : files (
157- ' unicode/CaseFolding.txt' ,
158- ' unicode/CompositionExclusions.txt' ,
159- ' unicode/DerivedCoreProperties.txt' ,
160- ' unicode/DerivedNormalizationProps.txt' ,
161- ' unicode/emoji-data.txt' ,
162- ' unicode/NormalizationTest.txt' ,
163- ' unicode/PropertyValueAliases.txt' ,
164- ' unicode/PropList.txt' ,
165- ' unicode/ScriptExtensions.txt' ,
166- ' unicode/Scripts.txt' ,
167- ' unicode/SpecialCasing.txt' ,
168- ' unicode/UnicodeData.txt' ,
169- ),
170- output : ' codegen_libunicode-table.h' ,
171- )
151+ if qjs_codegen.enabled()
152+ unicode_table_gen = custom_target (
153+ ' codegen_libunicode-table.h' ,
154+ command : [
155+ unicode_gen,
156+ ' @CURRENT_SOURCE_DIR@/unicode' ,
157+ ' @OUTPUT@' ,
158+ ],
159+ depend_files : files (
160+ ' unicode/CaseFolding.txt' ,
161+ ' unicode/CompositionExclusions.txt' ,
162+ ' unicode/DerivedCoreProperties.txt' ,
163+ ' unicode/DerivedNormalizationProps.txt' ,
164+ ' unicode/emoji-data.txt' ,
165+ ' unicode/NormalizationTest.txt' ,
166+ ' unicode/PropertyValueAliases.txt' ,
167+ ' unicode/PropList.txt' ,
168+ ' unicode/ScriptExtensions.txt' ,
169+ ' unicode/Scripts.txt' ,
170+ ' unicode/SpecialCasing.txt' ,
171+ ' unicode/UnicodeData.txt' ,
172+ ),
173+ output : ' codegen_libunicode-table.h' ,
174+ )
172175
173- run_target (
174- ' libunicode-table.h' ,
175- command : [
176- copy,
177- unicode_table,
178- files (' libunicode-table.h' ),
179- ],
180- )
176+ run_target (
177+ ' libunicode-table.h' ,
178+ command : [
179+ copy,
180+ unicode_table_gen,
181+ files (' libunicode-table.h' ),
182+ ],
183+ )
184+
185+ unicode_table = unicode_table_gen
186+ else
187+ unicode_table = files (' libunicode-table.h' )
188+ endif
181189
182190qjs_sys_deps = []
183191
@@ -375,6 +383,7 @@ gen_repl_src = custom_target(
375383 ],
376384 input : files (' repl.js' ),
377385 output : ' repl.c' ,
386+ build_by_default : false ,
378387)
379388gen_standalone_src = custom_target (
380389 ' gen_standalone.c' ,
@@ -388,6 +397,7 @@ gen_standalone_src = custom_target(
388397 ],
389398 input : files (' standalone.js' ),
390399 output : ' standalone.c' ,
400+ build_by_default : false ,
391401)
392402gen_function_source_src = custom_target (
393403 ' gen_function_source.c' ,
@@ -400,6 +410,7 @@ gen_function_source_src = custom_target(
400410 ],
401411 input : files (' tests/function_source.js' ),
402412 output : ' function_source.c' ,
413+ build_by_default : false ,
403414)
404415gen_hello_src = custom_target (
405416 ' gen_hello.c' ,
@@ -412,6 +423,7 @@ gen_hello_src = custom_target(
412423 ],
413424 input : files (' examples/hello.js' ),
414425 output : ' hello.c' ,
426+ build_by_default : false ,
415427)
416428gen_hello_module_src = custom_target (
417429 ' gen_hello_module.c' ,
@@ -425,6 +437,7 @@ gen_hello_module_src = custom_target(
425437 ],
426438 input : files (' examples/hello_module.js' ),
427439 output : ' hello_module.c' ,
440+ build_by_default : false ,
428441)
429442gen_test_fib_src = custom_target (
430443 ' gen_test_fib.c' ,
@@ -438,6 +451,7 @@ gen_test_fib_src = custom_target(
438451 ],
439452 input : files (' examples/test_fib.js' ),
440453 output : ' test_fib.c' ,
454+ build_by_default : false ,
441455)
442456alias_target (' codegen' ,
443457 run_target (
@@ -500,6 +514,21 @@ alias_target('codegen',
500514 ],
501515 ),
502516)
517+ if qjs_codegen.enabled()
518+ repl_src = gen_repl_src
519+ standalone_src = gen_standalone_src
520+ function_source_src = gen_function_source_src
521+ hello_src = gen_hello_src
522+ hello_module_src = gen_hello_module_src
523+ test_fib_src = gen_test_fib_src
524+ else
525+ repl_src = files (' gen/repl.c' )
526+ standalone_src = files (' gen/standalone.c' )
527+ function_source_src = files (' gen/function_source.c' )
528+ hello_src = files (' gen/hello.c' )
529+ hello_module_src = files (' gen/hello_module.c' )
530+ test_fib_src = files (' gen/test_fib.c' )
531+ endif
503532
504533mimalloc_dep = []
505534mimalloc_sys_dep = dependency (' mimalloc' , required : get_option (' cli_mimalloc' ))
@@ -514,8 +543,8 @@ endif
514543qjs_exe_srcs = files (
515544 ' qjs.c' ,
516545) + [
517- gen_repl_src ,
518- gen_standalone_src
546+ repl_src ,
547+ standalone_src
519548]
520549qjs_exe = executable (
521550 ' qjs' ,
@@ -685,7 +714,7 @@ if tests.allowed()
685714 ' function_source' ,
686715 executable (
687716 ' function_source' ,
688- gen_function_source_src ,
717+ function_source_src ,
689718 qjs_libc_srcs,
690719
691720 c_args : qjs_c_args,
@@ -715,7 +744,7 @@ endif
715744if examples.allowed()
716745 executable (
717746 ' hello' ,
718- gen_hello_src ,
747+ hello_src ,
719748 qjs_libc_srcs,
720749
721750 c_args : qjs_c_args,
@@ -724,7 +753,7 @@ if examples.allowed()
724753
725754 executable (
726755 ' hello_module' ,
727- gen_hello_module_src ,
756+ hello_module_src ,
728757 qjs_libc_srcs,
729758
730759 c_args : qjs_c_args,
@@ -736,7 +765,7 @@ if examples.allowed()
736765 executable (
737766 ' test_fib' ,
738767 ' examples/fib.c' ,
739- gen_test_fib_src ,
768+ test_fib_src ,
740769 qjs_libc_srcs,
741770
742771 c_args : qjs_c_args,
0 commit comments