1# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. 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/test.gni") 15import("//developtools/profiler/device/base/config.gni") 16import("//developtools/profiler/protos/protos.gni") 17 18module_output_path = "${OHOS_PROFILER_TEST_MODULE_OUTPUT_PATH}/proto_encoder" 19config("module_private_config") { 20 visibility = [ ":*" ] 21} 22 23protos_dir = "../example/" 24protos_root_dir = rebase_path(protos_dir, root_build_dir) 25proto_out_dir = "$root_gen_dir/cpp/" + rebase_path(protos_dir, "//") 26proto_rel_out_dir = rebase_path(proto_out_dir, root_build_dir) 27 28protos_defines = [ "$protos_dir" + "example.proto" ] 29example_codegen_all = [] 30foreach(proto, protos_defines) { 31 name = get_path_info(proto, "name") 32 example_codegen_all += [ 33 "$proto_out_dir/$name.pb.h", 34 "$proto_out_dir/$name.pb.cc", 35 "$proto_out_dir/$name.pbencoder.h", 36 "$proto_out_dir/$name.pbencoder.cc", 37 ] 38} 39 40action("proto_gen_source") { 41 script = "${OHOS_PROFILER_DIR}/build/protoc.sh" 42 sources = protos_defines 43 outputs = example_codegen_all 44 args = [ 45 "$libc_dir_proto", 46 "$root_output_dir_proto", 47 "$proto_rel_out_dir", 48 "--cpp_out", 49 "$proto_rel_out_dir", 50 "--proto_path", 51 "$protos_root_dir", 52 ] 53 args += rebase_path(sources, root_build_dir) 54 args += [ "$ohos_indep_compiler_enable" ] 55 deps = [ "${OHOS_PROFILER_DIR}/device/services/ipc:protoencoder_plugin(${host_toolchain})" ] 56 external_deps = [ "protobuf:protoc(${host_toolchain})" ] 57} 58 59ohos_source_set("proto_example_source") { 60 deps = [ ":proto_gen_source" ] 61 include_dirs = [ "$proto_out_dir" ] 62 sources = example_codegen_all 63 external_deps = [ 64 "protobuf:protobuf_lite_static", 65 "protobuf:protobuf_static", 66 ] 67 subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 68 part_name = "${OHOS_PROFILER_PART_NAME}" 69} 70 71ohos_unittest("proto_encoder_ut") { 72 module_out_path = module_output_path 73 sources = [ 74 "unittest/base_message_unittest.cpp", 75 "unittest/varint_encode_unittest.cpp", 76 ] 77 deps = [ 78 ":proto_example_source", 79 "../:proto_encoder_source", 80 ] 81 include_dirs = [ 82 "../include", 83 "../example", 84 "$proto_out_dir", 85 ] 86 external_deps = [ 87 "bounds_checking_function:libsec_shared", 88 "googletest:gtest", 89 "protobuf:protobuf_lite", 90 ] 91 configs = [ ":module_private_config" ] 92 subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 93 part_name = "${OHOS_PROFILER_PART_NAME}" 94} 95 96group("unittest") { 97 testonly = true 98 deps = [ ":proto_encoder_ut" ] 99} 100