From 72ef7f5e017c004137b75fdda82d3053ee60e265 Mon Sep 17 00:00:00 2001 From: Jan Kohnert Date: Fri, 29 Mar 2024 16:20:50 +0100 Subject: [PATCH 1/3] Update default driver install dir to follow cmake install prefix. --- CMakeLists.txt | 2 +- config.h.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3bcb5c75e..d99438309 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -167,7 +167,7 @@ set(GDL_LIB_DIR "" CACHE PATH "GDL: library directory relative to CMAKE_INSTALL_ if ( GDL_LIB_DIR STREQUAL "" OR NOT GDL_LIB_DIR) set (GDL_DRV_DIR "${CMAKE_INSTALL_PREFIX}/${GDL_DATA_DIR}/drivers") # CACHE PATH "GDL: where the drivers will be installed.") else() - set (GDL_DRV_DIR "${GDL_LIB_DIR}" ) # CACHE PATH "GDL: where the drivers will be installed.") + set (GDL_DRV_DIR "${CMAKE_INSTALL_PREFIX}/${GDL_LIB_DIR}" ) # CACHE PATH "GDL: where the drivers will be installed.") endif() # check for 64-bit OS if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) diff --git a/config.h.cmake b/config.h.cmake index 0eb7a2f01..16accb1ad 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -3,7 +3,7 @@ #define EXEC_PREFIX "@CMAKE_INSTALL_PREFIX@" #define GDLDATADIR "@CMAKE_INSTALL_PREFIX@@GDL_DATA_DIR@" -#define GDLLIBDIR "@GDL_LIB_DIR@" +#define GDLLIBDIR "@CMAKE_INSTALL_PREFIX@@GDL_LIB_DIR@" #define GDL_DRV_DIR "@GDL_DRV_DIR@" #define _CRT_SECURE_NO_WARNINGS From 769d92f9a3e3bf56ea6a2d631f4fc180d646e3cc Mon Sep 17 00:00:00 2001 From: Jan Kohnert Date: Sun, 31 Mar 2024 23:19:26 +0200 Subject: [PATCH 2/3] Reworked driver install patch. --- CMakeLists.txt | 9 +--- INSTALL.CMake | 3 ++ config.h.cmake | 6 +-- src/gdl.cpp | 51 ++++++++++---------- src/plplotdriver/CMakeLists.txt | 82 +++++++++++++++++++-------------- src/pythongdl.cpp | 2 +- src/str.cpp | 21 ++++----- 7 files changed, 88 insertions(+), 86 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d99438309..fb63ef82b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,14 +161,7 @@ set(JPEGDIR "" CACHE PATH "GDL: Specify the JPEG directory tree") set(SZIPDIR "" CACHE PATH "GDL: Specify the SZip directory tree") set(GDL_DATA_DIR "/share/gnudatalanguage" CACHE PATH "GDL: data directory relative to CMAKE_INSTALL_PREFIX") -set(GDL_LIB_DIR "" CACHE PATH "GDL: library directory relative to CMAKE_INSTALL_PREFIX") -#define (for plplotdriver/CMakeLists.txt) the GDL_DRV_DIR where the drivers will be installed. -#if GDL_LIB_DIR is empty, it will be the default (GDL_DATA_DIR/drivers) otherwise it is GDL_LIB_DIR (not GDL_LIB_DIR/drivers) -if ( GDL_LIB_DIR STREQUAL "" OR NOT GDL_LIB_DIR) - set (GDL_DRV_DIR "${CMAKE_INSTALL_PREFIX}/${GDL_DATA_DIR}/drivers") # CACHE PATH "GDL: where the drivers will be installed.") -else() - set (GDL_DRV_DIR "${CMAKE_INSTALL_PREFIX}/${GDL_LIB_DIR}" ) # CACHE PATH "GDL: where the drivers will be installed.") -endif() +set(GDL_LIB_DIR "/lib/gnudatalanguage" CACHE PATH "GDL: library directory relative to CMAKE_INSTALL_PREFIX") # check for 64-bit OS if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) set(HAVE_64BIT_OS 1) diff --git a/INSTALL.CMake b/INSTALL.CMake index f4faa129e..ad9311bbe 100644 --- a/INSTALL.CMake +++ b/INSTALL.CMake @@ -41,6 +41,9 @@ Other options include: - GDL_DATA_DIR (default: /share/gnudatalanguage) to specify a custom installation location for GDL files (a subdirectory of the main installation prefix) +- GDL_LIB_DIR (default: /lib/gnudatalanguage) to specify + a custom installation location for local PlPlot driver files + (a subdirectory of the main installation prefix) The list of all GDL-related options accepted by CMake along with their default values can be obtained by calling: diff --git a/config.h.cmake b/config.h.cmake index 16accb1ad..e87c72991 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -1,10 +1,8 @@ #ifndef __CONFIG_H__ #define __CONFIG_H__ -#define EXEC_PREFIX "@CMAKE_INSTALL_PREFIX@" -#define GDLDATADIR "@CMAKE_INSTALL_PREFIX@@GDL_DATA_DIR@" -#define GDLLIBDIR "@CMAKE_INSTALL_PREFIX@@GDL_LIB_DIR@" -#define GDL_DRV_DIR "@GDL_DRV_DIR@" +#cmakedefine GDL_DATA_DIR "@GDL_DATA_DIR@" +#cmakedefine GDL_LIB_DIR "@GDL_LIB_DIR@" #define _CRT_SECURE_NO_WARNINGS diff --git a/src/gdl.cpp b/src/gdl.cpp index 9ac8e6995..21489ba03 100644 --- a/src/gdl.cpp +++ b/src/gdl.cpp @@ -224,7 +224,7 @@ namespace MyPaths { if (length > 0) { path = (char*)malloc(length + 1); - if (!path) return std::string("."); + if (!path) return {"."}; wai_getExecutablePath(path, length, &dirname_length); path[dirname_length] = '\0'; // printf(" dirname: %s\n", path); @@ -232,7 +232,7 @@ namespace MyPaths { free(path); return pathstring; } - return std::string("."); + return {"."}; } } @@ -243,38 +243,37 @@ int main(int argc, char *argv[]) bool quiet = false; bool gdlde = false; -//The default installation location --- will not always be there. - gdlDataDir = std::string(GDLDATADIR); - gdlLibDir = std::string(GDLLIBDIR); + // The default installation location --- will not always be there. + gdlDataDir = std::string(GDL_DATA_DIR); + gdlLibDir = std::string(GDL_LIB_DIR); #ifdef _WIN32 std::replace(gdlDataDir.begin(), gdlDataDir.end(), '/', '\\'); std::replace(gdlLibDir.begin(), gdlLibDir.end(), '/', '\\'); -#endif +#endif + // make sure dirs are prefixed with the system's path separator + if (gdlDataDir.at(0) != lib::PathSeparator()) gdlDataDir.assign(lib::PathSeparator() + gdlDataDir); + if (gdlLibDir.at(0) != lib::PathSeparator()) gdlLibDir.assign(lib::PathSeparator() + gdlLibDir); //check where is the executable being run - std::string whereami=MyPaths::getExecutablePath(); -// if I am at a 'bin' location, then there are chances that I've bee INSTALLED, so all the resources I need can be accessed relatively to this 'bin' directory. -// if not, then I'm probably just a 'build' gdl and my ressources may (should?) be in the default location GDLDATADIR - std::size_t pos=whereami.rfind("bin"); - if (pos == whereami.size()-3) { //we are the installed gdl! - gdlDataDir.assign( whereami+ lib::PathSeparator() + ".." + lib::PathSeparator() + "share" + lib::PathSeparator() + "gnudatalanguage") ; -// std::cerr<<"installed at: "< Date: Thu, 11 Apr 2024 22:04:47 +0200 Subject: [PATCH 3/3] Added driver dir env variable. --- .gitignore | 1 + scripts/build_gdl.sh | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index f766b8f95..e2747859b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ gdlde/ gdlde*.zip .vscode .idea/ +Testing/ \ No newline at end of file diff --git a/scripts/build_gdl.sh b/scripts/build_gdl.sh index 19e048718..ba9f0d231 100755 --- a/scripts/build_gdl.sh +++ b/scripts/build_gdl.sh @@ -559,11 +559,12 @@ function install_gdl { function test_gdl { log "Testing GDL..." - cd ${ROOT_DIR}/build - if [ -f ${GDL_DIR}/CMakeModules/CodeCoverage.cmake ]; then + cd "${ROOT_DIR}/build" || exit 1 + if [ -f "${GDL_DIR}/CMakeModules/CodeCoverage.cmake" ]; then make codecov || exit 1 else - CTEST_OUTPUT_ON_FAILURE=1 make test || exit 1 + # since we do not install anything we need to set the driver path to the directory of the compiles drivers + CTEST_OUTPUT_ON_FAILURE=1 GDL_DRV_DIR="${ROOT_DIR}/build/src/plplotdriver" make test || exit 1 fi }