@@ -17,14 +17,92 @@ FsCreator::FsCreator()
17
17
{
18
18
}
19
19
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)
21
98
{
22
99
bool ret = false ;
23
100
24
101
// find free directory
25
102
struct stat info;
26
103
27
104
std::string work_dir_path;
105
+ const auto & basepath = FS.file .core_h .dir ;
28
106
29
107
if (rw)
30
108
{
@@ -34,7 +112,7 @@ bool FsCreator::PrepareDirectory(std::string drvname, std::string basepath, bool
34
112
// for this case check only if directory exists
35
113
if (stat (work_dir_path.c_str (), &info) != 0 )
36
114
{
37
- if (std::filesystem::create_directory (work_dir_path) != 0 )
115
+ if (! std::filesystem::create_directory (work_dir_path))
38
116
{
39
117
ret = false ;
40
118
}
@@ -73,86 +151,12 @@ bool FsCreator::PrepareDirectory(std::string drvname, std::string basepath, bool
73
151
}
74
152
}
75
153
76
- FS.file .libdir = work_dir_path + kLibDir ;
77
-
78
154
std::filesystem::create_directory (FS.file .libdir );
79
- FS.file .usrdir = work_dir_path + kUsrDir ;
80
-
81
155
std::filesystem::create_directory (FS.file .usrdir );
82
- FS.file .incdir = work_dir_path + kIncDir ;
83
-
84
156
std::filesystem::create_directory (FS.file .incdir );
85
- FS.file .confdir = work_dir_path + kConfDir ;
86
-
87
157
std::filesystem::create_directory (FS.file .confdir );
88
- FS.file .utildir = work_dir_path + kUtilDir ;
89
-
90
158
std::filesystem::create_directory (FS.file .utildir );
91
159
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
-
156
160
return ret;
157
161
}
158
162
0 commit comments