LCOV - code coverage report
Current view: top level - config - Config.inc (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 10 73 13.7 %
Date: 2024-10-18 14:00:25 Functions: 4 26 15.4 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2011-2023 The plumed team
       3             :    (see the PEOPLE file at the root of the distribution for a list of names)
       4             : 
       5             :    See http://www.plumed.org for more information.
       6             : 
       7             :    This file is part of plumed, version 2.
       8             : 
       9             :    plumed is free software: you can redistribute it and/or modify
      10             :    it under the terms of the GNU Lesser General Public License as published by
      11             :    the Free Software Foundation, either version 3 of the License, or
      12             :    (at your option) any later version.
      13             : 
      14             :    plumed is distributed in the hope that it will be useful,
      15             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      16             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17             :    GNU Lesser General Public License for more details.
      18             : 
      19             :    You should have received a copy of the GNU Lesser General Public License
      20             :    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
      21             : +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
      22             : 
      23             : #include "Config.h"
      24             : #include "version.h"
      25             : #include <cstdlib>
      26             : #include <cstring>
      27             : #include <dlfcn.h>
      28             : 
      29             : namespace PLMD {
      30             : namespace config {
      31             : 
      32             : namespace {
      33             : /// local tool that, given a string, returns a new string which is:
      34             : /// - enclosed in single quotes (')
      35             : /// - with all single quotes escaped
      36           0 : std::string escapeForSingleQuote(const std::string& input) {
      37             :   std::string escaped;
      38           0 :   for (char c : input) {
      39           0 :     if (c == '\'') {
      40             :       escaped += "'\\''";
      41             :     } else {
      42           0 :       escaped += c;
      43             :     }
      44             :   }
      45           0 :   return "'" + escaped + "'";
      46             : }
      47             : }
      48             : 
      49             : // This is a fix to allow conda to correctly replace paths in binary files.
      50             : // These functions should not be static or they will be optimized away!
      51         440 : const char* plumed_root() {return "/home/runner/work/plumed2/plumed2/";}
      52           0 : const char* plumed_soext() {return "so";}
      53           0 : const char* plumed_htmldir() {return "xxxxNAxxxx";}
      54           0 : const char* plumed_includedir() {return "xxxxNAxxxx";}
      55           0 : const char* plumed_program_name() {return "xxxxNAxxxx";}
      56             : 
      57           0 : std::string getSoExt() {
      58           0 :   return plumed_soext();
      59             : }
      60             : 
      61           0 : bool isInstalled() {
      62           0 :   return false;
      63             : }
      64             : 
      65         440 : std::string getPlumedRoot() {
      66         440 :   char *env = std::getenv("PLUMED_ROOT");
      67             :   std::string ss;
      68         440 :   if( env == NULL) {
      69         440 :     ss=plumed_root();
      70             :   } else {
      71           0 :     ss=std::string( env );
      72             :   }
      73         440 :   return ss;
      74             : }
      75             : 
      76           0 : std::string getPlumedHtmldir() {
      77           0 :   if(!isInstalled()) return getPlumedRoot();
      78           0 :   char *env = std::getenv("PLUMED_HTMLDIR");
      79             :   std::string ss;
      80           0 :   if( env == NULL) {
      81           0 :     ss=plumed_htmldir();
      82             :   } else {
      83           0 :     ss=std::string( env );
      84             :   }
      85             :   return ss;
      86             : }
      87             : 
      88           0 : std::string getPlumedIncludedir() {
      89           0 :   if(!isInstalled()) return getPlumedRoot()+"/src/include";
      90           0 :   char *env = std::getenv("PLUMED_INCLUDEDIR");
      91             :   std::string ss;
      92           0 :   if( env == NULL) {
      93           0 :     ss=plumed_includedir();
      94             :   } else {
      95           0 :     ss=std::string( env );
      96             :   }
      97             :   return ss;
      98             : }
      99             : 
     100           0 : std::string getPlumedProgramName() {
     101           0 :   if(!isInstalled()) return "plumed";
     102           0 :   char *env = std::getenv("PLUMED_PROGRAM_NAME");
     103             :   std::string ss;
     104           0 :   if( env == NULL) {
     105           0 :     ss=plumed_program_name();
     106             :   } else {
     107           0 :     ss=std::string( env );
     108             :   }
     109             :   return ss;
     110             : }
     111             : 
     112           0 : std::string getEnvCommand() {
     113           0 :   return "env PLUMED_ROOT="+escapeForSingleQuote(getPlumedRoot())+
     114           0 :          " PLUMED_VERSION="+escapeForSingleQuote(getVersionLong())+
     115           0 :          " PLUMED_HTMLDIR="+escapeForSingleQuote(getPlumedHtmldir())+
     116           0 :          " PLUMED_INCLUDEDIR="+escapeForSingleQuote(getPlumedIncludedir())+
     117           0 :          " PLUMED_PROGRAM_NAME="+escapeForSingleQuote(getPlumedProgramName())+
     118           0 :          " PLUMED_IS_INSTALLED='"+(false?"yes":"no")+"'";
     119             : }
     120             : 
     121           1 : std::string getVersion() {
     122           1 :   return PLUMED_VERSION_SHORT;
     123             : }
     124             : 
     125           1 : std::string getVersionLong() {
     126           1 :   return PLUMED_VERSION_LONG;
     127             : }
     128             : 
     129           0 : std::string getVersionGit() {
     130           0 :   return PLUMED_VERSION_GIT;
     131             : }
     132             : 
     133           0 : std::string getMakefile() {
     134             :   static const unsigned char confu [] = {
     135             : #include "Makefile.conf.xxd"
     136             :     , 0x00
     137             :   };
     138             :   auto conf=(char*)confu;
     139           0 :   return std::string(conf,conf+std::strlen(conf));
     140             : }
     141             : 
     142           0 : bool hasMatheval() {
     143             : #ifdef __PLUMED_HAS_MATHEVAL
     144             :   return true;
     145             : #else
     146           0 :   return false;
     147             : #endif
     148             : }
     149             : 
     150           0 : bool hasDlopen() {
     151             : #ifdef __PLUMED_HAS_DLOPEN
     152           0 :   return true;
     153             : #else
     154             :   return false;
     155             : #endif
     156             : }
     157             : 
     158           0 : bool hasCregex() {
     159             : #ifdef __PLUMED_HAS_CREGEX
     160             :   return true;
     161             : #else
     162           0 :   return false;
     163             : #endif
     164             : }
     165             : 
     166           0 : bool hasMolfile() {
     167             : #ifdef __PLUMED_HAS_MOLFILE_PLUGINS
     168           0 :   return true;
     169             : #else
     170             :   return false;
     171             : #endif
     172             : }
     173             : 
     174           0 : bool hasExternalMolfile() {
     175             : #ifdef __PLUMED_HAS_EXTERNAL_MOLFILE_PLUGINS
     176             :   return true;
     177             : #else
     178           0 :   return false;
     179             : #endif
     180             : }
     181             : 
     182           0 : bool hasZlib() {
     183             : #ifdef __PLUMED_HAS_ZLIB
     184           0 :   return true;
     185             : #else
     186             :   return false;
     187             : #endif
     188             : }
     189             : 
     190           0 : std::string getCompilationDate() {
     191           0 :   return __DATE__;
     192             : }
     193             : 
     194           0 : std::string getCompilationTime() {
     195           0 :   return __TIME__;
     196             : }
     197             : 
     198           0 : std::string getLibraryPath() {
     199             : #ifdef __PLUMED_HAS_DLADDR
     200             :   Dl_info info;
     201           0 :   if(dladdr((void*)getLibraryPath,&info)) {
     202           0 :     return info.dli_fname;
     203             :   } else {
     204           0 :     return "";
     205             :   }
     206             : #endif
     207             : 
     208             : }
     209             : 
     210             : 
     211             : }
     212             : }
     213             : 

Generated by: LCOV version 1.16