Make tool out of json_converter
This commit is contained in:
@@ -160,6 +160,8 @@ endif()
|
|||||||
add_subdirectory(src/configuration)
|
add_subdirectory(src/configuration)
|
||||||
add_subdirectory(src/libdramsys)
|
add_subdirectory(src/libdramsys)
|
||||||
|
|
||||||
|
add_subdirectory(tools)
|
||||||
|
|
||||||
if(DRAMSYS_BUILD_CLI)
|
if(DRAMSYS_BUILD_CLI)
|
||||||
add_subdirectory(src/simulator)
|
add_subdirectory(src/simulator)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -18,7 +18,3 @@ target_link_libraries(tests_configuration PRIVATE
|
|||||||
gtest_discover_tests(tests_configuration
|
gtest_discover_tests(tests_configuration
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(jsonconverter ${CMAKE_CURRENT_SOURCE_DIR}/jsonconverter.cpp)
|
|
||||||
target_link_libraries(jsonconverter PRIVATE DRAMSys::config)
|
|
||||||
set_target_properties(jsonconverter PROPERTIES FOLDER tests/configuration)
|
|
||||||
|
|||||||
2
tools/CMakeLists.txt
Normal file
2
tools/CMakeLists.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
add_executable(json_converter json_converter.cpp)
|
||||||
|
target_link_libraries(json_converter PRIVATE DRAMSys::config)
|
||||||
@@ -43,19 +43,25 @@ int main(int argc, char** argv)
|
|||||||
{
|
{
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
{
|
{
|
||||||
std::cerr << "Must specify a simulation json as single argument.\n";
|
std::cerr << "Must specify a simulation json.\n";
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc < 3)
|
||||||
|
{
|
||||||
|
std::cerr << "Must specify the output json.\n";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string pathToJson = argv[1];
|
std::string pathToJson = argv[1];
|
||||||
std::string resourceDirectory = argc <= 2 ? DRAMSYS_RESOURCE_DIR : argv[2];
|
std::string resourceDirectory = argc <= 3 ? DRAMSYS_RESOURCE_DIR : argv[3];
|
||||||
|
|
||||||
auto configuration = DRAMSys::Config::from_path(pathToJson, resourceDirectory);
|
auto configuration = DRAMSys::Config::from_path(pathToJson, resourceDirectory);
|
||||||
|
|
||||||
nlohmann::json json;
|
nlohmann::json json;
|
||||||
json["simulation"] = configuration;
|
json["simulation"] = configuration;
|
||||||
|
|
||||||
std::ofstream output(pathToJson + "_converted.json");
|
std::ofstream output(argv[2]);
|
||||||
output << json.dump(4);
|
output << json.dump(4);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
Reference in New Issue
Block a user