@@ -30,22 +30,19 @@ import (
30
30
"github.com/arduino/arduino-cli/arduino/builder/utils"
31
31
"github.com/arduino/arduino-cli/arduino/globals"
32
32
"github.com/arduino/arduino-cli/arduino/libraries"
33
- "github.com/arduino/arduino-cli/arduino/sketch"
34
33
"github.com/arduino/arduino-cli/legacy/builder/constants"
35
34
)
36
35
37
36
var lineMatcher = regexp .MustCompile (`^#line\s\d+\s"` )
38
37
39
- func ExportProjectCMake (
38
+ // ExportProjectCMake fixdoc
39
+ func (b * Builder ) ExportProjectCMake (
40
40
sketchError bool , // Was there an error while compiling the sketch?
41
- buildPath , sketchBuildPath * paths.Path ,
42
41
importedLibraries libraries.List ,
43
- buildProperties * properties.Map ,
44
- sketch * sketch.Sketch ,
45
42
includeFolders paths.PathList ,
46
43
lineOffset int ,
47
44
onlyUpdateCompilationDatabase bool ,
48
- ) ([] byte , [] byte , error ) {
45
+ ) error {
49
46
// copies the contents of the file named src to the file named
50
47
// by dst. The file will be created if it does not already exist. If the
51
48
// destination file exists, all it's contents will be replaced by the contents
@@ -182,12 +179,12 @@ func ExportProjectCMake(
182
179
var validStaticLibExtensions = []string {".a" }
183
180
184
181
// If sketch error or cannot export Cmake project
185
- if sketchError || buildProperties .Get ("compiler.export_cmake" ) == "" {
186
- return nil , nil , nil
182
+ if sketchError || b . buildProperties .Get ("compiler.export_cmake" ) == "" {
183
+ return nil
187
184
}
188
185
189
186
// Create new cmake subFolder - clean if the folder is already there
190
- cmakeFolder := buildPath .Join ("_cmake" )
187
+ cmakeFolder := b . buildPath .Join ("_cmake" )
191
188
if _ , err := cmakeFolder .Stat (); err == nil {
192
189
cmakeFolder .RemoveAll ()
193
190
}
@@ -207,7 +204,7 @@ func ExportProjectCMake(
207
204
for _ , library := range importedLibraries {
208
205
// Copy used libraries in the correct folder
209
206
libDir := libBaseFolder .Join (library .DirName )
210
- mcu := buildProperties .Get ("build.mcu" )
207
+ mcu := b . buildProperties .Get ("build.mcu" )
211
208
copyDir (library .InstallDir .String (), libDir .String (), validExportExtensions )
212
209
213
210
// Read cmake options if available
@@ -238,28 +235,20 @@ func ExportProjectCMake(
238
235
}
239
236
240
237
// Copy core + variant in use + preprocessed sketch in the correct folders
241
- err := copyDir (buildProperties .Get ("build.core.path" ), coreFolder .String (), validExportExtensions )
238
+ err := copyDir (b . buildProperties .Get ("build.core.path" ), coreFolder .String (), validExportExtensions )
242
239
if err != nil {
243
240
fmt .Println (err )
244
241
}
245
- err = copyDir (buildProperties .Get ("build.variant.path" ), coreFolder .Join ("variant" ).String (), validExportExtensions )
242
+ err = copyDir (b . buildProperties .Get ("build.variant.path" ), coreFolder .Join ("variant" ).String (), validExportExtensions )
246
243
if err != nil {
247
244
fmt .Println (err )
248
245
}
249
246
250
- normalOutput , verboseOutput , err := PreprocessSketch (
251
- sketch ,
252
- buildPath ,
253
- includeFolders ,
254
- lineOffset ,
255
- buildProperties ,
256
- onlyUpdateCompilationDatabase ,
257
- )
258
- if err != nil {
259
- return normalOutput , verboseOutput , err
247
+ if err := b .PreprocessSketch (includeFolders , lineOffset , onlyUpdateCompilationDatabase ); err != nil {
248
+ return err
260
249
}
261
250
262
- err = copyDir (sketchBuildPath .String (), cmakeFolder .Join ("sketch" ).String (), validExportExtensions )
251
+ err = copyDir (b . sketchBuildPath .String (), cmakeFolder .Join ("sketch" ).String (), validExportExtensions )
263
252
if err != nil {
264
253
fmt .Println (err )
265
254
}
@@ -294,9 +283,9 @@ func ExportProjectCMake(
294
283
var dynamicLibsFromGccMinusL []string
295
284
var linkDirectories []string
296
285
297
- extractCompileFlags (buildProperties , constants .RECIPE_C_COMBINE_PATTERN , & defines , & dynamicLibsFromGccMinusL , & linkerflags , & linkDirectories )
298
- extractCompileFlags (buildProperties , "recipe.c.o.pattern" , & defines , & dynamicLibsFromGccMinusL , & linkerflags , & linkDirectories )
299
- extractCompileFlags (buildProperties , "recipe.cpp.o.pattern" , & defines , & dynamicLibsFromGccMinusL , & linkerflags , & linkDirectories )
286
+ extractCompileFlags (b . buildProperties , constants .RECIPE_C_COMBINE_PATTERN , & defines , & dynamicLibsFromGccMinusL , & linkerflags , & linkDirectories )
287
+ extractCompileFlags (b . buildProperties , "recipe.c.o.pattern" , & defines , & dynamicLibsFromGccMinusL , & linkerflags , & linkDirectories )
288
+ extractCompileFlags (b . buildProperties , "recipe.cpp.o.pattern" , & defines , & dynamicLibsFromGccMinusL , & linkerflags , & linkDirectories )
300
289
301
290
// Extract folders with .h in them for adding in include list
302
291
headerFiles , _ := utils .FindFilesInFolder (cmakeFolder , true , validHeaderExtensions ... )
@@ -307,7 +296,7 @@ func ExportProjectCMake(
307
296
308
297
// Generate the CMakeLists global file
309
298
310
- projectName := sketch .Name
299
+ projectName := b . sketch .Name
311
300
312
301
cmakelist := "cmake_minimum_required(VERSION 3.5.0)\n "
313
302
cmakelist += "INCLUDE(FindPkgConfig)\n "
@@ -364,7 +353,7 @@ func ExportProjectCMake(
364
353
365
354
cmakeFile .WriteFile ([]byte (cmakelist ))
366
355
367
- return normalOutput , verboseOutput , nil
356
+ return nil
368
357
}
369
358
370
359
func extractCompileFlags (buildProperties * properties.Map , recipe string , defines , dynamicLibs , linkerflags , linkDirectories * []string ) {
0 commit comments