LCOV - code coverage report
Current view: top level - config - ConfigInstall.inc (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 52 69 75.4 %
Date: 2024-10-11 08:09:47 Functions: 18 25 72.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        3250 :   std::string escapeForSingleQuote(const std::string& input) {
      36             :     std::string escaped;
      37       65005 :     for (char c : input) {
      38       61755 :         if (c == '\'') {
      39             :             escaped += "'\\''";
      40             :         } else {
      41       61755 :             escaped += c;
      42             :         }
      43             :     }
      44        8450 :     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        6222 : const char* plumed_root() {return "/home/runner/opt/lib/plumed";}
      51         593 : const char* plumed_soext() {return "so";}
      52         650 : const char* plumed_htmldir() {return "/home/runner/opt/share/doc/plumed";}
      53         649 : const char* plumed_includedir() {return "/home/runner/opt/include";}
      54         650 : const char* plumed_program_name() {return "plumed";}
      55             : 
      56         593 : std::string getSoExt() {
      57         593 :   return plumed_soext();
      58             : }
      59             : 
      60        2569 : bool isInstalled() {
      61        2569 :   return true;
      62             : }
      63             : 
      64        6222 : std::string getPlumedRoot() {
      65        6222 :   char *env = std::getenv("PLUMED_ROOT");
      66             :   std::string ss;
      67        6222 :   if( env == NULL) {
      68        6222 :     ss=plumed_root();
      69             :   } else {
      70           0 :     ss=std::string( env );
      71             :   }
      72        6222 :   return ss;
      73             : }
      74             : 
      75         650 : std::string getPlumedHtmldir() {
      76         650 :   if(!isInstalled()) return getPlumedRoot();
      77         650 :   char *env = std::getenv("PLUMED_HTMLDIR");
      78             :   std::string ss;
      79         650 :   if( env == NULL) {
      80         650 :     ss=plumed_htmldir();
      81             :   } else {
      82           0 :     ss=std::string( env );
      83             :   }
      84             :   return ss;
      85             : }
      86             : 
      87         650 : std::string getPlumedIncludedir() {
      88         650 :   if(!isInstalled()) return getPlumedRoot()+"/src/include";
      89         650 :   char *env = std::getenv("PLUMED_INCLUDEDIR");
      90             :   std::string ss;
      91         650 :   if( env == NULL) {
      92         649 :     ss=plumed_includedir();
      93             :   } else {
      94           2 :     ss=std::string( env );
      95             :   }
      96             :   return ss;
      97             : }
      98             : 
      99         650 : std::string getPlumedProgramName() {
     100         650 :   if(!isInstalled()) return "plumed";
     101         650 :   char *env = std::getenv("PLUMED_PROGRAM_NAME");
     102             :   std::string ss;
     103         650 :   if( env == NULL) {
     104         650 :     ss=plumed_program_name();
     105             :   } else {
     106           0 :     ss=std::string( env );
     107             :   }
     108             :   return ss;
     109             : }
     110             : 
     111         650 : std::string getEnvCommand() {
     112        1950 :   return "env PLUMED_ROOT="+escapeForSingleQuote(getPlumedRoot())+
     113        2600 :          " PLUMED_VERSION="+escapeForSingleQuote(getVersionLong())+
     114        3250 :          " PLUMED_HTMLDIR="+escapeForSingleQuote(getPlumedHtmldir())+
     115        3250 :          " PLUMED_INCLUDEDIR="+escapeForSingleQuote(getPlumedIncludedir())+
     116        2600 :          " PLUMED_PROGRAM_NAME="+escapeForSingleQuote(getPlumedProgramName())+
     117        1950 :          " PLUMED_IS_INSTALLED='"+(true?"yes":"no")+"'";
     118             : }
     119             : 
     120           0 : std::string getVersion() {
     121           0 :   return PLUMED_VERSION_SHORT;
     122             : }
     123             : 
     124        1559 : std::string getVersionLong() {
     125        1559 :   return PLUMED_VERSION_LONG;
     126             : }
     127             : 
     128         909 : std::string getVersionGit() {
     129         909 :   return PLUMED_VERSION_GIT;
     130             : }
     131             : 
     132          27 : std::string getMakefile() {
     133             :   static const unsigned char confu [] = {
     134             : #include "Makefile.conf.xxd"
     135             :     , 0x00
     136             :   };
     137             :   auto conf=(char*)confu;
     138          27 :   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         909 : std::string getCompilationDate() {
     190         909 :   return __DATE__;
     191             : }
     192             : 
     193         909 : std::string getCompilationTime() {
     194         909 :   return __TIME__;
     195             : }
     196             : 
     197             : 
     198             : }
     199             : }
     200             : 

Generated by: LCOV version 1.15