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_ERROR_MESSAGES=1", 221 "JERRY_LINE_INFO=1", 222 "JERRY_FUNCTION_NAME", 223 "JERRY_FUNCTION_BACKTRACE", 224 "JERRY_STACK_LIMIT=0", 225 ] 226} else { 227 jerry_core_sources += [ 228 "api/external-context-helpers.c", 229 "api/generate-bytecode.c", 230 "api/jerryscript_adapter.c", 231 ] 232 config("jerry_core_config") { 233 cflags = [ 234 "--diag_suppress", 235 "Pa089,Pe111,Pe188,Pe191,Pe546,Pe940,Pe128", 236 ] 237 defines = [ 238 "JERRY_FOR_IAR_CONFIG", 239 "JERRY_GC_LIMIT=(0)", 240 "JERRY_CPOINTER_32_BIT=0", 241 "JERRY_ERROR_MESSAGES=1", 242 "JERRY_PARSER=1", 243 "JERRY_LINE_INFO=1", 244 "JERRY_LOGGING=0", 245 "JERRY_DEBUGGER=0", 246 "JERRY_MEM_GC_BEFORE_EACH_ALLOC=0", 247 "JERRY_PARSER_DUMP_BYTE_CODE=0", 248 "JERRY_ES2015=0", 249 "JERRY_REGEXP_STRICT_MODE=0", 250 "JERRY_REGEXP_DUMP_BYTE_CODE=0", 251 "JERRY_SNAPSHOT_EXEC=1", 252 "JERRY_SNAPSHOT_SAVE=1", 253 "JERRY_SYSTEM_ALLOCATOR=0", 254 "JERRY_VALGRIND=0", 255 "JERRY_VM_EXEC_STOP=0", 256 "JERRY_STACK_LIMIT=(8)", 257 "JERRY_IAR_JUPITER", 258 "INPUTJS_BUFFER_SIZE=64*1024", 259 "SNAPSHOT_BUFFER_SIZE=48*1024", 260 "_BSD_SOURCE", 261 ] 262 if (thirdparty_jerryscript_enable_external_context == true) { 263 defines += [ "JERRY_EXTERNAL_CONTEXT=1" ] 264 } 265 include_dirs = jerry_core_includes 266 include_dirs += [ 267 "$port_path", 268 "$port_path/default/include", 269 "//commonlibrary/utils_lite/memory/include", 270 ] 271 } 272} 273 274if (ohos_kernel_type == "liteos_m") { 275 lite_library("jerry-core_static") { 276 target_type = "static_library" 277 sources = jerry_core_sources 278 if (board_toolchain_type == "iccarm") { 279 public_configs = [ ":jerry_core_config" ] 280 } else { 281 include_dirs = jerry_core_includes 282 defines = jerry_core_defines 283 } 284 } 285} else { 286 lite_library("jerry-core_shared") { 287 target_type = "shared_library" 288 sources = jerry_core_sources 289 include_dirs = jerry_core_includes 290 defines = jerry_core_defines 291 } 292} 293