From 786b291d9c6b784c7ce6ceef0e38a4ec76ea14db Mon Sep 17 00:00:00 2001 From: Nicky Date: Wed, 6 Apr 2022 16:32:52 +0200 Subject: Move CMake files to modernized cmake syntax, step 1. Change projects to cmake targetsto get rid of havig to hardcore include directories and link libraries in consumer projects. --- indra/llcommon/CMakeLists.txt | 37 +++++++++++-------------------------- indra/llcommon/stringize.h | 2 +- 2 files changed, 12 insertions(+), 27 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 68378222d9..901686c815 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -13,14 +13,6 @@ include(Copy3rdPartyLibs) include(ZLIBNG) include(URIPARSER) -include_directories( - ${EXPAT_INCLUDE_DIRS} - ${LLCOMMON_INCLUDE_DIRS} - ${JSONCPP_INCLUDE_DIR} - ${ZLIBNG_INCLUDE_DIRS} - ${URIPARSER_INCLUDE_DIRS} - ) - # add_executable(lltreeiterators lltreeiterators.cpp) # # target_link_libraries(lltreeiterators @@ -286,22 +278,19 @@ else(LLCOMMON_LINK_SHARED) endif(LLCOMMON_LINK_SHARED) target_link_libraries( - llcommon - ${APRUTIL_LIBRARIES} - ${APR_LIBRARIES} - ${EXPAT_LIBRARIES} - ${JSONCPP_LIBRARIES} - ${ZLIBNG_LIBRARIES} + llcommon + apr::apr + expat::expat + jsoncpp::jsoncpp + zlib-ng::zlib-ng ${WINDOWS_LIBRARIES} - ${BOOST_FIBER_LIBRARY} - ${BOOST_CONTEXT_LIBRARY} - ${BOOST_PROGRAM_OPTIONS_LIBRARY} - ${BOOST_REGEX_LIBRARY} - ${BOOST_SYSTEM_LIBRARY} + boost::boost ${GOOGLE_PERFTOOLS_LIBRARIES} - ${URIPARSER_LIBRARIES} + uriparser::uriparser ) +set_target_include_dirs( llcommon ${CMAKE_CURRENT_SOURCE_DIR}) + if (DARWIN) include(CMakeFindFrameworks) find_library(CARBON_LIBRARY Carbon) @@ -319,13 +308,9 @@ if (LL_TESTS) #set(TEST_DEBUG on) set(test_libs llcommon - ${LLCOMMON_LIBRARIES} - ${WINDOWS_LIBRARIES} + ${WINDOWS_LIBRARIES} ${GOOGLEMOCK_LIBRARIES} - ${BOOST_FIBER_LIBRARY} - ${BOOST_CONTEXT_LIBRARY} - ${BOOST_THREAD_LIBRARY} - ${BOOST_SYSTEM_LIBRARY}) + ) LL_ADD_INTEGRATION_TEST(bitpack "" "${test_libs}") LL_ADD_INTEGRATION_TEST(classic_callback "" "${test_libs}") LL_ADD_INTEGRATION_TEST(commonmisc "" "${test_libs}") diff --git a/indra/llcommon/stringize.h b/indra/llcommon/stringize.h index 38dd198ad3..174c9051a8 100644 --- a/indra/llcommon/stringize.h +++ b/indra/llcommon/stringize.h @@ -30,7 +30,7 @@ #define LL_STRINGIZE_H #include -#include +#include "llstring.h" /** * gstringize(item) encapsulates an idiom we use constantly, using -- cgit v1.2.3 From ef989bce374516192c59be32af674de19295a31a Mon Sep 17 00:00:00 2001 From: Nicky Date: Wed, 6 Apr 2022 22:38:08 +0200 Subject: On OSX llcommon also needs CMAKE_CURRENT_SOURCE_DIR as PRIVATE include dir. --- indra/llcommon/CMakeLists.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 901686c815..0fd2581dd4 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -290,6 +290,7 @@ target_link_libraries( ) set_target_include_dirs( llcommon ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories( llcommon PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ) if (DARWIN) include(CMakeFindFrameworks) @@ -307,10 +308,10 @@ if (LL_TESTS) LL_ADD_PROJECT_UNIT_TESTS(llcommon "${llcommon_TEST_SOURCE_FILES}") #set(TEST_DEBUG on) - set(test_libs llcommon - ${WINDOWS_LIBRARIES} - ${GOOGLEMOCK_LIBRARIES} - ) + set(test_libs llcommon + ${WINDOWS_LIBRARIES} + googlemock::googlemock + ) LL_ADD_INTEGRATION_TEST(bitpack "" "${test_libs}") LL_ADD_INTEGRATION_TEST(classic_callback "" "${test_libs}") LL_ADD_INTEGRATION_TEST(commonmisc "" "${test_libs}") -- cgit v1.2.3 From 241919e7f7986c11586a49bff53cf19c2c0e0ea6 Mon Sep 17 00:00:00 2001 From: Nicky Date: Wed, 13 Apr 2022 19:21:55 +0200 Subject: Rework cmake, the original plan was to maybe be able to use conan targets with the same name (that's why 3ps had names like apr::apr), but it's safer and saner to put the LL 3ps under the ll:: prefix. This also allows means it is possible to get rid of that bad "if( TRAGET ...) return() endif()" pattern and rather use include_guard(). --- indra/llcommon/CMakeLists.txt | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 0fd2581dd4..c934d47cc9 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -13,11 +13,6 @@ include(Copy3rdPartyLibs) include(ZLIBNG) include(URIPARSER) -# add_executable(lltreeiterators lltreeiterators.cpp) -# -# target_link_libraries(lltreeiterators -# ${LLCOMMON_LIBRARIES}) - set(llcommon_SOURCE_FILES indra_constants.cpp llallocator.cpp @@ -279,14 +274,14 @@ endif(LLCOMMON_LINK_SHARED) target_link_libraries( llcommon - apr::apr - expat::expat - jsoncpp::jsoncpp - zlib-ng::zlib-ng + ll::apr + ll::expat + ll::jsoncpp + ll::zlib-ng ${WINDOWS_LIBRARIES} - boost::boost + ll::boost ${GOOGLE_PERFTOOLS_LIBRARIES} - uriparser::uriparser + ll::uriparser ) set_target_include_dirs( llcommon ${CMAKE_CURRENT_SOURCE_DIR}) @@ -310,7 +305,7 @@ if (LL_TESTS) #set(TEST_DEBUG on) set(test_libs llcommon ${WINDOWS_LIBRARIES} - googlemock::googlemock + ll::googlemock ) LL_ADD_INTEGRATION_TEST(bitpack "" "${test_libs}") LL_ADD_INTEGRATION_TEST(classic_callback "" "${test_libs}") -- cgit v1.2.3 From bb85651d987a6cb969de7dd7c2b130411de6203c Mon Sep 17 00:00:00 2001 From: Nicky Date: Sat, 16 Apr 2022 15:29:02 +0200 Subject: Create a new target ll::oslibrary to link against libs specific to the OS compiled on. This gets rid of the a few OS specific set and uses variables (which some even seemed mostly duplicate like WINDOWS_LIBRARIES ans UI_LIBRARIES) and it also solves the problem of having them to tack on every target, as of no they come as a transitive dependency from llcommon --- indra/llcommon/CMakeLists.txt | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index c934d47cc9..4673630a8e 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -278,21 +278,15 @@ target_link_libraries( ll::expat ll::jsoncpp ll::zlib-ng - ${WINDOWS_LIBRARIES} ll::boost ${GOOGLE_PERFTOOLS_LIBRARIES} ll::uriparser + ll::oslibraries ) set_target_include_dirs( llcommon ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories( llcommon PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ) -if (DARWIN) - include(CMakeFindFrameworks) - find_library(CARBON_LIBRARY Carbon) - target_link_libraries(llcommon ${CARBON_LIBRARY}) -endif (DARWIN) - add_dependencies(llcommon stage_third_party_libs) if (LL_TESTS) @@ -303,10 +297,7 @@ if (LL_TESTS) LL_ADD_PROJECT_UNIT_TESTS(llcommon "${llcommon_TEST_SOURCE_FILES}") #set(TEST_DEBUG on) - set(test_libs llcommon - ${WINDOWS_LIBRARIES} - ll::googlemock - ) + set(test_libs llcommon) LL_ADD_INTEGRATION_TEST(bitpack "" "${test_libs}") LL_ADD_INTEGRATION_TEST(classic_callback "" "${test_libs}") LL_ADD_INTEGRATION_TEST(commonmisc "" "${test_libs}") -- cgit v1.2.3 From 5803625db552900fd54c248c1f41e2f04bf66d62 Mon Sep 17 00:00:00 2001 From: Nicky Date: Sat, 16 Apr 2022 17:18:38 +0200 Subject: Remove undefined variable GOOGLE_PERFTOOLS_LIBRARIES --- indra/llcommon/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 4673630a8e..11849c3766 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -279,7 +279,6 @@ target_link_libraries( ll::jsoncpp ll::zlib-ng ll::boost - ${GOOGLE_PERFTOOLS_LIBRARIES} ll::uriparser ll::oslibraries ) -- cgit v1.2.3 From 3ac18ad9932b4e2fda8e850bd18a524fb1593520 Mon Sep 17 00:00:00 2001 From: Nicky Date: Sat, 16 Apr 2022 22:08:40 +0200 Subject: Streamline bugsplat target: - Fix usage of bugsplat::bugsplat by using ll::bugsplat - Use bugsplat define by importing target not by using hand crafted magic --- indra/llcommon/CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 11849c3766..d5c57bbeaf 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -247,11 +247,6 @@ set(llcommon_HEADER_FILES set_source_files_properties(${llcommon_HEADER_FILES} PROPERTIES HEADER_FILE_ONLY TRUE) -if (USE_BUGSPLAT) - set_source_files_properties(${llcommon_SOURCE_FILES} - PROPERTIES COMPILE_DEFINITIONS "${BUGSPLAT_DEFINE}") -endif (USE_BUGSPLAT) - list(APPEND llcommon_SOURCE_FILES ${llcommon_HEADER_FILES}) if(LLCOMMON_LINK_SHARED) @@ -275,6 +270,7 @@ endif(LLCOMMON_LINK_SHARED) target_link_libraries( llcommon ll::apr + ll::bugsplat ll::expat ll::jsoncpp ll::zlib-ng -- cgit v1.2.3 From e0cf0cdfd49e5a946dcd202a083fb23f01e4f1fe Mon Sep 17 00:00:00 2001 From: Nicky Date: Sun, 17 Apr 2022 18:04:57 +0200 Subject: Switch to target_include_directories All 3Ps include dirs are treated as SYSTEM, this will stop compilers stop emitting warnings from those files and greatly helps having high warning levels and not being swamped by warnings that come from external libraries. --- indra/llcommon/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index d5c57bbeaf..61d6196f50 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -279,7 +279,7 @@ target_link_libraries( ll::oslibraries ) -set_target_include_dirs( llcommon ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories( llcommon INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories( llcommon PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ) add_dependencies(llcommon stage_third_party_libs) -- cgit v1.2.3 From 1966d837e196f1ef043ee46666a9f661d6f54db1 Mon Sep 17 00:00:00 2001 From: Nicky Date: Mon, 18 Apr 2022 02:50:43 +0200 Subject: jsoncpp includepath should not include json/. jsoncpp includes a header "features.h" which has the same name as a glibc header, allowing this header to be found without any prefix will lead to head conflicts when there is a '#include "features.h"' As a result all json headers need to be included via #include "json/reader.h"/"json/writer.h" --- indra/llcommon/llsdjson.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/llsdjson.h b/indra/llcommon/llsdjson.h index 2be7112404..e56cf03b45 100644 --- a/indra/llcommon/llsdjson.h +++ b/indra/llcommon/llsdjson.h @@ -34,7 +34,7 @@ #include "stdtypes.h" #include "llsd.h" -#include "value.h" +#include "json/value.h" /// Convert a parsed JSON structure into LLSD maintaining member names and /// array indexes. -- cgit v1.2.3 From 7a66e77694743c5806c1c161b5764e1e3dda9153 Mon Sep 17 00:00:00 2001 From: Nicky Date: Mon, 18 Apr 2022 03:44:09 +0200 Subject: Remove some remnants of breakpad. --- indra/llcommon/llapp.cpp | 43 ------------------------------------------- 1 file changed, 43 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/llapp.cpp b/indra/llcommon/llapp.cpp index 8ddd132793..3ff8d16bbb 100644 --- a/indra/llcommon/llapp.cpp +++ b/indra/llcommon/llapp.cpp @@ -68,10 +68,6 @@ void setup_signals(); void default_unix_signal_handler(int signum, siginfo_t *info, void *); #if LL_LINUX -#include "google_breakpad/minidump_descriptor.h" -static bool unix_minidump_callback(const google_breakpad::MinidumpDescriptor& minidump_desc, - void* context, - bool succeeded); #else // Called by breakpad exception handler after the minidump has been generated. bool unix_post_minidump_callback(const char *dump_dir, @@ -856,47 +852,8 @@ void default_unix_signal_handler(int signum, siginfo_t *info, void *) } #if LL_LINUX -bool unix_minidump_callback(const google_breakpad::MinidumpDescriptor& minidump_desc, void* context, bool succeeded) -{ - // Copy minidump file path into fixed buffer in the app instance to avoid - // heap allocations in a crash handler. - - // path format: /.dmp - - //HACK: *path points to the buffer in getMiniDumpFilename which has already allocated space - //to avoid doing allocation during crash. - char * path = LLApp::instance()->getMiniDumpFilename(); - int dir_path_len = strlen(path); - - // The path must not be truncated. - S32 remaining = LLApp::MAX_MINDUMP_PATH_LENGTH - dir_path_len; - - llassert( (remaining - strlen(minidump_desc.path())) > 5); - - path += dir_path_len; - - if (dir_path_len > 0 && path[-1] != '/') - { - *path++ = '/'; - --remaining; - } - - strncpy(path, minidump_desc.path(), remaining); - - LL_INFOS("CRASHREPORT") << "generated minidump: " << LLApp::instance()->getMiniDumpFilename() << LL_ENDL; - LLApp::runErrorHandler(); - -#ifndef LL_RELEASE_FOR_DOWNLOAD - clear_signals(); - return false; -#else - return true; #endif -} -#endif - - bool unix_post_minidump_callback(const char *dump_dir, const char *minidump_id, void *context, bool succeeded) -- cgit v1.2.3 From 283c2a20cc4ef856076d287303c7143332b201fe Mon Sep 17 00:00:00 2001 From: Nicky Date: Sun, 1 May 2022 00:38:40 +0200 Subject: Remove setting of HEADER_FILE_ONLY on .h* files, cmake automatically sets the property on those. --- indra/llcommon/CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 61d6196f50..f3e4f7f7f9 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -244,9 +244,6 @@ set(llcommon_HEADER_FILES StackWalker.h ) -set_source_files_properties(${llcommon_HEADER_FILES} - PROPERTIES HEADER_FILE_ONLY TRUE) - list(APPEND llcommon_SOURCE_FILES ${llcommon_HEADER_FILES}) if(LLCOMMON_LINK_SHARED) -- cgit v1.2.3 From 767464a2627036e8a16ac323c886e0a1712e0a5f Mon Sep 17 00:00:00 2001 From: Nicky Date: Sat, 7 May 2022 02:19:51 +0200 Subject: Adapt gnerator expression usage to work on OSX. --- indra/llcommon/CMakeLists.txt | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index f3e4f7f7f9..832ff105f6 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -246,23 +246,7 @@ set(llcommon_HEADER_FILES list(APPEND llcommon_SOURCE_FILES ${llcommon_HEADER_FILES}) -if(LLCOMMON_LINK_SHARED) - add_library (llcommon SHARED ${llcommon_SOURCE_FILES}) - if(NOT ADDRESS_SIZE EQUAL 32) - if(WINDOWS) - ##add_definitions(/FIXED:NO) - else(WINDOWS) # not windows therefore gcc LINUX and DARWIN - add_definitions(-fPIC) - endif(WINDOWS) - endif(NOT ADDRESS_SIZE EQUAL 32) - if(WINDOWS) - # always generate llcommon.pdb, even for "Release" builds - set_target_properties(llcommon PROPERTIES LINK_FLAGS "/DEBUG") - endif(WINDOWS) - ll_stage_sharedlib(llcommon) -else(LLCOMMON_LINK_SHARED) - add_library (llcommon ${llcommon_SOURCE_FILES}) -endif(LLCOMMON_LINK_SHARED) +add_library (llcommon ${llcommon_SOURCE_FILES}) target_link_libraries( llcommon -- cgit v1.2.3 From c0f709b637d800fe07fb265c8ab6f28080994224 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Sat, 18 Jun 2022 11:53:57 -0400 Subject: DRTVWR-564: Add LL::apply(): call function, passing args from tuple. This anticipates C++17's std::apply(), and in fact once we detect C++17, we'll just use that. But in C++14 we must still provide our own implementation. (cherry picked from commit dc2e2cd76f387ea6e80787fb94adcbc269cd1f25) --- indra/llcommon/apply.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 indra/llcommon/apply.h (limited to 'indra/llcommon') diff --git a/indra/llcommon/apply.h b/indra/llcommon/apply.h new file mode 100644 index 0000000000..ef4a8fd68b --- /dev/null +++ b/indra/llcommon/apply.h @@ -0,0 +1,51 @@ +/** + * @file apply.h + * @author Nat Goodspeed + * @date 2022-06-18 + * @brief C++14 version of std::apply() + * + * $LicenseInfo:firstyear=2022&license=viewerlgpl$ + * Copyright (c) 2022, Linden Research, Inc. + * $/LicenseInfo$ + */ + +#if ! defined(LL_APPLY_H) +#define LL_APPLY_H + +#include + +namespace LL +{ + +#if __cplusplus >= 201703L + +// C++17 implementation +using std::apply; + +#else // C++14 + +// Derived from https://stackoverflow.com/a/20441189 +// and https://en.cppreference.com/w/cpp/utility/apply +template +auto apply_impl(CALLABLE&& func, TUPLE&& args, std::index_sequence) +{ + // call func(unpacked args) + return std::forward(func)(std::move(std::get(args))...); +} + +template +auto apply(CALLABLE&& func, std::tuple&& args) +{ + // std::index_sequence_for is the magic sauce here, generating an argument + // pack of indexes for each entry in args. apply_impl() can then pass + // those to std::get() to unpack args into individual arguments. + return apply_impl(std::forward(func), + std::forward>(args), + std::index_sequence_for{}); +} + +#endif // C++14 + +} // namespace LL + +#endif /* ! defined(LL_APPLY_H) */ -- cgit v1.2.3 From 15d37713b9113a6f70dde48c764df02c76e18cbc Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 22 Aug 2022 21:00:42 -0400 Subject: DRTVWR-558: Fix builds on macOS 12.5 Monterey. Always search for python3[.exe] instead of plain 'python'. macOS Monterey no longer bundles Python 2 at all. Explicitly make PYTHON_EXECUTABLE a cached value so if the user edits it in CMakeCache.txt, it won't be overwritten by indra/cmake/Python.cmake. Do NOT set DYLD_LIBRARY_PATH for test executables! That has Bad Effects, as discussed in https://stackoverflow.com/q/73418423/5533635. Instead, create symlinks from build-mumble/sharedlibs/Resources -> Release/Resources and from build-mumble/test/Resources -> ../sharedlibs/Release/Resources. For test executables in sharedlibs/RelWithDebInfo and test/RelWithDebInfo, this supports our dylibs' baked-in load path @executable_path/../Resources. That load path assumes running in a standard app bundle (which the viewer in fact does), but we've been avoiding creating an app bundle for every test program. These symlinks allow us to continue doing that while avoiding DYLD_LIBRARY_PATH. Add indra/llcommon/apply.h. The LL::apply() function and its wrapper macro VAPPLY were very useful in diagnosing the problem. Tweak llleap_test.cpp. This source was modified extensively for diagnostic purposes; these are the small improvements that remain. --- indra/llcommon/apply.h | 68 ++++++++++++++++++++++++++++++++++-- indra/llcommon/tests/llleap_test.cpp | 14 +++----- 2 files changed, 71 insertions(+), 11 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/apply.h b/indra/llcommon/apply.h index ef4a8fd68b..7c58d63bc0 100644 --- a/indra/llcommon/apply.h +++ b/indra/llcommon/apply.h @@ -12,11 +12,48 @@ #if ! defined(LL_APPLY_H) #define LL_APPLY_H +#include #include namespace LL { +/** + * USAGE NOTE: + * https://stackoverflow.com/a/40523474/5533635 + * + * If you're trying to pass apply() a variadic function, the compiler + * complains that it can't deduce the callable type, presumably because it + * doesn't know which arity to reify to pass. + * + * But it works to wrap the variadic function in a generic lambda, e.g.: + * + * @CODE + * LL::apply( + * [](auto&&... args) + * { + * return variadic(std::forward(args)...); + * }, + * args); + * @ENDCODE + * + * Presumably this is because there's only one instance of the generic lambda + * @em type, with a variadic operator()(). + * + * It's pointless to provide a wrapper @em function that implicitly supplies + * the generic lambda. You couldn't pass your variadic function to our wrapper + * function, for the same original reason! + * + * Instead we provide a wrapper @em macro. Sorry, Dr. Stroustrup. + */ +#define VAPPLY(FUNC, ARGS) \ + LL::apply( \ + [](auto&&... args) \ + { \ + return (FUNC)(std::forward(args)...); \ + }, \ + (ARGS)) + #if __cplusplus >= 201703L // C++17 implementation @@ -34,16 +71,43 @@ auto apply_impl(CALLABLE&& func, TUPLE&& args, std::index_sequence) } template -auto apply(CALLABLE&& func, std::tuple&& args) +auto apply(CALLABLE&& func, const std::tuple& args) { // std::index_sequence_for is the magic sauce here, generating an argument // pack of indexes for each entry in args. apply_impl() can then pass // those to std::get() to unpack args into individual arguments. return apply_impl(std::forward(func), - std::forward>(args), + args, std::index_sequence_for{}); } +// per https://stackoverflow.com/a/57510428/5533635 +template +auto apply(CALLABLE&& func, const std::array& args) +{ + return apply(std::forward(func), std::tuple_cat(args)); +} + +// per https://stackoverflow.com/a/28411055/5533635 +template +auto apply_impl(CALLABLE&& func, const std::vector& args, std::index_sequence) +{ + return apply_impl(std::forward(func), + std::make_tuple(std::forward(args[I])...), + I...); +} + +// this goes beyond C++17 std::apply() +template +auto apply(CALLABLE&& func, const std::vector& args) +{ + constexpr auto arity = boost::function_traits::arity; + assert(args.size() == arity); + return apply_impl(std::forward(func), + args, + std::make_index_sequence()); +} + #endif // C++14 } // namespace LL diff --git a/indra/llcommon/tests/llleap_test.cpp b/indra/llcommon/tests/llleap_test.cpp index 9754353ab0..25db4b6542 100644 --- a/indra/llcommon/tests/llleap_test.cpp +++ b/indra/llcommon/tests/llleap_test.cpp @@ -15,10 +15,11 @@ #include "llleap.h" // STL headers // std headers +#include // external library headers +//#include #include #include -#include // other Linden headers #include "../test/lltut.h" #include "../test/namedtempfile.h" @@ -29,7 +30,6 @@ #include "llstring.h" #include "stringize.h" #include "StringVec.h" -#include using boost::assign::list_of; @@ -110,11 +110,6 @@ namespace tut "import os\n" "import sys\n" "\n" - // Don't forget that this Python script is written to some - // temp directory somewhere! Its __file__ is useless in - // finding indra/lib/python. Use our __FILE__, with - // raw-string syntax to deal with Windows pathnames. - "mydir = os.path.dirname(r'" << __FILE__ << "')\n" "from llbase import llsd\n" "\n" "class ProtocolError(Exception):\n" @@ -241,9 +236,10 @@ namespace tut "import sys\n" "sys.stderr.write('''Hello from Python!\n" "note partial line''')\n"); + StringVec vcommand{ PYTHON, script.getName() }; +// std::string command{ boost::algorithm::join(vcommand, " ") }; CaptureLog log(LLError::LEVEL_INFO); - waitfor(LLLeap::create(get_test_name(), - sv(list_of(PYTHON)(script.getName())))); + waitfor(LLLeap::create(get_test_name(), vcommand)); log.messageWith("Hello from Python!"); log.messageWith("note partial line"); } -- cgit v1.2.3 From 2c95174031ecf3970bee685d90c3e2469cd15254 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 23 Aug 2022 17:23:40 -0400 Subject: DRTVWR-558: Remove references to string join() per code review. --- indra/llcommon/tests/llleap_test.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/tests/llleap_test.cpp b/indra/llcommon/tests/llleap_test.cpp index 25db4b6542..daa84df792 100644 --- a/indra/llcommon/tests/llleap_test.cpp +++ b/indra/llcommon/tests/llleap_test.cpp @@ -17,7 +17,6 @@ // std headers #include // external library headers -//#include #include #include // other Linden headers @@ -237,7 +236,6 @@ namespace tut "sys.stderr.write('''Hello from Python!\n" "note partial line''')\n"); StringVec vcommand{ PYTHON, script.getName() }; -// std::string command{ boost::algorithm::join(vcommand, " ") }; CaptureLog log(LLError::LEVEL_INFO); waitfor(LLLeap::create(get_test_name(), vcommand)); log.messageWith("Hello from Python!"); -- cgit v1.2.3 From 592abc460c96b63b1b1e0d15914f7b64a0c88038 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 26 Aug 2022 22:49:16 -0400 Subject: DRTVWR-568: More cleanup of deleted obsolete std library features. --- indra/llcommon/llsd.h | 12 +++--- indra/llcommon/llstl.h | 81 +++++++++++++++++------------------- indra/llcommon/tests/llleap_test.cpp | 2 +- 3 files changed, 45 insertions(+), 50 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/llsd.h b/indra/llcommon/llsd.h index 24cb9bbce1..3daaef44fc 100644 --- a/indra/llcommon/llsd.h +++ b/indra/llcommon/llsd.h @@ -421,42 +421,42 @@ public: static std::string typeString(Type type); // Return human-readable type as a string }; -struct llsd_select_bool : public std::unary_function +struct llsd_select_bool { LLSD::Boolean operator()(const LLSD& sd) const { return sd.asBoolean(); } }; -struct llsd_select_integer : public std::unary_function +struct llsd_select_integer { LLSD::Integer operator()(const LLSD& sd) const { return sd.asInteger(); } }; -struct llsd_select_real : public std::unary_function +struct llsd_select_real { LLSD::Real operator()(const LLSD& sd) const { return sd.asReal(); } }; -struct llsd_select_float : public std::unary_function +struct llsd_select_float { F32 operator()(const LLSD& sd) const { return (F32)sd.asReal(); } }; -struct llsd_select_uuid : public std::unary_function +struct llsd_select_uuid { LLSD::UUID operator()(const LLSD& sd) const { return sd.asUUID(); } }; -struct llsd_select_string : public std::unary_function +struct llsd_select_string { LLSD::String operator()(const LLSD& sd) const { diff --git a/indra/llcommon/llstl.h b/indra/llcommon/llstl.h index a90c2c7e08..25131291f9 100644 --- a/indra/llcommon/llstl.h +++ b/indra/llcommon/llstl.h @@ -142,7 +142,7 @@ struct DeletePairedPointerArray // llselect2nd())); template -struct DeletePointerFunctor : public std::unary_function +struct DeletePointerFunctor { bool operator()(T* ptr) const { @@ -153,7 +153,7 @@ struct DeletePointerFunctor : public std::unary_function // See notes about DeleteArray for why you should consider avoiding this. template -struct DeleteArrayFunctor : public std::unary_function +struct DeleteArrayFunctor { bool operator()(T* ptr) const { @@ -395,16 +395,17 @@ OutputIter ll_transform_n( // select... with the stl. Look up usage on the sgi website. template -struct _LLSelect1st : public std::unary_function<_Pair, typename _Pair::first_type> { - const typename _Pair::first_type& operator()(const _Pair& __x) const { +struct _LLSelect1st +{ + const auto& operator()(const _Pair& __x) const { return __x.first; } }; template -struct _LLSelect2nd : public std::unary_function<_Pair, typename _Pair::second_type> +struct _LLSelect2nd { - const typename _Pair::second_type& operator()(const _Pair& __x) const { + const auto& operator()(const _Pair& __x) const { return __x.second; } }; @@ -416,9 +417,7 @@ template struct llselect2nd : public _LLSelect2nd<_Pair> {}; // compose... with the stl. Look up usage on the sgi website. template -class ll_unary_compose : - public std::unary_function +class ll_unary_compose { protected: _Operation1 __op1; @@ -426,8 +425,9 @@ protected: public: ll_unary_compose(const _Operation1& __x, const _Operation2& __y) : __op1(__x), __op2(__y) {} - typename _Operation1::result_type - operator()(const typename _Operation2::argument_type& __x) const { + template + auto + operator()(const _Op2Arg& __x) const { return __op1(__op2(__x)); } }; @@ -441,8 +441,7 @@ llcompose1(const _Operation1& __op1, const _Operation2& __op2) template class ll_binary_compose - : public std::unary_function { +{ protected: _Operation1 _M_op1; _Operation2 _M_op2; @@ -451,8 +450,9 @@ public: ll_binary_compose(const _Operation1& __x, const _Operation2& __y, const _Operation3& __z) : _M_op1(__x), _M_op2(__y), _M_op3(__z) { } - typename _Operation1::result_type - operator()(const typename _Operation2::argument_type& __x) const { + template + auto + operator()(const OP2ARG& __x) const { return _M_op1(_M_op2(__x), _M_op3(__x)); } }; @@ -468,54 +468,51 @@ llcompose2(const _Operation1& __op1, const _Operation2& __op2, // helpers to deal with the fact that MSDev does not package // bind... with the stl. Again, this is from sgi. -template -class llbinder1st : - public std::unary_function { +template +class llbinder1st +{ protected: _Operation op; - typename _Operation::first_argument_type value; + _Arg1 value; public: - llbinder1st(const _Operation& __x, - const typename _Operation::first_argument_type& __y) + llbinder1st(const _Operation& __x, const _Arg1& __y) : op(__x), value(__y) {} - typename _Operation::result_type - operator()(const typename _Operation::second_argument_type& __x) const { - return op(value, __x); - } + template + auto + operator()(const _Arg2& __x) const { + return op(value, __x); + } }; template -inline llbinder1st<_Operation> +inline auto llbind1st(const _Operation& __oper, const _Tp& __x) { - typedef typename _Operation::first_argument_type _Arg1_type; - return llbinder1st<_Operation>(__oper, _Arg1_type(__x)); + return llbinder1st<_Operation, _Tp>(__oper, __x); } -template +template class llbinder2nd - : public std::unary_function { +{ protected: _Operation op; - typename _Operation::second_argument_type value; + _Arg2 value; public: llbinder2nd(const _Operation& __x, - const typename _Operation::second_argument_type& __y) + const _Arg2& __y) : op(__x), value(__y) {} - typename _Operation::result_type - operator()(const typename _Operation::first_argument_type& __x) const { + template + auto + operator()(const _Arg1& __x) const { return op(__x, value); } }; template -inline llbinder2nd<_Operation> +inline auto llbind2nd(const _Operation& __oper, const _Tp& __x) { - typedef typename _Operation::second_argument_type _Arg2_type; - return llbinder2nd<_Operation>(__oper, _Arg2_type(__x)); + return llbinder2nd<_Operation, _Tp>(__oper, __x); } /** @@ -548,8 +545,7 @@ bool before(const std::type_info* lhs, const std::type_info* rhs) namespace std { template <> - struct less: - public std::binary_function + struct less { bool operator()(const std::type_info* lhs, const std::type_info* rhs) const { @@ -558,8 +554,7 @@ namespace std }; template <> - struct less: - public std::binary_function + struct less { bool operator()(std::type_info* lhs, std::type_info* rhs) const { diff --git a/indra/llcommon/tests/llleap_test.cpp b/indra/llcommon/tests/llleap_test.cpp index daa84df792..7ee36a9ea6 100644 --- a/indra/llcommon/tests/llleap_test.cpp +++ b/indra/llcommon/tests/llleap_test.cpp @@ -525,7 +525,7 @@ namespace tut result.ensure(); } - struct TestLargeMessage: public std::binary_function + struct TestLargeMessage { TestLargeMessage(const std::string& PYTHON_, const std::string& reader_module_, const std::string& test_name_): -- cgit v1.2.3 From c7366f4c55c6442414eb6c5a6736baf90f1a4700 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Sat, 17 Sep 2022 02:09:04 +0300 Subject: SL-17238 Fix coding policy build issues --- indra/llcommon/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 8625060720..b576cdc1e1 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -268,8 +268,7 @@ target_link_libraries( ll::boost ll::uriparser ll::oslibraries - ll::tracy - + ll::tracy ) target_include_directories( llcommon INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) -- cgit v1.2.3 From 069ccb30241716403c2de2d2d1faad62720917a3 Mon Sep 17 00:00:00 2001 From: Nicky Date: Sun, 23 Oct 2022 20:04:32 +0200 Subject: Remove ll::bugsplat as a llcommon depencency In theory it is fine to do that, in practice it does break gatekeeper in subtle ways due to https://developer.apple.com/library/archive/technotes/tn2206/_index.html#//apple_ref/doc/uid/DTS40007919-CH1-TNTAG207 Having bugsplat linked to all executables results in executables with an embedded rpath that is invalid for Gatekeeper. Luckily it shows this is in the worst possible way. The viewer cannot be started with a non helpful message of teh viewer being unable to verified. While at the same time spctl and codesign both show no errors at all. --- indra/llcommon/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index b576cdc1e1..56939584bb 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -261,7 +261,6 @@ add_library (llcommon ${llcommon_SOURCE_FILES}) target_link_libraries( llcommon ll::apr - ll::bugsplat ll::expat ll::jsoncpp ll::zlib-ng -- cgit v1.2.3