From 7ec9db6d9ebc308e7f717ed43746ce0d5c3d3d5d Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Fri, 25 Aug 2023 17:17:48 -0500 Subject: [PATCH 1/8] cmake: add more executables --- CMakeLists.txt | 14 +++++++++ include/tscore/ink_config.h.cmake.in | 4 +++ src/traffic_cache_tool/CMakeLists.txt | 24 ++++++++++++++ src/traffic_logcat/CMakeLists.txt | 20 ++++++++++++ src/traffic_logstats/CMakeLists.txt | 31 +++++++++++++++++++ src/traffic_logstats/tests/test_logstats_json | 4 +++ .../tests/test_logstats_summary | 6 +++- src/traffic_top/CMakeLists.txt | 21 +++++++++++++ src/traffic_via/CMakeLists.txt | 27 ++++++++++++++++ src/traffic_via/test_traffic_via | 6 +++- src/traffic_wccp/CMakeLists.txt | 1 + 11 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 src/traffic_cache_tool/CMakeLists.txt create mode 100644 src/traffic_logcat/CMakeLists.txt create mode 100644 src/traffic_logstats/CMakeLists.txt create mode 100644 src/traffic_top/CMakeLists.txt create mode 100644 src/traffic_via/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index a7ca2551794..53abdefc091 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -228,6 +228,13 @@ endif() find_package(ZLIB REQUIRED) +# ncurses is used in traffic_top +find_package(Curses) +set(HAVE_CURSES_H ${CURSES_HAVE_CURSES_H}) +set(HAVE_NCURSES_H ${CURSES_HAVE_NCURSES_H}) +set(HAVE_NCURSES_CURSES_H ${CURSES_HAVE_NCURSES_CURSES_H}) +set(HAVE_NCURSES_NCURSES_H ${CURSES_HAVE_NCURSES_NCURSES_H}) + include(Check128BitCas) include(ConfigureTransparentProxy) @@ -388,6 +395,13 @@ add_subdirectory(src/traffic_crashlog) add_subdirectory(src/traffic_server) add_subdirectory(src/traffic_ctl) add_subdirectory(src/traffic_layout) +add_subdirectory(src/traffic_cache_tool) +add_subdirectory(src/traffic_logcat) +add_subdirectory(src/traffic_logstats) +if(CURSES_FOUND) +add_subdirectory(src/traffic_top) +endif() +add_subdirectory(src/traffic_via) if(ENABLE_WCCP) add_subdirectory(src/wccp) add_subdirectory(src/traffic_wccp) diff --git a/include/tscore/ink_config.h.cmake.in b/include/tscore/ink_config.h.cmake.in index 25b74ef8095..1bf6d071098 100644 --- a/include/tscore/ink_config.h.cmake.in +++ b/include/tscore/ink_config.h.cmake.in @@ -34,6 +34,10 @@ #cmakedefine HAVE_BROTLI_ENCODE_H 1 #cmakedefine HAVE_CLOCK_GETTIME 1 +#cmakedefine HAVE_CURSES_H 1 +#cmakedefine HAVE_NCURSES_H 1 +#cmakedefine HAVE_NCURSES_CURSES_H 1 +#cmakedefine HAVE_NCURSES_NCURSES_H 1 #cmakedefine HAVE_DLFCN_H 1 #cmakedefine HAVE_FLOAT_H 1 #cmakedefine HAVE_LZMA_H 1 diff --git a/src/traffic_cache_tool/CMakeLists.txt b/src/traffic_cache_tool/CMakeLists.txt new file mode 100644 index 00000000000..e8864cdbe64 --- /dev/null +++ b/src/traffic_cache_tool/CMakeLists.txt @@ -0,0 +1,24 @@ +####################### +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor license +# agreements. See the NOTICE file distributed with this work for additional information regarding +# copyright ownership. The ASF licenses this file to you 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. +# +####################### + +add_executable(traffic_cache_tool + CacheDefs.cc + CacheTool.cc + CacheScan.cc) + +target_link_libraries(traffic_cache_tool PRIVATE ts::tscore libswoc) +install(TARGETS traffic_cache_tool) diff --git a/src/traffic_logcat/CMakeLists.txt b/src/traffic_logcat/CMakeLists.txt new file mode 100644 index 00000000000..7a0c3978fc5 --- /dev/null +++ b/src/traffic_logcat/CMakeLists.txt @@ -0,0 +1,20 @@ +####################### +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor license +# agreements. See the NOTICE file distributed with this work for additional information regarding +# copyright ownership. The ASF licenses this file to you 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. +# +####################### + +add_executable(traffic_logcat logcat.cc) +target_link_libraries(traffic_logcat PRIVATE ts::tscore ts::proxy ts::logging ts::hdrs ts::tsapi ts::diagsconfig libswoc) +install(TARGETS traffic_logcat) diff --git a/src/traffic_logstats/CMakeLists.txt b/src/traffic_logstats/CMakeLists.txt new file mode 100644 index 00000000000..f3f507610cd --- /dev/null +++ b/src/traffic_logstats/CMakeLists.txt @@ -0,0 +1,31 @@ +####################### +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor license +# agreements. See the NOTICE file distributed with this work for additional information regarding +# copyright ownership. The ASF licenses this file to you 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. +# +####################### + +add_executable(traffic_logstats logstats.cc) +target_link_libraries(traffic_logstats PRIVATE ts::logging ts::hdrs ts::tscore ts::tsapi ts::records ts::diagsconfig) + +add_test( + NAME test_logstats_json + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_logstats_json ${CMAKE_SOURCE_DIR}/src + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/src +) + +add_test( + NAME test_logstats_summary + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_logstats_summary ${CMAKE_SOURCE_DIR}/src + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/src +) diff --git a/src/traffic_logstats/tests/test_logstats_json b/src/traffic_logstats/tests/test_logstats_json index 413ad429b61..c2c11f66b51 100755 --- a/src/traffic_logstats/tests/test_logstats_json +++ b/src/traffic_logstats/tests/test_logstats_json @@ -18,6 +18,10 @@ set -e # exit on error +if [ ! -z $1 ]; then + srcdir=$1 +fi + TMPDIR=${TMPDIR:-/tmp} tmpfile=$(mktemp "$TMPDIR/logstats.XXXXXX") srcdir=$(cd $srcdir && pwd)/traffic_logstats diff --git a/src/traffic_logstats/tests/test_logstats_summary b/src/traffic_logstats/tests/test_logstats_summary index 9c8b63d071e..5b395df46ed 100755 --- a/src/traffic_logstats/tests/test_logstats_summary +++ b/src/traffic_logstats/tests/test_logstats_summary @@ -17,7 +17,11 @@ # limitations under the License. set -e # exit on error -set -x # turn on debug +#set -x # turn on debug + +if [ ! -z $1 ]; then + srcdir=$1 +fi TMPDIR=${TMPDIR:-/tmp} tmpfile=$(mktemp "$TMPDIR/logstats.XXXXXX") diff --git a/src/traffic_top/CMakeLists.txt b/src/traffic_top/CMakeLists.txt new file mode 100644 index 00000000000..4a0c9728bcd --- /dev/null +++ b/src/traffic_top/CMakeLists.txt @@ -0,0 +1,21 @@ +####################### +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor license +# agreements. See the NOTICE file distributed with this work for additional information regarding +# copyright ownership. The ASF licenses this file to you 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. +# +####################### + +add_executable(traffic_top traffic_top.cc ${CMAKE_SOURCE_DIR}/src/shared/rpc/IPCSocketClient.cc) +target_include_directories(traffic_top PRIVATE ${CURSES_INCLUDE_DIRS}) +target_link_libraries(traffic_top PRIVATE ts::tscore ts::inkevent libswoc ${CURSES_LIBRARIES}) +install(TARGETS traffic_top) diff --git a/src/traffic_via/CMakeLists.txt b/src/traffic_via/CMakeLists.txt new file mode 100644 index 00000000000..9f6f1c421ea --- /dev/null +++ b/src/traffic_via/CMakeLists.txt @@ -0,0 +1,27 @@ +####################### +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor license +# agreements. See the NOTICE file distributed with this work for additional information regarding +# copyright ownership. The ASF licenses this file to you 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. +# +####################### + +add_executable(traffic_via traffic_via.cc) +target_link_libraries(traffic_via ts::tscore) +install(TARGETS traffic_via) + +# Odd test to maintain compatibility with autotools. This could be better. +add_test( + NAME test_traffic_via + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_traffic_via ${CMAKE_SOURCE_DIR}/src + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/src +) diff --git a/src/traffic_via/test_traffic_via b/src/traffic_via/test_traffic_via index d8bb617df30..9d732eb1ff5 100755 --- a/src/traffic_via/test_traffic_via +++ b/src/traffic_via/test_traffic_via @@ -18,9 +18,13 @@ set -e # exit on error +if [ ! -z $1 ]; then + srcdir=$1 +fi + TMPDIR=${TMPDIR:-/tmp} tmpfile=$(mktemp "$TMPDIR/via.XXXXXX") -if [ ! -z "$srcdir"]; then +if [ ! -z "$srcdir" ]; then srcdir=$(cd $srcdir && pwd) else srcdir=$(pwd) diff --git a/src/traffic_wccp/CMakeLists.txt b/src/traffic_wccp/CMakeLists.txt index 1a83912e587..de2a5fb65a2 100644 --- a/src/traffic_wccp/CMakeLists.txt +++ b/src/traffic_wccp/CMakeLists.txt @@ -16,5 +16,6 @@ ####################### add_executable(traffic_wccp wccp_client.cc) +install(TARGETS traffic_wccp) target_link_libraries(traffic_wccp PRIVATE tscore wccp) From bf2a2b7b3f3759d35880569382639c1dbe5a41ed Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Fri, 25 Aug 2023 17:31:23 -0500 Subject: [PATCH 2/8] Add libswoc --- src/traffic_logstats/CMakeLists.txt | 2 +- src/traffic_via/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/traffic_logstats/CMakeLists.txt b/src/traffic_logstats/CMakeLists.txt index f3f507610cd..c0fbd3d5e8c 100644 --- a/src/traffic_logstats/CMakeLists.txt +++ b/src/traffic_logstats/CMakeLists.txt @@ -16,7 +16,7 @@ ####################### add_executable(traffic_logstats logstats.cc) -target_link_libraries(traffic_logstats PRIVATE ts::logging ts::hdrs ts::tscore ts::tsapi ts::records ts::diagsconfig) +target_link_libraries(traffic_logstats PRIVATE ts::logging ts::hdrs ts::tscore ts::tsapi ts::records ts::diagsconfig libswoc) add_test( NAME test_logstats_json diff --git a/src/traffic_via/CMakeLists.txt b/src/traffic_via/CMakeLists.txt index 9f6f1c421ea..d27675d94e2 100644 --- a/src/traffic_via/CMakeLists.txt +++ b/src/traffic_via/CMakeLists.txt @@ -16,7 +16,7 @@ ####################### add_executable(traffic_via traffic_via.cc) -target_link_libraries(traffic_via ts::tscore) +target_link_libraries(traffic_via ts::tscore libswoc) install(TARGETS traffic_via) # Odd test to maintain compatibility with autotools. This could be better. From d5887fc3e87856f20b7c65753819476fec157a58 Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Fri, 25 Aug 2023 18:10:36 -0500 Subject: [PATCH 3/8] logcat needs inknet --- src/traffic_logcat/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/traffic_logcat/CMakeLists.txt b/src/traffic_logcat/CMakeLists.txt index 7a0c3978fc5..b73def874cd 100644 --- a/src/traffic_logcat/CMakeLists.txt +++ b/src/traffic_logcat/CMakeLists.txt @@ -16,5 +16,5 @@ ####################### add_executable(traffic_logcat logcat.cc) -target_link_libraries(traffic_logcat PRIVATE ts::tscore ts::proxy ts::logging ts::hdrs ts::tsapi ts::diagsconfig libswoc) +target_link_libraries(traffic_logcat PRIVATE ts::tscore ts::proxy ts::logging ts::hdrs ts::tsapi ts::diagsconfig ts::inknet libswoc) install(TARGETS traffic_logcat) From 78e689dd828bb11375ffbcb023c8c79eeed64060 Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Fri, 25 Aug 2023 19:12:11 -0500 Subject: [PATCH 4/8] also traffic_logstats --- src/traffic_logstats/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/traffic_logstats/CMakeLists.txt b/src/traffic_logstats/CMakeLists.txt index c0fbd3d5e8c..396565cc218 100644 --- a/src/traffic_logstats/CMakeLists.txt +++ b/src/traffic_logstats/CMakeLists.txt @@ -16,7 +16,7 @@ ####################### add_executable(traffic_logstats logstats.cc) -target_link_libraries(traffic_logstats PRIVATE ts::logging ts::hdrs ts::tscore ts::tsapi ts::records ts::diagsconfig libswoc) +target_link_libraries(traffic_logstats PRIVATE ts::logging ts::hdrs ts::tscore ts::tsapi ts::records ts::diagsconfig ts::inknet libswoc) add_test( NAME test_logstats_json From 7756eee6ab6125a5f2b69d70776086208285b7c8 Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Fri, 25 Aug 2023 20:57:30 -0500 Subject: [PATCH 5/8] move ts::tsapi to be linked by records target --- proxy/http/unit_tests/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/proxy/http/unit_tests/CMakeLists.txt b/proxy/http/unit_tests/CMakeLists.txt index 1f9ef16c43b..64cc7d3d1bf 100644 --- a/proxy/http/unit_tests/CMakeLists.txt +++ b/proxy/http/unit_tests/CMakeLists.txt @@ -35,7 +35,6 @@ target_link_libraries(test_http PRIVATE catch2::catch2 ts::http - ts::tsapi ts::hdrs # transitive logging # transitive http_remap # transitive From 4ffa97e4b1726120449ffd87c05a07a8bcc4774b Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Sat, 26 Aug 2023 16:27:07 -0500 Subject: [PATCH 6/8] reduce libraries http3 links --- proxy/http3/CMakeLists.txt | 14 +------------- src/api/CMakeLists.txt | 2 ++ src/traffic_logcat/CMakeLists.txt | 2 +- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/proxy/http3/CMakeLists.txt b/proxy/http3/CMakeLists.txt index d3408bd1ff2..063e93669df 100644 --- a/proxy/http3/CMakeLists.txt +++ b/proxy/http3/CMakeLists.txt @@ -38,17 +38,5 @@ add_library(http3 STATIC add_library(ts::http3 ALIAS http3) target_include_directories(http3 PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") +target_link_libraries(http3 PRIVATE ts::quic ts::proxy) -target_link_libraries(http3 - PUBLIC - ts::hdrs - ts::http - ts::inknet - ts::inkutils - ts::inkevent - ts::proxy - ts::quic - ts::records - ts::tscpputil - ts::tscore -) diff --git a/src/api/CMakeLists.txt b/src/api/CMakeLists.txt index 8ee2b3ddb45..ad417a9a37b 100644 --- a/src/api/CMakeLists.txt +++ b/src/api/CMakeLists.txt @@ -17,6 +17,8 @@ add_library(tsapi SHARED Metrics.cc) add_library(ts::tsapi ALIAS tsapi) +target_link_libraries(tsapi PRIVATE ts::tscore) + install(TARGETS tsapi) diff --git a/src/traffic_logcat/CMakeLists.txt b/src/traffic_logcat/CMakeLists.txt index b73def874cd..7a0c3978fc5 100644 --- a/src/traffic_logcat/CMakeLists.txt +++ b/src/traffic_logcat/CMakeLists.txt @@ -16,5 +16,5 @@ ####################### add_executable(traffic_logcat logcat.cc) -target_link_libraries(traffic_logcat PRIVATE ts::tscore ts::proxy ts::logging ts::hdrs ts::tsapi ts::diagsconfig ts::inknet libswoc) +target_link_libraries(traffic_logcat PRIVATE ts::tscore ts::proxy ts::logging ts::hdrs ts::tsapi ts::diagsconfig libswoc) install(TARGETS traffic_logcat) From 6025550a26908f0fe42b1f490dc4ab5ae5f244a0 Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Sun, 27 Aug 2023 10:52:14 -0500 Subject: [PATCH 7/8] adjust http3 libraries --- proxy/http3/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proxy/http3/CMakeLists.txt b/proxy/http3/CMakeLists.txt index 063e93669df..2f8ce3f9ca3 100644 --- a/proxy/http3/CMakeLists.txt +++ b/proxy/http3/CMakeLists.txt @@ -38,5 +38,5 @@ add_library(http3 STATIC add_library(ts::http3 ALIAS http3) target_include_directories(http3 PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") -target_link_libraries(http3 PRIVATE ts::quic ts::proxy) +target_link_libraries(http3 PUBLIC ts::quic PRIVATE ts::proxy) From eb4dfbc60ac1f8cd19eeeb7ad9178f44c6d262fb Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Sun, 27 Aug 2023 11:07:26 -0500 Subject: [PATCH 8/8] adjust traffic_logstats link --- src/traffic_logstats/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/traffic_logstats/CMakeLists.txt b/src/traffic_logstats/CMakeLists.txt index 396565cc218..be589c1761b 100644 --- a/src/traffic_logstats/CMakeLists.txt +++ b/src/traffic_logstats/CMakeLists.txt @@ -16,7 +16,7 @@ ####################### add_executable(traffic_logstats logstats.cc) -target_link_libraries(traffic_logstats PRIVATE ts::logging ts::hdrs ts::tscore ts::tsapi ts::records ts::diagsconfig ts::inknet libswoc) +target_link_libraries(traffic_logstats PRIVATE ts::logging ts::hdrs ts::tscore ts::tsapi ts::records ts::diagsconfig ts::inkevent libswoc) add_test( NAME test_logstats_json