fix(server): better support for the --help option (#349)

Co-authored-by: Boaz Sade <boaz@dragonflydb.io>
This commit is contained in:
Boaz Sade 2022-10-03 15:15:15 +03:00 committed by GitHub
parent d2b216077d
commit a1b800e23b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View File

@ -4,7 +4,7 @@ cxx_link(dragonfly base dragonfly_lib)
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND CMAKE_BUILD_TYPE STREQUAL "Release")
# Add core2 only to this file, thus avoiding instructions in this object file that
# can cause SIGILL.
set_source_files_properties(dfly_main.cc PROPERTIES COMPILE_FLAGS -march=core2)
set_source_files_properties(dfly_main.cc PROPERTIES COMPILE_FLAGS -march=core2 COMPILE_DEFINITIONS SOURCE_PATH_FROM_BUILD_ENV=${CMAKE_SOURCE_DIR})
endif()
add_library(dfly_transaction db_slice.cc engine_shard_set.cc blocking_controller.cc common.cc

View File

@ -29,6 +29,13 @@
#include "util/uring/uring_pool.h"
#include "util/varz.h"
#define STRING_PP_NX(A) #A
#define STRING_MAKE_PP(A) STRING_PP_NX(A)
// This would create a string value from a "defined" location of the source code
// Note that SOURCE_PATH_FROM_BUILD_ENV is taken from the build system
#define BUILD_LOCATION_PATH STRING_MAKE_PP(SOURCE_PATH_FROM_BUILD_ENV)
using namespace std;
ABSL_DECLARE_FLAG(uint32_t, port);
@ -92,10 +99,14 @@ bool HelpFlags(std::string_view f) {
}
string NormalizePaths(std::string_view path) {
if (absl::ConsumePrefix(&path, "../src/"))
const std::string FULL_PATH = BUILD_LOCATION_PATH;
const std::string FULL_PATH_SRC = FULL_PATH + "/src";
const std::string FULL_PATH_HELIO = FULL_PATH + "/helio";
if (absl::ConsumePrefix(&path, "../src/") || absl::ConsumePrefix(&path, FULL_PATH_SRC))
return ColoredStr(TermColor::kGreen, path);
if (absl::ConsumePrefix(&path, "../"))
if (absl::ConsumePrefix(&path, "../") || absl::ConsumePrefix(&path, FULL_PATH_HELIO))
return ColoredStr(TermColor::kYellow, path);
if (absl::ConsumePrefix(&path, "_deps/"))