From 82b585947465662c6e8bef23fcea815bd2a707a9 Mon Sep 17 00:00:00 2001 From: Mateusz Grzegorzek Date: Fri, 11 Jun 2021 11:45:45 +0200 Subject: [PATCH] [BH-363] Move libphonenumber to a separate directory Move libphonenumber to a separate directory --- .gitmodules | 6 +- cmake/modules/PureCoverage.cmake | 1 - doc/Doxyfile.in | 1 - module-apps/CMakeLists.txt | 1 + module-utils/CMakeLists.txt | 7 +- module-utils/third-party/libphonenumber.cmake | 69 ------------------- products/BellHybrid/BellHybridMain.cpp | 1 - products/PurePhone/PurePhoneMain.cpp | 1 - third-party/CMakeLists.txt | 1 + third-party/libphonenumber/CMakeLists.txt | 50 ++++++++++++++ .../libphonenumber/src | 0 11 files changed, 57 insertions(+), 81 deletions(-) delete mode 100644 module-utils/third-party/libphonenumber.cmake create mode 100644 third-party/libphonenumber/CMakeLists.txt rename module-utils/libphonenumber => third-party/libphonenumber/src (100%) diff --git a/.gitmodules b/.gitmodules index cf48cb3dd8ddcf7e424e724126f7bfa4b01776bd..a5c745c472b7c171b39bae3fbe3b16a3791359b6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,8 +16,8 @@ url = ../protobuf.git branch = rt1051 shallow = true -[submodule "module-utils/libphonenumber"] - path = module-utils/libphonenumber +[submodule "third-party/libphonenumber"] + path = third-party/libphonenumber/src url = ../libphonenumber.git branch = rt1051 shallow = true @@ -28,7 +28,7 @@ [submodule "test/Catch2"] path = test/Catch2 url = https://github.com/catchorg/Catch2 -[submodule "module-utils/date"] +[submodule "third-party/date"] path = third-party/date url = ../date.git [submodule "module-utils/taglib"] diff --git a/cmake/modules/PureCoverage.cmake b/cmake/modules/PureCoverage.cmake index 4cb1b2abd881ae5facb9e9f1a50f36fc03c75b21..5f099ae1672c3be034c03ce645a811d2a9ddfc99 100644 --- a/cmake/modules/PureCoverage.cmake +++ b/cmake/modules/PureCoverage.cmake @@ -30,7 +30,6 @@ if(COVERAGE_ENABLE) module-os/.* module-utils/gsl/.* module-utils/json/.* - module-utils/libphonenumber/.* module-utils/segger/.* source/main.cpp test/.* diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index f773af613baa9d33b720dfe98337156f5dd95c70..d74556598f02dd2073c48f6eb0dfe6cec9a7738e 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -889,7 +889,6 @@ EXCLUDE = @PROJECT_SOURCE_DIR@/module-bluetooth/lib \ @PROJECT_SOURCE_DIR@/module-utils/tinyfsm \ @PROJECT_SOURCE_DIR@/module-utils/segger \ @PROJECT_SOURCE_DIR@/module-utils/sbini \ - @PROJECT_SOURCE_DIR@/module-utils/libphonenumber \ @PROJECT_SOURCE_DIR@/module-utils/test \ @PROJECT_SOURCE_DIR@/module-db/tests \ @PROJECT_SOURCE_DIR@/module-db/Database/sqlite3.c \ diff --git a/module-apps/CMakeLists.txt b/module-apps/CMakeLists.txt index e7434962651bc51e28aa41543557ed9799d3b4c4..545392c4fcd19e33d36bda5c775fc03ba453702b 100644 --- a/module-apps/CMakeLists.txt +++ b/module-apps/CMakeLists.txt @@ -74,6 +74,7 @@ target_link_libraries(${PROJECT_NAME} date::date eventstore i18n + libphonenumber::libphonenumber Microsoft.GSL::GSL service-antenna service-appmgr diff --git a/module-utils/CMakeLists.txt b/module-utils/CMakeLists.txt index 046291f850f9565859695a9a2661fc158edcef85..f4900bf789fe122eda5724f29d78a4fee2a7c35c 100644 --- a/module-utils/CMakeLists.txt +++ b/module-utils/CMakeLists.txt @@ -21,20 +21,17 @@ add_library(${PROJECT_NAME} STATIC ${SOURCES}) include(segger/rtt/CMakeLists.txt) -# add third party libs -include(third-party/libphonenumber.cmake) - target_link_libraries(${PROJECT_NAME} PUBLIC board + libphonenumber::libphonenumber log magic_enum module-os module-vfs - ${LIBPHONENUMBER_TARGET} PRIVATE - json::json crc32 + json::json time ) diff --git a/module-utils/third-party/libphonenumber.cmake b/module-utils/third-party/libphonenumber.cmake deleted file mode 100644 index 40981c3e986fcd4fcb7035524187dd6642a95aa4..0000000000000000000000000000000000000000 --- a/module-utils/third-party/libphonenumber.cmake +++ /dev/null @@ -1,69 +0,0 @@ -include (thirdparty) - -# choose metadata to use -option (LIBPHONENUMBER_USE_MINIMAL_METADATA "Use minimal metadata for libphonenumber" OFF) - -# add sources -set (LIBPHONENUMBER_SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/libphonenumber/cpp/src) -set (LIBPHONENUMBER ${LIBPHONENUMBER_SRCDIR}/phonenumbers) -if (LIBPHONENUMBER_USE_MINIMAL_METADATA) - set (LIBPHONENUMBER_METADATA ${LIBPHONENUMBER}/metadata-minimal.cc) -else () - set (LIBPHONENUMBER_METADATA ${LIBPHONENUMBER}/metadata.cc) -endif () -set (LIBPHONENUMBER_SOURCES - ${LIBPHONENUMBER}/asyoutypeformatter.cc - ${LIBPHONENUMBER}/base/strings/string_piece.cc - ${LIBPHONENUMBER}/default_logger.cc - ${LIBPHONENUMBER}/logger.cc - ${LIBPHONENUMBER}/phonemetadata.pb.cc - ${LIBPHONENUMBER}/phonenumber.cc - ${LIBPHONENUMBER}/phonenumber.pb.cc - ${LIBPHONENUMBER}/phonenumberutil.cc - ${LIBPHONENUMBER}/regex_based_matcher.cc - ${LIBPHONENUMBER}/regexp_adapter_re2.cc - ${LIBPHONENUMBER}/regexp_cache.cc - ${LIBPHONENUMBER}/shortnumberinfo.cc - ${LIBPHONENUMBER}/stringutil.cc - ${LIBPHONENUMBER}/unicodestring.cc - ${LIBPHONENUMBER}/utf/rune.c - ${LIBPHONENUMBER}/utf/unicodetext.cc - ${LIBPHONENUMBER}/utf/unilib.cc - ${LIBPHONENUMBER_METADATA} -) - -# create static library for the third party -set (LIBPHONENUMBER_TARGET phonenumber) -add_library (${LIBPHONENUMBER_TARGET} STATIC ${LIBPHONENUMBER_SOURCES}) - -# setup flags for the third party -third_party_target_setup (${LIBPHONENUMBER_TARGET}) - -# set compile definitions -target_compile_definitions (${LIBPHONENUMBER_TARGET} - PRIVATE - I18N_PHONENUMBERS_ASCII_DECIMALS_ONLY - PUBLIC - I18N_PHONENUMBERS_USE_RTOS_WRAPPER - I18N_PHONENUMBERS_ASCII_DECIMALS_ONLY - I18N_PHONENUMBERS_USE_RE2 -) - -# suppress warning for libphonenumber -set_source_files_properties (${LIBPHONENUMBER}/asyoutypeformatter.cc - PROPERTIES COMPILE_FLAGS - -Wno-implicit-fallthrough -) - -# add include directory path -target_include_directories (${LIBPHONENUMBER_TARGET} PUBLIC ${LIBPHONENUMBER_SRCDIR}) - -target_link_libraries (${LIBPHONENUMBER_TARGET} - PRIVATE - re2::re2 - PUBLIC - protobuf::libprotobuf-lite -) - -# turn on optimization in debug -third_party_source_optimization (${LIBPHONENUMBER_SOURCES}) diff --git a/products/BellHybrid/BellHybridMain.cpp b/products/BellHybrid/BellHybridMain.cpp index c43bfa92e2f89f2a9ab4488394414fb2eeda4916..f884015b8c2ea9b6132be452eb70535c71043ae0 100644 --- a/products/BellHybrid/BellHybridMain.cpp +++ b/products/BellHybrid/BellHybridMain.cpp @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include diff --git a/products/PurePhone/PurePhoneMain.cpp b/products/PurePhone/PurePhoneMain.cpp index 6fae965a81f3b64f2c7cd0d4ac6bce1d97ddcce2..cd6666c13759f67aa126da99308b2096877b4b1d 100644 --- a/products/PurePhone/PurePhoneMain.cpp +++ b/products/PurePhone/PurePhoneMain.cpp @@ -48,7 +48,6 @@ #include #include #include -#include #include #include #include diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index cc43f0d5a106b85c20456bdb9ac8da7079c930d2..cbbc27fa70663bbef5ba1a8731749b3a6ea66bde 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -14,6 +14,7 @@ add_subdirectory(json) add_subdirectory(gsl) add_subdirectory(re2) add_subdirectory(utz) +add_subdirectory(libphonenumber) if (${PROJECT_TARGET} STREQUAL "TARGET_RT1051") add_subdirectory(CrashDebug) endif() diff --git a/third-party/libphonenumber/CMakeLists.txt b/third-party/libphonenumber/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..e59a5d221523cb60046efac1d1921cde69e6a195 --- /dev/null +++ b/third-party/libphonenumber/CMakeLists.txt @@ -0,0 +1,50 @@ +add_library(libphonenumber STATIC) +add_library(libphonenumber::libphonenumber ALIAS libphonenumber) + +# choose metadata to use +option (LIBPHONENUMBER_USE_MINIMAL_METADATA "Use minimal metadata for libphonenumber" OFF) + +target_sources(libphonenumber + PRIVATE + src/cpp/src/phonenumbers/asyoutypeformatter.cc + src/cpp/src/phonenumbers/base/strings/string_piece.cc + src/cpp/src/phonenumbers/default_logger.cc + src/cpp/src/phonenumbers/logger.cc + src/cpp/src/phonenumbers/phonemetadata.pb.cc + src/cpp/src/phonenumbers/phonenumber.cc + src/cpp/src/phonenumbers/phonenumber.pb.cc + src/cpp/src/phonenumbers/phonenumberutil.cc + src/cpp/src/phonenumbers/regex_based_matcher.cc + src/cpp/src/phonenumbers/regexp_adapter_re2.cc + src/cpp/src/phonenumbers/regexp_cache.cc + src/cpp/src/phonenumbers/shortnumberinfo.cc + src/cpp/src/phonenumbers/stringutil.cc + src/cpp/src/phonenumbers/unicodestring.cc + src/cpp/src/phonenumbers/utf/rune.c + src/cpp/src/phonenumbers/utf/unicodetext.cc + src/cpp/src/phonenumbers/utf/unilib.cc + $,src/cpp/src/phonenumbers/metadata-minimal.cc,src/cpp/src/phonenumbers/metadata.cc> +) + +target_include_directories(libphonenumber PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/src) + +target_compile_definitions (libphonenumber + PRIVATE + I18N_PHONENUMBERS_ASCII_DECIMALS_ONLY + PUBLIC + I18N_PHONENUMBERS_USE_RTOS_WRAPPER + I18N_PHONENUMBERS_USE_RE2 +) + +# suppress warning for libphonenumber +set_source_files_properties (${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/src/phonenumbers/asyoutypeformatter.cc + PROPERTIES COMPILE_FLAGS + -Wno-implicit-fallthrough +) + +target_link_libraries (libphonenumber + PRIVATE + re2::re2 + PUBLIC + protobuf::libprotobuf-lite +) diff --git a/module-utils/libphonenumber b/third-party/libphonenumber/src similarity index 100% rename from module-utils/libphonenumber rename to third-party/libphonenumber/src