• 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
14import("//build/lite/config/component/lite_component.gni")
15import("//third_party/jerryscript/engine.gni")
16
17lite_component("jerry-core") {
18  if (ohos_kernel_type == "liteos_m") {
19    features = [ ":jerry-core_static" ]
20  } else {
21    features = [ ":jerry-core_shared" ]
22  }
23}
24
25jerry_core_sources = [
26  "api/jerry-debugger-transport.c",
27  "api/jerry-debugger.c",
28  "api/jerry-snapshot.c",
29  "api/jerry.c",
30  "debugger/debugger.c",
31  "ecma/base/ecma-alloc.c",
32  "ecma/base/ecma-gc.c",
33  "ecma/base/ecma-helpers-collection.c",
34  "ecma/base/ecma-helpers-conversion.c",
35  "ecma/base/ecma-helpers-errol.c",
36  "ecma/base/ecma-helpers-external-pointers.c",
37  "ecma/base/ecma-helpers-number.c",
38  "ecma/base/ecma-helpers-string.c",
39  "ecma/base/ecma-helpers-value.c",
40  "ecma/base/ecma-helpers.c",
41  "ecma/base/ecma-init-finalize.c",
42  "ecma/base/ecma-lcache.c",
43  "ecma/base/ecma-literal-storage.c",
44  "ecma/base/ecma-module.c",
45  "ecma/base/ecma-property-hashmap.c",
46  "ecma/builtin-objects/ecma-builtin-array-iterator-prototype.c",
47  "ecma/builtin-objects/ecma-builtin-array-prototype-unscopables.c",
48  "ecma/builtin-objects/ecma-builtin-array-prototype.c",
49  "ecma/builtin-objects/ecma-builtin-array.c",
50  "ecma/builtin-objects/ecma-builtin-arraybuffer-prototype.c",
51  "ecma/builtin-objects/ecma-builtin-arraybuffer.c",
52  "ecma/builtin-objects/ecma-builtin-boolean-prototype.c",
53  "ecma/builtin-objects/ecma-builtin-boolean.c",
54  "ecma/builtin-objects/ecma-builtin-dataview-prototype.c",
55  "ecma/builtin-objects/ecma-builtin-dataview.c",
56  "ecma/builtin-objects/ecma-builtin-date-prototype.c",
57  "ecma/builtin-objects/ecma-builtin-date.c",
58  "ecma/builtin-objects/ecma-builtin-error-prototype.c",
59  "ecma/builtin-objects/ecma-builtin-error.c",
60  "ecma/builtin-objects/ecma-builtin-evalerror-prototype.c",
61  "ecma/builtin-objects/ecma-builtin-evalerror.c",
62  "ecma/builtin-objects/ecma-builtin-function-prototype.c",
63  "ecma/builtin-objects/ecma-builtin-function.c",
64  "ecma/builtin-objects/ecma-builtin-generator-function.c",
65  "ecma/builtin-objects/ecma-builtin-generator-prototype.c",
66  "ecma/builtin-objects/ecma-builtin-generator.c",
67  "ecma/builtin-objects/ecma-builtin-global.c",
68  "ecma/builtin-objects/ecma-builtin-helpers-date.c",
69  "ecma/builtin-objects/ecma-builtin-helpers-error.c",
70  "ecma/builtin-objects/ecma-builtin-helpers-json.c",
71  "ecma/builtin-objects/ecma-builtin-helpers-sort.c",
72  "ecma/builtin-objects/ecma-builtin-helpers.c",
73  "ecma/builtin-objects/ecma-builtin-intrinsic.c",
74  "ecma/builtin-objects/ecma-builtin-iterator-prototype.c",
75  "ecma/builtin-objects/ecma-builtin-json.c",
76  "ecma/builtin-objects/ecma-builtin-map-iterator-prototype.c",
77  "ecma/builtin-objects/ecma-builtin-map-prototype.c",
78  "ecma/builtin-objects/ecma-builtin-map.c",
79  "ecma/builtin-objects/ecma-builtin-math.c",
80  "ecma/builtin-objects/ecma-builtin-number-prototype.c",
81  "ecma/builtin-objects/ecma-builtin-number.c",
82  "ecma/builtin-objects/ecma-builtin-object-prototype.c",
83  "ecma/builtin-objects/ecma-builtin-object.c",
84  "ecma/builtin-objects/ecma-builtin-promise-prototype.c",
85  "ecma/builtin-objects/ecma-builtin-promise.c",
86  "ecma/builtin-objects/ecma-builtin-proxy.c",
87  "ecma/builtin-objects/ecma-builtin-rangeerror-prototype.c",
88  "ecma/builtin-objects/ecma-builtin-rangeerror.c",
89  "ecma/builtin-objects/ecma-builtin-referenceerror-prototype.c",
90  "ecma/builtin-objects/ecma-builtin-referenceerror.c",
91  "ecma/builtin-objects/ecma-builtin-reflect.c",
92  "ecma/builtin-objects/ecma-builtin-regexp-prototype.c",
93  "ecma/builtin-objects/ecma-builtin-regexp.c",
94  "ecma/builtin-objects/ecma-builtin-set-iterator-prototype.c",
95  "ecma/builtin-objects/ecma-builtin-set-prototype.c",
96  "ecma/builtin-objects/ecma-builtin-set.c",
97  "ecma/builtin-objects/ecma-builtin-string-iterator-prototype.c",
98  "ecma/builtin-objects/ecma-builtin-string-prototype.c",
99  "ecma/builtin-objects/ecma-builtin-string.c",
100  "ecma/builtin-objects/ecma-builtin-symbol-prototype.c",
101  "ecma/builtin-objects/ecma-builtin-symbol.c",
102  "ecma/builtin-objects/ecma-builtin-syntaxerror-prototype.c",
103  "ecma/builtin-objects/ecma-builtin-syntaxerror.c",
104  "ecma/builtin-objects/ecma-builtin-type-error-thrower.c",
105  "ecma/builtin-objects/ecma-builtin-typeerror-prototype.c",
106  "ecma/builtin-objects/ecma-builtin-typeerror.c",
107  "ecma/builtin-objects/ecma-builtin-urierror-prototype.c",
108  "ecma/builtin-objects/ecma-builtin-urierror.c",
109  "ecma/builtin-objects/ecma-builtin-weakmap-prototype.c",
110  "ecma/builtin-objects/ecma-builtin-weakmap.c",
111  "ecma/builtin-objects/ecma-builtin-weakset-prototype.c",
112  "ecma/builtin-objects/ecma-builtin-weakset.c",
113  "ecma/builtin-objects/ecma-builtins.c",
114  "ecma/builtin-objects/typedarray/ecma-builtin-float32array-prototype.c",
115  "ecma/builtin-objects/typedarray/ecma-builtin-float32array.c",
116  "ecma/builtin-objects/typedarray/ecma-builtin-float64array-prototype.c",
117  "ecma/builtin-objects/typedarray/ecma-builtin-float64array.c",
118  "ecma/builtin-objects/typedarray/ecma-builtin-int16array-prototype.c",
119  "ecma/builtin-objects/typedarray/ecma-builtin-int16array.c",
120  "ecma/builtin-objects/typedarray/ecma-builtin-int32array-prototype.c",
121  "ecma/builtin-objects/typedarray/ecma-builtin-int32array.c",
122  "ecma/builtin-objects/typedarray/ecma-builtin-int8array-prototype.c",
123  "ecma/builtin-objects/typedarray/ecma-builtin-int8array.c",
124  "ecma/builtin-objects/typedarray/ecma-builtin-typedarray-helpers.c",
125  "ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c",
126  "ecma/builtin-objects/typedarray/ecma-builtin-typedarray.c",
127  "ecma/builtin-objects/typedarray/ecma-builtin-uint16array-prototype.c",
128  "ecma/builtin-objects/typedarray/ecma-builtin-uint16array.c",
129  "ecma/builtin-objects/typedarray/ecma-builtin-uint32array-prototype.c",
130  "ecma/builtin-objects/typedarray/ecma-builtin-uint32array.c",
131  "ecma/builtin-objects/typedarray/ecma-builtin-uint8array-prototype.c",
132  "ecma/builtin-objects/typedarray/ecma-builtin-uint8array.c",
133  "ecma/builtin-objects/typedarray/ecma-builtin-uint8clampedarray-prototype.c",
134  "ecma/builtin-objects/typedarray/ecma-builtin-uint8clampedarray.c",
135  "ecma/operations/ecma-array-object.c",
136  "ecma/operations/ecma-arraybuffer-object.c",
137  "ecma/operations/ecma-boolean-object.c",
138  "ecma/operations/ecma-comparison.c",
139  "ecma/operations/ecma-container-object.c",
140  "ecma/operations/ecma-conversion.c",
141  "ecma/operations/ecma-dataview-object.c",
142  "ecma/operations/ecma-eval.c",
143  "ecma/operations/ecma-exceptions.c",
144  "ecma/operations/ecma-function-object.c",
145  "ecma/operations/ecma-get-put-value.c",
146  "ecma/operations/ecma-iterator-object.c",
147  "ecma/operations/ecma-jobqueue.c",
148  "ecma/operations/ecma-lex-env.c",
149  "ecma/operations/ecma-number-arithmetic.c",
150  "ecma/operations/ecma-number-object.c",
151  "ecma/operations/ecma-objects-arguments.c",
152  "ecma/operations/ecma-objects-general.c",
153  "ecma/operations/ecma-objects.c",
154  "ecma/operations/ecma-promise-object.c",
155  "ecma/operations/ecma-proxy-object.c",
156  "ecma/operations/ecma-reference.c",
157  "ecma/operations/ecma-regexp-object.c",
158  "ecma/operations/ecma-string-object.c",
159  "ecma/operations/ecma-symbol-object.c",
160  "ecma/operations/ecma-typedarray-object.c",
161  "ext/ext-utils.c",
162  "ext/heapdump.c",
163  "ext/tracker.c",
164  "jcontext/jcontext.c",
165  "jmem/jmem-allocator.c",
166  "jmem/jmem-heap.c",
167  "jmem/jmem-poolman.c",
168  "jrt/jrt-fatals.c",
169  "lit/lit-char-helpers.c",
170  "lit/lit-magic-strings.c",
171  "lit/lit-strings.c",
172  "parser/js/byte-code.c",
173  "parser/js/common.c",
174  "parser/js/js-lexer.c",
175  "parser/js/js-parser-expr.c",
176  "parser/js/js-parser-mem.c",
177  "parser/js/js-parser-module.c",
178  "parser/js/js-parser-statm.c",
179  "parser/js/js-parser-tagged-template-literal.c",
180  "parser/js/js-parser-util.c",
181  "parser/js/js-parser.c",
182  "parser/js/js-scanner-ops.c",
183  "parser/js/js-scanner-util.c",
184  "parser/js/js-scanner.c",
185  "parser/regexp/re-bytecode.c",
186  "parser/regexp/re-compiler.c",
187  "parser/regexp/re-parser.c",
188  "vm/opcodes-ecma-arithmetics.c",
189  "vm/opcodes-ecma-bitwise.c",
190  "vm/opcodes-ecma-relational-equality.c",
191  "vm/opcodes.c",
192  "vm/vm-stack.c",
193  "vm/vm-utils.c",
194  "vm/vm.c",
195]
196
197jerry_core_includes = [
198  "include",
199  "api",
200  "debugger",
201  "ecma/base",
202  "ecma/builtin-objects",
203  "ecma/builtin-objects/typedarray",
204  "ecma/operations",
205  "ext",
206  "jcontext",
207  "jmem",
208  "jrt",
209  "lit",
210  "parser",
211  "parser/js",
212  "parser/regexp",
213  "vm",
214  "$core_path",
215]
216
217if (board_toolchain_type != "iccarm") {
218  jerry_core_defines = [
219    "JERRY_GLOBAL_HEAP_SIZE=(128)",
220    "JERRY_FUNCTION_NAME",
221    "JERRY_FUNCTION_BACKTRACE",
222    "JERRY_STACK_LIMIT=0",
223  ]
224  jerry_core_defines += [
225    "JERRY_ERROR_MESSAGES=${jerryscript_jerry_error_messages}",
226    "JERRY_LINE_INFO=${jerryscript_jerry_line_info}",
227    "JERRY_ES2015=${jerryscript_jerry_es2015}",
228    "JERRY_ES2015_BUILTIN_TYPEDARRAY=${jerryscript_jerry_es2015_builtin_typedarray}",
229    "JERRY_ES2015_BUILTIN_SET=${jerryscript_jerry_es2015_builtin_set}",
230    "JERRY_ES2015_BUILTIN_PROMISE=${jerryscript_jerry_es2015_builtin_promise}",
231    "JERRY_ES2015_BUILTIN_PROXY=${jerryscript_jerry_es2015_builtin_proxy}",
232    "JERRY_ES2015_MODULE_SYSTEM=${jerryscript_jerry_es2015_module_system}",
233    "JERRY_ES2015_BUILTIN_MAP=${jerryscript_jerry_es2015_builtin_map}",
234    "JERRY_ES2015_BUILTIN_WEAKMAP=${jerryscript_jerry_es2015_builtin_weakmap}",
235    "JERRY_ES2015_BUILTIN_WEAKSET=${jerryscript_jerry_es2015_builtin_weakset}",
236    "JERRY_ES2015_BUILTIN_DATAVIEW=${jerryscript_jerry_es2015_builtin_dataview}",
237    "JERRY_ES2015_BUILTIN_REFLECT=${jerryscript_jerry_es2015_builtin_reflect}",
238  ]
239} else {
240  jerry_core_sources += [
241    "api/external-context-helpers.c",
242    "api/generate-bytecode.c",
243    "api/jerryscript_adapter.c",
244  ]
245  config("jerry_core_config") {
246    cflags = [
247      "--diag_suppress",
248      "Pa089,Pe111,Pe188,Pe191,Pe546,Pe940,Pe128",
249    ]
250    defines = [
251      "JERRY_FOR_IAR_CONFIG",
252      "JERRY_DEBUGGER=0",
253      "JERRY_STACK_LIMIT=(8)",
254      "JERRY_IAR_JUPITER",
255      "INPUTJS_BUFFER_SIZE=64*1024",
256      "SNAPSHOT_BUFFER_SIZE=48*1024",
257      "_BSD_SOURCE",
258    ]
259    defines += [
260      "JERRY_GC_LIMIT=${jerryscript_jerry_gc_limit}",
261      "JERRY_CPOINTER_32_BIT=${jerryscript_jerry_cpointer_32_bit}",
262      "JERRY_ERROR_MESSAGES=${jerryscript_jerry_error_messages}",
263      "JERRY_PARSER=${jerryscript_jerry_parser}",
264      "JERRY_LINE_INFO=${jerryscript_jerry_line_info}",
265      "JERRY_LOGGING=${jerryscript_jerry_logging}",
266      "JERRY_MEM_GC_BEFORE_EACH_ALLOC=${jerryscript_jerry_mem_gc_before_each_alloc}",
267      "JERRY_PARSER_DUMP_BYTE_CODE=${jerryscript_jerry_parser_dump_byte_code}",
268      "JERRY_REGEXP_STRICT_MODE=${jerryscript_jerry_regexp_strict_mode}",
269      "JERRY_REGEXP_DUMP_BYTE_CODE=${jerryscript_jerry_regexp_dump_byte_code}",
270      "JERRY_SNAPSHOT_EXEC=${jerryscript_jerry_snapshot_exec}",
271      "JERRY_SNAPSHOT_SAVE=${jerryscript_jerry_snapshot_save}",
272      "JERRY_SYSTEM_ALLOCATOR=${jerryscript_jerry_system_allocator}",
273      "JERRY_VALGRIND=${jerryscript_jerry_valgrind}",
274      "JERRY_VM_EXEC_STOP=${jerryscript_jerry_vm_exec_stop}",
275      "JERRY_ES2015=${jerryscript_jerry_es2015}",
276      "JERRY_ES2015_BUILTIN_TYPEDARRAY=${jerryscript_jerry_es2015_builtin_typedarray}",
277      "JERRY_ES2015_BUILTIN_SET=${jerryscript_jerry_es2015_builtin_set}",
278      "JERRY_ES2015_BUILTIN_PROMISE=${jerryscript_jerry_es2015_builtin_promise}",
279      "JERRY_ES2015_BUILTIN_PROXY=${jerryscript_jerry_es2015_builtin_proxy}",
280      "JERRY_ES2015_MODULE_SYSTEM=${jerryscript_jerry_es2015_module_system}",
281      "JERRY_ES2015_BUILTIN_MAP=${jerryscript_jerry_es2015_builtin_map}",
282      "JERRY_ES2015_BUILTIN_WEAKMAP=${jerryscript_jerry_es2015_builtin_weakmap}",
283      "JERRY_ES2015_BUILTIN_WEAKSET=${jerryscript_jerry_es2015_builtin_weakset}",
284      "JERRY_ES2015_BUILTIN_DATAVIEW=${jerryscript_jerry_es2015_builtin_dataview}",
285      "JERRY_ES2015_BUILTIN_REFLECT=${jerryscript_jerry_es2015_builtin_reflect}",
286    ]
287    if (jerryscript_enable_external_context == true) {
288      defines += [ "JERRY_EXTERNAL_CONTEXT=1" ]
289    }
290    defines += [ "INPUTJS_BUFFER_SIZE=${jerryscript_inputjs_buffer_size}" ]
291    defines += [ "SNAPSHOT_BUFFER_SIZE=${jerryscript_snapshot_buffer_size}" ]
292    defines += [ "BMS_TASK_HEAP_SIZE=${jerryscript_bms_task_heap_size}" ]
293    defines += [ "JS_TASK_HEAP_SIZE=${jerryscript_js_task_heap_size}" ]
294
295    include_dirs = jerry_core_includes
296    include_dirs += [
297      "$port_path",
298      "$port_path/default/include",
299      "//commonlibrary/utils_lite/memory/include",
300    ]
301  }
302}
303
304if (ohos_kernel_type == "liteos_m") {
305  lite_library("jerry-core_static") {
306    target_type = "static_library"
307    sources = jerry_core_sources
308    if (board_toolchain_type == "iccarm") {
309      public_configs = [ ":jerry_core_config" ]
310    } else {
311      include_dirs = jerry_core_includes
312      defines = jerry_core_defines
313    }
314  }
315} else {
316  lite_library("jerry-core_shared") {
317    target_type = "shared_library"
318    sources = jerry_core_sources
319    include_dirs = jerry_core_includes
320    defines = jerry_core_defines
321  }
322}
323