1# Copyright (c) 2025 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/ohos.gni") 15 16shared_library("es2panda") { 17 external_deps = [ 18 "ets_frontend:libes2panda_public_headers", 19 "node:node_header_notice", 20 ] 21 sources = [ 22 "../koalaui/interop/src/cpp/common-interop.cc", 23 "../koalaui/interop/src/cpp/interop-logging.cc", 24 "../koalaui/interop/src/cpp/napi/convertors-napi.cc", 25 "./src/bridges.cc", 26 "./src/common.cc", 27 "./src/generated/bridges.cc", 28 ] 29 30 include_dirs = [ 31 "../koalaui/interop/src/cpp", 32 "../koalaui/interop/src/cpp/types", 33 "../koalaui/interop/src/cpp/napi", 34 "../node_modules/node-api-headers/include", 35 "../node_modules/node-addon-api", 36 "./include", 37 rebase_path("$root_gen_dir/arkcompiler/ets_frontend/ets2panda/"), 38 ] 39 40 defines = [ 41 "KOALA_INTEROP_MODULE=NativeModule", 42 "INTEROP_LIBRARY_NAME=es2panda", 43 "KOALA_USE_NODE_VM", 44 "KOALA_NAPI", 45 "NODE_ADDON_API_DISABLE_CPP_EXCEPTIONS", 46 ] 47 48 configs -= [ "//build/config/compiler:compiler" ] 49 50 if (is_mac) { 51 cflags_cc = [ 52 "-std=c++17", 53 "-Wall", 54 "-Werror", 55 "-Wno-unused-variable", 56 "-fPIC", 57 ] 58 59 ldflags = [ 60 "-fPIC", 61 "-Wl,-undefined,dynamic_lookup", 62 "-fuse-ld=lld", 63 "-Wl,--icf=all", 64 "-Wl,--color-diagnostics", 65 "-m64", 66 ] 67 defines += [ "KOALA_MACOS" ] 68 output_extension = "node" 69 } 70 71 if (current_os == "linux") { 72 cflags_cc = [ 73 "-std=c++17", 74 "-Wall", 75 "-Werror", 76 "-Wno-unused-variable", 77 "-fPIC", 78 ] 79 80 ldflags = [ 81 "-Wl,--allow-shlib-undefined", 82 "-Wl,--fatal-warnings", 83 "-Wl,--build-id=md5", 84 "-fPIC", 85 "-Wl,-z,noexecstack", 86 "-Wl,-z,now", 87 "-Wl,-z,relro", 88 89 # "-Wl,-z,defs", # must no use this option 90 "-Wl,--as-needed", 91 "-fuse-ld=lld", 92 "-Wl,--icf=all", 93 "-Wl,--color-diagnostics", 94 "-m64", 95 ] 96 defines += [ "KOALA_LINUX" ] 97 output_extension = "node" 98 } else if (current_os == "mingw") { 99 output_extension = "dll" 100 cflags_cc = [ 101 "-std=c++17", 102 "-Wall", 103 "-Werror", 104 "-Wno-unused-variable", 105 "-fPIC", 106 "-Wno-error=deprecated-copy", 107 "-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang", 108 "-ftrivial-auto-var-init=zero", 109 "-fcolor-diagnostics", 110 "-fmerge-all-constants", 111 "-Xclang", 112 "-mllvm", 113 "-Xclang", 114 "-instcombine-lower-dbg-declare=0", 115 "-no-canonical-prefixes", 116 "-static", 117 "-rtlib=compiler-rt", 118 "-stdlib=libc++", 119 "-lunwind", 120 "-lpthread", 121 "-Qunused-arguments", 122 "-fuse-ld=lld", 123 "-fno-stack-protector", 124 "-fno-strict-aliasing", 125 "-Wno-builtin-macro-redefined", 126 "-fms-extensions", 127 "-static", 128 "-rtlib=compiler-rt", 129 "-stdlib=libc++", 130 "-std=c++17", 131 "-lunwind", 132 "-lpthread", 133 "-Qunused-arguments", 134 "-target", 135 "x86_64-pc-windows-gnu", 136 "-D__CUSTOM_SECURITY_LIBRARY", 137 ] 138 139 ldflags = [ 140 "-Wl,--fatal-warnings", 141 "-fPIC", 142 "-Wl,--as-needed", 143 "-fuse-ld=lld", 144 "-Wl,--icf=all", 145 "-m64", 146 "-static", 147 "-rtlib=compiler-rt", 148 "-stdlib=libc++", 149 "-std=c++17", 150 "-lunwind", 151 "-lpthread", 152 "-Qunused-arguments", 153 "-target", 154 "x86_64-pc-windows-gnu", 155 ] 156 defines += [ "KOALA_WINDOWS" ] 157 sources += [ "../koalaui/interop/src/cpp/napi/win-dynamic-node.cc" ] 158 } 159} 160