Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes MacOs installation and adding options to restListMacros #509

Merged
merged 10 commits into from
Mar 18, 2024
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")
jgalan marked this conversation as resolved.
Show resolved Hide resolved

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;
}
Loading