xref: /aosp_15_r20/tools/netsim/proto/CMakeLists.txt (revision cf78ab8cffb8fc9207af348f23af247fb04370a6)
1# Copyright 2022 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15cmake_minimum_required(VERSION 3.5)
16
17set(ROOTCANAL_PROTO_DIR
18    ${AOSP_ROOT}/packages/modules/Bluetooth/tools/rootcanal/proto)
19
20# For netsimd (netsimd-proto-lib)
21protobuf_generate_grpc_cpp(
22  SOURCE_DIR ${ROOTCANAL_PROTO_DIR} SOURCES rootcanal/configuration.proto
23  OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR} GENERATED ROOTCANAL_PROTO_SRC)
24
25# For netsimd (netsimd-proto-lib)
26protobuf_generate_grpc_cpp(
27  SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}
28  SOURCES netsim/common.proto netsim/config.proto netsim/hci_packet.proto
29          netsim/model.proto netsim/startup.proto netsim/stats.proto
30  INCLUDES ${ROOTCANAL_PROTO_DIR}
31  OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}
32  GENERATED NETSIM_PROTO_SRC)
33
34android_add_library(
35  TARGET netsimd-proto-lib LICENSE Apache-2.0 SRC ${NETSIM_PROTO_SRC}
36                                                  ${ROOTCANAL_PROTO_SRC}
37  DEPS grpc++ protobuf::libprotobuf)
38
39target_include_directories(netsimd-proto-lib PRIVATE ${PROTOBUF_INCLUDE_DIR} ..
40                           PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
41
42# For netsim-cli (netsim-cli-proto-lib)
43protobuf_generate_grpc_cpp(
44  SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR} SOURCES netsim/frontend.proto
45  INCLUDES ${ROOTCANAL_PROTO_DIR} OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}
46  GENERATED NETSIM_FRONTEND_GRPC_SRC)
47
48android_add_library(
49  TARGET netsim-cli-proto-lib LICENSE Apache-2.0 SRC ${NETSIM_FRONTEND_GRPC_SRC}
50  DEPS grpc++ netsimd-proto-lib protobuf::libprotobuf)
51
52target_include_directories(
53  netsim-cli-proto-lib PRIVATE ${PROTOBUF_INCLUDE_DIR} ..
54  PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
55
56# For network packet streamer client (packet-streamer-proto-lib)
57protobuf_generate_grpc_cpp(
58  SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR} SOURCES netsim/packet_streamer.proto
59  OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR} INCLUDES ${ROOTCANAL_PROTO_DIR}
60  GENERATED NETSIM_PACKET_STREAMER_GRPC_SRC)
61
62android_add_library(
63  TARGET packet-streamer-proto-lib LICENSE Apache-2.0
64  SRC ${NETSIM_PACKET_STREAMER_GRPC_SRC} DEPS grpc++ netsimd-proto-lib
65                                              protobuf::libprotobuf)
66
67target_include_directories(
68  packet-streamer-proto-lib PRIVATE ${PROTOBUF_INCLUDE_DIR} ..
69  PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
70
71android_license(TARGET "packet-streamer-proto-lib" LIBNAME None SPDX None
72                LICENSE None LOCAL None)
73android_license(TARGET "netsim-cli-proto-lib" LIBNAME None SPDX None
74                LICENSE None LOCAL None)
75