LCOV - code coverage report
Current view: top level - config - Config.inc (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 34 69 49.3 %
Date: 2024-10-11 08:09:47 Functions: 12 25 48.0 %

          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             : 
      28             : namespace PLMD {
      29             : namespace config {
      30             : 
      31             : namespace {
      32             :   /// local tool that, given a string, returns a new string which is:
      33             :   /// - enclosed in single quotes (')
      34             :   /// - with all single quotes escaped
      35           5 :   std::string escapeForSingleQuote(const std::string& input) {
      36             :     std::string escaped;
      37         130 :     for (char c : input) {
      38         125 :         if (c == '\'') {
      39             :             escaped += "'\\''";
      40             :         } else {
      41         125 :             escaped += c;
      42             :         }
      43             :     }
      44          13 :     return "'" + escaped + "'";
      45             :   }
      46             : }
      47             : 
      48             : // This is a fix to allow conda to correctly replace paths in binary files.
      49             : // These functions should not be static or they will be optimized away!
      50         301 : const char* plumed_root() {return "/home/runner/work/plumed2/plumed2/";}
      51           0 : const char* plumed_soext() {return "so";}
      52           0 : const char* plumed_htmldir() {return "xxxxNAxxxx";}
      53           0 : const char* plumed_includedir() {return "xxxxNAxxxx";}
      54           0 : const char* plumed_program_name() {return "xxxxNAxxxx";}
      55             : 
      56           0 : std::string getSoExt() {
      57           0 :   return plumed_soext();
      58             : }
      59             : 
      60           3 : bool isInstalled() {
      61           3 :   return false;
      62             : }
      63             : 
      64         301 : std::string getPlumedRoot() {
      65         301 :   char *env = std::getenv("PLUMED_ROOT");
      66             :   std::string ss;
      67         301 :   if( env == NULL) {
      68         301 :     ss=plumed_root();
      69             :   } else {
      70           0 :     ss=std::string( env );
      71             :   }
      72         301 :   return ss;
      73             : }
      74             : 
      75           1 : std::string getPlumedHtmldir() {
      76           1 :   if(!isInstalled()) return getPlumedRoot();
      77           0 :   char *env = std::getenv("PLUMED_HTMLDIR");
      78             :   std::string ss;
      79           0 :   if( env == NULL) {
      80           0 :     ss=plumed_htmldir();
      81             :   } else {
      82           0 :     ss=std::string( env );
      83             :   }
      84             :   return ss;
      85             : }
      86             : 
      87           1 : std::string getPlumedIncludedir() {
      88           2 :   if(!isInstalled()) return getPlumedRoot()+"/src/include";
      89           0 :   char *env = std::getenv("PLUMED_INCLUDEDIR");
      90             :   std::string ss;
      91           0 :   if( env == NULL) {
      92           0 :     ss=plumed_includedir();
      93             :   } else {
      94           0 :     ss=std::string( env );
      95             :   }
      96             :   return ss;
      97             : }
      98             : 
      99           1 : std::string getPlumedProgramName() {
     100           1 :   if(!isInstalled()) return "plumed";
     101           0 :   char *env = std::getenv("PLUMED_PROGRAM_NAME");
     102             :   std::string ss;
     103           0 :   if( env == NULL) {
     104           0 :     ss=plumed_program_name();
     105             :   } else {
     106           0 :     ss=std::string( env );
     107             :   }
     108             :   return ss;
     109             : }
     110             : 
     111           1 : std::string getEnvCommand() {
     112           3 :   return "env PLUMED_ROOT="+escapeForSingleQuote(getPlumedRoot())+
     113           4 :          " PLUMED_VERSION="+escapeForSingleQuote(getVersionLong())+
     114           5 :          " PLUMED_HTMLDIR="+escapeForSingleQuote(getPlumedHtmldir())+
     115           5 :          " PLUMED_INCLUDEDIR="+escapeForSingleQuote(getPlumedIncludedir())+
     116           4 :          " PLUMED_PROGRAM_NAME="+escapeForSingleQuote(getPlumedProgramName())+
     117           3 :          " PLUMED_IS_INSTALLED='"+(false?"yes":"no")+"'";
     118             : }
     119             : 
     120           0 : std::string getVersion() {
     121           0 :   return PLUMED_VERSION_SHORT;
     122             : }
     123             : 
     124           6 : std::string getVersionLong() {
     125           6 :   return PLUMED_VERSION_LONG;
     126             : }
     127             : 
     128           5 : std::string getVersionGit() {
     129           5 :   return PLUMED_VERSION_GIT;
     130             : }
     131             : 
     132           0 : std::string getMakefile() {
     133             :   static const unsigned char confu [] = {
     134             : #include "Makefile.conf.xxd"
     135             :     , 0x00
     136             :   };
     137             :   auto conf=(char*)confu;
     138           0 :   return std::string(conf,conf+std::strlen(conf));
     139             : }
     140             : 
     141           0 : bool hasMatheval() {
     142             : #ifdef __PLUMED_HAS_MATHEVAL
     143             :   return true;
     144             : #else
     145           0 :   return false;
     146             : #endif
     147             : }
     148             : 
     149           0 : bool hasDlopen() {
     150             : #ifdef __PLUMED_HAS_DLOPEN
     151           0 :   return true;
     152             : #else
     153             :   return false;
     154             : #endif
     155             : }
     156             : 
     157           0 : bool hasCregex() {
     158             : #ifdef __PLUMED_HAS_CREGEX
     159           0 :   return true;
     160             : #else
     161             :   return false;
     162             : #endif
     163             : }
     164             : 
     165           0 : bool hasMolfile() {
     166             : #ifdef __PLUMED_HAS_MOLFILE_PLUGINS
     167           0 :   return true;
     168             : #else
     169             :   return false;
     170             : #endif
     171             : }
     172             : 
     173           0 : bool hasExternalMolfile() {
     174             : #ifdef __PLUMED_HAS_EXTERNAL_MOLFILE_PLUGINS
     175             :   return true;
     176             : #else
     177           0 :   return false;
     178             : #endif
     179             : }
     180             : 
     181           0 : bool hasZlib() {
     182             : #ifdef __PLUMED_HAS_ZLIB
     183           0 :   return true;
     184             : #else
     185             :   return false;
     186             : #endif
     187             : }
     188             : 
     189           5 : std::string getCompilationDate() {
     190           5 :   return __DATE__;
     191             : }
     192             : 
     193           5 : std::string getCompilationTime() {
     194           5 :   return __TIME__;
     195             : }
     196             : 
     197             : 
     198             : }
     199             : }
     200             : 

Generated by: LCOV version 1.15