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

Generated by: LCOV version 1.16