LCOV - code coverage report
Current view: top level - config - Config.inc (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 11 77 14.3 %
Date: 2026-03-30 13:16:06 Functions: 4 25 16.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           0 : std::string escapeForSingleQuote(const std::string& input) {
      36             :   std::string escaped;
      37           0 :   for (char c : input) {
      38           0 :     if (c == '\'') {
      39             :       escaped += "'\\''";
      40             :     } else {
      41           0 :       escaped += c;
      42             :     }
      43             :   }
      44           0 :   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         588 : const char* plumed_root() {
      51         588 :   return "/home/runner/work/plumed2/plumed2/";
      52             : }
      53           0 : const char* plumed_soext() {
      54           0 :   return "so";
      55             : }
      56           0 : const char* plumed_htmldir() {
      57           0 :   return "xxxxNAxxxx";
      58             : }
      59           0 : const char* plumed_includedir() {
      60           0 :   return "xxxxNAxxxx";
      61             : }
      62           0 : const char* plumed_program_name() {
      63           0 :   return "xxxxNAxxxx";
      64             : }
      65             : 
      66           0 : std::string getSoExt() {
      67           0 :   return plumed_soext();
      68             : }
      69             : 
      70           0 : bool isInstalled() {
      71           0 :   return false;
      72             : }
      73             : 
      74         588 : std::string getPlumedRoot() {
      75         588 :   char *env = std::getenv("PLUMED_ROOT");
      76             :   std::string ss;
      77         588 :   if( env == NULL) {
      78         588 :     ss=plumed_root();
      79             :   } else {
      80           0 :     ss=std::string( env );
      81             :   }
      82         588 :   return ss;
      83             : }
      84             : 
      85           0 : std::string getPlumedHtmldir() {
      86           0 :   if(!isInstalled()) {
      87           0 :     return getPlumedRoot();
      88             :   }
      89           0 :   char *env = std::getenv("PLUMED_HTMLDIR");
      90             :   std::string ss;
      91           0 :   if( env == NULL) {
      92           0 :     ss=plumed_htmldir();
      93             :   } else {
      94           0 :     ss=std::string( env );
      95             :   }
      96             :   return ss;
      97             : }
      98             : 
      99           0 : std::string getPlumedIncludedir() {
     100           0 :   if(!isInstalled()) {
     101           0 :     return getPlumedRoot()+"/src/include";
     102             :   }
     103           0 :   char *env = std::getenv("PLUMED_INCLUDEDIR");
     104             :   std::string ss;
     105           0 :   if( env == NULL) {
     106           0 :     ss=plumed_includedir();
     107             :   } else {
     108           0 :     ss=std::string( env );
     109             :   }
     110             :   return ss;
     111             : }
     112             : 
     113           0 : std::string getPlumedProgramName() {
     114           0 :   if(!isInstalled()) {
     115           0 :     return "plumed";
     116             :   }
     117           0 :   char *env = std::getenv("PLUMED_PROGRAM_NAME");
     118             :   std::string ss;
     119           0 :   if( env == NULL) {
     120           0 :     ss=plumed_program_name();
     121             :   } else {
     122           0 :     ss=std::string( env );
     123             :   }
     124             :   return ss;
     125             : }
     126             : 
     127           0 : std::string getEnvCommand() {
     128           0 :   return "env PLUMED_ROOT="+escapeForSingleQuote(getPlumedRoot())+
     129           0 :          " PLUMED_VERSION="+escapeForSingleQuote(getVersionLong())+
     130           0 :          " PLUMED_HTMLDIR="+escapeForSingleQuote(getPlumedHtmldir())+
     131           0 :          " PLUMED_INCLUDEDIR="+escapeForSingleQuote(getPlumedIncludedir())+
     132           0 :          " PLUMED_PROGRAM_NAME="+escapeForSingleQuote(getPlumedProgramName())+
     133           0 :          " PLUMED_IS_INSTALLED='"+(false?"yes":"no")+"'";
     134             : }
     135             : 
     136           2 : std::string getVersion() {
     137           2 :   return PLUMED_VERSION_SHORT;
     138             : }
     139             : 
     140           2 : std::string getVersionLong() {
     141           2 :   return PLUMED_VERSION_LONG;
     142             : }
     143             : 
     144           0 : std::string getVersionGit() {
     145           0 :   return PLUMED_VERSION_GIT;
     146             : }
     147             : 
     148           0 : std::string getMakefile() {
     149             :   static const unsigned char confu [] = {
     150             : #include "Makefile.conf.xxd"
     151             :     , 0x00
     152             :   };
     153             :   auto conf=(char*)confu;
     154           0 :   return std::string(conf,conf+std::strlen(conf));
     155             : }
     156             : 
     157           0 : bool hasMatheval() {
     158             : #ifdef __PLUMED_HAS_MATHEVAL
     159             :   return true;
     160             : #else
     161           0 :   return false;
     162             : #endif
     163             : }
     164             : 
     165           0 : bool hasDlopen() {
     166             : #ifdef __PLUMED_HAS_DLOPEN
     167           0 :   return true;
     168             : #else
     169             :   return false;
     170             : #endif
     171             : }
     172             : 
     173           0 : bool hasCregex() {
     174             : #ifdef __PLUMED_HAS_CREGEX
     175           0 :   return true;
     176             : #else
     177             :   return false;
     178             : #endif
     179             : }
     180             : 
     181           0 : bool hasMolfile() {
     182             : #ifdef __PLUMED_HAS_MOLFILE_PLUGINS
     183           0 :   return true;
     184             : #else
     185             :   return false;
     186             : #endif
     187             : }
     188             : 
     189           0 : bool hasExternalMolfile() {
     190             : #ifdef __PLUMED_HAS_EXTERNAL_MOLFILE_PLUGINS
     191             :   return true;
     192             : #else
     193           0 :   return false;
     194             : #endif
     195             : }
     196             : 
     197           0 : bool hasZlib() {
     198             : #ifdef __PLUMED_HAS_ZLIB
     199           0 :   return true;
     200             : #else
     201             :   return false;
     202             : #endif
     203             : }
     204             : 
     205           0 : std::string getCompilationDate() {
     206           0 :   return __DATE__;
     207             : }
     208             : 
     209           0 : std::string getCompilationTime() {
     210           0 :   return __TIME__;
     211             : }
     212             : 
     213             : 
     214             : }
     215             : }
     216             : 

Generated by: LCOV version 1.16