Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMake.in.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SET(OFBUILD_CUSTOM_CMAKE_VERSION "${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.
SET(OPENFLUID_VERSION_MAJOR 2)
SET(OPENFLUID_VERSION_MINOR 2)
SET(OPENFLUID_VERSION_PATCH 1)
SET(OPENFLUID_VERSION_STATUS "beta5") # example: SET(OPENFLUID_VERSION_STATUS "rc1")
SET(OPENFLUID_VERSION_STATUS "") # example: SET(OPENFLUID_VERSION_STATUS "rc1")

SET(OPENFLUID_VERSION_FULL "${OPENFLUID_VERSION_MAJOR}.${OPENFLUID_VERSION_MINOR}.${OPENFLUID_VERSION_PATCH}")

Expand Down
19 changes: 10 additions & 9 deletions src/apps/openfluid-devstudio/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,15 +776,16 @@ void MainWindow::onDuplicateWareRequested()
// TOIMPL reuse here the filter checking if ware name OK (not existing + only accepted symbols)
if (OK && !NewWareName.isEmpty() && WareInfo.WareDirName != NewWareName.toStdString())
{

mp_WidgetsCollection->duplicateWare(WarePath, NewWareName);
QMessageBox::warning(QApplication::activeWindow(),
tr("Ware duplication warning"),
tr("If this ware is versioned, change now the remote repository "
"(using 'git remote set-url origin <newurl>'). "
"It is currently the same than original ware and would "
"generate conflict or data loss risk."),
QMessageBox::Close);
if (mp_WidgetsCollection->duplicateWare(WarePath, NewWareName))
{
QMessageBox::warning(QApplication::activeWindow(),
tr("Ware duplication warning"),
tr("If this ware is versioned, change now the remote repository "
"(using 'git remote set-url origin <newurl>'). "
"It is currently the same than original ware and would "
"generate conflict or data loss risk."),
QMessageBox::Close);
}
}
}
}
Expand Down
21 changes: 11 additions & 10 deletions src/apps/openfluid/DataTasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,26 +244,27 @@ int DataTasks::processCreateData() const


bool DataTasks::processInstall(const std::string& OptStr,
std::function<bool(const std::string&, const std::string&, const std::string&, bool)>
InstallFunc,
std::function<bool(const std::string&, const std::string&, bool)> InstallAllFunc,
const std::string& ResPath,
const std::string& InstPath,
const bool Force) const
std::function<bool(const std::string&, const std::string&, const std::string&, bool, bool)>
InstallFunc,
std::function<bool(const std::string&, const std::string&, bool, bool)> InstallAllFunc,
const std::string& ResPath,
const std::string& InstPath,
const bool Force, const bool Verbose) const
{
std::cout << "Verbose:" << Verbose << std::endl;
if (!OptStr.empty() && OptStr != "*")
{
auto Selection = openfluid::tools::split(OptStr,",");
auto Selection = openfluid::tools::split(OptStr, ",");
bool AllIsOK = true;
for (const auto& S : Selection)
{
AllIsOK &= InstallFunc(S,ResPath,InstPath,Force);
AllIsOK &= InstallFunc(S, ResPath, InstPath, Force, Verbose);
}
return AllIsOK;
}
else
{
return InstallAllFunc(ResPath,InstPath,Force);
return InstallAllFunc(ResPath, InstPath, Force, Verbose);
}
}

Expand Down Expand Up @@ -321,7 +322,7 @@ int DataTasks::processInstallExamples() const

if (!m_Cmd.isOptionActive("simulators") && !m_Cmd.isOptionActive("observers") && !m_Cmd.isOptionActive("projects"))
{
return (openfluid::base::ExamplesManager::installAll(ResPath,InstPath,Force) ?
return (openfluid::base::ExamplesManager::installAll(ResPath,InstPath,Force,true) ?
0 : error("problems occurred during installation"));
}

Expand Down
6 changes: 3 additions & 3 deletions src/apps/openfluid/DataTasks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ class DataTasks : public TasksBase
int processCreateData() const;

bool processInstall(const std::string& OptStr,
std::function<bool(const std::string&, const std::string&, const std::string&, bool)>
std::function<bool(const std::string&, const std::string&, const std::string&, bool, bool)>
InstallFunc,
std::function<bool(const std::string&, const std::string&, bool)> InstallAllFunc,
std::function<bool(const std::string&, const std::string&, bool, bool)> InstallAllFunc,
const std::string& ResPath,
const std::string& InstPath,
const bool Force) const;
const bool Force, const bool Verbose=true) const;

