# Copyright (c) 2021 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/ohos.gni") import("../protos.gni") ####################################################### proto_out_dir = "$root_gen_dir/cpp/" + rebase_path(".", "//") proto_rel_out_dir = rebase_path(proto_out_dir, root_build_dir) grpc_cpp_plugin = "$subsys_x64_out/grpc_cpp_plugin" ipc_cpp_plugin = "$subsys_x64_out/protoc_gen_ipc" config("public_configs") { include_dirs = [ "$proto_out_dir" ] } ####################################################### all_type_proto = [ "./common_types.proto", "./profiler_service_types.proto", "./plugin_service_types.proto", ] all_type_codegen = [] foreach(proto, all_type_proto) { name = get_path_info(proto, "name") all_type_codegen += [ "$proto_out_dir/$name.pb.h", "$proto_out_dir/$name.pb.cc", ] } action("all_type_gen") { script = "${OHOS_PROFILER_DIR}/build/protoc.sh" sources = all_type_proto outputs = all_type_codegen args = [ "$libc_dir_proto", "$root_output_dir_proto", "$proto_rel_out_dir", # standard proto file destination path "--cpp_out", "$proto_rel_out_dir", "--proto_path", rebase_path(".", root_build_dir), ] args += rebase_path(sources, root_build_dir) deps = [ "${OHOS_PROFILER_3RDPARTY_GRPC_DIR}:grpc_cpp_plugin(${host_toolchain})", "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protoc(${host_toolchain})", ] } ######################################################## profiler_service_type_proto = [ "./common_types.proto", "./profiler_service_types.proto", ] profiler_service_type_codegen = [] foreach(proto, profiler_service_type_proto) { name = get_path_info(proto, "name") profiler_service_type_codegen += [ "$proto_out_dir/$name.pb.h", "$proto_out_dir/$name.pb.cc", ] } ohos_source_set("profiler_service_type_source") { deps = [ ":all_type_gen" ] public_deps = [ "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf", "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf_lite", ] include_dirs = [ "$proto_out_dir" ] public_configs = [ ":public_configs" ] sources = profiler_service_type_codegen } ohos_source_set("profiler_service_all_type_source") { deps = [ ":all_type_gen" ] public_deps = [ "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf", "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf_lite", ] include_dirs = [ "$proto_out_dir" ] public_configs = [ ":public_configs" ] sources = all_type_codegen } ######################################################## profiler_service_interface_proto = [ "./profiler_service.proto" ] profiler_service_interface_codegen = [] foreach(proto, profiler_service_interface_proto) { name = get_path_info(proto, "name") profiler_service_interface_codegen += [ "$proto_out_dir/$name.pb.h", "$proto_out_dir/$name.pb.cc", "$proto_out_dir/$name.grpc.pb.h", "$proto_out_dir/$name.grpc.pb.cc", ] } action("profiler_service_interface_gen") { script = "${OHOS_PROFILER_DIR}/build/protoc.sh" sources = profiler_service_interface_proto outputs = profiler_service_interface_codegen args = [ "$libc_dir_proto", "$root_output_dir_proto", "$proto_rel_out_dir", # standard proto file destination path "--plugin=protoc-gen-grpc=$grpc_cpp_plugin", "--grpc_out", "$proto_rel_out_dir", "--cpp_out", "$proto_rel_out_dir", "--proto_path", rebase_path(".", root_build_dir), ] args += rebase_path(sources, root_build_dir) deps = [ ":all_type_gen", "${OHOS_PROFILER_3RDPARTY_GRPC_DIR}:grpc_cpp_plugin(//build/toolchain/linux:clang_x64)", "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protoc(//build/toolchain/linux:clang_x64)", ] } ohos_source_set("profiler_service_proto") { deps = [ ":all_type_gen", ":profiler_service_interface_gen", ] public_deps = [ "${OHOS_PROFILER_3RDPARTY_GRPC_DIR}:grpc", "${OHOS_PROFILER_3RDPARTY_GRPC_DIR}:grpcxx", "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf", "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf_lite", ] include_dirs = [ "$proto_out_dir" ] public_configs = [ ":public_configs" ] sources = profiler_service_interface_codegen } ######################################################## plugin_service_type_proto = [ "./common_types.proto", "./plugin_service_types.proto", ] plugin_service_type_codegen = [] foreach(proto, plugin_service_type_proto) { name = get_path_info(proto, "name") plugin_service_type_codegen += [ "$proto_out_dir/$name.pb.h", "$proto_out_dir/$name.pb.cc", ] } ######################################################## plugin_service_interface_proto = [ "./plugin_service.proto" ] plugin_service_interface_codegen = [] foreach(proto, plugin_service_interface_proto) { name = get_path_info(proto, "name") plugin_service_interface_codegen += [ "$proto_out_dir/$name.pb.h", "$proto_out_dir/$name.pb.cc", "$proto_out_dir/$name.ipc.h", "$proto_out_dir/$name.ipc.cc", ] } action("plugin_service_interface_proto_gen") { script = "${OHOS_PROFILER_DIR}/build/protoc.sh" sources = plugin_service_interface_proto outputs = plugin_service_interface_codegen args = [ "$libc_dir_proto", "$root_output_dir_proto", "$proto_rel_out_dir", # standard proto file destination path "--plugin=protoc-gen-ipc=$ipc_cpp_plugin", "--ipc_out", "$proto_rel_out_dir", "--cpp_out", "$proto_rel_out_dir", "--proto_path", rebase_path(".", root_build_dir), ] args += rebase_path(sources, root_build_dir) deps = [ ":all_type_gen", "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protoc(${host_toolchain})", "${OHOS_PROFILER_DIR}/device/services/ipc:protoc_gen_ipc(${host_toolchain})", ] } ohos_source_set("plugin_service_proto") { deps = [ ":all_type_gen", ":plugin_service_interface_proto_gen", ] public_deps = [ "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf", "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf_lite", "${OHOS_PROFILER_DIR}/device/services/ipc:ipc", ] include_dirs = [ "$proto_out_dir", "${OHOS_PROFILER_DIR}/device/services/ipc/include", ] public_configs = [ ":public_configs" ] sources = plugin_service_interface_codegen } ####################################################### ohos_source_set("proto_services_cpp") { public_deps = [ ":plugin_service_proto", ":profiler_service_all_type_source", ":profiler_service_proto", ] }