mirror of https://gitee.com/bigwinds/arangodb
fix locating of relative ICU files
This commit is contained in:
parent
f1da0c54f6
commit
a3ac94d3b2
|
@ -28,7 +28,7 @@ void IcuInitializer::setup(char const* path) {
|
|||
initialized = true;
|
||||
std::string p;
|
||||
std::string binaryPath = TRI_LocateBinaryPath(path);
|
||||
icuDataPtr = arangodb::LanguageFeature::prepareIcu(SBIN_DIRECTORY, binaryPath, p);
|
||||
icuDataPtr = arangodb::LanguageFeature::prepareIcu(TEST_DIRECTORY, binaryPath, p, "basics_suite");
|
||||
if (icuDataPtr == nullptr ||
|
||||
!arangodb::basics::Utf8Helper::DefaultUtf8Helper.setCollatorLanguage("", icuDataPtr)) {
|
||||
std::string msg =
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
include_directories(.)
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/tests/")
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${CMAKE_TEST_DIRECTORY}")
|
||||
|
||||
################################################################################
|
||||
## basics_suite
|
||||
|
|
|
@ -41,6 +41,8 @@ FILE(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/var/log/${CMAKE_PROJECT_NAME}")
|
|||
|
||||
set(INSTALL_ICU_DT_DEST "${CMAKE_INSTALL_DATAROOTDIR}/${CMAKE_PROJECT_NAME}")
|
||||
|
||||
set(CMAKE_TEST_DIRECTORY "tests")
|
||||
|
||||
include(InstallMacros)
|
||||
# install ----------------------------------------------------------------------
|
||||
install(DIRECTORY ${PROJECT_SOURCE_DIR}/Documentation/man/
|
||||
|
@ -173,6 +175,7 @@ to_native_path("ICU_DT_DEST")
|
|||
to_native_path("CMAKE_INSTALL_SBINDIR")
|
||||
to_native_path("CMAKE_INSTALL_BINDIR")
|
||||
to_native_path("INSTALL_ICU_DT_DEST")
|
||||
to_native_path("CMAKE_TEST_DIRECTORY")
|
||||
|
||||
configure_file (
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/lib/Basics/directories.h.in"
|
||||
|
|
|
@ -58,7 +58,7 @@ void LanguageFeature::collectOptions(
|
|||
new StringParameter(&_language));
|
||||
}
|
||||
|
||||
void* LanguageFeature::prepareIcu(std::string const& binaryPath, std::string const& binaryExecutionPath, std::string& path) {
|
||||
void* LanguageFeature::prepareIcu(std::string const& binaryPath, std::string const& binaryExecutionPath, std::string& path, std::string const& binaryName) {
|
||||
char const* icuDataEnv = getenv("ICU_DATA");
|
||||
|
||||
std::string fn("icudtl.dat");
|
||||
|
@ -71,6 +71,7 @@ void* LanguageFeature::prepareIcu(std::string const& binaryPath, std::string con
|
|||
LOG(WARN) << "failed to locate '" << fn << "' at '"<< path << "'";
|
||||
}
|
||||
std::string bpfn = binaryExecutionPath + TRI_DIR_SEPARATOR_STR + fn;
|
||||
|
||||
if (TRI_IsRegularFile(fn.c_str())) {
|
||||
path = fn;
|
||||
}
|
||||
|
@ -78,11 +79,8 @@ void* LanguageFeature::prepareIcu(std::string const& binaryPath, std::string con
|
|||
path = bpfn;
|
||||
}
|
||||
else {
|
||||
#if _WIN32
|
||||
path = TRI_LocateInstallDirectory(binaryPath.c_str());
|
||||
#else
|
||||
path = TRI_DIR_SEPARATOR_STR;
|
||||
#endif
|
||||
std::string argv_0 = binaryExecutionPath + TRI_DIR_SEPARATOR_STR + binaryName;
|
||||
path = TRI_LocateInstallDirectory(argv_0.c_str(), binaryPath.c_str());
|
||||
path += ICU_DESTINATION_DIRECTORY TRI_DIR_SEPARATOR_STR + fn;
|
||||
}
|
||||
if (!TRI_IsRegularFile(path.c_str())) {
|
||||
|
@ -112,7 +110,8 @@ void LanguageFeature::prepare() {
|
|||
std::string p;
|
||||
auto context = ArangoGlobalContext::CONTEXT;
|
||||
std::string binaryExecutionPath = context->getBinaryPath();
|
||||
_icuDataPtr = LanguageFeature::prepareIcu(_binaryPath, binaryExecutionPath, p);
|
||||
std::string binaryName = context->binaryName();
|
||||
_icuDataPtr = LanguageFeature::prepareIcu(_binaryPath, binaryExecutionPath, p, binaryName);
|
||||
|
||||
if (!Utf8Helper::DefaultUtf8Helper.setCollatorLanguage(_language, _icuDataPtr)) {
|
||||
LOG(FATAL) << "error initializing ICU with the contents of '" << p << "'";
|
||||
|
|
|
@ -34,7 +34,7 @@ class LanguageFeature final : public application_features::ApplicationFeature {
|
|||
void collectOptions(std::shared_ptr<options::ProgramOptions>) override final;
|
||||
void prepare() override final;
|
||||
void start() override final;
|
||||
static void* prepareIcu(std::string const& binaryPath, std::string const& binaryExecutionPath, std::string& path);
|
||||
static void* prepareIcu(std::string const& binaryPath, std::string const& binaryExecutionPath, std::string& path, std::string const& binaryName);
|
||||
|
||||
private:
|
||||
std::string _language;
|
||||
|
|
|
@ -5,3 +5,4 @@
|
|||
#define ICU_DESTINATION_DIRECTORY "@INC_INSTALL_ICU_DT_DEST@"
|
||||
#define SBIN_DIRECTORY "@INC_CMAKE_INSTALL_SBINDIR@"
|
||||
#define BIN_DIRECTORY "@INC_CMAKE_INSTALL_BINDIR@"
|
||||
#define TEST_DIRECTORY "@INC_CMAKE_TEST_DIRECTORY@"
|
||||
|
|
|
@ -2370,17 +2370,12 @@ void TRI_SetUserTempPath(std::string const& path) { TempPath = path; }
|
|||
//
|
||||
/// Will always end in a directory separator.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if _WIN32
|
||||
|
||||
std::string TRI_LocateInstallDirectory(char const* binaryPath) {
|
||||
std::string thisPath = TRI_LocateBinaryPath(nullptr);
|
||||
std::string TRI_LocateInstallDirectory(char const* argv_0, char const* binaryPath) {
|
||||
std::string thisPath = TRI_LocateBinaryPath(argv_0);
|
||||
return TRI_GetInstallRoot(thisPath, binaryPath) +
|
||||
std::string(1, TRI_DIR_SEPARATOR_CHAR);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief locates the configuration directory
|
||||
///
|
||||
|
@ -2407,7 +2402,7 @@ char* TRI_LocateConfigDirectory(char const* binaryPath) {
|
|||
|
||||
#elif defined(_SYSCONFDIR_)
|
||||
|
||||
char* TRI_LocateConfigDirectory(const char* binaryPath) {
|
||||
char* TRI_LocateConfigDirectory(char const* binaryPath) {
|
||||
char* v = LocateConfigDirectoryEnv();
|
||||
|
||||
if (v != nullptr) {
|
||||
|
|
|
@ -342,15 +342,13 @@ bool TRI_CopySymlink(std::string const& srcItem, std::string const& dstItem,
|
|||
/// @brief locate the installation directory
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if _WIN32
|
||||
std::string TRI_LocateInstallDirectory(const char* binaryPath);
|
||||
#endif
|
||||
std::string TRI_LocateInstallDirectory(char const* argv_0, const char* binaryPath);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief locate the configuration directory
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
char* TRI_LocateConfigDirectory(const char * binaryPath);
|
||||
char* TRI_LocateConfigDirectory(char const* binaryPath);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get the address of the null buffer
|
||||
|
|
|
@ -93,7 +93,7 @@ std::string arangodb::options::EnvironmentTranslator(std::string const& value,
|
|||
if (v == nullptr) {
|
||||
#if _WIN32
|
||||
if (TRI_EqualString(k.c_str(), "ROOTDIR")) {
|
||||
vv = TRI_LocateInstallDirectory(binaryPath);
|
||||
vv = TRI_LocateInstallDirectory(nullptr, binaryPath);
|
||||
|
||||
if (!vv.empty()) {
|
||||
char c = *(vv.rbegin());
|
||||
|
|
Loading…
Reference in New Issue