• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2022 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14if (defined(ohos_lite)) {  # is on lite Os for ipcamera
15  import("//build/lite/config/component/lite_component.gni")
16
17  lite_component("jerry_engine") {
18    features = [
19      "jerry-core",
20      "jerry-ext",
21      "jerry-port/default:jerry-port-default",
22    ]
23    if (ohos_kernel_type != "liteos_m") {
24      features += [ "jerry_libm" ]
25    }
26  }
27} else {
28  import("//build/ohos.gni")
29  import("//third_party/jerryscript/engine.gni")
30  config("jerryscript_config") {
31    defines = [
32      "JERRY_SNAPSHOT_SAVE=1",
33      "JERRY_COMMIT_HASH=\"ignored\"",
34      "JERRY_NDEBUG",
35      "JERRY_HEAPDUMP",
36      "JERRY_REF_TRACKER",
37    ]
38    cflags = [
39      "-Wno-unused-function",
40      "-Wno-sign-compare",
41      "-Wno-implicit-fallthrough",
42    ]
43    include_dirs = [ "." ]
44  }
45
46  config("jerryscript_simulator") {
47    defines = [
48      "JERRY_CPOINTER_32_BIT=0",
49      "JERRY_DEBUGGER=1",
50      "JERRY_ES2015=0",
51      "JERRY_FUNCTION_BACKTRACE",
52      "JERRY_FUNCTION_NAME",
53      "JERRY_GC_LIMIT=(0)",
54      "JERRY_HEAPDUMP",
55      "JERRY_LINE_INFO=1",
56      "JERRY_MEM_GC_BEFORE_EACH_ALLOC=0",
57      "JERRY_NDEBUG",
58      "JERRY_PARSER=1",
59      "JERRY_PARSER_DUMP_BYTE_CODE=0",
60      "JERRY_REF_TRACKER",
61      "JERRY_REGEXP_DUMP_BYTE_CODE=0",
62      "JERRY_REGEXP_STRICT_MODE=0",
63      "JERRY_STACK_LIMIT=(0)",
64      "JERRY_SYSTEM_ALLOCATOR=0",
65      "JERRY_VALGRIND=0",
66      "JERRY_VM_EXEC_STOP=0",
67    ]
68    if (thirdparty_jerryscript_enable_external_context == true) {
69      defines += [ "JERRY_EXTERNAL_CONTEXT=1" ]
70    }
71    cflags = [
72      "-Wno-unused-function",
73      "-Wno-sign-compare",
74      "-Wno-error",  # jerry add
75      "-Wno-implicit-fallthrough",
76    ]
77    include_dirs = [ "." ]
78  }
79
80  jerry_core_sources = [
81    "jerry-core/api/jerry-debugger-transport.c",
82    "jerry-core/api/jerry-debugger.c",
83    "jerry-core/api/jerry-snapshot.c",
84    "jerry-core/api/jerry.c",
85    "jerry-core/debugger/debugger.c",
86    "jerry-core/ecma/base/ecma-alloc.c",
87    "jerry-core/ecma/base/ecma-gc.c",
88    "jerry-core/ecma/base/ecma-helpers-collection.c",
89    "jerry-core/ecma/base/ecma-helpers-conversion.c",
90    "jerry-core/ecma/base/ecma-helpers-errol.c",
91    "jerry-core/ecma/base/ecma-helpers-external-pointers.c",
92    "jerry-core/ecma/base/ecma-helpers-number.c",
93    "jerry-core/ecma/base/ecma-helpers-string.c",
94    "jerry-core/ecma/base/ecma-helpers-value.c",
95    "jerry-core/ecma/base/ecma-helpers.c",
96    "jerry-core/ecma/base/ecma-init-finalize.c",
97    "jerry-core/ecma/base/ecma-lcache.c",
98    "jerry-core/ecma/base/ecma-literal-storage.c",
99    "jerry-core/ecma/base/ecma-module.c",
100    "jerry-core/ecma/base/ecma-property-hashmap.c",
101    "jerry-core/ecma/builtin-objects/ecma-builtin-array-iterator-prototype.c",
102    "jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype-unscopables.c",
103    "jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype.c",
104    "jerry-core/ecma/builtin-objects/ecma-builtin-array.c",
105    "jerry-core/ecma/builtin-objects/ecma-builtin-arraybuffer-prototype.c",
106    "jerry-core/ecma/builtin-objects/ecma-builtin-arraybuffer.c",
107    "jerry-core/ecma/builtin-objects/ecma-builtin-boolean-prototype.c",
108    "jerry-core/ecma/builtin-objects/ecma-builtin-boolean.c",
109    "jerry-core/ecma/builtin-objects/ecma-builtin-dataview-prototype.c",
110    "jerry-core/ecma/builtin-objects/ecma-builtin-dataview.c",
111    "jerry-core/ecma/builtin-objects/ecma-builtin-date-prototype.c",
112    "jerry-core/ecma/builtin-objects/ecma-builtin-date.c",
113    "jerry-core/ecma/builtin-objects/ecma-builtin-error-prototype.c",
114    "jerry-core/ecma/builtin-objects/ecma-builtin-error.c",
115    "jerry-core/ecma/builtin-objects/ecma-builtin-evalerror-prototype.c",
116    "jerry-core/ecma/builtin-objects/ecma-builtin-evalerror.c",
117    "jerry-core/ecma/builtin-objects/ecma-builtin-function-prototype.c",
118    "jerry-core/ecma/builtin-objects/ecma-builtin-function.c",
119    "jerry-core/ecma/builtin-objects/ecma-builtin-generator-function.c",
120    "jerry-core/ecma/builtin-objects/ecma-builtin-generator-prototype.c",
121    "jerry-core/ecma/builtin-objects/ecma-builtin-generator.c",
122    "jerry-core/ecma/builtin-objects/ecma-builtin-global.c",
123    "jerry-core/ecma/builtin-objects/ecma-builtin-helpers-date.c",
124    "jerry-core/ecma/builtin-objects/ecma-builtin-helpers-error.c",
125    "jerry-core/ecma/builtin-objects/ecma-builtin-helpers-json.c",
126    "jerry-core/ecma/builtin-objects/ecma-builtin-helpers-sort.c",
127    "jerry-core/ecma/builtin-objects/ecma-builtin-helpers.c",
128    "jerry-core/ecma/builtin-objects/ecma-builtin-intrinsic.c",
129    "jerry-core/ecma/builtin-objects/ecma-builtin-iterator-prototype.c",
130    "jerry-core/ecma/builtin-objects/ecma-builtin-json.c",
131    "jerry-core/ecma/builtin-objects/ecma-builtin-map-iterator-prototype.c",
132    "jerry-core/ecma/builtin-objects/ecma-builtin-map-prototype.c",
133    "jerry-core/ecma/builtin-objects/ecma-builtin-map.c",
134    "jerry-core/ecma/builtin-objects/ecma-builtin-math.c",
135    "jerry-core/ecma/builtin-objects/ecma-builtin-number-prototype.c",
136    "jerry-core/ecma/builtin-objects/ecma-builtin-number.c",
137    "jerry-core/ecma/builtin-objects/ecma-builtin-object-prototype.c",
138    "jerry-core/ecma/builtin-objects/ecma-builtin-object.c",
139    "jerry-core/ecma/builtin-objects/ecma-builtin-promise-prototype.c",
140    "jerry-core/ecma/builtin-objects/ecma-builtin-promise.c",
141    "jerry-core/ecma/builtin-objects/ecma-builtin-proxy.c",
142    "jerry-core/ecma/builtin-objects/ecma-builtin-rangeerror-prototype.c",
143    "jerry-core/ecma/builtin-objects/ecma-builtin-rangeerror.c",
144    "jerry-core/ecma/builtin-objects/ecma-builtin-referenceerror-prototype.c",
145    "jerry-core/ecma/builtin-objects/ecma-builtin-referenceerror.c",
146    "jerry-core/ecma/builtin-objects/ecma-builtin-reflect.c",
147    "jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.c",
148    "jerry-core/ecma/builtin-objects/ecma-builtin-regexp.c",
149    "jerry-core/ecma/builtin-objects/ecma-builtin-set-iterator-prototype.c",
150    "jerry-core/ecma/builtin-objects/ecma-builtin-set-prototype.c",
151    "jerry-core/ecma/builtin-objects/ecma-builtin-set.c",
152    "jerry-core/ecma/builtin-objects/ecma-builtin-string-iterator-prototype.c",
153    "jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c",
154    "jerry-core/ecma/builtin-objects/ecma-builtin-string.c",
155    "jerry-core/ecma/builtin-objects/ecma-builtin-symbol-prototype.c",
156    "jerry-core/ecma/builtin-objects/ecma-builtin-symbol.c",
157    "jerry-core/ecma/builtin-objects/ecma-builtin-syntaxerror-prototype.c",
158    "jerry-core/ecma/builtin-objects/ecma-builtin-syntaxerror.c",
159    "jerry-core/ecma/builtin-objects/ecma-builtin-type-error-thrower.c",
160    "jerry-core/ecma/builtin-objects/ecma-builtin-typeerror-prototype.c",
161    "jerry-core/ecma/builtin-objects/ecma-builtin-typeerror.c",
162    "jerry-core/ecma/builtin-objects/ecma-builtin-urierror-prototype.c",
163    "jerry-core/ecma/builtin-objects/ecma-builtin-urierror.c",
164    "jerry-core/ecma/builtin-objects/ecma-builtin-weakmap-prototype.c",
165    "jerry-core/ecma/builtin-objects/ecma-builtin-weakmap.c",
166    "jerry-core/ecma/builtin-objects/ecma-builtin-weakset-prototype.c",
167    "jerry-core/ecma/builtin-objects/ecma-builtin-weakset.c",
168    "jerry-core/ecma/builtin-objects/ecma-builtins.c",
169    "jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-float32array-prototype.c",
170    "jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-float32array.c",
171    "jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-float64array-prototype.c",
172    "jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-float64array.c",
173    "jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-int16array-prototype.c",
174    "jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-int16array.c",
175    "jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-int32array-prototype.c",
176    "jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-int32array.c",
177    "jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-int8array-prototype.c",
178    "jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-int8array.c",
179    "jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-helpers.c",
180    "jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c",
181    "jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray.c",
182    "jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint16array-prototype.c",
183    "jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint16array.c",
184    "jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint32array-prototype.c",
185    "jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint32array.c",
186    "jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint8array-prototype.c",
187    "jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint8array.c",
188    "jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint8clampedarray-prototype.c",
189    "jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint8clampedarray.c",
190    "jerry-core/ecma/operations/ecma-array-object.c",
191    "jerry-core/ecma/operations/ecma-arraybuffer-object.c",
192    "jerry-core/ecma/operations/ecma-boolean-object.c",
193    "jerry-core/ecma/operations/ecma-comparison.c",
194    "jerry-core/ecma/operations/ecma-container-object.c",
195    "jerry-core/ecma/operations/ecma-conversion.c",
196    "jerry-core/ecma/operations/ecma-dataview-object.c",
197    "jerry-core/ecma/operations/ecma-eval.c",
198    "jerry-core/ecma/operations/ecma-exceptions.c",
199    "jerry-core/ecma/operations/ecma-function-object.c",
200    "jerry-core/ecma/operations/ecma-get-put-value.c",
201    "jerry-core/ecma/operations/ecma-iterator-object.c",
202    "jerry-core/ecma/operations/ecma-jobqueue.c",
203    "jerry-core/ecma/operations/ecma-lex-env.c",
204    "jerry-core/ecma/operations/ecma-number-arithmetic.c",
205    "jerry-core/ecma/operations/ecma-number-object.c",
206    "jerry-core/ecma/operations/ecma-objects-arguments.c",
207    "jerry-core/ecma/operations/ecma-objects-general.c",
208    "jerry-core/ecma/operations/ecma-objects.c",
209    "jerry-core/ecma/operations/ecma-promise-object.c",
210    "jerry-core/ecma/operations/ecma-proxy-object.c",
211    "jerry-core/ecma/operations/ecma-reference.c",
212    "jerry-core/ecma/operations/ecma-regexp-object.c",
213    "jerry-core/ecma/operations/ecma-string-object.c",
214    "jerry-core/ecma/operations/ecma-symbol-object.c",
215    "jerry-core/ecma/operations/ecma-typedarray-object.c",
216    "jerry-core/ext/ext-utils.c",
217    "jerry-core/ext/heapdump.c",
218    "jerry-core/ext/tracker.c",
219    "jerry-core/jcontext/jcontext.c",
220    "jerry-core/jmem/jmem-allocator.c",
221    "jerry-core/jmem/jmem-heap.c",
222    "jerry-core/jmem/jmem-poolman.c",
223    "jerry-core/jrt/jrt-fatals.c",
224    "jerry-core/lit/lit-char-helpers.c",
225    "jerry-core/lit/lit-magic-strings.c",
226    "jerry-core/lit/lit-strings.c",
227    "jerry-core/parser/js/byte-code.c",
228    "jerry-core/parser/js/common.c",
229    "jerry-core/parser/js/js-lexer.c",
230    "jerry-core/parser/js/js-parser-expr.c",
231    "jerry-core/parser/js/js-parser-mem.c",
232    "jerry-core/parser/js/js-parser-module.c",
233    "jerry-core/parser/js/js-parser-statm.c",
234    "jerry-core/parser/js/js-parser-tagged-template-literal.c",
235    "jerry-core/parser/js/js-parser-util.c",
236    "jerry-core/parser/js/js-parser.c",
237    "jerry-core/parser/js/js-scanner-ops.c",
238    "jerry-core/parser/js/js-scanner-util.c",
239    "jerry-core/parser/js/js-scanner.c",
240    "jerry-core/parser/regexp/re-bytecode.c",
241    "jerry-core/parser/regexp/re-compiler.c",
242    "jerry-core/parser/regexp/re-parser.c",
243    "jerry-core/vm/opcodes-ecma-arithmetics.c",
244    "jerry-core/vm/opcodes-ecma-bitwise.c",
245    "jerry-core/vm/opcodes-ecma-relational-equality.c",
246    "jerry-core/vm/opcodes.c",
247    "jerry-core/vm/vm-stack.c",
248    "jerry-core/vm/vm-utils.c",
249    "jerry-core/vm/vm.c",
250  ]
251
252  jerry_core_include_dirs = [
253    "jerry-core/include",
254    "jerry-core/api",
255    "jerry-core/debugger",
256    "jerry-core/ecma/base",
257    "jerry-core/ecma/builtin-objects",
258    "jerry-core/ecma/builtin-objects/typedarray",
259    "jerry-core/ecma/operations",
260    "jerry-core/ext",
261    "jerry-core/jcontext",
262    "jerry-core/jmem",
263    "jerry-core/jrt",
264    "jerry-core/lit",
265    "jerry-core/parser",
266    "jerry-core/parser/js",
267    "jerry-core/parser/regexp",
268    "jerry-core/vm",
269    "jerry-core",
270  ]
271
272  jerry_ext_sources = [
273    "jerry-ext/arg/arg-js-iterator-helper.c",
274    "jerry-ext/arg/arg-transform-functions.c",
275    "jerry-ext/arg/arg.c",
276    "jerry-ext/debugger/debugger-common.c",
277    "jerry-ext/debugger/debugger-rp.c",
278    "jerry-ext/debugger/debugger-serial.c",
279    "jerry-ext/debugger/debugger-sha1.c",
280    "jerry-ext/debugger/debugger-tcp.c",
281    "jerry-ext/debugger/debugger-ws.c",
282    "jerry-ext/handle-scope/handle-scope-allocator.c",
283    "jerry-ext/handle-scope/handle-scope.c",
284    "jerry-ext/handler/handler-assert.c",
285    "jerry-ext/handler/handler-gc.c",
286    "jerry-ext/handler/handler-print.c",
287    "jerry-ext/handler/handler-register.c",
288    "jerry-ext/handler/handler-resource-name.c",
289    "jerry-ext/module/module.c",
290  ]
291  jerry_ext_include_dirs = [
292    "jerry-ext/include",
293    "jerry-ext/debugger",
294    "jerry-ext/common",
295    "jerry-ext/arg",
296    "jerry-ext/handle-scope",
297    "jerry-core/include",
298  ]
299
300  jerry_port_default_sources = [
301    "jerry-port/default/default-date.c",
302    "jerry-port/default/default-debugger.c",
303    "jerry-port/default/default-external-context.c",
304    "jerry-port/default/default-fatal.c",
305    "jerry-port/default/default-io.c",
306    "jerry-port/default/default-module.c",
307  ]
308  jerry_port_default_include_dirs = [
309    "jerry-port/default/include",
310    "jerry-core/include",
311  ]
312
313  jerry_libm_sources = [
314    "jerry-libm/acos.c",
315    "jerry-libm/acosh.c",
316    "jerry-libm/asin.c",
317    "jerry-libm/asinh.c",
318    "jerry-libm/atan.c",
319    "jerry-libm/atan2.c",
320    "jerry-libm/atanh.c",
321    "jerry-libm/cbrt.c",
322    "jerry-libm/ceil.c",
323    "jerry-libm/copysign.c",
324    "jerry-libm/cosh.c",
325    "jerry-libm/exp.c",
326    "jerry-libm/expm1.c",
327    "jerry-libm/fabs.c",
328    "jerry-libm/finite.c",
329    "jerry-libm/floor.c",
330    "jerry-libm/fmod.c",
331    "jerry-libm/isnan.c",
332    "jerry-libm/log.c",
333    "jerry-libm/log10.c",
334    "jerry-libm/log1p.c",
335    "jerry-libm/log2.c",
336    "jerry-libm/nextafter.c",
337    "jerry-libm/pow.c",
338    "jerry-libm/scalbn.c",
339    "jerry-libm/sinh.c",
340    "jerry-libm/sqrt.c",
341    "jerry-libm/tanh.c",
342    "jerry-libm/trig.c",
343  ]
344  jerry_libm_include_dirs = [ "jerry-libm/include" ]
345
346  jerry_sources = [
347    "jerry-main/cli.c",
348    "jerry-main/main-unix.c",
349  ]
350  jerry_include_dirs = [
351    "jerry-ext",
352    "jerry-ext/common",
353    "jerry-ext/debugger",
354    "jerry-ext/handle-scope",
355    "jerry-ext/include/jerryscript-ext",
356    "jerry-ext/include",
357    "jerry-libm",
358    "jerry-debugger",
359    "jerry-port",
360    "jerry-main",
361    "jerry-core",
362    "jerry-port/default/include",
363    "jerry-core/ecma/base",
364    "jerry-core/ecma/operations",
365    "jerry-core/ecma/builtin-objects",
366    "jerry-core/vm",
367    "jerry-core/jcontext",
368    "jerry-core/jmem",
369    "jerry-core/parser/js",
370    "jerry-core/parser/regexp",
371    "jerry-core/jrt",
372    "jerry-core/lit",
373    "jerry-core/include",
374    "jerry-core/ecma/builtin-objects/",
375  ]
376
377  jerry_snapshot_sources = [
378    "jerry-main/cli.c",
379    "jerry-main/main-unix-snapshot.c",
380  ]
381  jerry_snapshot_include_dirs = [
382    "jerry-ext",
383    "jerry-ext/common",
384    "jerry-ext/debugger",
385    "jerry-ext/handle-scope",
386    "jerry-ext/include/jerryscript-ext",
387    "jerry-ext/include",
388    "jerry-libm",
389    "jerry-debugger",
390    "jerry-port",
391    "jerry-main",
392    "jerry-core",
393    "jerry-port/default/include",
394    "jerry-core/ecma/base",
395    "jerry-core/ecma/operations",
396    "jerry-core/ecma/builtin-objects",
397    "jerry-core/vm",
398    "jerry-core/jcontext",
399    "jerry-core/jmem",
400    "jerry-core/parser/js",
401    "jerry-core/parser/regexp",
402    "jerry-core/jrt",
403    "jerry-core/lit",
404    "jerry-core/include",
405    "jerry-core/ecma/builtin-objects/",
406  ]
407
408  ohos_executable("jerry") {
409    configs = [ ":jerryscript_config" ]
410    sources = jerry_core_sources
411    sources += jerry_ext_sources
412    sources += jerry_libm_sources
413    sources += jerry_port_default_sources
414    sources += jerry_sources
415
416    include_dirs = jerry_core_include_dirs
417    include_dirs += jerry_ext_include_dirs
418    include_dirs += jerry_libm_include_dirs
419    include_dirs += jerry_port_default_include_dirs
420    include_dirs += jerry_include_dirs
421  }
422
423  ohos_executable("jerry-snapshot") {
424    configs = [ ":jerryscript_config" ]
425    sources = jerry_core_sources
426    sources += jerry_libm_sources
427    sources += jerry_port_default_sources
428    sources += jerry_snapshot_sources
429
430    include_dirs = jerry_core_include_dirs
431    include_dirs += jerry_libm_include_dirs
432    include_dirs += jerry_port_default_include_dirs
433    include_dirs += jerry_snapshot_include_dirs
434  }
435
436  ohos_static_library("libjerryscript") {
437    configs = [ ":jerryscript_simulator" ]
438    sources = jerry_core_sources
439    sources += jerry_ext_sources
440    sources += jerry_libm_sources
441    sources += jerry_port_default_sources
442
443    include_dirs = jerry_core_include_dirs
444    include_dirs += jerry_ext_include_dirs
445    include_dirs += jerry_libm_include_dirs
446    include_dirs += jerry_port_default_include_dirs
447  }
448}
449