geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbarr...@apache.org
Subject [2/2] geode-native git commit: GEODE-2508: Fixes for Windows + suggested changes
Date Thu, 23 Feb 2017 15:22:20 GMT
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 <eburghardt@pivotal.io>
Authored: Wed Feb 22 22:29:56 2017 +0000
Committer: Jacob Barrett <jbarrett@pivotal.io>
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
     $<TARGET_PROPERTY:_apache-geode,INTERFACE_INCLUDE_DIRECTORIES>
 )
 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 <geode/Exception.hpp>
 #include <ace/TSS_T.h>
 
+#include <string>
+#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.");
-  }
-}
-*/
 }
 }
 }


Mime
View raw message