Skip to content

Commit

Permalink
rewrite scary construction in DynamicModule::generateModuleInstallingR
Browse files Browse the repository at this point in the history
  • Loading branch information
JorisGoosen authored and RensDofferhoff committed Jun 18, 2024
1 parent 84026ee commit a5b6659
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions Desktop/modules/dynamicmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,24 @@ std::string DynamicModule::generateModuleInstallingR(bool onlyModPkg)
return "stop('Something went wrong during intialization of the Description!\nMake sure it follows the standard set in https://github.com/jasp-stats/jasp-desktop/blob/development/Docs/development/jasp-adding-module.md#descriptionqml\n')";
}
setInstallLog("Installing module " + _name + ".\n");
return "tmp <- .libPaths(); .libPaths(\"" + AppDirs::bundledModulesDir().toStdString() + "Tools/jaspModuleInstaller_library" + "\"); Sys.setenv(MODULE_INSTALL_MODE=\"localizeModuleOnly\");options(\"renv.config.install.verbose\" = TRUE, \"PKGDEPENDS_LIBRARY\"=\"" + AppDirs::bundledModulesDir().toStdString() + "Tools/pkgdepends_library/" + "\"); result <- jaspModuleInstaller::installJaspModule(modulePkg='" + _modulePackage + "', moduleLibrary='" + moduleRLibrary().toStdString() +
"', repos='" + Settings::value(Settings::CRAN_REPO_URL).toString().toStdString() + "', onlyModPkg=" + (onlyModPkg ? "TRUE" : "FALSE") +
", force=TRUE, frameworkLibrary='"+fq(AppDirs::rHome())+"/library'); .libPaths(tmp); result";
return QString(
R"readableR(
tmp <- .libPaths();
.libPaths("%1");
Sys.setenv(MODULE_INSTALL_MODE="localizeModuleOnly");
options("renv.config.install.verbose" = TRUE, "PKGDEPENDS_LIBRARY"="%2");
result <- jaspModuleInstaller::installJaspModule(modulePkg='%3', moduleLibrary='%4', repos='%5', onlyModPkg=%6, force=TRUE, frameworkLibrary='%7');
.libPaths(tmp);
return(result);
)readableR")
.arg(AppDirs::bundledModulesDir() + "Tools/jaspModuleInstaller_library/")
.arg(AppDirs::bundledModulesDir() + "Tools/pkgdepends_library/")
.arg(tq(_modulePackage))
.arg(moduleRLibrary())
.arg(Settings::value(Settings::CRAN_REPO_URL).toString())
.arg(onlyModPkg ? "TRUE" : "FALSE")
.arg(AppDirs::rHome()+"/library")
.toStdString();
}

std::string DynamicModule::generateModuleLoadingR(bool shouldReturnSucces)
Expand Down

0 comments on commit a5b6659

Please sign in to comment.