Skip to content

Commit c05ee54

Browse files
committed
Added versions to FS gen config.
1 parent 2ae8673 commit c05ee54

File tree

3 files changed

+88
-79
lines changed

3 files changed

+88
-79
lines changed

src/app.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ void CoderApp::GenerateCode()
5454
std::string info("");
5555

5656
// create main destination directory
57-
auto ret = fscreator->PrepareDirectory(Params.drvname.value.c_str(), Params.outdir.value.c_str(), Params.is_rewrite,
58-
info);
57+
fscreator->Configure(Params.drvname.value, Params.outdir.value, info, scanner->dblist.ver.hi, scanner->dblist.ver.low);
58+
59+
auto ret = fscreator->PrepareDirectory(Params.is_rewrite);
5960

6061
if (ret)
6162
{

src/codegen/fs-creator.cpp

Lines changed: 80 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,92 @@ FsCreator::FsCreator()
1717
{
1818
}
1919

20-
bool FsCreator::PrepareDirectory(std::string drvname, std::string basepath, bool rw, std::string& strinfo)
20+
21+
void FsCreator::Configure(const std::string& drvname, const std::string& outpath,
22+
const std::string& info, uint32_t h, uint32_t l)
23+
{
24+
FS.file.libdir = outpath + kLibDir;
25+
FS.file.usrdir = outpath + kUsrDir;
26+
FS.file.incdir = outpath + kIncDir;
27+
FS.file.confdir = outpath + kConfDir;
28+
FS.file.utildir = outpath + kUtilDir;
29+
// directory valid and exists, set all the values
30+
FS.gen.DrvName_orig = drvname;
31+
FS.gen.DRVNAME = str_toupper(drvname);
32+
FS.gen.drvname = str_tolower(drvname);
33+
34+
FS.file.core_h.dir = outpath;
35+
FS.file.core_h.fname = FS.gen.drvname + ".h";
36+
FS.file.core_h.fpath = FS.file.libdir + "/" + FS.file.core_h.fname;
37+
38+
FS.file.core_c.dir = outpath;
39+
FS.file.core_c.fname = FS.gen.drvname + ".c";
40+
FS.file.core_c.fpath = FS.file.libdir + "/" + FS.file.core_c.fname;
41+
42+
FS.file.util_h.dir = outpath;
43+
FS.file.util_h.fname = FS.gen.drvname + "-binutil" + ".h";
44+
FS.file.util_h.fpath = FS.file.utildir + "/" + FS.file.util_h.fname;
45+
46+
FS.file.util_c.dir = outpath;
47+
FS.file.util_c.fname = FS.gen.drvname + "-binutil" + ".c";
48+
FS.file.util_c.fpath = FS.file.utildir + "/" + FS.file.util_c.fname;
49+
50+
FS.file.fmon_h.dir = outpath;
51+
FS.file.fmon_h.fname = FS.gen.drvname + "-fmon.h";
52+
FS.file.fmon_h.fpath = FS.file.libdir + "/" + FS.file.fmon_h.fname;
53+
54+
FS.file.fmon_c.dir = outpath;
55+
FS.file.fmon_c.fname = FS.gen.drvname + "-fmon.c";
56+
FS.file.fmon_c.fpath = FS.file.usrdir + "/" + FS.file.fmon_c.fname;
57+
58+
snprintf(_tmpb, kTmpLen, "%s_USE_BITS_SIGNAL", FS.gen.DRVNAME.c_str());
59+
FS.gen.usebits_def = _tmpb;
60+
61+
snprintf(_tmpb, kTmpLen, "%s_USE_DIAG_MONITORS", FS.gen.DRVNAME.c_str());
62+
FS.gen.usemon_def = _tmpb;
63+
64+
snprintf(_tmpb, kTmpLen, "%s_USE_MONO_FMON", FS.gen.DRVNAME.c_str());
65+
FS.gen.usemonofmon_def = _tmpb;
66+
67+
snprintf(_tmpb, kTmpLen, "%s_USE_SIGFLOAT", FS.gen.DRVNAME.c_str());
68+
FS.gen.usesigfloat_def = _tmpb;
69+
70+
snprintf(_tmpb, kTmpLen, "%s_USE_CANSTRUCT", FS.gen.DRVNAME.c_str());
71+
FS.gen.usesruct_def = _tmpb;
72+
73+
snprintf(_tmpb, kTmpLen, "%s_AUTO_ROLL", FS.gen.DRVNAME.c_str());
74+
FS.gen.useroll_def = _tmpb;
75+
76+
snprintf(_tmpb, kTmpLen, "%s_AUTO_CSM", FS.gen.DRVNAME.c_str());
77+
FS.gen.usecsm_def = _tmpb;
78+
79+
snprintf(_tmpb, kTmpLen, "VER_%s_MAJ", FS.gen.DRVNAME.c_str());
80+
FS.gen.verhigh_def = _tmpb;
81+
82+
snprintf(_tmpb, kTmpLen, "VER_%s_MIN", FS.gen.DRVNAME.c_str());
83+
FS.gen.verlow_def = _tmpb;
84+
85+
// load start info to fdescriptor
86+
FS.gen.start_info.clear();
87+
88+
if (info.size() > 0)
89+
{
90+
FS.gen.start_info = info;
91+
}
92+
93+
FS.gen.hiver = h;
94+
FS.gen.lowver = l;
95+
}
96+
97+
bool FsCreator::PrepareDirectory(bool rw)
2198
{
2299
bool ret = false;
23100

24101
// find free directory
25102
struct stat info;
26103

27104
std::string work_dir_path;
105+
const auto& basepath = FS.file.core_h.dir;
28106

29107
if (rw)
30108
{
@@ -34,7 +112,7 @@ bool FsCreator::PrepareDirectory(std::string drvname, std::string basepath, bool
34112
// for this case check only if directory exists
35113
if (stat(work_dir_path.c_str(), &info) != 0)
36114
{
37-
if (std::filesystem::create_directory(work_dir_path) != 0)
115+
if (!std::filesystem::create_directory(work_dir_path))
38116
{
39117
ret = false;
40118
}
@@ -73,86 +151,12 @@ bool FsCreator::PrepareDirectory(std::string drvname, std::string basepath, bool
73151
}
74152
}
75153

76-
FS.file.libdir = work_dir_path + kLibDir;
77-
78154
std::filesystem::create_directory(FS.file.libdir);
79-
FS.file.usrdir = work_dir_path + kUsrDir;
80-
81155
std::filesystem::create_directory(FS.file.usrdir);
82-
FS.file.incdir = work_dir_path + kIncDir;
83-
84156
std::filesystem::create_directory(FS.file.incdir);
85-
FS.file.confdir = work_dir_path + kConfDir;
86-
87157
std::filesystem::create_directory(FS.file.confdir);
88-
FS.file.utildir = work_dir_path + kUtilDir;
89-
90158
std::filesystem::create_directory(FS.file.utildir);
91159

92-
// directory valid and exists, set all the values
93-
FS.gen.DrvName_orig = drvname;
94-
FS.gen.DRVNAME = str_toupper(drvname);
95-
FS.gen.drvname = str_tolower(drvname);
96-
97-
FS.file.core_h.dir = work_dir_path;
98-
FS.file.core_h.fname = FS.gen.drvname + ".h";
99-
FS.file.core_h.fpath = FS.file.libdir + "/" + FS.file.core_h.fname;
100-
101-
FS.file.core_c.dir = work_dir_path;
102-
FS.file.core_c.fname = FS.gen.drvname + ".c";
103-
FS.file.core_c.fpath = FS.file.libdir + "/" + FS.file.core_c.fname;
104-
105-
FS.file.util_h.dir = work_dir_path;
106-
FS.file.util_h.fname = FS.gen.drvname + "-binutil" + ".h";
107-
FS.file.util_h.fpath = FS.file.utildir + "/" + FS.file.util_h.fname;
108-
109-
FS.file.util_c.dir = work_dir_path;
110-
FS.file.util_c.fname = FS.gen.drvname + "-binutil" + ".c";
111-
FS.file.util_c.fpath = FS.file.utildir + "/" + FS.file.util_c.fname;
112-
113-
FS.file.fmon_h.dir = work_dir_path;
114-
FS.file.fmon_h.fname = FS.gen.drvname + "-fmon.h";
115-
FS.file.fmon_h.fpath = FS.file.libdir + "/" + FS.file.fmon_h.fname;
116-
117-
FS.file.fmon_c.dir = work_dir_path;
118-
FS.file.fmon_c.fname = FS.gen.drvname + "-fmon.c";
119-
FS.file.fmon_c.fpath = FS.file.usrdir + "/" + FS.file.fmon_c.fname;
120-
121-
snprintf(_tmpb, kTmpLen, "%s_USE_BITS_SIGNAL", FS.gen.DRVNAME.c_str());
122-
FS.gen.usebits_def = _tmpb;
123-
124-
snprintf(_tmpb, kTmpLen, "%s_USE_DIAG_MONITORS", FS.gen.DRVNAME.c_str());
125-
FS.gen.usemon_def = _tmpb;
126-
127-
snprintf(_tmpb, kTmpLen, "%s_USE_MONO_FMON", FS.gen.DRVNAME.c_str());
128-
FS.gen.usemonofmon_def = _tmpb;
129-
130-
snprintf(_tmpb, kTmpLen, "%s_USE_SIGFLOAT", FS.gen.DRVNAME.c_str());
131-
FS.gen.usesigfloat_def = _tmpb;
132-
133-
snprintf(_tmpb, kTmpLen, "%s_USE_CANSTRUCT", FS.gen.DRVNAME.c_str());
134-
FS.gen.usesruct_def = _tmpb;
135-
136-
snprintf(_tmpb, kTmpLen, "%s_AUTO_ROLL", FS.gen.DRVNAME.c_str());
137-
FS.gen.useroll_def = _tmpb;
138-
139-
snprintf(_tmpb, kTmpLen, "%s_AUTO_CSM", FS.gen.DRVNAME.c_str());
140-
FS.gen.usecsm_def = _tmpb;
141-
142-
snprintf(_tmpb, kTmpLen, "VER_%s_MAJ", FS.gen.DRVNAME.c_str());
143-
FS.gen.verhigh_def = _tmpb;
144-
145-
snprintf(_tmpb, kTmpLen, "VER_%s_MIN", FS.gen.DRVNAME.c_str());
146-
FS.gen.verlow_def = _tmpb;
147-
148-
// load start info to fdescriptor
149-
FS.gen.start_info.clear();
150-
151-
if (strinfo.size() > 0)
152-
{
153-
FS.gen.start_info = strinfo;
154-
}
155-
156160
return ret;
157161
}
158162

src/codegen/fs-creator.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ typedef struct
4545

4646
// inforamtion to be placed at the start of each source file
4747
std::string start_info;
48+
49+
uint32_t hiver{0};
50+
uint32_t lowver{0};
4851
} GenDescriptor_t;
4952

5053
typedef struct
@@ -62,7 +65,8 @@ class FsCreator {
6265
public:
6366
FsCreator();
6467

65-
bool PrepareDirectory(std::string drvname, std::string basepath, bool rw, std::string& info);
68+
void Configure(const std::string& drvname, const std::string& outpath, const std::string& info, uint32_t h, uint32_t l);
69+
bool PrepareDirectory(bool rw);
6670

6771
std::string CreateSubDir(std::string basepath, std::string subdir, bool rm = true);
6872

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy