@@ -158,29 +158,33 @@ function main($request, $compiler_config)
158
158
//handleCompile sets any include directories needed and calls the doCompile function, which does the actual compilation
159
159
$ ret = $ this ->handleCompile ("$ compiler_dir/files " , $ files ["sketch_files " ], $ compiler_config , $ CC , $ CFLAGS , $ CPP , $ CPPFLAGS , $ AS , $ ASFLAGS , $ CLANG , $ CLANG_FLAGS , $ core_includes , $ target_arch , $ clang_target_arch , $ include_directories ["main " ], $ format );
160
160
161
- if ($ ARCHIVE_OPTION === true ){
162
- $ arch_ret = $ this ->createArchive ($ compiler_dir , $ TEMP_DIR , $ ARCHIVE_DIR , $ ARCHIVE_PATH );
163
- if ($ arch_ret ["success " ] === false )
164
- return $ arch_ret ;
165
- }
166
-
167
161
$ log_content = (($ compiler_config ['logging ' ] === true ) ? @file_get_contents ($ compiler_config ['logFileName ' ]) : "" );
168
162
if ($ compiler_config ['logging ' ] === true ){
169
163
if ($ log_content !== false ) {
170
164
$ ret ["log " ] = $ log_content ;
171
165
file_put_contents ($ compiler_config ["compiler_dir " ] . "/log " , $ log_content );
172
166
}
173
167
else
174
- return array_merge ( array ( " success " => " false " , " message " => " Failed to access logfile. "), ( $ ARCHIVE_OPTION === true ) ? array ( " archive " => $ ARCHIVE_PATH ) : array ()) ;
168
+ $ ret [ " log " ] = " Failed to access logfile. " ;
175
169
}
170
+
171
+ if ($ ARCHIVE_OPTION === true ){
172
+ $ arch_ret = $ this ->createArchive ($ compiler_dir , $ TEMP_DIR , $ ARCHIVE_DIR , $ ARCHIVE_PATH );
173
+ if ($ arch_ret ["success " ] === false )
174
+ $ ret ["archive " ] = $ arch_ret ["message " ];
175
+ else
176
+ $ ret ["archive " ] = $ ARCHIVE_PATH ;
177
+ }
178
+
176
179
if (!$ ret ["success " ])
177
- return array_merge ( $ ret, ( $ ARCHIVE_OPTION === true ) ? array ( " archive " => $ ARCHIVE_PATH ) : array ()) ;
180
+ return $ ret ;
178
181
179
182
if ($ format == "syntax " )
180
183
return array_merge (array (
181
184
"success " => true ,
182
185
"time " => microtime (true ) - $ start_time ),
183
- ($ ARCHIVE_OPTION ===true ) ? array ("archive " => $ ARCHIVE_PATH ) : array ());
186
+ ($ ARCHIVE_OPTION ===true ) ? array ("archive " => $ ret ["archive " ]) : array (),
187
+ ($ compiler_config ['logging ' ] === true ) ? array ("log " => $ ret ["log " ]) : array ());
184
188
185
189
//Keep all object files urls needed for linking.
186
190
$ objects_to_link = $ files ["sketch_files " ]["o " ];
@@ -190,35 +194,20 @@ function main($request, $compiler_config)
190
194
{
191
195
$ content = base64_encode (file_get_contents ($ files ["sketch_files " ]["o " ][0 ].".o " ));
192
196
if (count ($ files ["sketch_files " ]["o " ]) != 1 || !$ content ){
193
- if ($ compiler_config ['logging ' ] === false )
194
- return array_merge (array (
195
- "success " => false ,
196
- "step " => -1 , //TODO: Fix this step?
197
- "message " => "" ),
198
- ($ ARCHIVE_OPTION ===true ) ? array ("archive " => $ ARCHIVE_PATH ) : array ());
199
- else
200
- return array_merge (array (
201
- "success " => false ,
202
- "step " => -1 , //TODO: Fix this step?
203
- "message " => "" ,
204
- "log " => $ log_content ),
205
- ($ ARCHIVE_OPTION ===true ) ? array ("archive " => $ ARCHIVE_PATH ) : array ());
206
- }
207
- else {
208
- if ($ compiler_config ['logging ' ] === false )
209
- return array_merge (array (
210
- "success " => true ,
211
- "time " => microtime (true ) - $ start_time ,
212
- "output " => $ content ),
213
- ($ ARCHIVE_OPTION ===true ) ? array ("archive " => $ ARCHIVE_PATH ) : array ());
214
- else
215
- return array_merge (array (
216
- "success " => true ,
217
- "time " => microtime (true ) - $ start_time ,
218
- "output " => $ content ,
219
- "log " => $ log_content ),
220
- ($ ARCHIVE_OPTION ===true ) ? array ("archive " => $ ARCHIVE_PATH ) : array ());
197
+ return array_merge (array (
198
+ "success " => false ,
199
+ "step " => -1 , //TODO: Fix this step?
200
+ "message " => "" ),
201
+ ($ ARCHIVE_OPTION ===true ) ? array ("archive " => $ ret ["archive " ]) : array (),
202
+ ($ compiler_config ['logging ' ] === true ) ? array ("log " => $ ret ["log " ]) : array ());
221
203
}
204
+ else
205
+ return array_merge (array (
206
+ "success " => true ,
207
+ "time " => microtime (true ) - $ start_time ,
208
+ "output " => $ content ),
209
+ ($ ARCHIVE_OPTION ===true ) ? array ("archive " => $ ret ["archive " ]) : array (),
210
+ ($ compiler_config ['logging ' ] === true ) ? array ("log " => $ ret ["log " ]) : array ());
222
211
}
223
212
224
213
// Step 5: Create objects for core files (if core file does not already exist)
@@ -233,19 +222,12 @@ function main($request, $compiler_config)
233
222
$ make_dir_success = @mkdir ($ this ->object_directory , 0777 , true );
234
223
}
235
224
if (!$ make_dir_success ){
236
- if ($ compiler_config ['logging ' ] === false )
237
225
return array_merge (array (
238
226
"success " => false ,
239
227
"step " => 5 ,
240
228
"message " => "Could not create object files directory. " ),
241
- ($ ARCHIVE_OPTION ===true ) ? array ("archive " => $ ARCHIVE_PATH ) : array ());
242
- else
243
- return array_merge (array (
244
- "success " => false ,
245
- "step " => 5 ,
246
- "message " => "Could not create object files directory. " ,
247
- "log " => $ log_content ),
248
- ($ ARCHIVE_OPTION ===true ) ? array ("archive " => $ ARCHIVE_PATH ) : array ());
229
+ ($ ARCHIVE_OPTION ===true ) ? array ("archive " => $ ret ["archive " ]) : array (),
230
+ ($ compiler_config ['logging ' ] === true ) ? array ("log " => $ ret ["log " ]) : array ());
249
231
}
250
232
}
251
233
@@ -260,35 +242,34 @@ function main($request, $compiler_config)
260
242
$ tmp = $ this ->makeCoresTmp ($ CORE_DIR , $ CORE_OVERRIDE_DIR , $ TEMP_DIR , $ compiler_dir , $ files );
261
243
262
244
if (!$ tmp ["success " ]){
263
- if ($ compiler_config ['logging ' ] === false )
264
- return array_merge ($ tmp , ($ ARCHIVE_OPTION ===true ) ? array ("archive " => $ ARCHIVE_PATH ) : array ());
265
- else {
266
- $ tmp ["log " ] = $ log_content ;
267
- return array_merge ($ tmp , ($ ARCHIVE_OPTION ===true ) ? array ("archive " => $ ARCHIVE_PATH ) : array ());
268
- }
245
+ return array_merge ($ tmp ,
246
+ ($ ARCHIVE_OPTION ===true ) ? array ("archive " => $ ret ["archive " ]) : array (),
247
+ ($ compiler_config ['logging ' ] === true ) ? array ("log " => $ ret ["log " ]) : array ());
269
248
}
270
249
271
250
$ ret = $ this ->handleCompile ("$ compiler_dir/core " , $ files ["core " ], $ compiler_config , $ CC , $ CFLAGS , $ CPP , $ CPPFLAGS , $ AS , $ ASFLAGS , $ CLANG , $ CLANG_FLAGS , $ core_includes , $ target_arch , $ clang_target_arch , $ include_directories ["core " ], "object " );
272
251
273
252
$ log_content = (($ compiler_config ['logging ' ] === true ) ? @file_get_contents ($ compiler_config ['logFileName ' ]) : "" );
274
253
254
+ if ($ compiler_config ['logging ' ] === true ){
255
+ if ($ log_content !== false ){
256
+ $ ret ["log " ] = $ log_content ;
257
+ file_put_contents ($ compiler_config ["compiler_dir " ] . "/log " , $ log_content );
258
+ }
259
+ else
260
+ $ ret ["log " ] = "Failed to access logfile. " ;
261
+ }
262
+
275
263
if ($ ARCHIVE_OPTION === true ){
276
264
$ arch_ret = $ this ->createArchive ($ compiler_dir , $ TEMP_DIR , $ ARCHIVE_DIR , $ ARCHIVE_PATH );
277
265
if ($ arch_ret ["success " ] === false )
278
- return $ arch_ret ;
266
+ $ ret ["archive " ] = $ arch_ret ["message " ];
267
+ else
268
+ $ ret ["archive " ] = $ ARCHIVE_PATH ;
279
269
}
280
270
281
- if (!$ ret ["success " ]){
282
- if ($ compiler_config ['logging ' ] === true ){
283
- if ($ log_content !== false ){
284
- $ ret ["log " ] = $ log_content ;
285
- file_put_contents ($ compiler_config ["compiler_dir " ] . "/log " , $ log_content );
286
- }
287
- else
288
- return array_merge (array ("success " => "false " , "message " => "Failed to access logfile. " ), ($ ARCHIVE_OPTION ===true ) ? array ("archive " => $ ARCHIVE_PATH ) : array ());
289
- }
290
- return array_merge ($ ret , ($ ARCHIVE_OPTION ===true ) ? array ("archive " => $ ARCHIVE_PATH ) : array ());
291
- }
271
+ if (!$ ret ["success " ])
272
+ return $ ret ;
292
273
293
274
foreach ($ files ["core " ]["o " ] as $ core_object ){
294
275
//Link object file to library.
@@ -321,24 +302,26 @@ function main($request, $compiler_config)
321
302
322
303
$ ret = $ this ->handleCompile ("$ compiler_dir/libraries/ $ library_name " , $ files ["libs " ][$ library_name ], $ compiler_config , $ CC , $ CFLAGS , $ CPP , $ CPPFLAGS , $ AS , $ ASFLAGS , $ CLANG , $ CLANG_FLAGS , $ core_includes , $ target_arch , $ clang_target_arch , $ include_directories ["main " ], $ format , true , $ lib_object_naming_params );
323
304
324
- if ($ ARCHIVE_OPTION === true ){
325
- $ arch_ret = $ this ->createArchive ($ compiler_dir , $ TEMP_DIR , $ ARCHIVE_DIR , $ ARCHIVE_PATH );
326
- if ($ arch_ret ["success " ] === false )
327
- return $ arch_ret ;
328
- }
329
-
330
305
$ log_content = (($ compiler_config ['logging ' ] === true ) ? @file_get_contents ($ compiler_config ['logFileName ' ]) : "" );
331
306
if ($ compiler_config ['logging ' ] === true ){
332
307
if ($ log_content !== false ) {
333
308
$ ret ["log " ] = $ log_content ;
334
309
file_put_contents ($ compiler_config ["compiler_dir " ] . "/log " , $ log_content );
335
310
}
336
311
else
337
- return array_merge (array ("success " => "false " , "message " => "Failed to access logfile. " ), ($ ARCHIVE_OPTION ===true ) ? array ("archive " => $ ARCHIVE_PATH ) : array ());
312
+ $ ret ["log " ] = "Failed to access logfile. " ;
313
+ }
314
+
315
+ if ($ ARCHIVE_OPTION === true ){
316
+ $ arch_ret = $ this ->createArchive ($ compiler_dir , $ TEMP_DIR , $ ARCHIVE_DIR , $ ARCHIVE_PATH );
317
+ if ($ arch_ret ["success " ] === false )
318
+ $ ret ["archive " ] = $ arch_ret ["message " ];
319
+ else
320
+ $ ret ["archive " ] = $ ARCHIVE_PATH ;
338
321
}
339
322
340
323
if (!$ ret ["success " ])
341
- return array_merge ( $ ret, ( $ ARCHIVE_OPTION === true ) ? array ( " archive " => $ ARCHIVE_PATH ) : array ()) ;
324
+ return $ ret ;
342
325
343
326
$ objects_to_link = array_merge ($ objects_to_link , $ files ["libs " ][$ library_name ]["o " ]);
344
327
}
@@ -359,50 +342,53 @@ function main($request, $compiler_config)
359
342
// Log the fact that an error occurred during linking
360
343
$ this ->compiler_logger ->addInfo ($ compiler_config ["compiler_dir " ] . " - An error occurred during linking: " . json_encode (implode ("\n" , $ output )));
361
344
362
- if ($ ARCHIVE_OPTION === true ){
363
- $ arch_ret = $ this ->createArchive ($ compiler_dir , $ TEMP_DIR , $ ARCHIVE_DIR , $ ARCHIVE_PATH );
364
- if ($ arch_ret ["success " ] === false )
365
- return $ arch_ret ;
366
- }
367
- $ returner = array_merge (array (
345
+ $ returner = array (
368
346
"success " => false ,
369
347
"step " => 7 ,
370
- "message " => implode ("\n" , $ output )), ($ ARCHIVE_OPTION ===true ) ? array ("archive " => $ ARCHIVE_PATH ) : array ());
371
- if ($ compiler_config ['logging ' ] === false )
372
- return $ returner ;
373
- else {
348
+ "message " => implode ("\n" , $ output ));
349
+
350
+ if ($ compiler_config ['logging ' ] === true ) {
374
351
$ log_content = @file_get_contents ($ compiler_config ['logFileName ' ]);
375
352
if (!$ log_content )
376
- return array ( " success " => " false " , " message " => " Failed to access logfile. ", " archive " => $ ARCHIVE_PATH ) ;
353
+ $ returner [ " log " ] = " Failed to access logfile. " ;
377
354
else {
378
355
file_put_contents ($ compiler_config ["compiler_dir " ] . "/log " , $ log_content );
379
- return array_merge ( $ returner, array ( "log " => $ log_content)) ;
356
+ $ returner[ "log " ] = $ log_content ;
380
357
}
381
358
}
359
+
360
+ if ($ ARCHIVE_OPTION === true ){
361
+ $ arch_ret = $ this ->createArchive ($ compiler_dir , $ TEMP_DIR , $ ARCHIVE_DIR , $ ARCHIVE_PATH );
362
+ if ($ arch_ret ["success " ] === false )
363
+ $ returner ["archive " ] = $ arch_ret ["message " ];
364
+ else
365
+ $ returner ["archive " ] = $ ARCHIVE_PATH ;
366
+ }
367
+ return $ returner ;
382
368
}
383
369
384
370
// Step 8: Convert the output to the requested format and measure its
385
371
// size.
386
372
$ tmp = $ this ->convertOutput ("$ compiler_dir/files " , $ format , $ SIZE , $ SIZE_FLAGS , $ OBJCOPY , $ OBJCOPY_FLAGS , $ OUTPUT , $ start_time , $ compiler_config );
387
373
388
- if ($ ARCHIVE_OPTION === true ){
389
- $ arch_ret = $ this ->createArchive ($ compiler_dir , $ TEMP_DIR , $ ARCHIVE_DIR , $ ARCHIVE_PATH );
390
- if ($ arch_ret ["success " ] === false )
391
- return $ arch_ret ;
392
- }
393
-
394
- if ($ compiler_config ['logging ' ] === false )
395
- return array_merge ($ tmp , ($ ARCHIVE_OPTION ===true ) ? array ("archive " => $ ARCHIVE_PATH ) : array ());
396
- else {
374
+ if ($ compiler_config ['logging ' ] === true ) {
397
375
$ log_content = @file_get_contents ($ compiler_config ['logFileName ' ]);
398
376
if (!$ log_content )
399
- return array_merge ( array ( " success " => " false " , " message " => " Failed to access logfile. "), ( $ ARCHIVE_OPTION === true ) ? array ( " archive " => $ ARCHIVE_PATH ) : array ()) ;
377
+ $ tmp [ " log " ] = " Failed to access logfile. " ;
400
378
else {
401
379
file_put_contents ($ compiler_config ["compiler_dir " ] . "/log " , $ log_content );
402
- return array_merge ( $ tmp, array ( "log " => $ log_content), ( $ ARCHIVE_OPTION === true ) ? array ( " archive " => $ ARCHIVE_PATH ) : array ()) ;
380
+ $ tmp[ "log " ] = $ log_content ;
403
381
}
404
382
}
405
383
384
+ if ($ ARCHIVE_OPTION === true ){
385
+ $ arch_ret = $ this ->createArchive ($ compiler_dir , $ TEMP_DIR , $ ARCHIVE_DIR , $ ARCHIVE_PATH );
386
+ if ($ arch_ret ["success " ] === false )
387
+ $ tmp ["archive " ] = $ arch_ret ["message " ];
388
+ else
389
+ $ tmp ["archive " ] = $ ARCHIVE_PATH ;
390
+ }
391
+ return $ tmp ;
406
392
}
407
393
408
394
private function requestValid (&$ request )
0 commit comments