Skip to content

Commit c965b8d

Browse files
amarpadAmar Padmanabhan
and
Amar Padmanabhan
authored
Create a super build for LiAgent (magma#7517)
* Create a superbuild for Li-agent Move files into a sub directory Signed-off-by: Amar Padmanabhan <[email protected]> * Cleanup submakefile for super build - Include package dependencies from common - Add dependency on MAGMA_LOGGING package - Add dependency on mobilityd grpc, which in turns brings in subscriberdb which brings in apn - Remove all include directory directives. Signed-off-by: Amar Padmanabhan <[email protected]> * Update makefile and deploy script Update makefile and deploy script Signed-off-by: Amar Padmanabhan <[email protected]> * Move test directory Move test directory to new location under superbuild Signed-off-by: Amar Padmanabhan <[email protected]> * Update li_agent tests for new superbuild Replace include_directory with target_include_directory Update Makefile target Testing done: 1/1 Test #1: test_pdu_generator ............... Passed 0.02 sec 100% tests passed, 0 tests failed out of 1 Signed-off-by: Amar Padmanabhan <[email protected]> Co-authored-by: Amar Padmanabhan <[email protected]>
1 parent 15d3c50 commit c965b8d

20 files changed

+133
-100
lines changed

lte/gateway/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ build_sctpd: format_sctpd
184184
build_session_manager: format_session_manager build_common ## Build session manager
185185
$(call run_cmake, $(C_BUILD)/session_manager, $(GATEWAY_C_DIR)/session_manager, )
186186

187-
build_li_agent: format_li_agent build_common ## Build li agent
187+
build_li_agent: format_li_agent ## Build li agent
188188
$(call run_cmake, $(C_BUILD)/li_agent, $(GATEWAY_C_DIR)/li_agent, )
189189

190190
build_connection_tracker: format_connection_tracker
@@ -213,6 +213,10 @@ test_sctpd: ## Run all OAI-specific tests
213213
test_common: build_common ## Run all tests in magma_common
214214
$(call run_ctest, $(C_BUILD)/magma_common, $(C_BUILD)/magma_common, $(MAGMA_ROOT)/orc8r/gateway/c/common, )
215215

216+
test_li_agent:
217+
$(call run_ctest, $(C_BUILD)/li_agent, $(C_BUILD)/li_agent/src, $(GATEWAY_C_DIR)/li_agent, )
218+
219+
216220
# Catch all for c service tests
217221
# This works with test_dpi and test_session_manager
218222
test_%: build_common

lte/gateway/c/li_agent/CMakeLists.txt

Lines changed: 33 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -9,96 +9,36 @@
99
# See the License for the specific language governing permissions and
1010
# limitations under the License.
1111

12-
cmake_minimum_required(VERSION 3.0.2)
13-
14-
PROJECT(LIAgent)
15-
16-
include($ENV{MAGMA_ROOT}/orc8r/gateway/c/common/CMakeProtoMacros.txt)
17-
18-
if (BUILD_TESTS)
19-
message("Adding code coverage build and linker flags for BUILD_TESTS")
20-
set (CMAKE_CXX_FLAGS_DEBUG
21-
"${CMAKE_CXX_FLAGS_DEBUG} -g -O0 -fprofile-arcs -ftest-coverage")
22-
set(CMAKE_LINKER_FLAGS_DEBUG
23-
"${CMAKE_LINKER_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")
24-
endif ()
25-
26-
# Add AddressSanitizer (asan) support for debug builds of LiAgentD
27-
set (CMAKE_CXX_FLAGS_DEBUG
28-
"${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
29-
set (CMAKE_LINKER_FLAGS_DEBUG
30-
"${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
31-
# Add LeakSanitizer (lsan) support to the release build of LIAgentD so that
32-
# we can find memory leaks in production.
33-
set(CMAKE_C_FLAGS_RELWITHDEBINFO
34-
"${CMAKE_C_FLAGS_RELWITHDEBINFO} -fsanitize=leak -fno-omit-frame-pointer")
35-
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO
36-
"${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} -fsanitize=leak")
37-
38-
set(OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}")
39-
40-
set(MAGMA_LIB_DIR $ENV{C_BUILD}/magma_common)
41-
add_definitions(-DLOG_WITH_GLOG)
42-
43-
include_directories("${OUTPUT_DIR}")
44-
include_directories("${MAGMA_ROOT}/orc8r/gateway/c/common/logging")
45-
46-
include_directories(${MAGMA_LIB_DIR}/service303)
47-
include_directories(${MAGMA_LIB_DIR}/service_registry)
48-
include_directories(${MAGMA_LIB_DIR}/async_grpc)
49-
include_directories(${MAGMA_LIB_DIR}/config)
50-
51-
include($ENV{MAGMA_ROOT}/orc8r/gateway/c/common/CMakeProtoMacros.txt)
52-
# TODO: Temp workaround until packages are imported by these cmakefile
53-
# Will be removed in subsequent patch
54-
set(MAGMA_COMMON_INCL_DIR $ENV{C_BUILD}/common)
55-
include_directories(${MAGMA_COMMON_INCL_DIR})
56-
57-
find_library(SERVICE303_LIB SERVICE303_LIB HINTS ${MAGMA_LIB_DIR}/service303)
58-
59-
# compile the needed macros
60-
create_proto_dir("lte" LTE_CPP_OUT_DIR)
61-
62-
list(APPEND PROTO_SRCS "")
63-
list(APPEND PROTO_HDRS "")
64-
65-
message("Proto_srcs are ${PROTO_SRCS}")
66-
67-
set(SMGR_LTE_CPP_PROTOS mconfig/mconfigs)
68-
generate_cpp_protos("${SMGR_LTE_CPP_PROTOS}" "${PROTO_SRCS}"
69-
"${PROTO_HDRS}" ${LTE_PROTO_DIR} ${LTE_CPP_OUT_DIR})
70-
71-
link_directories(
72-
${MAGMA_LIB_DIR}/async_grpc
73-
${MAGMA_LIB_DIR}/config
74-
${MAGMA_LIB_DIR}/service303
75-
${MAGMA_LIB_DIR}/service_registry)
76-
77-
add_library(LI_AGENT
78-
Utilities.h
79-
Utilities.cpp
80-
MobilitydClient.cpp
81-
MobilitydClient.h
82-
PDUGenerator.cpp
83-
PDUGenerator.h
84-
InterfaceMonitor.cpp
85-
InterfaceMonitor.h
86-
ProxyConnector.cpp
87-
ProxyConnector.h
88-
${PROTO_SRCS}
89-
${PROTO_HDRS})
90-
91-
target_link_libraries(LI_AGENT
92-
SERVICE303_LIB SERVICE_REGISTRY MAGMA_CONFIG ASYNC_GRPC
93-
glog gflags folly pthread ${GCOV_LIB} grpc++ grpc yaml-cpp protobuf cpp_redis
94-
prometheus-cpp tacopie mnl tins pcap ssl crypto uuid
95-
)
96-
97-
add_executable(liagentd ${PROJECT_SOURCE_DIR}/main.cpp)
98-
99-
target_link_libraries (liagentd LI_AGENT)
100-
101-
if (BUILD_TESTS)
102-
ENABLE_TESTING()
103-
ADD_SUBDIRECTORY(test)
104-
endif (BUILD_TESTS)
12+
cmake_minimum_required(VERSION 3.7.2)
13+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
14+
set(CMAKE_VERBOSE_MAKEFILE ON)
15+
16+
get_cmake_property(vars CACHE_VARIABLES)
17+
foreach (var ${vars})
18+
get_property(currentHelpString CACHE "${var}" PROPERTY HELPSTRING)
19+
# message("${var} = [${${var}}] -- ${currentHelpString}")
20+
if ("${currentHelpString}" MATCHES
21+
"No help, variable specified on the command line." OR
22+
"${currentHelpString}" STREQUAL "")
23+
list(APPEND CL_ARGS "-D${var}=${${var}}")
24+
endif ()
25+
endforeach ()
26+
27+
28+
project(MagmaLiAgent)
29+
30+
include(ExternalProject)
31+
32+
ExternalProject_Add(MagmaCommon
33+
SOURCE_DIR "$ENV{MAGMA_ROOT}/orc8r/gateway/c/common"
34+
BUILD_ALWAYS 1
35+
BINARY_DIR "${CMAKE_BINARY_DIR}/common"
36+
INSTALL_COMMAND "")
37+
38+
ExternalProject_Add(LiAgent
39+
SOURCE_DIR "${CMAKE_SOURCE_DIR}/src"
40+
BUILD_ALWAYS 1
41+
BINARY_DIR "${CMAKE_BINARY_DIR}/src"
42+
INSTALL_COMMAND ""
43+
DEPENDS MagmaCommon
44+
CMAKE_ARGS ${CL_ARGS})
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Copyright 2020 The Magma Authors.
2+
3+
# This source code is licensed under the BSD-style license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
# Unless required by applicable law or agreed to in writing, software
7+
# distributed under the License is distributed on an "AS IS" BASIS,
8+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
# See the License for the specific language governing permissions and
10+
# limitations under the License.
11+
12+
cmake_minimum_required(VERSION 3.7.2)
13+
14+
PROJECT(LIAgent)
15+
16+
find_package(SERVICE303_LIB REQUIRED)
17+
find_package(SERVICE_REGISTRY REQUIRED)
18+
find_package(MAGMA_CONFIG REQUIRED)
19+
find_package(ASYNC_GRPC REQUIRED)
20+
find_package(MAGMA_LOGGING REQUIRED)
21+
22+
include($ENV{MAGMA_ROOT}/orc8r/gateway/c/common/CMakeProtoMacros.txt)
23+
24+
if (BUILD_TESTS)
25+
message("Adding code coverage build and linker flags for BUILD_TESTS")
26+
set(CMAKE_CXX_FLAGS_DEBUG
27+
"${CMAKE_CXX_FLAGS_DEBUG} -g -O0 -fprofile-arcs -ftest-coverage")
28+
set(CMAKE_LINKER_FLAGS_DEBUG
29+
"${CMAKE_LINKER_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")
30+
endif ()
31+
32+
# Add AddressSanitizer (asan) support for debug builds of LiAgentD
33+
set(CMAKE_CXX_FLAGS_DEBUG
34+
"${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
35+
set(CMAKE_LINKER_FLAGS_DEBUG
36+
"${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
37+
# Add LeakSanitizer (lsan) support to the release build of LIAgentD so that
38+
# we can find memory leaks in production.
39+
set(CMAKE_C_FLAGS_RELWITHDEBINFO
40+
"${CMAKE_C_FLAGS_RELWITHDEBINFO} -fsanitize=leak -fno-omit-frame-pointer")
41+
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO
42+
"${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} -fsanitize=leak")
43+
44+
add_definitions(-DLOG_WITH_GLOG)
45+
46+
# compile the needed macros
47+
create_proto_dir("lte" LTE_CPP_OUT_DIR)
48+
list(APPEND PROTO_SRCS "")
49+
list(APPEND PROTO_HDRS "")
50+
message("Proto_srcs are ${PROTO_SRCS}")
51+
set(LI_AGENT_LTE_CPP_PROTOS mconfig/mconfigs mobilityd
52+
mobilityd subscriberdb apn)
53+
set(RPC_LTE_GRPC_PROTOS mobilityd)
54+
generate_cpp_protos("${LI_AGENT_LTE_CPP_PROTOS}" "${PROTO_SRCS}"
55+
"${PROTO_HDRS}" ${LTE_PROTO_DIR} ${LTE_CPP_OUT_DIR})
56+
generate_grpc_protos("${RPC_LTE_GRPC_PROTOS}" "${PROTO_SRCS}" "${PROTO_HDRS}"
57+
${LTE_PROTO_DIR} ${LTE_CPP_OUT_DIR})
58+
59+
add_library(LI_AGENT
60+
Utilities.h
61+
Utilities.cpp
62+
MobilitydClient.cpp
63+
MobilitydClient.h
64+
PDUGenerator.cpp
65+
PDUGenerator.h
66+
InterfaceMonitor.cpp
67+
InterfaceMonitor.h
68+
ProxyConnector.cpp
69+
ProxyConnector.h
70+
${PROTO_SRCS}
71+
${PROTO_HDRS})
72+
73+
target_link_libraries(LI_AGENT
74+
SERVICE303_LIB SERVICE_REGISTRY MAGMA_CONFIG ASYNC_GRPC MAGMA_LOGGING
75+
glog gflags folly pthread ${GCOV_LIB} grpc++ grpc yaml-cpp protobuf cpp_redis
76+
prometheus-cpp tacopie mnl tins pcap ssl crypto uuid
77+
)
78+
79+
target_include_directories(LI_AGENT PUBLIC
80+
$<TARGET_FILE_DIR:LI_AGENT>)
81+
82+
add_executable(liagentd main.cpp)
83+
84+
target_link_libraries(liagentd LI_AGENT)
85+
86+
if (BUILD_TESTS)
87+
ENABLE_TESTING()
88+
ADD_SUBDIRECTORY(test)
89+
endif (BUILD_TESTS)
File renamed without changes.

lte/gateway/c/li_agent/test/CMakeLists.txt renamed to lte/gateway/c/li_agent/src/test/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ set(CMAKE_CXX_STANDARD 14)
1313
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1414
set(CMAKE_CXX_EXTENSIONS OFF)
1515

16-
set(OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}")
17-
18-
include_directories("${PROJECT_SOURCE_DIR}")
1916
include_directories("/usr/src/googletest/googlemock/include/")
2017

2118
add_library(LIAGENTD_TEST_LIB
@@ -24,7 +21,10 @@ add_library(LIAGENTD_TEST_LIB
2421
)
2522

2623
link_directories(/usr/src/googletest/googlemock/lib/)
27-
target_link_libraries(LIAGENTD_TEST_LIB LI_AGENT gmock_main gtest gtest_main gmock rt)
24+
target_link_libraries(LIAGENTD_TEST_LIB LI_AGENT gmock_main gtest gtest_main
25+
gmock rt)
26+
target_include_directories(LIAGENTD_TEST_LIB PUBLIC
27+
${PROJECT_SOURCE_DIR})
2828

2929
foreach (li_agent_test pdu_generator)
3030
add_executable(${li_agent_test}_test test_${li_agent_test}.cpp)

lte/gateway/deploy/roles/magma/tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
when: full_provision
143143

144144
- name: Create symlink for li agent binary
145-
file: src='{{ c_build }}/li_agent/liagentd' path=/usr/local/bin/liagentd state=link force=yes follow=no
145+
file: src='{{ c_build }}/li_agent/src/liagentd' path=/usr/local/bin/liagentd state=link force=yes follow=no
146146
when: full_provision
147147

148148
- name: Create symlink for corefile collection script

lte/gateway/release/build-magma.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ fi
266266
cd "${MAGMA_ROOT}/lte/gateway"
267267
OAI_BUILD="${C_BUILD}/core/oai"
268268
SESSIOND_BUILD="${C_BUILD}/session_manager"
269-
CONNECTIOND_BUILD="${C_BUILD}/connection_tracker"
269+
CONNECTIOND_BUILD="${C_BUILD}/connection_tracker/src"
270270
SCTPD_BUILD="${C_BUILD}/sctpd/src"
271271

272272
make build_oai BUILD_TYPE="${BUILD_TYPE}"

0 commit comments

Comments
 (0)