Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 1B744200C24 for ; Thu, 23 Feb 2017 16:22:21 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 1A25B160B64; Thu, 23 Feb 2017 15:22:21 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3DB98160B50 for ; Thu, 23 Feb 2017 16:22:20 +0100 (CET) Received: (qmail 31230 invoked by uid 500); 23 Feb 2017 15:22:19 -0000 Mailing-List: contact commits-help@geode.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.apache.org Delivered-To: mailing list commits@geode.apache.org Received: (qmail 31220 invoked by uid 99); 23 Feb 2017 15:22:19 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Feb 2017 15:22:19 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3EDB7DFE8F; Thu, 23 Feb 2017 15:22:19 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jbarrett@apache.org To: commits@geode.apache.org Date: Thu, 23 Feb 2017 15:22:20 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/2] geode-native git commit: GEODE-2508: Fixes for Windows + suggested changes archived-at: Thu, 23 Feb 2017 15:22:21 -0000 GEODE-2508: Fixes for Windows + suggested changes - removed dead code - reworked algo for dll finding to be modern c++ - clean up of CMakeList.txt file This closes #24. Project: http://git-wip-us.apache.org/repos/asf/geode-native/repo Commit: http://git-wip-us.apache.org/repos/asf/geode-native/commit/c45b7895 Tree: http://git-wip-us.apache.org/repos/asf/geode-native/tree/c45b7895 Diff: http://git-wip-us.apache.org/repos/asf/geode-native/diff/c45b7895 Branch: refs/heads/develop Commit: c45b7895d91bbace062b26061aae1b50b484ab6c Parents: 90f7514 Author: Ernie Burghardt Authored: Wed Feb 22 22:29:56 2017 +0000 Committer: Jacob Barrett Committed: Thu Feb 23 07:14:56 2017 -0800 ---------------------------------------------------------------------- src/clicache/src/CMakeLists.txt | 2 +- src/cppcache/src/CMakeLists.txt | 4 ++- src/cppcache/src/CppCacheLibrary.cpp | 47 +++++++++++-------------------- src/cppcache/src/dllmain.cpp | 40 ++++++-------------------- 4 files changed, 29 insertions(+), 64 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/geode-native/blob/c45b7895/src/clicache/src/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/src/clicache/src/CMakeLists.txt b/src/clicache/src/CMakeLists.txt index 6b73dd7..80b0c1c 100644 --- a/src/clicache/src/CMakeLists.txt +++ b/src/clicache/src/CMakeLists.txt @@ -56,7 +56,7 @@ include_directories(${CMAKE_SOURCE_DIR}/clicache/src) include_directories(${CMAKE_SOURCE_DIR}/cppcache/src) set_target_properties(Apache.Geode PROPERTIES - OUTPUT_NAME Apache.Geode + OUTPUT_NAME ${PRODUCT_DLL_NAME} VS_DOTNET_TARGET_FRAMEWORK_VERSION "v4.5.2" VS_DOTNET_REFERENCES "System;System.Xml") http://git-wip-us.apache.org/repos/asf/geode-native/blob/c45b7895/src/cppcache/src/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/src/cppcache/src/CMakeLists.txt b/src/cppcache/src/CMakeLists.txt index 5095f4d..5a64d8a 100644 --- a/src/cppcache/src/CMakeLists.txt +++ b/src/cppcache/src/CMakeLists.txt @@ -125,7 +125,9 @@ target_include_directories(apache-geode $ ) add_dependencies(client-libraries apache-geode) -set_target_properties(apache-geode PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}" OUTPUT_NAME ${PRODUCT_LIB_NAME} ) +set_target_properties(apache-geode PROPERTIES + PUBLIC_HEADER "${PUBLIC_HEADERS}" + OUTPUT_NAME ${PRODUCT_LIB_NAME}) add_library(apache-geode-static STATIC ${SOURCES_ALL}) target_link_libraries(apache-geode-static http://git-wip-us.apache.org/repos/asf/geode-native/blob/c45b7895/src/cppcache/src/CppCacheLibrary.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/CppCacheLibrary.cpp b/src/cppcache/src/CppCacheLibrary.cpp index 4764d74..93c0fec 100644 --- a/src/cppcache/src/CppCacheLibrary.cpp +++ b/src/cppcache/src/CppCacheLibrary.cpp @@ -117,42 +117,35 @@ std::string CppCacheLibrary::getProductLibDir(const char* addon) { // return the directory where the library/DLL resides std::string CppCacheLibrary::getProductLibDir() { // otherwise... get the DLL path, and work backwards from it. - char path[PATH_MAX + 1]; - char* dllNamePtr; + char buffer[PATH_MAX + 1]; + buffer[0] = '\0'; + DllMainGetPath(buffer, PATH_MAX); - path[0] = '\0'; - DllMainGetPath(path, PATH_MAX); + std::string path(buffer); + fprintf(stderr, "MOOF: %s\n", path.c_str()); + std::string::size_type pos = std::string::npos; #ifdef WIN32 - // windows paths are case insensitive - for (int i = 0; i < PATH_MAX && path[i] != 0; i++) { - path[i] = ::tolower(path[i]); - } std::string cppName = PRODUCT_LIB_NAME; cppName += ".dll"; - std::string dotNetName = PRODUCT_DLL_NAME; - dotNetName += ".dll"; - dllNamePtr = strstr(path, cppName.c_str()); - if (dllNamePtr == NULL) { - dllNamePtr = strstr(path, dotNetName.c_str()); + pos = path.find(cppName); + if (std::string::npos == pos) { + std::string dotNetName = PRODUCT_DLL_NAME; + dotNetName += ".dll"; + pos = path.find(dotNetName); } #else std::string cppName = "lib"; cppName += PRODUCT_LIB_NAME; - dllNamePtr = strstr(path, cppName.c_str()); + pos = path.find(cppName); #endif - std::string libDir; - if (dllNamePtr != NULL) { - dllNamePtr--; - // null terminate at the directory containing the library. - *dllNamePtr = '\0'; - libDir = path; + if (0 < pos) { + return path.substr(0, --pos); } - return libDir; + return std::string(); } std::string CppCacheLibrary::getProductDir() { // If the environment variable is set, use it. - // char * gfcppenv = ACE_OS::getenv( "GFCPP" ); std::string gfcppenv = Utils::getEnv("GFCPP"); if (gfcppenv.length() > 0) { return gfcppenv; @@ -205,13 +198,5 @@ std::string CppCacheLibrary::getProductDir() { } else { return libdirname; } - /* Bug 728 fix - don't fail here, rather assume user installs product - manually in place. - fprintf(stderr, "Cannot determine location of product directory.\n" - "Please set GFCPP environment variable.\n"); - fflush(stderr); - throw apache::geode::client::IllegalStateException("Product installation - directory " - "not found. Please set GFCPP environment variable."); - */ + } http://git-wip-us.apache.org/repos/asf/geode-native/blob/c45b7895/src/cppcache/src/dllmain.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/dllmain.cpp b/src/cppcache/src/dllmain.cpp index d7d9854..a930c92 100644 --- a/src/cppcache/src/dllmain.cpp +++ b/src/cppcache/src/dllmain.cpp @@ -25,6 +25,9 @@ #include #include +#include +#include "config.h" + void initLibDllEntry(void); extern "C" { @@ -64,12 +67,13 @@ LIBEXP void DllMainGetPath(char *result, int maxLen) { result[0] = '\0'; return; } - HMODULE module = GetModuleHandle("apache-geode.dll"); + std::string cppLibName = PRODUCT_LIB_NAME; + cppLibName += ".dll"; + std::string dotNetLibName = PRODUCT_DLL_NAME; + dotNetLibName += ".dll"; + HMODULE module = GetModuleHandle(cppLibName.c_str()); if (module == 0) { - module = GetModuleHandle("apache-geode_g.dll"); - if (module == 0) { - module = GetModuleHandle("Apache.Geode.dll"); - } + module = GetModuleHandle(dotNetLibName.c_str()); } if (module != 0) { GetModuleFileName(module, result, maxLen); @@ -113,33 +117,7 @@ void setDefaultNewAndDelete() { Utils::s_pDelete = (pDelete)&free; // operator delete; } -/* -void setDefaultNewAndDelete_disabled() -{ - HMODULE hModule = GetModuleHandle("msvcrtd"); - - if (!hModule) hModule = GetModuleHandle("msvcrt"); - - if (hModule) - { - // 32-bit versions - Utils::s_pNew = (pNew) GetProcAddress(hModule, "??2@YAPAXI@Z"); - Utils::s_pDelete = (pDelete) GetProcAddress(hModule, "??3@YAXPAX@Z"); - if (Utils::s_pNew && Utils::s_pDelete) return; - - // 64-bit versions - Utils::s_pNew = (pNew) GetProcAddress(hModule, "??2@YAPEAX_K@Z"); - Utils::s_pDelete = (pDelete) GetProcAddress(hModule, "??3@YAXPEAX@Z"); - } - - if (!Utils::s_pNew || !Utils::s_pDelete) - { - throw IllegalStateException("Could not set default new and delete -operators."); - } -} -*/ } } }