Skip to content

Commit

Permalink
Merge pull request #509 from rest-for-physics/jgalan_macos_brew
Browse files Browse the repository at this point in the history
Fixes MacOs installation and adding options to restListMacros
  • Loading branch information
jgalan authored Mar 18, 2024
2 parents 64169ca + 3b54c8e commit 75b29bb
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 30 deletions.
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ endif ()
set(external_include_dirs)
set(external_libs)

if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(external_include_dirs ${external_include_dirs} "/usr/local/include/")
message(STATUS "Adding BREW include directory: /usr/local/include")
endif (CMAKE_SYSTEM_NAME MATCHES "Darwin")

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${DECAY_PATH}/cmake
${CMAKE_MODULE_PATH})
set(CMAKE_MACOSX_RPATH 1)
Expand Down Expand Up @@ -356,7 +361,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "Darwin") # we must call library install here in
endif ()

# Copy pcm files
if (CMAKE_SYSTEM_NAME MATCHES "Darwin" OR CMAKE_SYSTEM_NAME MATCHES "Windows")
if (CMAKE_SYSTEM_NAME MATCHES "Windows")

# Copy pcm files to bin
install(
Expand Down
2 changes: 1 addition & 1 deletion cmake/cmake_uninstall.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program(
execute_process(
"${CMAKE_COMMAND}" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
Expand Down
84 changes: 56 additions & 28 deletions macros/REST_ListMacros.C
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,21 @@ using namespace std;
//*** Lists all the official macros together with its documentation
//***
//*******************************************************************************************************
Int_t REST_ListMacros() {
Int_t REST_ListMacros(int details = 0, std::string onlyThisMacro = "") {
string macrosPath = (string)getenv("REST_PATH") + "/macros";
vector<string> directories = TRestTools::GetSubdirectories(macrosPath);

cout << "Directory : " << macrosPath << endl;
cout << endl;
cout << "Entering directory : " << macrosPath << endl;
vector<string> main_files = TRestTools::GetFilesMatchingPattern(macrosPath + "/REST_*.C");
for (int m = 0; m < main_files.size(); m++) {
cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
cout << " ++ "
<< " Macro : " << TRestTools::SeparatePathAndName(main_files[m]).second << endl;
std::ifstream t(main_files[m]);
std::string str((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>());

std::vector<string> lines = REST_StringHelper::Split(str, "\n");

cout << " ++ " << endl;
for (int l = 0; l < lines.size(); l++)
if (lines[l].find("//*** ") != string::npos)
cout << " ++ " << lines[l].substr(6, -1) << endl;
cout << " ++ " << endl;
}
cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;

for (int n = 0; n < directories.size(); n++) {
cout << "Directory : " << directories[n] << endl;
if (directories[n].find("pipeline") != string::npos) continue;
if (directories[n].find("/macros/mac/") != string::npos) continue;
vector<string> files = TRestTools::GetFilesMatchingPattern(directories[n] + "/REST_*.C");

for (int m = 0; m < files.size(); m++) {
if (details) {
for (int m = 0; m < main_files.size(); m++) {
std::string macro = TRestTools::SeparatePathAndName(main_files[m]).second;
if (!onlyThisMacro.empty() && onlyThisMacro != macro) continue;
cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
cout << " ++ "
<< " Macro : " << TRestTools::SeparatePathAndName(files[m]).second << endl;
std::ifstream t(files[m]);
<< " Macro : " << macro << endl;
std::ifstream t(main_files[m]);
std::string str((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>());

std::vector<string> lines = REST_StringHelper::Split(str, "\n");
Expand All @@ -58,6 +39,53 @@ Int_t REST_ListMacros() {
cout << " ++ " << endl;
}
cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
} else {
for (int m = 0; m < main_files.size(); m++) {
cout << " + " << TRestTools::SeparatePathAndName(main_files[m]).second << endl;
}
}

for (int n = 0; n < directories.size(); n++) {
cout << endl;
cout << "Entering directory : " << directories[n] << endl;
if (directories[n].find("pipeline") != string::npos) continue;
if (directories[n].find("/macros/mac/") != string::npos) continue;
vector<string> files = TRestTools::GetFilesMatchingPattern(directories[n] + "/REST_*.C");

if (details) {
for (int m = 0; m < files.size(); m++) {
std::string macro = TRestTools::SeparatePathAndName(files[m]).second;
if (!onlyThisMacro.empty() && onlyThisMacro != macro) continue;
cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
<< endl;
cout << " ++ Macro : " << macro << endl;
std::ifstream t(files[m]);
std::string str((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>());

std::vector<string> lines = REST_StringHelper::Split(str, "\n");

cout << " ++ " << endl;
for (int l = 0; l < lines.size(); l++)
if (lines[l].find("//*** ") != string::npos)
cout << " ++ " << lines[l].substr(6, -1) << endl;
cout << " ++ " << endl;
}
cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
} else {
for (int m = 0; m < files.size(); m++) {
cout << " + " << TRestTools::SeparatePathAndName(files[m]).second << endl;
}
std::cout << std::endl;
std::cout << " ------- " << std::endl;
std::cout << "IMPORTANT. To get a more detailed macro documentation enable the details argument:"
<< std::endl;
std::cout << "Execute: restListMacros 1" << std::endl;
std::cout << "OR if you want to show only the documentation of a given macro, add the macro.C "
"filename as argument"
<< std::endl;
std::cout << "Execute: restListMacros 1 REST_CheckValidRuns.C" << std::endl;
std::cout << " ------- " << std::endl;
}
}
return 0;
}

0 comments on commit 75b29bb

Please sign in to comment.