Skip to content

Commit

Permalink
added file and cli flag for retrieving cyclus core and dependency ver…
Browse files Browse the repository at this point in the history
…sions.

Fixes #578.
  • Loading branch information
rwcarlsen committed Sep 23, 2013
1 parent f675fb6 commit 2238c6a
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 18 deletions.
4 changes: 4 additions & 0 deletions src/Core/Config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ ELSE()
CONFIGURE_FILE(suffix.h.in ${CMAKE_CURRENT_SOURCE_DIR}/suffix.h @ONLY)
ENDIF()

EXECUTE_PROCESS(COMMAND git describe OUTPUT_VARIABLE core_version OUTPUT_STRIP_TRAILING_WHITESPACE)
CONFIGURE_FILE(version.h.in ${CMAKE_CURRENT_SOURCE_DIR}/version.h @ONLY)

# Here we set some components for installation with cpack
INSTALL(FILES
${CMAKE_CURRENT_SOURCE_DIR}/cyclus.rng.in
Expand All @@ -25,6 +28,7 @@ INSTALL(FILES
unix_helper_functions.h
windows_helper_functions.h
suffix.h
version.h
DESTINATION include/cyclus
COMPONENT core
)
46 changes: 46 additions & 0 deletions src/Core/Config/version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#ifndef VERSION_H_
#define VERSION_H_

#include <sstream>

#include "boost/version.hpp"
#include "sqlite3.h"
#include "hdf5.h"
#include "libxml/xmlversion.h"
#include "coin/CbcConfig.h"


namespace cyclus {
namespace version {
const char* core() {
return "@core_version@";
};

const char* boost() {
return BOOST_LIB_VERSION;
};

const char* sqlite3() {
return SQLITE_VERSION;
};

const char* hdf5() {
std::stringstream ss;
ss << H5_VERS_MAJOR << ".";
ss << H5_VERS_MINOR << ".";
ss << H5_VERS_RELEASE << "-";
ss << H5_VERS_SUBRELEASE;
return ss.str().c_str();
};

const char* xml2() {
return LIBXML_DOTTED_VERSION;
};

const char* coincbc() {
return CBC_VERSION;
};
};
} // namespace cyclus

#endif
36 changes: 18 additions & 18 deletions src/app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,17 @@
#include "hdf5_back.h"
#include "csv_back.h"
#include "context.h"
#include "version.h"

namespace po = boost::program_options;
namespace fs = boost::filesystem;

using namespace cyclus;

//-----------------------------------------------------------------------
// Main entry point for the test application...
//-----------------------------------------------------------------------
int main(int argc, char* argv[]) {
using cyclus::Logger;
using cyclus::Env;
using cyclus::Model;
using cyclus::Timer;
using cyclus::Logger;
using cyclus::LogLevel;
using cyclus::LEV_ERROR;
using cyclus::EventManager;
using cyclus::EventBackend;
using cyclus::Hdf5Back;
using cyclus::SqliteBack;
using cyclus::CsvBack;
using cyclus::XMLFileLoader;
using cyclus::Context;

// verbosity help msg
std::string vmessage = "output log verbosity. Can be text:\n\n";
Expand All @@ -52,6 +41,7 @@ int main(int argc, char* argv[]) {
po::options_description desc("Allowed options");
desc.add_options()
("help,h", "produce help message")
("version", "print cyclus core and dependency versions and quit")
("no-model", "only print log entries from cyclus core code")
("no-mem", "exclude memory log statement from logger output")
("verb,v", po::value<std::string>(), vmessage.c_str())
Expand Down Expand Up @@ -91,6 +81,16 @@ int main(int argc, char* argv[]) {
return 0;
}

if (vm.count("version")) {
std::cout << "Cyclus Core " << version::core() << "\n\nDependencies:\n";
std::cout << " Boost " << version::boost() << "\n";
std::cout << " Coin-Cbc " << version::coincbc() << "\n";
std::cout << " Hdf5 " << version::hdf5() << "\n";
std::cout << " Sqlite3 " << version::sqlite3() << "\n";
std::cout << " xml2 " << version::xml2() << "\n";
return 0;
}

if (vm.count("no-model")) {
Logger::NoModel() = true;
}
Expand Down Expand Up @@ -130,7 +130,7 @@ int main(int argc, char* argv[]) {
std::string inputFile = vm["input-file"].as<std::string>();
XMLFileLoader loader(&ctx, inputFile);
loader.LoadAll();
} catch (cyclus::Error e) {
} catch (Error e) {
success = false;
CLOG(LEV_ERROR) << e.what();
}
Expand All @@ -141,7 +141,7 @@ int main(int argc, char* argv[]) {
if (vm.count("output-path")){
output_path = vm["output-path"].as<std::string>();
}
} catch (cyclus::Error ge) {
} catch (Error ge) {
success = false;
CLOG(LEV_ERROR) << ge.what();
}
Expand All @@ -166,7 +166,7 @@ int main(int argc, char* argv[]) {
// Run the simulation
try {
ti.RunSim();
} catch (cyclus::Error err) {
} catch (Error err) {
success = false;
CLOG(LEV_ERROR) << err.what();
}
Expand All @@ -177,7 +177,7 @@ int main(int argc, char* argv[]) {
// Close Dynamically loaded modules
try {
Model::UnloadModules();
} catch (cyclus::Error err) {
} catch (Error err) {
success = false;
CLOG(LEV_ERROR) << err.what();
}
Expand Down

0 comments on commit 2238c6a

Please sign in to comment.