int processInstallExamples() const;

Expand Down
21 changes: 15 additions & 6 deletions src/apps/openfluid/WareTasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,24 @@ int WareTasks::processCreate() const
if (m_Cmd.isOptionActive("from"))
{
const std::string ReferenceWarePath = m_Cmd.getOptionValue("from");
if (!openfluid::tools::Path(ReferenceWarePath).exists())
if (!openfluid::tools::Path(ReferenceWarePath).exists() || (
!openfluid::tools::Path(ReferenceWarePath).fromThis(openfluid::config::WARESDEV_WAREMETA_FILE).exists() &&
!openfluid::tools::Path(ReferenceWarePath).fromThis(openfluid::config::WARESDEV_WARESHUB_FILE).exists()))
{
return error("invalid reference ware path");
}
const std::string WarePath = openfluid::waresdev::WareSrcFactory::duplicateWare(ID, ParentPath,
m_Cmd.getOptionValue("from"),
m_Cmd.isOptionActive("accept-all"));
postWareCreation(WarePath);
return 0;
try
{
const std::string WarePath = openfluid::waresdev::WareSrcFactory::duplicateWare(ID, ParentPath,
m_Cmd.getOptionValue("from"),
m_Cmd.isOptionActive("accept-all"));
postWareCreation(WarePath);
return 0;
}
catch(const std::exception& e)
{
return error(e.what());
}
}

if (!m_Cmd.isOptionActive("type"))
Expand Down
3 changes: 2 additions & 1 deletion src/apps/openfluid/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ int main(int argc, char **argv)
// ---

