@@ -75,6 +75,9 @@ function main($request, $compiler_config)
75
75
if ($ tmp ["success " ] == false )
76
76
return $ tmp ;
77
77
78
+ // Add the compiler temp directory to the compiler_config struct.
79
+ $ compiler_config ["compiler_dir " ] = $ compiler_dir ;
80
+
78
81
// Step 1(part 2): Extract the library files included in the request.
79
82
$ files ["libs " ] = array ();
80
83
foreach ($ libraries as $ library => $ library_files ){
@@ -111,6 +114,21 @@ function main($request, $compiler_config)
111
114
if ($ tmp ["success " ] == false )
112
115
return array_merge ($ tmp , ($ ARCHIVE_OPTION ===true ) ? array ("archive " => $ ARCHIVE_PATH ) : array ());
113
116
117
+ // Log the names of the project files and the libraries used in it.
118
+ $ req_elements = array ();
119
+ $ req_elements [] = "Files: " ;
120
+ foreach ($ request ["files " ] as $ file ) {
121
+ $ req_elements [] = $ file ["filename " ];
122
+ }
123
+
124
+ if ($ request ["libraries " ]) {
125
+ $ req_elements [] = "Libraries: " ;
126
+ foreach ($ request ["libraries " ] as $ key => $ var ) {
127
+ $ req_elements [] = $ key ;
128
+ }
129
+ }
130
+ $ this ->compiler_logger ->addInfo ($ compiler_config ["compiler_dir " ] . " - " . implode (" " , $ req_elements ));
131
+
114
132
// Step 4: Syntax-check and compile source files.
115
133
//Use the include paths for the AVR headers that are bundled with each Arduino SDK version
116
134
//These may differ between linux and MAC OS versions of the Arduino core files, so check before including
@@ -138,24 +156,6 @@ function main($request, $compiler_config)
138
156
//handleCompile sets any include directories needed and calls the doCompile function, which does the actual compilation
139
157
$ 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 );
140
158
141
- // If clang output was different than gcc output, log the filenames and library names.
142
- if (array_key_exists ("clang_diff " , $ ret )) {
143
-
144
- $ req_elements = array ();
145
- $ req_elements [] = "Files: " ;
146
- foreach ($ request ["files " ] as $ file ) {
147
- $ req_elements [] = $ file ["filename " ];
148
- }
149
-
150
- if ($ request ["libraries " ]) {
151
- $ req_elements [] = "Libraries: " ;
152
- foreach ($ request ["libraries " ] as $ key => $ var ) {
153
- $ req_elements [] = $ key ;
154
- }
155
- }
156
- $ this ->compiler_logger ->addInfo (implode (" " , $ req_elements ));
157
- }
158
-
159
159
if ($ ARCHIVE_OPTION === true ){
160
160
$ arch_ret = $ this ->createArchive ($ compiler_dir , $ TEMP_DIR , $ ARCHIVE_DIR , $ ARCHIVE_PATH );
161
161
if ($ arch_ret ["success " ] === false )
@@ -348,6 +348,10 @@ function main($request, $compiler_config)
348
348
}
349
349
350
350
if ($ ret_link ){
351
+
352
+ // Log the fact that an error occurred during linking
353
+ $ this ->compiler_logger ->addInfo ($ compiler_config ["compiler_dir " ] . " - An error occurred during linking: " . json_encode (implode ("\n" , $ output )));
354
+
351
355
if ($ ARCHIVE_OPTION === true ){
352
356
$ arch_ret = $ this ->createArchive ($ compiler_dir , $ TEMP_DIR , $ ARCHIVE_DIR , $ ARCHIVE_PATH );
353
357
if ($ arch_ret ["success " ] === false )
@@ -658,21 +662,20 @@ private function doCompile($compiler_config, &$files, $dir, $CC, $CFLAGS, $CPP,
658
662
if (array_diff (array_keys ($ clangElements ), array_keys ($ gccElements ))) {
659
663
$ resp ["old_message " ] = $ output ;
660
664
661
- $ this ->compiler_logger ->addInfo (" Mismatch between clang and gcc output found. " );
662
- $ new_clang_output = $ this ->cleanUpClangOutput ($ output );
665
+ $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - Mismatch between clang and gcc output found. " );
666
+ $ new_clang_output = $ this ->cleanUpClangOutput ($ output, $ compiler_config );
663
667
664
668
$ clangElements = $ this ->getClangErrorFileList ($ new_clang_output );
665
669
if (array_diff (array_keys ($ clangElements ), array_keys ($ gccElements )))
666
- $ this ->compiler_logger ->addInfo (" Clang still reports errors in different files than gcc. " );
670
+ $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - Clang still reports errors in different files than gcc. " );
667
671
else
668
- $ this ->compiler_logger ->addInfo (" Clang reports errors in the same files as gcc. " );
672
+ $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - Clang reports errors in the same files as gcc. " );
669
673
670
- $ this ->compiler_logger ->addInfo (" Gcc output: " . $ avr_output );
671
- $ this ->compiler_logger ->addInfo (" Clang initial output: " . $ output );
672
- $ this ->compiler_logger ->addInfo (" Clang reformated output: " . $ new_clang_output );
674
+ $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - Gcc output: " . json_encode ( $ avr_output) );
675
+ $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - Clang initial output: " . json_encode ( $ output) );
676
+ $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - Clang reformated output: " . json_encode ( $ new_clang_output) );
673
677
674
678
$ resp ["message " ] = $ new_clang_output ;
675
- return array_merge ($ resp , array ("clang_diff " => true ));
676
679
}
677
680
678
681
return $ resp ;
@@ -1098,7 +1101,7 @@ private function getGccErrorFileList ($avr_output) {
1098
1101
return $ gcc_elements ;
1099
1102
}
1100
1103
1101
- private function cleanUpClangOutput ($ clang_output ) {
1104
+ private function cleanUpClangOutput ($ clang_output, $ compiler_config ) {
1102
1105
1103
1106
$ clang_output = strip_tags ($ clang_output );
1104
1107
$ content_line_array = explode ("\n" , $ clang_output );
@@ -1122,20 +1125,26 @@ private function cleanUpClangOutput ($clang_output) {
1122
1125
1123
1126
if ($ header_found === false ) {
1124
1127
if (preg_match ('/(\/compiler\.\w+\/libraries\/)/ ' , $ header )
1125
- || strpos ($ header , "core " ) !== false
1128
+ || strpos ($ header , $ compiler_config ["arduino_cores_dir " ]) !== false
1129
+ || (array_key_exists ("external_core_files " , $ compiler_config )
1130
+ && strpos ($ header , $ compiler_config ["external_core_files " ]) !== false )
1126
1131
|| strpos ($ header , "note: " ) !== false
1132
+ || strpos ($ header , "in asm " ) !== false
1127
1133
|| strpos ($ body , "in asm " ) !== false ) {
1128
1134
1129
1135
if (preg_match ('/(\/compiler\.\w+\/libraries\/)/ ' , $ header ) && $ libFound === false ) {
1130
- $ this ->compiler_logger ->addInfo (" Clang reports library issue. " );
1136
+ $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - Clang reports library issue. " );
1131
1137
$ libFound = true ;
1132
1138
}
1133
- if (strpos ($ header , "core " ) !== false && $ coreFound === false ) {
1134
- $ this ->compiler_logger ->addInfo ("Clang reports core issue. " );
1139
+ if ((strpos ($ header , $ compiler_config ["arduino_cores_dir " ]) !== false
1140
+ || (array_key_exists ("external_core_files " , $ compiler_config )
1141
+ && strpos ($ header , $ compiler_config ["external_core_files " ]) !== false ))
1142
+ && $ coreFound === false ) {
1143
+ $ this ->compiler_logger ->addInfo ($ compiler_config ["compiler_dir " ] . " - Clang reports core issue. " );
1135
1144
$ coreFound = true ;
1136
1145
}
1137
1146
if (strpos ($ body , "in asm " ) !== false && $ asmFound === false ) {
1138
- $ this ->compiler_logger ->addInfo (" Clang reports assembly issue. " );
1147
+ $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - Clang reports assembly issue. " );
1139
1148
$ asmFound = true ;
1140
1149
}
1141
1150
$ header = "" ;
@@ -1157,8 +1166,11 @@ private function cleanUpClangOutput ($clang_output) {
1157
1166
1158
1167
if (!array_key_exists ($ key + 1 , $ content_line_array )) {
1159
1168
if (!preg_match ('/(\/compiler\.\w+\/libraries\/)/ ' , $ header )
1160
- && strpos ($ header , "core " ) === false
1169
+ && strpos ($ header , $ compiler_config ["arduino_cores_dir " ]) === false
1170
+ && (array_key_exists ("external_core_files " , $ compiler_config )
1171
+ && strpos ($ header , $ compiler_config ["external_core_files " ]) === false )
1161
1172
&& strpos ($ header , "note: " ) === false
1173
+ && strpos ($ header , "in asm " ) === false
1162
1174
&& strpos ($ body , "in asm " ) === false ) {
1163
1175
if ($ header != "" && $ body != "" ) {
1164
1176
$ final .= $ header ."\n" ;
0 commit comments