# Copyright (c) 2022 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import("//build/lite/config/component/lite_component.gni") import("//third_party/jerryscript/engine.gni") lite_component("jerry-core") { if (ohos_kernel_type == "liteos_m") { features = [ ":jerry-core_static" ] } else { features = [ ":jerry-core_shared" ] } } jerry_core_sources = [ "api/jerry-debugger-transport.c", "api/jerry-debugger.c", "api/jerry-snapshot.c", "api/jerry.c", "debugger/debugger.c", "ecma/base/ecma-alloc.c", "ecma/base/ecma-gc.c", "ecma/base/ecma-helpers-collection.c", "ecma/base/ecma-helpers-conversion.c", "ecma/base/ecma-helpers-errol.c", "ecma/base/ecma-helpers-external-pointers.c", "ecma/base/ecma-helpers-number.c", "ecma/base/ecma-helpers-string.c", "ecma/base/ecma-helpers-value.c", "ecma/base/ecma-helpers.c", "ecma/base/ecma-init-finalize.c", "ecma/base/ecma-lcache.c", "ecma/base/ecma-literal-storage.c", "ecma/base/ecma-module.c", "ecma/base/ecma-property-hashmap.c", "ecma/builtin-objects/ecma-builtin-array-iterator-prototype.c", "ecma/builtin-objects/ecma-builtin-array-prototype-unscopables.c", "ecma/builtin-objects/ecma-builtin-array-prototype.c", "ecma/builtin-objects/ecma-builtin-array.c", "ecma/builtin-objects/ecma-builtin-arraybuffer-prototype.c", "ecma/builtin-objects/ecma-builtin-arraybuffer.c", "ecma/builtin-objects/ecma-builtin-boolean-prototype.c", "ecma/builtin-objects/ecma-builtin-boolean.c", "ecma/builtin-objects/ecma-builtin-dataview-prototype.c", "ecma/builtin-objects/ecma-builtin-dataview.c", "ecma/builtin-objects/ecma-builtin-date-prototype.c", "ecma/builtin-objects/ecma-builtin-date.c", "ecma/builtin-objects/ecma-builtin-error-prototype.c", "ecma/builtin-objects/ecma-builtin-error.c", "ecma/builtin-objects/ecma-builtin-evalerror-prototype.c", "ecma/builtin-objects/ecma-builtin-evalerror.c", "ecma/builtin-objects/ecma-builtin-function-prototype.c", "ecma/builtin-objects/ecma-builtin-function.c", "ecma/builtin-objects/ecma-builtin-generator-function.c", "ecma/builtin-objects/ecma-builtin-generator-prototype.c", "ecma/builtin-objects/ecma-builtin-generator.c", "ecma/builtin-objects/ecma-builtin-global.c", "ecma/builtin-objects/ecma-builtin-helpers-date.c", "ecma/builtin-objects/ecma-builtin-helpers-error.c", "ecma/builtin-objects/ecma-builtin-helpers-json.c", "ecma/builtin-objects/ecma-builtin-helpers-sort.c", "ecma/builtin-objects/ecma-builtin-helpers.c", "ecma/builtin-objects/ecma-builtin-intrinsic.c", "ecma/builtin-objects/ecma-builtin-iterator-prototype.c", "ecma/builtin-objects/ecma-builtin-json.c", "ecma/builtin-objects/ecma-builtin-map-iterator-prototype.c", "ecma/builtin-objects/ecma-builtin-map-prototype.c", "ecma/builtin-objects/ecma-builtin-map.c", "ecma/builtin-objects/ecma-builtin-math.c", "ecma/builtin-objects/ecma-builtin-number-prototype.c", "ecma/builtin-objects/ecma-builtin-number.c", "ecma/builtin-objects/ecma-builtin-object-prototype.c", "ecma/builtin-objects/ecma-builtin-object.c", "ecma/builtin-objects/ecma-builtin-promise-prototype.c", "ecma/builtin-objects/ecma-builtin-promise.c", "ecma/builtin-objects/ecma-builtin-proxy.c", "ecma/builtin-objects/ecma-builtin-rangeerror-prototype.c", "ecma/builtin-objects/ecma-builtin-rangeerror.c", "ecma/builtin-objects/ecma-builtin-referenceerror-prototype.c", "ecma/builtin-objects/ecma-builtin-referenceerror.c", "ecma/builtin-objects/ecma-builtin-reflect.c", "ecma/builtin-objects/ecma-builtin-regexp-prototype.c", "ecma/builtin-objects/ecma-builtin-regexp.c", "ecma/builtin-objects/ecma-builtin-set-iterator-prototype.c", "ecma/builtin-objects/ecma-builtin-set-prototype.c", "ecma/builtin-objects/ecma-builtin-set.c", "ecma/builtin-objects/ecma-builtin-string-iterator-prototype.c", "ecma/builtin-objects/ecma-builtin-string-prototype.c", "ecma/builtin-objects/ecma-builtin-string.c", "ecma/builtin-objects/ecma-builtin-symbol-prototype.c", "ecma/builtin-objects/ecma-builtin-symbol.c", "ecma/builtin-objects/ecma-builtin-syntaxerror-prototype.c", "ecma/builtin-objects/ecma-builtin-syntaxerror.c", "ecma/builtin-objects/ecma-builtin-type-error-thrower.c", "ecma/builtin-objects/ecma-builtin-typeerror-prototype.c", "ecma/builtin-objects/ecma-builtin-typeerror.c", "ecma/builtin-objects/ecma-builtin-urierror-prototype.c", "ecma/builtin-objects/ecma-builtin-urierror.c", "ecma/builtin-objects/ecma-builtin-weakmap-prototype.c", "ecma/builtin-objects/ecma-builtin-weakmap.c", "ecma/builtin-objects/ecma-builtin-weakset-prototype.c", "ecma/builtin-objects/ecma-builtin-weakset.c", "ecma/builtin-objects/ecma-builtins.c", "ecma/builtin-objects/typedarray/ecma-builtin-float32array-prototype.c", "ecma/builtin-objects/typedarray/ecma-builtin-float32array.c", "ecma/builtin-objects/typedarray/ecma-builtin-float64array-prototype.c", "ecma/builtin-objects/typedarray/ecma-builtin-float64array.c", "ecma/builtin-objects/typedarray/ecma-builtin-int16array-prototype.c", "ecma/builtin-objects/typedarray/ecma-builtin-int16array.c", "ecma/builtin-objects/typedarray/ecma-builtin-int32array-prototype.c", "ecma/builtin-objects/typedarray/ecma-builtin-int32array.c", "ecma/builtin-objects/typedarray/ecma-builtin-int8array-prototype.c", "ecma/builtin-objects/typedarray/ecma-builtin-int8array.c", "ecma/builtin-objects/typedarray/ecma-builtin-typedarray-helpers.c", "ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c", "ecma/builtin-objects/typedarray/ecma-builtin-typedarray.c", "ecma/builtin-objects/typedarray/ecma-builtin-uint16array-prototype.c", "ecma/builtin-objects/typedarray/ecma-builtin-uint16array.c", "ecma/builtin-objects/typedarray/ecma-builtin-uint32array-prototype.c", "ecma/builtin-objects/typedarray/ecma-builtin-uint32array.c", "ecma/builtin-objects/typedarray/ecma-builtin-uint8array-prototype.c", "ecma/builtin-objects/typedarray/ecma-builtin-uint8array.c", "ecma/builtin-objects/typedarray/ecma-builtin-uint8clampedarray-prototype.c", "ecma/builtin-objects/typedarray/ecma-builtin-uint8clampedarray.c", "ecma/operations/ecma-array-object.c", "ecma/operations/ecma-arraybuffer-object.c", "ecma/operations/ecma-boolean-object.c", "ecma/operations/ecma-comparison.c", "ecma/operations/ecma-container-object.c", "ecma/operations/ecma-conversion.c", "ecma/operations/ecma-dataview-object.c", "ecma/operations/ecma-eval.c", "ecma/operations/ecma-exceptions.c", "ecma/operations/ecma-function-object.c", "ecma/operations/ecma-get-put-value.c", "ecma/operations/ecma-iterator-object.c", "ecma/operations/ecma-jobqueue.c", "ecma/operations/ecma-lex-env.c", "ecma/operations/ecma-number-arithmetic.c", "ecma/operations/ecma-number-object.c", "ecma/operations/ecma-objects-arguments.c", "ecma/operations/ecma-objects-general.c", "ecma/operations/ecma-objects.c", "ecma/operations/ecma-promise-object.c", "ecma/operations/ecma-proxy-object.c", "ecma/operations/ecma-reference.c", "ecma/operations/ecma-regexp-object.c", "ecma/operations/ecma-string-object.c", "ecma/operations/ecma-symbol-object.c", "ecma/operations/ecma-typedarray-object.c", "ext/ext-utils.c", "ext/heapdump.c", "ext/tracker.c", "jcontext/jcontext.c", "jmem/jmem-allocator.c", "jmem/jmem-heap.c", "jmem/jmem-poolman.c", "jrt/jrt-fatals.c", "lit/lit-char-helpers.c", "lit/lit-magic-strings.c", "lit/lit-strings.c", "parser/js/byte-code.c", "parser/js/common.c", "parser/js/js-lexer.c", "parser/js/js-parser-expr.c", "parser/js/js-parser-mem.c", "parser/js/js-parser-module.c", "parser/js/js-parser-statm.c", "parser/js/js-parser-tagged-template-literal.c", "parser/js/js-parser-util.c", "parser/js/js-parser.c", "parser/js/js-scanner-ops.c", "parser/js/js-scanner-util.c", "parser/js/js-scanner.c", "parser/regexp/re-bytecode.c", "parser/regexp/re-compiler.c", "parser/regexp/re-parser.c", "vm/opcodes-ecma-arithmetics.c", "vm/opcodes-ecma-bitwise.c", "vm/opcodes-ecma-relational-equality.c", "vm/opcodes.c", "vm/vm-stack.c", "vm/vm-utils.c", "vm/vm.c", ] jerry_core_includes = [ "include", "api", "debugger", "ecma/base", "ecma/builtin-objects", "ecma/builtin-objects/typedarray", "ecma/operations", "ext", "jcontext", "jmem", "jrt", "lit", "parser", "parser/js", "parser/regexp", "vm", "$core_path", ] if (board_toolchain_type != "iccarm") { jerry_core_defines = [ "JERRY_GLOBAL_HEAP_SIZE=(128)", "JERRY_FUNCTION_NAME", "JERRY_FUNCTION_BACKTRACE", "JERRY_STACK_LIMIT=0", ] jerry_core_defines += [ "JERRY_ERROR_MESSAGES=${jerryscript_jerry_error_messages}", "JERRY_LINE_INFO=${jerryscript_jerry_line_info}", "JERRY_ES2015=${jerryscript_jerry_es2015}", "JERRY_ES2015_BUILTIN_TYPEDARRAY=${jerryscript_jerry_es2015_builtin_typedarray}", "JERRY_ES2015_BUILTIN_SET=${jerryscript_jerry_es2015_builtin_set}", "JERRY_ES2015_BUILTIN_PROMISE=${jerryscript_jerry_es2015_builtin_promise}", "JERRY_ES2015_BUILTIN_PROXY=${jerryscript_jerry_es2015_builtin_proxy}", "JERRY_ES2015_MODULE_SYSTEM=${jerryscript_jerry_es2015_module_system}", "JERRY_ES2015_BUILTIN_MAP=${jerryscript_jerry_es2015_builtin_map}", "JERRY_ES2015_BUILTIN_WEAKMAP=${jerryscript_jerry_es2015_builtin_weakmap}", "JERRY_ES2015_BUILTIN_WEAKSET=${jerryscript_jerry_es2015_builtin_weakset}", "JERRY_ES2015_BUILTIN_DATAVIEW=${jerryscript_jerry_es2015_builtin_dataview}", "JERRY_ES2015_BUILTIN_REFLECT=${jerryscript_jerry_es2015_builtin_reflect}", ] } else { jerry_core_sources += [ "api/external-context-helpers.c", "api/generate-bytecode.c", "api/jerryscript_adapter.c", ] config("jerry_core_config") { cflags = [ "--diag_suppress", "Pa089,Pe111,Pe188,Pe191,Pe546,Pe940,Pe128", ] defines = [ "JERRY_FOR_IAR_CONFIG", "JERRY_DEBUGGER=0", "JERRY_STACK_LIMIT=(8)", "JERRY_IAR_JUPITER", "INPUTJS_BUFFER_SIZE=64*1024", "SNAPSHOT_BUFFER_SIZE=48*1024", "_BSD_SOURCE", ] defines += [ "JERRY_GC_LIMIT=${jerryscript_jerry_gc_limit}", "JERRY_CPOINTER_32_BIT=${jerryscript_jerry_cpointer_32_bit}", "JERRY_ERROR_MESSAGES=${jerryscript_jerry_error_messages}", "JERRY_PARSER=${jerryscript_jerry_parser}", "JERRY_LINE_INFO=${jerryscript_jerry_line_info}", "JERRY_LOGGING=${jerryscript_jerry_logging}", "JERRY_MEM_GC_BEFORE_EACH_ALLOC=${jerryscript_jerry_mem_gc_before_each_alloc}", "JERRY_PARSER_DUMP_BYTE_CODE=${jerryscript_jerry_parser_dump_byte_code}", "JERRY_REGEXP_STRICT_MODE=${jerryscript_jerry_regexp_strict_mode}", "JERRY_REGEXP_DUMP_BYTE_CODE=${jerryscript_jerry_regexp_dump_byte_code}", "JERRY_SNAPSHOT_EXEC=${jerryscript_jerry_snapshot_exec}", "JERRY_SNAPSHOT_SAVE=${jerryscript_jerry_snapshot_save}", "JERRY_SYSTEM_ALLOCATOR=${jerryscript_jerry_system_allocator}", "JERRY_VALGRIND=${jerryscript_jerry_valgrind}", "JERRY_VM_EXEC_STOP=${jerryscript_jerry_vm_exec_stop}", "JERRY_ES2015=${jerryscript_jerry_es2015}", "JERRY_ES2015_BUILTIN_TYPEDARRAY=${jerryscript_jerry_es2015_builtin_typedarray}", "JERRY_ES2015_BUILTIN_SET=${jerryscript_jerry_es2015_builtin_set}", "JERRY_ES2015_BUILTIN_PROMISE=${jerryscript_jerry_es2015_builtin_promise}", "JERRY_ES2015_BUILTIN_PROXY=${jerryscript_jerry_es2015_builtin_proxy}", "JERRY_ES2015_MODULE_SYSTEM=${jerryscript_jerry_es2015_module_system}", "JERRY_ES2015_BUILTIN_MAP=${jerryscript_jerry_es2015_builtin_map}", "JERRY_ES2015_BUILTIN_WEAKMAP=${jerryscript_jerry_es2015_builtin_weakmap}", "JERRY_ES2015_BUILTIN_WEAKSET=${jerryscript_jerry_es2015_builtin_weakset}", "JERRY_ES2015_BUILTIN_DATAVIEW=${jerryscript_jerry_es2015_builtin_dataview}", "JERRY_ES2015_BUILTIN_REFLECT=${jerryscript_jerry_es2015_builtin_reflect}", ] if (jerryscript_enable_external_context == true) { defines += [ "JERRY_EXTERNAL_CONTEXT=1" ] } defines += [ "INPUTJS_BUFFER_SIZE=${jerryscript_inputjs_buffer_size}" ] defines += [ "SNAPSHOT_BUFFER_SIZE=${jerryscript_snapshot_buffer_size}" ] defines += [ "BMS_TASK_HEAP_SIZE=${jerryscript_bms_task_heap_size}" ] defines += [ "JS_TASK_HEAP_SIZE=${jerryscript_js_task_heap_size}" ] include_dirs = jerry_core_includes include_dirs += [ "$port_path", "$port_path/default/include", "//commonlibrary/utils_lite/memory/include", ] } } if (ohos_kernel_type == "liteos_m") { lite_library("jerry-core_static") { target_type = "static_library" sources = jerry_core_sources if (board_toolchain_type == "iccarm") { public_configs = [ ":jerry_core_config" ] } else { include_dirs = jerry_core_includes defines = jerry_core_defines } } } else { lite_library("jerry-core_shared") { target_type = "shared_library" sources = jerry_core_sources include_dirs = jerry_core_includes defines = jerry_core_defines } }