auto CreateWareCmd = openfluid::utils::CommandLineCommand("create-ware","Create ware sources");
CreateWareCmd.addOptions({{"type","t","type of the ware sources to create (simulator|observer|builderext) (required)",
CreateWareCmd.addOptions({{"type","t","type of the ware sources to create (simulator|observer|builderext) "
"(required except when 'from' is used)",
true},
{"id","i","ID of the ware sources to create (required)",true},
{"main-class","m","name to use for the main C++ class",true},
Expand Down
71 changes: 48 additions & 23 deletions src/openfluid/base/ExamplesManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,20 @@ bool ExamplesManager::installDirectory(const std::string& FromPath, const std::s

if (!InstallTargetPathObj.isDirectory() || Force)
{
InstallTargetPathObj.makeDirectory();
if (!InstallTargetPathObj.makeDirectory())
{
openfluid::base::log::debug("Example installation", "Unable to create " + InstallTargetPathObj.toGeneric());
return false;
}

return openfluid::tools::Filesystem::copyDirectory(openfluid::tools::Filesystem::joinPath({FromPath,DirName}),
ToPath,true,true);
}

openfluid::base::log::debug("Example installation", "Unable to create " + InstallTargetPathObj.toGeneric() +
"dir because it already exists and force option is set to false");
return false;

return !std::filesystem::is_empty(InstallTargetPathObj.stdPath());
}


Expand All @@ -122,7 +127,7 @@ bool ExamplesManager::installDirectory(const std::string& FromPath, const std::s

bool ExamplesManager::installProject(const std::string& ProjectDir,
const std::string& ResourcesPath, const std::string& InstallPath,
const bool Force)
const bool Force, const bool Verbose)
{
std::string FromPath = openfluid::tools::Filesystem::joinPath({buildRessourcesPath(ResourcesPath),
openfluid::config::PROJECTS_PATH});
Expand All @@ -136,9 +141,15 @@ bool ExamplesManager::installProject(const std::string& ProjectDir,
}
std::string ToPath = openfluid::tools::Filesystem::joinPath({buildInstallPath(InstallPath),
openfluid::config::PROJECTS_PATH});
std::cout << "-- Installing project " << ProjectDir << " from " << FromPath << " to " << ToPath << " ";
if (Verbose)
{
std::cout << "-- Installing project " << ProjectDir << " from " << FromPath << " to " << ToPath << " ";
}
bool Status = installDirectory(FromPath, ToPath, ProjectDir, Force);
printSuccessStatus(Status);
if (Verbose)
{
printSuccessStatus(Status);
}
return Status;
}

Expand All @@ -149,7 +160,7 @@ bool ExamplesManager::installProject(const std::string& ProjectDir,

bool ExamplesManager::installSimulator(const std::string& SimulatorDir,
const std::string& ResourcesPath, const std::string& InstallPath,
const bool Force)
const bool Force, const bool Verbose)
{
std::string FromPath = openfluid::tools::Filesystem::joinPath({buildRessourcesPath(ResourcesPath),
openfluid::config::WARESDEV_PATH,
Expand All @@ -165,9 +176,15 @@ bool ExamplesManager::installSimulator(const std::string& SimulatorDir,
std::string ToPath = openfluid::tools::Filesystem::joinPath({buildInstallPath(InstallPath),
openfluid::config::WARESDEV_PATH,
openfluid::config::SIMULATORS_PATH});
std::cout << "-- Installing simulator " << SimulatorDir << " from " << FromPath << " to " << ToPath << " ";
if (Verbose)
{
std::cout << "-- Installing simulator " << SimulatorDir << " from " << FromPath << " to " << ToPath << " ";
}
bool Status = installDirectory(FromPath,ToPath,SimulatorDir,Force);
printSuccessStatus(Status);
if (Verbose)
{
printSuccessStatus(Status);
}
return Status;
}

Expand All @@ -178,7 +195,7 @@ bool ExamplesManager::installSimulator(const std::string& SimulatorDir,

bool ExamplesManager::installObserver(const std::string& ObserverDir,
const std::string& ResourcesPath, const std::string& InstallPath,
const bool Force)
const bool Force, const bool Verbose)
{
std::string FromPath = openfluid::tools::Filesystem::joinPath({buildRessourcesPath(ResourcesPath),
openfluid::config::WARESDEV_PATH,
Expand All @@ -194,9 +211,16 @@ bool ExamplesManager::installObserver(const std::string& ObserverDir,
std::string ToPath = openfluid::tools::Filesystem::joinPath({buildInstallPath(InstallPath),
openfluid::config::WARESDEV_PATH,
openfluid::config::OBSERVERS_PATH});
std::cout << "-- Installing observer " << ObserverDir << " from " << FromPath << " to " << ToPath << " ";

if (Verbose)
{
std::cout << "-- Installing observer " << ObserverDir << " from " << FromPath << " to " << ToPath << " ";
}
bool Status = installDirectory(FromPath,ToPath,ObserverDir,Force);
printSuccessStatus(Status);
if (Verbose)
{
printSuccessStatus(Status);
}
return Status;
}

Expand All @@ -206,7 +230,7 @@ bool ExamplesManager::installObserver(const std::string& ObserverDir,


bool ExamplesManager::installAllProjects(const std::string& ResourcesPath, const std::string& InstallPath,
const bool Force)
const bool Force, const bool Verbose)
{
auto ResPath = buildRessourcesPath(ResourcesPath);
auto InstPath = buildInstallPath(InstallPath);
Expand All @@ -220,7 +244,7 @@ bool ExamplesManager::installAllProjects(const std::string& ResourcesPath, const
bool AllIsOK = true;
for (const auto& Prj : FoundProjects)
{
AllIsOK &= installProject(Prj,ResPath,InstPath,Force);
AllIsOK &= installProject(Prj, ResPath, InstPath, Force, Verbose);
}
return AllIsOK;
}
Expand All @@ -238,7 +262,7 @@ bool ExamplesManager::installAllProjects(const std::string& ResourcesPath, const


bool ExamplesManager::installAllSimulators(const std::string& ResourcesPath, const std::string& InstallPath,
const bool Force)
const bool Force, const bool Verbose)
{
auto ResPath = buildRessourcesPath(ResourcesPath);
auto InstPath = buildInstallPath(InstallPath);
Expand All @@ -254,7 +278,7 @@ bool ExamplesManager::installAllSimulators(const std::string& ResourcesPath, con
bool AllIsOK = true;
for (const auto& Sim : FoundSimulators)
{
AllIsOK &= installSimulator(Sim,ResPath,InstPath,Force);
AllIsOK &= installSimulator(Sim, ResPath, InstPath, Force, Verbose);
}
return AllIsOK;
}
Expand All @@ -272,7 +296,7 @@ bool ExamplesManager::installAllSimulators(const std::string& ResourcesPath, con


bool ExamplesManager::installAllObservers(const std::string& ResourcesPath, const std::string& InstallPath,
const bool Force)
const bool Force, const bool Verbose)
{
auto ResPath = buildRessourcesPath(ResourcesPath);
auto InstPath = buildInstallPath(InstallPath);
Expand All @@ -288,7 +312,7 @@ bool ExamplesManager::installAllObservers(const std::string& ResourcesPath, cons
bool AllIsOK = true;
for (const auto& Obs : FoundObservers)
{
AllIsOK &= installObserver(Obs,ResPath,InstPath,Force);
AllIsOK &= installObserver(Obs, ResPath, InstPath, Force, Verbose);
}
return AllIsOK;
}
Expand All @@ -306,11 +330,11 @@ bool ExamplesManager::installAllObservers(const std::string& ResourcesPath, cons


bool ExamplesManager::installAllWares(const std::string& ResourcesPath, const std::string& InstallPath,
const bool Force)
const bool Force, const bool Verbose)
{
bool AllIsOK = true;
AllIsOK &= installAllSimulators(ResourcesPath,InstallPath,Force);
AllIsOK &= installAllObservers(ResourcesPath,InstallPath,Force);
AllIsOK &= installAllSimulators(ResourcesPath,InstallPath,Force,Verbose);
AllIsOK &= installAllObservers(ResourcesPath,InstallPath,Force,Verbose);

return AllIsOK;
}
Expand All @@ -320,11 +344,12 @@ bool ExamplesManager::installAllWares(const std::string& ResourcesPath, const st
// =====================================================================


bool ExamplesManager::installAll(const std::string& ResourcesPath, const std::string& InstallPath, const bool Force)
bool ExamplesManager::installAll(const std::string& ResourcesPath, const std::string& InstallPath, const bool Force,
const bool Verbose)
{
bool AllIsOK = true;
AllIsOK &= installAllProjects(ResourcesPath,InstallPath,Force);
AllIsOK &= installAllWares(ResourcesPath,InstallPath,Force);
AllIsOK &= installAllProjects(ResourcesPath,InstallPath,Force,Verbose);
AllIsOK &= installAllWares(ResourcesPath,InstallPath,Force,Verbose);

return AllIsOK;
}
Expand Down
16 changes: 8 additions & 8 deletions src/openfluid/base/ExamplesManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class OPENFLUID_API ExamplesManager
*/
static bool installProject(const std::string& ProjectDir,
const std::string& ResourcesPath = "", const std::string& InstallPath = "",
const bool Force = false);
const bool Force = false, const bool Verbose = false);

/**
Installs a single example simulator, using its directory name
Expand All @@ -94,11 +94,11 @@ class OPENFLUID_API ExamplesManager
*/
static bool installSimulator(const std::string& SimulatorDir,
const std::string& ResourcesPath = "", const std::string& InstallPath = "",
const bool Force = false);
const bool Force = false, const bool Verbose = false);

static bool installObserver(const std::string& ObserverDir,
const std::string& ResourcesPath = "", const std::string& InstallPath = "",
const bool Force = false);
const bool Force = false, const bool Verbose = false);

/**
Installs all example projects
Expand All @@ -109,7 +109,7 @@ class OPENFLUID_API ExamplesManager
@param[in] Force If true, the installation is forced even if it already exists (default is false)
*/
static bool installAllProjects(const std::string& ResourcesPath = "", const std::string& InstallPath = "",
const bool Force = false);
const bool Force = false, const bool Verbose = false);

/**
Installs all example simulators
Expand All @@ -120,7 +120,7 @@ class OPENFLUID_API ExamplesManager
@param[in] Force If true, the installation is forced even if it already exists (default is false)
*/
static bool installAllSimulators(const std::string& ResourcesPath = "", const std::string& InstallPath = "",
const bool Force = false);
const bool Force = false, const bool Verbose = false);

/**
Installs all example observers
Expand All @@ -131,7 +131,7 @@ class OPENFLUID_API ExamplesManager
@param[in] Force If true, the installation is forced even if it already exists (default is false)
*/
static bool installAllObservers(const std::string& ResourcesPath = "", const std::string& InstallPath = "",
const bool Force = false);
const bool Force = false, const bool Verbose = false);

/**
Installs all example wares (simulators and observers)
Expand All @@ -142,7 +142,7 @@ class OPENFLUID_API ExamplesManager
@param[in] Force If true, the installation is forced even if it already exists (default is false)
*/
static bool installAllWares(const std::string& ResourcesPath = "", const std::string& InstallPath = "",
const bool Force = false);
const bool Force = false, const bool Verbose = false);

/**
Installs all example projects and simulators
Expand All @@ -153,7 +153,7 @@ class OPENFLUID_API ExamplesManager
@param[in] Force If true, the installation is forced even if it already exists (default is false)
*/
static bool installAll(const std::string& ResourcesPath = "", const std::string& InstallPath = "",
const bool Force = false);
const bool Force = false, const bool Verbose = false);
};


Expand Down
Loading
Loading