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-ext") { 18 if (ohos_kernel_type == "liteos_m") { 19 features = [ ":jerry-ext_static" ] 20 } else { 21 features = [ ":jerry-ext_shared" ] 22 } 23} 24 25jerry_ext_sources = [ 26 "arg/arg-js-iterator-helper.c", 27 "arg/arg-transform-functions.c", 28 "arg/arg.c", 29 "debugger/debugger-common.c", 30 "debugger/debugger-rp.c", 31 "debugger/debugger-serial.c", 32 "debugger/debugger-sha1.c", 33 "debugger/debugger-tcp.c", 34 "debugger/debugger-ws.c", 35 "handle-scope/handle-scope-allocator.c", 36 "handle-scope/handle-scope.c", 37 "handler/handler-assert.c", 38 "handler/handler-gc.c", 39 "handler/handler-print.c", 40 "handler/handler-register.c", 41 "handler/handler-resource-name.c", 42 "module/module.c", 43] 44 45jerry_ext_include_dirs = [ 46 "include", 47 "debugger", 48 "common", 49 "arg", 50 "handle-scope", 51 "${core_path}/include", 52] 53 54if (board_toolchain_type == "iccarm") { 55 config("jerry_ext_config") { 56 cflags = [ 57 "--diag_suppress", 58 "Pe940", 59 ] 60 defines = [ 61 "JERRY_FOR_IAR_CONFIG", 62 "JERRY_DEBUGGER=0", 63 "JERRY_STACK_LIMIT=(8)", 64 "JERRY_IAR_JUPITER", 65 "INPUTJS_BUFFER_SIZE=64*1024", 66 "SNAPSHOT_BUFFER_SIZE=48*1024", 67 ] 68 defines += [ 69 "JERRY_GC_LIMIT=${jerryscript_jerry_gc_limit}", 70 "JERRY_CPOINTER_32_BIT=${jerryscript_jerry_cpointer_32_bit}", 71 "JERRY_ERROR_MESSAGES=${jerryscript_jerry_error_messages}", 72 "JERRY_PARSER=${jerryscript_jerry_parser}", 73 "JERRY_LINE_INFO=${jerryscript_jerry_line_info}", 74 "JERRY_LOGGING=${jerryscript_jerry_logging}", 75 "JERRY_MEM_GC_BEFORE_EACH_ALLOC=${jerryscript_jerry_mem_gc_before_each_alloc}", 76 "JERRY_PARSER_DUMP_BYTE_CODE=${jerryscript_jerry_parser_dump_byte_code}", 77 "JERRY_REGEXP_STRICT_MODE=${jerryscript_jerry_regexp_strict_mode}", 78 "JERRY_REGEXP_DUMP_BYTE_CODE=${jerryscript_jerry_regexp_dump_byte_code}", 79 "JERRY_SNAPSHOT_EXEC=${jerryscript_jerry_snapshot_exec}", 80 "JERRY_SNAPSHOT_SAVE=${jerryscript_jerry_snapshot_save}", 81 "JERRY_SYSTEM_ALLOCATOR=${jerryscript_jerry_system_allocator}", 82 "JERRY_VALGRIND=${jerryscript_jerry_valgrind}", 83 "JERRY_VM_EXEC_STOP=${jerryscript_jerry_vm_exec_stop}", 84 "JERRY_ES2015=${jerryscript_jerry_es2015}", 85 "JERRY_ES2015_BUILTIN_TYPEDARRAY=${jerryscript_jerry_es2015_builtin_typedarray}", 86 "JERRY_ES2015_BUILTIN_SET=${jerryscript_jerry_es2015_builtin_set}", 87 "JERRY_ES2015_BUILTIN_PROMISE=${jerryscript_jerry_es2015_builtin_promise}", 88 "JERRY_ES2015_BUILTIN_PROXY=${jerryscript_jerry_es2015_builtin_proxy}", 89 "JERRY_ES2015_MODULE_SYSTEM=${jerryscript_jerry_es2015_module_system}", 90 "JERRY_ES2015_BUILTIN_MAP=${jerryscript_jerry_es2015_builtin_map}", 91 "JERRY_ES2015_BUILTIN_WEAKMAP=${jerryscript_jerry_es2015_builtin_weakmap}", 92 "JERRY_ES2015_BUILTIN_WEAKSET=${jerryscript_jerry_es2015_builtin_weakset}", 93 "JERRY_ES2015_BUILTIN_DATAVIEW=${jerryscript_jerry_es2015_builtin_dataview}", 94 "JERRY_ES2015_BUILTIN_REFLECT=${jerryscript_jerry_es2015_builtin_reflect}", 95 ] 96 if (jerryscript_enable_external_context == true) { 97 defines += [ "JERRY_EXTERNAL_CONTEXT=1" ] 98 } 99 defines += [ "INPUTJS_BUFFER_SIZE=${jerryscript_inputjs_buffer_size}" ] 100 defines += [ "SNAPSHOT_BUFFER_SIZE=${jerryscript_snapshot_buffer_size}" ] 101 defines += [ "BMS_TASK_HEAP_SIZE=${jerryscript_bms_task_heap_size}" ] 102 defines += [ "JS_TASK_HEAP_SIZE=${jerryscript_js_task_heap_size}" ] 103 104 include_dirs = jerry_ext_include_dirs 105 include_dirs += [ 106 "${core_path}", 107 "${core_path}/jrt", 108 "//commonlibrary/utils_lite/memory/include", 109 ] 110 } 111} 112 113if (ohos_kernel_type == "liteos_m") { 114 lite_library("jerry-ext_static") { 115 target_type = "static_library" 116 sources = jerry_ext_sources 117 if (board_toolchain_type == "iccarm") { 118 public_configs = [ ":jerry_ext_config" ] 119 } else { 120 include_dirs = jerry_ext_include_dirs 121 } 122 } 123} else { 124 lite_library("jerry-ext_shared") { 125 target_type = "shared_library" 126 sources = jerry_ext_sources 127 include_dirs = jerry_ext_include_dirs 128 } 129} 130