Skip to content

Commit

Permalink
NewDevMod system (#5707) (#5711)
Browse files Browse the repository at this point in the history
* NewDevMod system (#5707)

* New Devmod System (#5701)

* New dev module system (#5690)

* initial functional draft

* add ugly name thing for now

* fix some issues loading sepertly compiled modules on mac

* fix more mac specific issues

* add shortcuts for manual reload of devmodules , add safety copy to mac

---------

* Update otoolstuff.cpp

* fix windows compile

* remove dumb comma

* fix weird comment

* remove spurious tabs

* add a button for libPaths and make the preferences a bit less ugly

* check whether everything is fileld in

Like the name and libpath of a direct libpath dev module

---------

Co-authored-by: Joris Goosen <Joris@JorisGoosen.nl>
  • Loading branch information
RensDofferhoff and JorisGoosen authored Oct 29, 2024
1 parent fa0bacd commit ddee9ba
Show file tree
Hide file tree
Showing 19 changed files with 449 additions and 117 deletions.
56 changes: 33 additions & 23 deletions Engine/otoolstuff.cpp → Common/otoolstuff.cpp
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
#include "otoolstuff.h"
#include "stringutils.h"
#include "rbridge.h"
#include <fstream>
#include <boost/algorithm/string/predicate.hpp>
#include "utils.h"
#include "appinfo.h"
#include <iostream>
#include <filesystem>

std::string _system(std::string cmd)
{
const char *root, *relativePath;

if (!rbridge_requestTempFileName("log", &root, &relativePath))
auto path = std::filesystem::temp_directory_path() / "jaspTmpSystem";
std::ofstream ofs(path , std::ofstream::out);
if (!ofs.is_open())
throw std::runtime_error("Cannot open output file for separate R/System cmd!");

std::string path = std::string(root) + "/" + relativePath;

cmd += " > " + path + " 2>&1 ";
cmd += " > " + path.generic_string() + " 2>&1 ";

#ifdef WIN32
cmd = '"' + cmd + '"'; // See: https://stackoverflow.com/questions/2642551/windows-c-system-call-with-spaces-in-command
#endif

system(cmd.c_str());

ofs.close();
std::ifstream readLog(path);
std::stringstream out;

Expand All @@ -36,7 +33,7 @@ std::string _system(std::string cmd)
return out.str();
}

void _moduleLibraryFixer(const std::string & moduleLibraryPath, bool engineCall, bool printStuff)
void _moduleLibraryFixer(const std::string & moduleLibraryPath, bool engineCall, bool printStuff, bool devMod)
{
using namespace boost;

Expand Down Expand Up @@ -117,17 +114,27 @@ void _moduleLibraryFixer(const std::string & moduleLibraryPath, bool engineCall,
{"/opt/X11/lib", framework_resources + "opt/X11/lib"},
};

// Known fix library id's and paths
const std::map<std::string, std::string> ids_to_be_replaced =
{
{"libtbbmalloc.dylib", "@executable_path/../Modules/" + jaspModuleName + "/RcppParallel/lib/libtbbmalloc.dylib"},
{"libtbbmalloc_proxy.dylib", "@executable_path/../Modules/" + jaspModuleName + "/RcppParallel/lib/libtbbmalloc_proxy.dylib"},
{"libtbb.dylib", "@executable_path/../Modules/" + jaspModuleName + "/RcppParallel/lib/libtbb.dylib"}
// Known fix library id's and paths
std::map<std::string, std::string> ids_to_be_replaced;
if(devMod) {
ids_to_be_replaced = {
#ifndef __aarch64__
,{"libgfortran.dylib", framework_resources + "opt/local/gfortran/lib/libgfortran.dylib"}
{"libgfortran.dylib", framework_resources + "opt/local/gfortran/lib/libgfortran.dylib"}
,{"libquadmath.dylib", framework_resources + "opt/local/gfortran/lib/libquadmath.dylib"}
#endif
};
};
}
else {
ids_to_be_replaced = {
{"libtbbmalloc.dylib", "@executable_path/../Modules/" + jaspModuleName + "/RcppParallel/lib/libtbbmalloc.dylib"},
{"libtbbmalloc_proxy.dylib", "@executable_path/../Modules/" + jaspModuleName + "/RcppParallel/lib/libtbbmalloc_proxy.dylib"},
{"libtbb.dylib", "@executable_path/../Modules/" + jaspModuleName + "/RcppParallel/lib/libtbb.dylib"}
#ifndef __aarch64__
,{"libgfortran.dylib", framework_resources + "opt/local/gfortran/lib/libgfortran.dylib"}
,{"libquadmath.dylib", framework_resources + "opt/local/gfortran/lib/libquadmath.dylib"}
#endif
};
}

auto install_name_tool_cmd = [&](const std::string & replaceThisLine, const std::string & withThisLine)
{
Expand Down Expand Up @@ -188,13 +195,16 @@ void _moduleLibraryFixer(const std::string & moduleLibraryPath, bool engineCall,

}

std::cout << "Signing the modified library\n";
const std::string sign_command = "codesign --force --deep --verbose=4 --timestamp --sign \"" + AppInfo::getSigningIdentity() + "\" " + path.string();
if(!devMod)
{
std::cout << "Signing the modified library\n";
const std::string sign_command = "codesign --force --deep --verbose=4 --timestamp --sign \"" + AppInfo::getSigningIdentity() + "\" " + path.string();

if (printStuff)
std::cout << sign_command << std::endl;
if (printStuff)
std::cout << sign_command << std::endl;

_system(sign_command);
_system(sign_command);
}
}
}
catch(std::filesystem::filesystem_error & error)
Expand Down
2 changes: 1 addition & 1 deletion Engine/otoolstuff.h → Common/otoolstuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
/// Depends on otool being present and callable in the users system.

std::string _system( std::string cmd);
void _moduleLibraryFixer(const std::string & moduleLibrary, bool engineCall = false, bool printStuff = false);
void _moduleLibraryFixer(const std::string & moduleLibrary, bool engineCall = false, bool printStuff = false, bool devMod = false);

#endif // OTOOLSTUFF_H
10 changes: 8 additions & 2 deletions Desktop/analysis/analyses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,7 @@ void Analyses::removeAnalysesOfDynamicModule(Modules::DynamicModule * module)

void Analyses::refreshAnalysesOfDynamicModule(Modules::DynamicModule * module)
{
//Log::log() << "void Analyses::refreshAnalysesOfDynamicModule(" << module->toString() << ")" << std::endl;

Log::log() << "void Analyses::refreshAnalysesOfDynamicModule(" << module->toString() << ")" << std::endl;

for(auto & keyval : _analysisMap)
if(keyval.second->dynamicModule() == module)
Expand Down Expand Up @@ -352,6 +351,13 @@ void Analyses::rescanAnalysisEntriesOfDynamicModule(Modules::DynamicModule * mod
removeAnalysisById(size_t(id));
}

void Analyses::reloadQmlAnalysesDynamicModule(Modules::DynamicModule * module)
{
for(auto idAnalysis : _analysisMap)
if(idAnalysis.second->dynamicModule() == module)
idAnalysis.second->analysisQMLFileChanged();
}

void Analyses::refreshAllAnalyses()
{
for(auto idAnalysis : _analysisMap)
Expand Down
1 change: 1 addition & 0 deletions Desktop/analysis/analyses.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public slots:
void refreshAnalysesOfDynamicModule(Modules::DynamicModule * module);
void replaceAnalysesOfDynamicModule(Modules::DynamicModule * oldModule, Modules::DynamicModule * newModule);
void rescanAnalysisEntriesOfDynamicModule(Modules::DynamicModule * module);
void reloadQmlAnalysesDynamicModule(Modules::DynamicModule * module);
void setChangedAnalysisTitle();
void analysisTitleChangedInResults(int id, QString title);
void setCurrentFormPrevH(double currentFormPrevH);
Expand Down
Loading

0 comments on commit ddee9ba

Please sign in to comment.