Move json generated files to ${MODFILE}/model/json/
parent
988a9f6e2d
commit
e376267a28
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
#include "ParsingDriver.hh"
|
#include "ParsingDriver.hh"
|
||||||
#include "ModFile.hh"
|
#include "ModFile.hh"
|
||||||
#include "ConfigFile.hh"
|
#include "ConfigFile.hh"
|
||||||
|
@ -40,6 +42,8 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear
|
||||||
{
|
{
|
||||||
ParsingDriver p(warnings, nostrict);
|
ParsingDriver p(warnings, nostrict);
|
||||||
|
|
||||||
|
boost::filesystem::remove_all(basename + "/model/json");
|
||||||
|
|
||||||
// Do parsing and construct internal representation of mod file
|
// Do parsing and construct internal representation of mod file
|
||||||
ModFile *mod_file = p.parse(in, debug);
|
ModFile *mod_file = p.parse(in, debug);
|
||||||
if (json == parsing)
|
if (json == parsing)
|
||||||
|
|
|
@ -753,7 +753,8 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
|
||||||
{
|
{
|
||||||
// Erase possible remnants of previous runs
|
// Erase possible remnants of previous runs
|
||||||
boost::filesystem::remove_all("+" + basename);
|
boost::filesystem::remove_all("+" + basename);
|
||||||
boost::filesystem::remove_all(basename + "/model");
|
boost::filesystem::remove_all(basename + "/model/src");
|
||||||
|
boost::filesystem::remove_all(basename + "/model/bytecode");
|
||||||
}
|
}
|
||||||
|
|
||||||
ofstream mOutputFile;
|
ofstream mOutputFile;
|
||||||
|
@ -1512,8 +1513,8 @@ ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType
|
||||||
|
|
||||||
if (basename.size())
|
if (basename.size())
|
||||||
{
|
{
|
||||||
string fname(basename);
|
boost::filesystem::create_directories(basename + "/model/json");
|
||||||
fname += ".json";
|
string fname{basename + "/model/json/modfile.json"};
|
||||||
jsonOutputFile.open(fname, ios::out | ios::binary);
|
jsonOutputFile.open(fname, ios::out | ios::binary);
|
||||||
if (!jsonOutputFile.is_open())
|
if (!jsonOutputFile.is_open())
|
||||||
{
|
{
|
||||||
|
@ -1534,8 +1535,7 @@ ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType
|
||||||
{
|
{
|
||||||
if (basename.size())
|
if (basename.size())
|
||||||
{
|
{
|
||||||
string fname(basename);
|
string fname{basename + "/model/json/modfile-original.json"};
|
||||||
fname += "_original.json";
|
|
||||||
jsonOutputFile.open(fname, ios::out | ios::binary);
|
jsonOutputFile.open(fname, ios::out | ios::binary);
|
||||||
if (!jsonOutputFile.is_open())
|
if (!jsonOutputFile.is_open())
|
||||||
{
|
{
|
||||||
|
@ -1556,8 +1556,7 @@ ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType
|
||||||
{
|
{
|
||||||
if (basename.size())
|
if (basename.size())
|
||||||
{
|
{
|
||||||
string fname(basename);
|
string fname{basename + "/model/json/steady_state_model.json"};
|
||||||
fname += "_steady_state_model.json";
|
|
||||||
jsonOutputFile.open(fname, ios::out | ios::binary);
|
jsonOutputFile.open(fname, ios::out | ios::binary);
|
||||||
if (!jsonOutputFile.is_open())
|
if (!jsonOutputFile.is_open())
|
||||||
{
|
{
|
||||||
|
@ -1621,31 +1620,21 @@ ModFile::writeJsonComputingPassOutput(const string &basename, JsonFileOutputType
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string fname_original, fname_static, fname_dynamic;
|
boost::filesystem::create_directories(basename + "/model/json");
|
||||||
fname_static = basename + "_static.json";
|
|
||||||
fname_dynamic = basename + "_dynamic.json";
|
|
||||||
|
|
||||||
writeJsonFileHelper(fname_static, static_output);
|
writeJsonFileHelper(basename + "/model/json/static.json", static_output);
|
||||||
writeJsonFileHelper(fname_dynamic, dynamic_output);
|
writeJsonFileHelper(basename + "/model/json/dynamic.json", dynamic_output);
|
||||||
|
|
||||||
if (!static_paramsd_output.str().empty())
|
if (!static_paramsd_output.str().empty())
|
||||||
{
|
writeJsonFileHelper(basename + "/model/json/static_params_derivs.json", static_paramsd_output);
|
||||||
string fname_static_params;
|
|
||||||
fname_static_params = basename + "_static_params_derivs.json";
|
|
||||||
writeJsonFileHelper(fname_static_params, static_paramsd_output);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dynamic_paramsd_output.str().empty())
|
if (!dynamic_paramsd_output.str().empty())
|
||||||
{
|
writeJsonFileHelper(basename + "/model/json/params_derivs.json", dynamic_paramsd_output);
|
||||||
string fname_dynamic_params;
|
|
||||||
fname_dynamic_params = basename + "_params_derivs.json";
|
|
||||||
writeJsonFileHelper(fname_dynamic_params, dynamic_paramsd_output);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ModFile::writeJsonFileHelper(string &fname, ostringstream &output) const
|
ModFile::writeJsonFileHelper(const string &fname, ostringstream &output) const
|
||||||
{
|
{
|
||||||
ofstream jsonOutput;
|
ofstream jsonOutput;
|
||||||
jsonOutput.open(fname, ios::out | ios::binary);
|
jsonOutput.open(fname, ios::out | ios::binary);
|
||||||
|
|
|
@ -122,7 +122,7 @@ private:
|
||||||
//! Functions used in writing of JSON outut. See writeJsonOutput
|
//! Functions used in writing of JSON outut. See writeJsonOutput
|
||||||
void writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType json_output_mode, bool transformpass, bool computingpass) const;
|
void writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType json_output_mode, bool transformpass, bool computingpass) const;
|
||||||
void writeJsonComputingPassOutput(const string &basename, JsonFileOutputType json_output_mode, bool jsonderivsimple) const;
|
void writeJsonComputingPassOutput(const string &basename, JsonFileOutputType json_output_mode, bool jsonderivsimple) const;
|
||||||
void writeJsonFileHelper(string &fname, ostringstream &output) const;
|
void writeJsonFileHelper(const string &fname, ostringstream &output) const;
|
||||||
public:
|
public:
|
||||||
//! Add a statement
|
//! Add a statement
|
||||||
void addStatement(Statement *st);
|
void addStatement(Statement *st);
|
||||||
|
|
Loading…
Reference in New Issue