@@ -149,11 +149,36 @@ int RunAsWorker(
149
149
return 0 ;
150
150
}
151
151
152
+ int RunStandalone (
153
+ const System::StrType& exec_path,
154
+ const System::EnvironmentBlock& environment_block,
155
+ const System::StrType& param_file_param
156
+ ) {
157
+ if (param_file_param[0 ] != ' @' ) {
158
+ std::cerr << " Param file must start with '@', got \" " << param_file_param << " \"\n " ;
159
+ return -1 ;
160
+ }
161
+
162
+ std::string param_file = ToUtf8 (param_file_param).substr (1 );
163
+ System::Arguments arguments;
164
+
165
+ std::ifstream source (param_file);
166
+ std::string line;
167
+ while (std::getline (source, line)) {
168
+ arguments.push_back (line);
169
+ }
170
+
171
+ std::string empty;
172
+
173
+ return System::Exec (exec_path, arguments, environment_block, empty, empty);
174
+ }
175
+
152
176
using CharType = process_wrapper::System::StrType::value_type;
153
177
154
178
int PW_MAIN (int argc, const CharType* argv[], const CharType* envp[]) {
155
179
System::StrType exec_path;
156
180
System::StrType compilation_mode;
181
+ System::StrType param_file;
157
182
System::EnvironmentBlock environment_block;
158
183
// Taking all environment variables from the current process
159
184
// and sending them down to the child process
@@ -188,6 +213,8 @@ int PW_MAIN(int argc, const CharType* argv[], const CharType* envp[]) {
188
213
return -1 ;
189
214
}
190
215
exec_path = argv[i];
216
+ } else if (arg[0 ] == ' @' ) {
217
+ param_file = arg;
191
218
} else {
192
219
std::cerr << " worker wrapper error: unknown argument \" " << ToUtf8 (arg)
193
220
<< " \" ." << ' \n ' ;
@@ -196,8 +223,12 @@ int PW_MAIN(int argc, const CharType* argv[], const CharType* envp[]) {
196
223
}
197
224
198
225
if (as_worker) {
199
- return RunAsWorker (exec_path, compilation_mode, environment_block);
226
+ if (!param_file.empty ()) {
227
+ std::cerr << " Param file argument \" " << param_file << " \" not supported in worker mode\n " ;
228
+ return -1 ;
229
+ }
230
+ return RunAsWorker (exec_path, compilation_mode, environment_block);
231
+ } else {
232
+ return RunStandalone (exec_path, environment_block, param_file);
200
233
}
201
- std::cerr << " Don't know how to run as non-worker yet\n " ;
202
- return -1 ;
203
234
}
0 commit comments