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("//arkcompiler/ets_frontend/ets_frontend_config.gni") 15import("//arkcompiler/runtime_core/ark_config.gni") 16import("//developtools/profiler/build/config.gni") 17 18proto_base_dir = "protos" 19proto_out_dir = "$target_gen_dir" + "/protos_generated" 20 21protobuf_snapshot_generator_sources = [ 22 "src/annotationProto.cpp", 23 "src/assemblyDebugProto.cpp", 24 "src/assemblyFieldProto.cpp", 25 "src/assemblyFileLocationProto.cpp", 26 "src/assemblyFunctionProto.cpp", 27 "src/assemblyInsProto.cpp", 28 "src/assemblyLabelProto.cpp", 29 "src/assemblyLiteralsProto.cpp", 30 "src/assemblyProgramProto.cpp", 31 "src/assemblyRecordProto.cpp", 32 "src/assemblyTypeProto.cpp", 33 "src/ideHelpersProto.cpp", 34 "src/mergeProgram.cpp", 35 "src/metaProto.cpp", 36 "src/protobufSnapshotGenerator.cpp", 37] 38 39config("panda_assembly_proto_public_config") { 40 include_dirs = [ 41 "$ark_root/assembler", 42 "$ark_root/libpandabase", 43 "$ark_root/libpandabase/mem", 44 "$ark_root", 45 "src", 46 "$proto_out_dir", 47 "//third_party/protobuf/src", 48 "//third_party/protobuf/src/google", 49 "//third_party/protobuf/src/google/protobuf", 50 "../es2panda", 51 "../es2panda/util", 52 ] 53} 54 55assembly_proto_configs = [ 56 sdk_libc_secshared_config, 57 "$ark_root:ark_config", 58 ":panda_assembly_proto_public_config", 59 "$ark_root/assembler:arkassembler_public_config", 60 "$ark_root/libpandabase:arkbase_public_config", 61 "$ark_root/libpandafile:arkfile_public_config", 62] 63 64proto_file_defines = [ 65 # add your proto file here 66 "annotation", 67 "assemblyDebug", 68 "assemblyField", 69 "assemblyFileLocation", 70 "assemblyFunction", 71 "assemblyIns", 72 "assemblyLabel", 73 "assemblyLiterals", 74 "assemblyProgram", 75 "assemblyRecord", 76 "assemblyType", 77 "compositeProgram", 78 "ideHelpers", 79 "meta", 80] 81 82proto_file_sources = [] 83proto_generated_header = [] 84proto_generated_source = [] 85 86foreach(proto_file, proto_file_defines) { 87 proto_generated_header += [ "$proto_out_dir" + "/" + "$proto_file.pb.h" ] 88 proto_generated_source += [ "$proto_out_dir" + "/" + "$proto_file.pb.cc" ] 89 proto_file_sources += [ "$proto_base_dir" + "/" + "$proto_file.proto" ] 90} 91 92protoc_binary_out_path = 93 "${OHOS_PROFILER_SUBSYS_NAME}/${OHOS_PROFILER_PART_NAME}" 94 95if (default_toolchain == current_toolchain) { 96 #if target build 97 host_out_path = "/" + get_label_info(host_toolchain, "name") 98} else { 99 #if host build (for some linke mingw) 100 host_out_path = "/../" + get_label_info(host_toolchain, "name") 101} 102 103host_protoc_path = 104 root_out_dir + host_out_path + "/" + protoc_binary_out_path + "/protoc" 105 106action("arkcompiler_generate_proto") { 107 deps = [ "$ark_third_party_root/protobuf:protoc($host_toolchain)" ] 108 args = [] 109 sources = [] 110 outputs = proto_generated_header + proto_generated_source 111 script = "./script/build_proto.sh" 112 113 args += [ rebase_path(host_protoc_path) ] 114 args += [ 115 "--proto_path", 116 rebase_path(proto_base_dir), 117 "--cpp_out", 118 rebase_path(proto_out_dir), 119 "--experimental_allow_proto3_optional", 120 ] 121 122 foreach(proto_file_source, proto_file_sources) { 123 #tell gn to check which files as source time 124 sources += [ rebase_path(proto_file_source) ] 125 args += [ rebase_path(proto_file_source) ] 126 } 127} 128 129config("proto_file_cpp_config") { 130 include_dirs = [ proto_out_dir ] 131} 132 133ohos_source_set("assembly_proto_static") { 134 cflags = [ "-Wno-error=zero-length-array" ] 135 136 deps = [ 137 ":arkcompiler_generate_proto", 138 "$ark_root/assembler:libarkassembler_frontend_static", 139 "$ark_root/libpandabase:libarkbase_frontend_static", 140 "$ark_root/libpandafile:libarkfile_frontend_static", 141 "$ark_third_party_root/protobuf:protobuf_lite_static", 142 "$ark_third_party_root/protobuf:protobuf_static", 143 ] 144 145 sources = proto_generated_header + proto_generated_source + 146 protobuf_snapshot_generator_sources 147 public_configs = assembly_proto_configs 148 public_configs += [ ":proto_file_cpp_config" ] 149} 150 151ohos_static_library("panda_assembly_proto_static") { 152 deps = [ ":assembly_proto_static" ] 153} 154 155ohos_executable("merge_abc") { 156 use_exceptions = true 157 sources = [ 158 "src/main.cpp", 159 "src/options.cpp", 160 ] 161 162 include_dirs = [ "./src" ] 163 164 configs = [ 165 sdk_libc_secshared_config, 166 "$ark_root:ark_config", 167 ":panda_assembly_proto_public_config", 168 "$ark_root/assembler:arkassembler_public_config", 169 "$ark_root/libpandabase:arkbase_public_config", 170 "$ark_root/libpandafile:arkfile_public_config", 171 ":proto_file_cpp_config", 172 ] 173 174 deps = [ 175 ":panda_assembly_proto_static", 176 "$ark_root/libziparchive:libarkziparchive_frontend_static", 177 "$ark_third_party_root/icu/icu4c:static_icuuc", 178 ] 179 180 ldflags = [] 181 if (is_linux) { 182 if (build_public_version) { 183 ldflags += [ "-static-libstdc++" ] 184 } else { 185 libs = [ libcpp_static_lib ] 186 } 187 188 defines = [ "PANDA_TARGET_LINUX" ] 189 } else if (is_mac) { 190 defines = [ "PANDA_TARGET_MACOS" ] 191 } else if (is_mingw) { 192 defines = [ "PANDA_TARGET_WINDOWS" ] 193 } 194 195 if (!use_musl) { 196 ldflags += [ "-lc++" ] 197 } 198 199 output_name = "merge_abc" 200 install_enable = false 201 part_name = "ets_frontend" 202 subsystem_name = "arkcompiler" 203} 204 205if (is_linux) { 206 ohos_copy("merge_abc_build") { 207 deps = [ ":merge_abc" ] 208 sources = [ "${root_out_dir}/arkcompiler/ets_frontend/merge_abc" ] 209 outputs = [ "${target_out_dir}/merge_abc-tmp" ] 210 module_source_dir = "${root_out_dir}/arkcompiler/ets_frontend" 211 module_install_name = "merge_abc" 212 } 213 214 ohos_copy("merge_abc_build_ets") { 215 deps = [ ":merge_abc" ] 216 sources = [ "${root_out_dir}/arkcompiler/ets_frontend/merge_abc" ] 217 outputs = [ "${root_out_dir}/arkcompiler/ets_frontend/merge_abc-ets" ] 218 module_source_dir = "${root_out_dir}/arkcompiler/ets_frontend" 219 module_install_name = "merge_abc" 220 } 221} 222 223if (is_mingw) { 224 ohos_copy("merge_abc_build_win") { 225 deps = [ ":merge_abc" ] 226 sources = [ "${root_out_dir}/arkcompiler/ets_frontend/merge_abc.exe" ] 227 outputs = [ "${target_out_dir}/merge_abc-tmp" ] 228 module_source_dir = "${root_out_dir}/arkcompiler/ets_frontend" 229 module_install_name = "merge_abc.exe" 230 } 231 232 ohos_copy("merge_abc_build_win_ets") { 233 deps = [ ":merge_abc" ] 234 sources = [ "${root_out_dir}/arkcompiler/ets_frontend/merge_abc.exe" ] 235 outputs = [ "${root_out_dir}/arkcompiler/ets_frontend/merge_abc-win-ets" ] 236 module_source_dir = "${root_out_dir}/arkcompiler/ets_frontend" 237 module_install_name = "merge_abc.exe" 238 } 239} 240 241if (is_mac) { 242 ohos_copy("merge_abc_build_mac") { 243 deps = [ ":merge_abc" ] 244 sources = [ "${root_out_dir}/arkcompiler/ets_frontend/merge_abc" ] 245 outputs = [ "${target_out_dir}/merge_abc-tmp" ] 246 module_source_dir = "${root_out_dir}/arkcompiler/ets_frontend" 247 module_install_name = "merge_abc" 248 } 249 250 ohos_copy("merge_abc_build_mac_ets") { 251 deps = [ ":merge_abc" ] 252 sources = [ "${root_out_dir}/arkcompiler/ets_frontend/merge_abc" ] 253 outputs = [ "${root_out_dir}/arkcompiler/ets_frontend/merge_abc-mac-ets" ] 254 module_source_dir = "${root_out_dir}/arkcompiler/ets_frontend" 255 module_install_name = "merge_abc" 256 } 257} 258 259group("merge_proto_abc_build") { 260 if (host_os == "linux") { 261 deps = [ ":merge_abc(${toolchain_linux})" ] 262 } 263 264 if (host_os == "mac") { 265 deps = [ ":merge_abc(${toolchain_mac})" ] 266 } 267} 268 269group("merge_proto_abc_build_win") { 270 deps = [ ":merge_abc(${toolchain_win})" ] 271} 272