1 #include "EnvironmentVariable.h" 16 const char* getEnv(
const char* envName,
const char* description,
bool failHard=
true){
18 const char* envVar = std::getenv(envName);
20 const char* RED =
"\x1b[31m";
21 const char* RESET =
"\x1b[0m";
25 std::cerr << RED <<
"Fatal error! " << RESET;
28 std::cerr << RED <<
"Warning! " << RESET;
32 std::cerr <<
"Could not find environment variable " 33 << RED << envName << RESET << std::endl;
37 std::cerr << description << std::endl;
42 std::cerr <<
"Giving up." << std::endl;
58 #ifdef ANITA_BUILD_TOOL 59 const char* icemc_src_dir = getEnv(
"ICEMC_SRC_DIR",
"Without this environment variable I can't find input data or config files!",
true);
62 const char* icemc_src_dir = getEnv(
"ICEMC_SRC_DIR",
"Will guess icemc source directory is present working directory",
false);
71 const char* EnvironmentVariable::ICEMC_VERSION(TString outputdir){
73 system(Form(
"git rev-parse HEAD > %s/gitversion.txt", outputdir.Data()));
74 static std::string gitversion;
75 std::ifstream gitversionfile (Form(
"%s/gitversion.txt", outputdir.Data()));
76 if (gitversionfile.is_open())
78 getline (gitversionfile,gitversion);
79 gitversionfile.close();
82 return gitversion.c_str();
const char * ICEMC_SRC_DIR()