# Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. # 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 = "$proto_gen_ipc_dir/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", ] common_type_proto = [ "./common_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", ] } lite_codegen = [] foreach(proto, common_type_proto) { name = get_path_info(proto, "name") lite_codegen += [ "$proto_out_dir/${name}_lite.pb.h", "$proto_out_dir/${name}_lite.pb.cc", ] } action("all_type_gen") { script = "${OHOS_PROFILER_DIR}/build/protoc.sh" sources = all_type_proto outputs = all_type_codegen outputs += lite_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_DIR}/device/services/ipc:protoencoder_plugin(${host_toolchain})" ] external_deps = [ "grpc:grpc_cpp_plugin(${host_toolchain})", "protobuf: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" ] external_deps = [ "protobuf:protobuf", "protobuf:protobuf_lite", ] include_dirs = [ "$proto_out_dir" ] public_configs = [ ":public_configs" ] sources = profiler_service_type_codegen subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" part_name = "${OHOS_PROFILER_PART_NAME}" } ohos_source_set("profiler_service_all_type_source") { deps = [ ":all_type_gen" ] external_deps = [ "protobuf:protobuf", "protobuf:protobuf_lite", ] include_dirs = [ "$proto_out_dir" ] public_configs = [ ":public_configs" ] sources = all_type_codegen subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" part_name = "${OHOS_PROFILER_PART_NAME}" } ######################################################## 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" ] external_deps = [ "grpc:grpc_cpp_plugin(//build/toolchain/linux:clang_${host_cpu})", "protobuf:protoc(//build/toolchain/linux:clang_${host_cpu})", ] } ohos_source_set("profiler_service_proto") { deps = [ ":all_type_gen", ":profiler_service_interface_gen", ] external_deps = [ "grpc:grpc", "grpc:grpcxx", "protobuf:protobuf", "protobuf:protobuf_lite", ] include_dirs = [ "$proto_out_dir" ] public_configs = [ ":public_configs" ] sources = profiler_service_interface_codegen subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" part_name = "${OHOS_PROFILER_PART_NAME}" } ######################################################## 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_DIR}/device/services/ipc:protoc_gen_ipc(${host_toolchain})", ] external_deps = [ "protobuf:protoc(${host_toolchain})" ] } ohos_source_set("plugin_service_proto") { deps = [ ":all_type_gen", ":plugin_service_interface_proto_gen", ] public_deps = [ "${OHOS_PROFILER_DIR}/device/services/ipc:ipc" ] external_deps = [ "protobuf:protobuf", "protobuf:protobuf_lite", ] include_dirs = [ "$proto_out_dir", "${OHOS_PROFILER_DIR}/device/services/ipc/include", ] public_configs = [ ":public_configs" ] sources = plugin_service_interface_codegen subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" part_name = "${OHOS_PROFILER_PART_NAME}" } ####################################################### ohos_source_set("proto_services_cpp") { public_deps = [ ":plugin_service_proto", ":profiler_service_all_type_source", ":profiler_service_proto", ] subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" part_name = "${OHOS_PROFILER_PART_NAME}" } ohos_source_set("common_types_lite_proto") { deps = [ ":all_type_gen" ] external_deps = [ "protobuf:protobuf", "protobuf:protobuf_lite", ] include_dirs = [ "$proto_out_dir" ] public_configs = [ ":public_configs" ] sources = lite_codegen subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" part_name = "${OHOS_PROFILER_PART_NAME}" }