From 100876337af28f9e86259e0a17e28d1ea1b737a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Sat, 3 Jul 2021 12:58:30 +0100 Subject: [PATCH] Move version_info.[ch] to ui/ Version info is an aspect of UI implementation so move it to a more appropriate place, such as ui/. This also helps declutter the top-level. A static library is appropriate to encapsulate the dependencies as private and it is better supported by CMake than object libraries. Also version_info.h should not be installed as a public header. --- CMakeLists.txt | 49 +++++++----------------- capinfos.c | 2 +- captype.c | 2 +- dumpcap.c | 2 +- editcap.c | 2 +- extcap.c | 2 +- file.c | 2 +- fuzz/CMakeLists.txt | 3 +- fuzz/fuzzshark.c | 2 +- mergecap.c | 2 +- rawshark.c | 2 +- reordercap.c | 2 +- sharkd.c | 2 +- sharkd_daemon.c | 2 +- sharkd_session.c | 2 +- text2pcap.c | 2 +- tfshark.c | 2 +- tshark.c | 2 +- ui/CMakeLists.txt | 29 +++++++++----- ui/commandline.c | 2 +- ui/decode_as_utils.c | 2 +- ui/export_pdu_ui_utils.c | 2 +- ui/qt/about_dialog.cpp | 2 +- ui/qt/capture_file_properties_dialog.cpp | 2 +- ui/qt/follow_stream_dialog.cpp | 2 +- ui/qt/main.cpp | 2 +- ui/qt/main_window.cpp | 2 +- ui/qt/welcome_page.cpp | 2 +- ui/tap_export_pdu.c | 2 +- version_info.c => ui/version_info.c | 0 version_info.h => ui/version_info.h | 0 31 files changed, 61 insertions(+), 72 deletions(-) rename version_info.c => ui/version_info.c (100%) rename version_info.h => ui/version_info.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 952e5f1fd3c..a9375dd5c78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1936,13 +1936,6 @@ if(NOT WIN32) list(APPEND INSTALL_FILES COPYING) endif() -set(VERSION_INFO_LIBS - ${ZLIB_LIBRARIES} -) -set(VERSION_INFO_INCLUDE_DIRS - ${ZLIB_INCLUDE_DIRS} -) - if(WIN32) set(_dll_output_dir "${DATAFILE_DIR}") add_custom_target(copy_cli_dlls) @@ -2331,13 +2324,6 @@ list(APPEND copy_data_files_depends add_custom_target(copy_data_files ALL DEPENDS ${copy_data_files_depends} ) set_target_properties(copy_data_files PROPERTIES FOLDER "Copy Tasks") - -# Shared code, build object files once for all users. -add_library(version_info OBJECT version_info.c) -target_include_directories(version_info SYSTEM PRIVATE ${VERSION_INFO_INCLUDE_DIRS}) -if(NOT VCSVERSION_OVERRIDE) - add_dependencies(version_info version) -endif() # sources common for wireshark, tshark, rawshark and sharkd add_library(shark_common OBJECT cfile.c @@ -2350,7 +2336,7 @@ add_library(shark_common OBJECT add_library(cli_main OBJECT cli_main.c) add_library(capture_opts OBJECT capture_opts.c) target_include_directories(capture_opts SYSTEM PRIVATE ${PCAP_INCLUDE_DIRS}) -set_target_properties(version_info shark_common cli_main capture_opts +set_target_properties(shark_common cli_main capture_opts PROPERTIES COMPILE_FLAGS "${WERROR_COMMON_FLAGS}" ) @@ -2366,7 +2352,6 @@ if(BUILD_wireshark AND QT_FOUND) $ $ $ - $ ${WIRESHARK_SRC} ${PLATFORM_UI_RC_FILES} ) @@ -2451,8 +2436,8 @@ if(BUILD_wireshark AND QT_FOUND) caputils wiretap epan + version_info ${QT_LIBRARIES} - ${VERSION_INFO_LIBS} ${APPLE_APPLICATION_SERVICES_LIBRARY} ${APPLE_APPKIT_LIBRARY} ${APPLE_CORE_FOUNDATION_LIBRARY} @@ -2591,7 +2576,7 @@ if(BUILD_tshark) caputils wiretap epan - ${VERSION_INFO_LIBS} + version_info ${APPLE_CORE_FOUNDATION_LIBRARY} ${APPLE_SYSTEM_CONFIGURATION_LIBRARY} ${WIN_WS2_32_LIBRARY} @@ -2601,7 +2586,6 @@ if(BUILD_tshark) $ $ $ - $ tshark-tap-register.c tshark.c ${TSHARK_TAP_SRC} @@ -2620,14 +2604,13 @@ if(BUILD_tfshark) ui wiretap epan - ${VERSION_INFO_LIBS} + version_info ${APPLE_CORE_FOUNDATION_LIBRARY} ${APPLE_SYSTEM_CONFIGURATION_LIBRARY} ) set(tfshark_FILES $ $ - $ tfshark.c ${TSHARK_TAP_SRC} ) @@ -2644,7 +2627,7 @@ if(BUILD_rawshark AND PCAP_FOUND) ui wiretap epan - ${VERSION_INFO_LIBS} + version_info ${APPLE_CORE_FOUNDATION_LIBRARY} ${APPLE_SYSTEM_CONFIGURATION_LIBRARY} ${WIN_WS2_32_LIBRARY} @@ -2652,7 +2635,6 @@ if(BUILD_rawshark AND PCAP_FOUND) set(rawshark_FILES $ $ - $ rawshark.c ) set_executable_resources(rawshark "Rawshark") @@ -2667,7 +2649,7 @@ if(BUILD_sharkd) ui wiretap epan - ${VERSION_INFO_LIBS} + version_info ${APPLE_CORE_FOUNDATION_LIBRARY} ${APPLE_SYSTEM_CONFIGURATION_LIBRARY} ${WIN_WS2_32_LIBRARY} @@ -2680,7 +2662,6 @@ if(BUILD_sharkd) # $ and has real_main(). # $ - $ sharkd.c sharkd_daemon.c sharkd_session.c @@ -2699,7 +2680,7 @@ if(BUILD_dftest) ui wiretap epan - ${VERSION_INFO_LIBS} + version_info ) set(dftest_FILES dftest.c @@ -2721,7 +2702,6 @@ if(BUILD_randpkt) ) set(randpkt_FILES $ - $ randpkt.c ) add_executable(randpkt ${randpkt_FILES}) @@ -2738,12 +2718,12 @@ if(BUILD_text2pcap) set(text2pcap_LIBS writecap wsutil + version_info ${M_LIBRARIES} ${ZLIB_LIBRARIES} ) set(text2pcap_FILES $ - $ text2pcap.c ) add_lex_files(text2pcap_LEX_FILES text2pcap_FILES @@ -2761,12 +2741,12 @@ if(BUILD_mergecap) set(mergecap_LIBS ui wiretap + version_info ${ZLIB_LIBRARIES} ${CMAKE_DL_LIBS} ) set(mergecap_FILES $ - $ mergecap.c ) set_executable_resources(mergecap "Mergecap") @@ -2780,12 +2760,12 @@ if(BUILD_reordercap) set(reordercap_LIBS ui wiretap + version_info ${ZLIB_LIBRARIES} ${CMAKE_DL_LIBS} ) set(reordercap_FILES $ - $ reordercap.c ) set_executable_resources(reordercap "Reordercap") @@ -2800,13 +2780,13 @@ if(BUILD_capinfos) ui wiretap wsutil + version_info ${ZLIB_LIBRARIES} ${GCRYPT_LIBRARIES} ${CMAKE_DL_LIBS} ) set(capinfos_FILES $ - $ capinfos.c ) set_executable_resources(capinfos "Capinfos") @@ -2821,12 +2801,12 @@ if(BUILD_captype) ui wiretap wsutil + version_info ${ZLIB_LIBRARIES} ${CMAKE_DL_LIBS} ) set(captype_FILES $ - $ captype.c ) set_executable_resources(captype "Captype") @@ -2840,13 +2820,13 @@ if(BUILD_editcap) set(editcap_LIBS ui wiretap + version_info ${ZLIB_LIBRARIES} ${GCRYPT_LIBRARIES} ${CMAKE_DL_LIBS} ) set(editcap_FILES $ - $ editcap.c ) set_executable_resources(editcap "Editcap") @@ -2862,6 +2842,7 @@ if(BUILD_dumpcap AND PCAP_FOUND) wsutil caputils ui + version_info pcap::pcap ${CAP_LIBRARIES} ${GLIB2_LIBRARIES} @@ -2874,7 +2855,6 @@ if(BUILD_dumpcap AND PCAP_FOUND) set(dumpcap_FILES $ $ - $ dumpcap.c ringbuffer.c sync_pipe_write.c @@ -3394,7 +3374,6 @@ set(SHARK_PUBLIC_HEADERS ws_diag_control.h ws_log_defs.h ws_symbol_export.h - version_info.h ${CMAKE_BINARY_DIR}/ws_version.h ) diff --git a/capinfos.c b/capinfos.c index 9043c25a0fc..495554b6996 100644 --- a/capinfos.c +++ b/capinfos.c @@ -73,7 +73,7 @@ #include #include #include -#include +#include #include #ifdef HAVE_PLUGINS diff --git a/captype.c b/captype.c index 558aa9465bf..c8448d4b916 100644 --- a/captype.c +++ b/captype.c @@ -42,7 +42,7 @@ #include #include #include -#include +#include #ifdef HAVE_PLUGINS #include diff --git a/dumpcap.c b/dumpcap.c index 6b560161e85..712b1379231 100644 --- a/dumpcap.c +++ b/dumpcap.c @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include #include diff --git a/editcap.c b/editcap.c index b14b3b299db..caa49faba43 100644 --- a/editcap.c +++ b/editcap.c @@ -80,7 +80,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/extcap.c b/extcap.c index d955feceefa..635e22683ed 100644 --- a/extcap.c +++ b/extcap.c @@ -49,7 +49,7 @@ #include "extcap.h" #include "extcap_parser.h" -#include "version_info.h" +#include "ui/version_info.h" static void extcap_child_watch_cb(GPid pid, gint status, gpointer user_data); diff --git a/file.c b/file.c index c8b651a650e..9218b6d37a1 100644 --- a/file.c +++ b/file.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include diff --git a/fuzz/CMakeLists.txt b/fuzz/CMakeLists.txt index 9e9598badc3..c4229922b5f 100644 --- a/fuzz/CMakeLists.txt +++ b/fuzz/CMakeLists.txt @@ -30,7 +30,7 @@ set(fuzzshark_LIBS ui wiretap epan - ${VERSION_INFO_LIBS} + version_info ) if(OSS_FUZZ) if("$ENV{LIB_FUZZING_ENGINE}" STREQUAL "") @@ -40,7 +40,6 @@ if(OSS_FUZZ) endif() set(fuzzshark_FILES fuzzshark.c - $ ) set(FUZZ_LINK_FLAGS "${WS_LINK_FLAGS}") if(ENABLE_FUZZER) diff --git a/fuzz/fuzzshark.c b/fuzz/fuzzshark.c index fdf25d64c36..162f23f56a1 100644 --- a/fuzz/fuzzshark.c +++ b/fuzz/fuzzshark.c @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include diff --git a/mergecap.c b/mergecap.c index 50e5c3481d8..66c1d5d792e 100644 --- a/mergecap.c +++ b/mergecap.c @@ -45,7 +45,7 @@ #include #include -#include +#include #ifdef HAVE_PLUGINS #include diff --git a/rawshark.c b/rawshark.c index 2dcf93b565b..1dafd06fa34 100644 --- a/rawshark.c +++ b/rawshark.c @@ -91,7 +91,7 @@ #include #include -#include +#include #include "capture/capture-pcap-util.h" diff --git a/reordercap.c b/reordercap.c index d845528cdd6..643732c2552 100644 --- a/reordercap.c +++ b/reordercap.c @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #ifdef HAVE_PLUGINS diff --git a/sharkd.c b/sharkd.c index cbc8f4dce8b..21a410e6a9e 100644 --- a/sharkd.c +++ b/sharkd.c @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include diff --git a/sharkd_daemon.c b/sharkd_daemon.c index 5f653275121..0c9363301fa 100644 --- a/sharkd_daemon.c +++ b/sharkd_daemon.c @@ -49,7 +49,7 @@ #endif #include -#include +#include #include "sharkd.h" diff --git a/sharkd_session.c b/sharkd_session.c index fa7e18e8815..25aafd03e44 100644 --- a/sharkd_session.c +++ b/sharkd_session.c @@ -53,7 +53,7 @@ #include #include #include -#include +#include #include #include diff --git a/text2pcap.c b/text2pcap.c index 9037e290311..a706027a864 100644 --- a/text2pcap.c +++ b/text2pcap.c @@ -101,7 +101,7 @@ #include #include #include -#include +#include #include #include diff --git a/tfshark.c b/tfshark.c index 2b9d0c8132d..a87149387f8 100644 --- a/tfshark.c +++ b/tfshark.c @@ -50,7 +50,7 @@ #include #include #include -#include +#include #include "globals.h" #include diff --git a/tshark.c b/tshark.c index 87547f2fea8..9f3e8ead4ba 100644 --- a/tshark.c +++ b/tshark.c @@ -61,7 +61,7 @@ #include #include #include -#include +#include #include #include "globals.h" diff --git a/ui/CMakeLists.txt b/ui/CMakeLists.txt index 06f829a77d8..f3e0c6d3e6f 100644 --- a/ui/CMakeLists.txt +++ b/ui/CMakeLists.txt @@ -78,17 +78,8 @@ set_source_files_properties( COMPILE_FLAGS "${WERROR_COMMON_FLAGS}" ) - add_library(ui STATIC ${UI_SRC}) -set_target_properties(ui PROPERTIES - LINK_FLAGS "${WS_LINK_FLAGS}" - FOLDER "UI" -) -if(MSVC) - set_target_properties(ui PROPERTIES LINK_FLAGS_DEBUG "${WS_MSVC_DEBUG_LINK_FLAGS}") -endif() - target_link_libraries(ui wsutil caputils) target_include_directories(ui SYSTEM @@ -96,6 +87,26 @@ target_include_directories(ui SYSTEM ${WINSPARKLE_INCLUDE_DIRS} ) +add_library(version_info STATIC version_info.c) + +if(NOT VCSVERSION_OVERRIDE) + add_dependencies(version_info version) +endif() + +target_link_libraries(version_info PRIVATE ${ZLIB_LIBRARIES}) + +target_include_directories(version_info PRIVATE ${ZLIB_INCLUDE_DIRS}) + +set_target_properties(ui version_info PROPERTIES + LINK_FLAGS "${WS_LINK_FLAGS}" + FOLDER "UI" +) +if(MSVC) + set_target_properties(ui version_info PROPERTIES + LINK_FLAGS_DEBUG "${WS_MSVC_DEBUG_LINK_FLAGS}" + ) +endif() + add_definitions(-DDOC_DIR="${CMAKE_INSTALL_FULL_DOCDIR}") CHECKAPI( diff --git a/ui/commandline.c b/ui/commandline.c index 96135f4472c..ebfc5eae50e 100644 --- a/ui/commandline.c +++ b/ui/commandline.c @@ -29,7 +29,7 @@ #include #endif -#include +#include #include #include diff --git a/ui/decode_as_utils.c b/ui/decode_as_utils.c index 5357b44d52a..be2164e3726 100644 --- a/ui/decode_as_utils.c +++ b/ui/decode_as_utils.c @@ -25,7 +25,7 @@ #include "wsutil/filesystem.h" #include #include "ui/cmdarg_err.h" -#include "version_info.h" +#include "ui/version_info.h" /* XXX - We might want to switch this to a UAT */ diff --git a/ui/export_pdu_ui_utils.c b/ui/export_pdu_ui_utils.c index 7246b57f663..53e43bbba26 100644 --- a/ui/export_pdu_ui_utils.c +++ b/ui/export_pdu_ui_utils.c @@ -15,7 +15,7 @@ #include "globals.h" #include "wsutil/os_version_info.h" #include "wsutil/tempfile.h" -#include "version_info.h" +#include "ui/version_info.h" #include #include diff --git a/ui/qt/about_dialog.cpp b/ui/qt/about_dialog.cpp index 14535baa609..27611a1f62a 100644 --- a/ui/qt/about_dialog.cpp +++ b/ui/qt/about_dialog.cpp @@ -38,7 +38,7 @@ #include "wsutil/tempfile.h" #include "wsutil/plugins.h" #include "wsutil/copyright_info.h" -#include "version_info.h" +#include "ui/version_info.h" #include "extcap.h" diff --git a/ui/qt/capture_file_properties_dialog.cpp b/ui/qt/capture_file_properties_dialog.cpp index 8c23a6cb196..39241dcc1aa 100644 --- a/ui/qt/capture_file_properties_dialog.cpp +++ b/ui/qt/capture_file_properties_dialog.cpp @@ -16,7 +16,7 @@ #include "wsutil/str_util.h" #include "wsutil/utf8_entities.h" -#include "version_info.h" +#include "ui/version_info.h" #include #include "wireshark_application.h" diff --git a/ui/qt/follow_stream_dialog.cpp b/ui/qt/follow_stream_dialog.cpp index e64bd5427b1..4e36e09ea5e 100644 --- a/ui/qt/follow_stream_dialog.cpp +++ b/ui/qt/follow_stream_dialog.cpp @@ -33,7 +33,7 @@ #include "wsutil/file_util.h" #include "wsutil/str_util.h" -#include "version_info.h" +#include "ui/version_info.h" #include "ws_symbol_export.h" diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp index 43b9b34ac17..975c0e21b5e 100644 --- a/ui/qt/main.cpp +++ b/ui/qt/main.cpp @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include #include diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp index 34ccf03ebdd..6ff429918a6 100644 --- a/ui/qt/main_window.cpp +++ b/ui/qt/main_window.cpp @@ -23,7 +23,7 @@ DIAG_ON(frame-larger-than=) #include #include #include -#include +#include #include #include #include diff --git a/ui/qt/welcome_page.cpp b/ui/qt/welcome_page.cpp index 059a57334da..8631423ce4d 100644 --- a/ui/qt/welcome_page.cpp +++ b/ui/qt/welcome_page.cpp @@ -16,7 +16,7 @@ #include "ui/capture_globals.h" #include "ui/urls.h" -#include "version_info.h" +#include "ui/version_info.h" #include "welcome_page.h" #include diff --git a/ui/tap_export_pdu.c b/ui/tap_export_pdu.c index 98190a8e2ec..850148ca557 100644 --- a/ui/tap_export_pdu.c +++ b/ui/tap_export_pdu.c @@ -18,7 +18,7 @@ #include #include -#include "version_info.h" +#include "ui/version_info.h" #include "tap_export_pdu.h" diff --git a/version_info.c b/ui/version_info.c similarity index 100% rename from version_info.c rename to ui/version_info.c diff --git a/version_info.h b/ui/version_info.h similarity index 100% rename from version_info.h rename to ui/version_info.h