Skip to content

Commit 00993b5

Browse files
make only necessary function public in the new builder
1 parent 918cfb7 commit 00993b5

File tree

9 files changed

+37
-45
lines changed

9 files changed

+37
-45
lines changed

arduino/builder/builder.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ func (b *Builder) preprocess() error {
261261
b.Progress.CompleteStep()
262262
b.Progress.PushProgress()
263263

264-
if err := b.PrepareSketchBuildPath(); err != nil {
264+
if err := b.prepareSketchBuildPath(); err != nil {
265265
return err
266266
}
267267
b.Progress.CompleteStep()
@@ -284,12 +284,12 @@ func (b *Builder) preprocess() error {
284284
b.Progress.CompleteStep()
285285
b.Progress.PushProgress()
286286

287-
b.WarnAboutArchIncompatibleLibraries(b.SketchLibrariesDetector.ImportedLibraries())
287+
b.warnAboutArchIncompatibleLibraries(b.SketchLibrariesDetector.ImportedLibraries())
288288
b.Progress.CompleteStep()
289289
b.Progress.PushProgress()
290290

291291
b.logIfVerbose(false, tr("Generating function prototypes..."))
292-
if err := b.PreprocessSketch(b.SketchLibrariesDetector.IncludeFolders()); err != nil {
292+
if err := b.preprocessSketch(b.SketchLibrariesDetector.IncludeFolders()); err != nil {
293293
return err
294294
}
295295
b.Progress.CompleteStep()
@@ -331,20 +331,20 @@ func (b *Builder) Build() error {
331331
b.Progress.CompleteStep()
332332
b.Progress.PushProgress()
333333

334-
b.PrintUsedLibraries(b.SketchLibrariesDetector.ImportedLibraries())
334+
b.printUsedLibraries(b.SketchLibrariesDetector.ImportedLibraries())
335335
b.Progress.CompleteStep()
336336
b.Progress.PushProgress()
337337

338338
if buildErr != nil {
339339
return buildErr
340340
}
341-
if err := b.ExportProjectCMake(b.SketchLibrariesDetector.ImportedLibraries(), b.SketchLibrariesDetector.IncludeFolders()); err != nil {
341+
if err := b.exportProjectCMake(b.SketchLibrariesDetector.ImportedLibraries(), b.SketchLibrariesDetector.IncludeFolders()); err != nil {
342342
return err
343343
}
344344
b.Progress.CompleteStep()
345345
b.Progress.PushProgress()
346346

347-
if err := b.Size(); err != nil {
347+
if err := b.size(); err != nil {
348348
return err
349349
}
350350
b.Progress.CompleteStep()
@@ -381,13 +381,13 @@ func (b *Builder) build() error {
381381
b.Progress.CompleteStep()
382382
b.Progress.PushProgress()
383383

384-
if err := b.RemoveUnusedCompiledLibraries(b.SketchLibrariesDetector.ImportedLibraries()); err != nil {
384+
if err := b.removeUnusedCompiledLibraries(b.SketchLibrariesDetector.ImportedLibraries()); err != nil {
385385
return err
386386
}
387387
b.Progress.CompleteStep()
388388
b.Progress.PushProgress()
389389

390-
if err := b.BuildLibraries(b.SketchLibrariesDetector.IncludeFolders(), b.SketchLibrariesDetector.ImportedLibraries()); err != nil {
390+
if err := b.buildLibraries(b.SketchLibrariesDetector.IncludeFolders(), b.SketchLibrariesDetector.ImportedLibraries()); err != nil {
391391
return err
392392
}
393393
b.Progress.CompleteStep()
@@ -406,7 +406,7 @@ func (b *Builder) build() error {
406406
b.Progress.CompleteStep()
407407
b.Progress.PushProgress()
408408

409-
if err := b.BuildCore(); err != nil {
409+
if err := b.buildCore(); err != nil {
410410
return err
411411
}
412412
b.Progress.CompleteStep()
@@ -425,7 +425,7 @@ func (b *Builder) build() error {
425425
b.Progress.CompleteStep()
426426
b.Progress.PushProgress()
427427

428-
if err := b.Link(); err != nil {
428+
if err := b.link(); err != nil {
429429
return err
430430
}
431431
b.Progress.CompleteStep()

arduino/builder/core.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import (
3030
"github.com/pkg/errors"
3131
)
3232

33-
// BuildCore fixdoc
34-
func (b *Builder) BuildCore() error {
33+
// buildCore fixdoc
34+
func (b *Builder) buildCore() error {
3535
if err := b.coreBuildPath.MkdirAll(); err != nil {
3636
return errors.WithStack(err)
3737
}

arduino/builder/export_cmake.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ import (
3434

3535
var lineMatcher = regexp.MustCompile(`^#line\s\d+\s"`)
3636

37-
// ExportProjectCMake fixdoc
38-
func (b *Builder) ExportProjectCMake(importedLibraries libraries.List, includeFolders paths.PathList) error {
37+
// exportProjectCMake fixdoc
38+
func (b *Builder) exportProjectCMake(importedLibraries libraries.List, includeFolders paths.PathList) error {
3939
// copies the contents of the file named src to the file named
4040
// by dst. The file will be created if it does not already exist. If the
4141
// destination file exists, all it's contents will be replaced by the contents
@@ -237,7 +237,7 @@ func (b *Builder) ExportProjectCMake(importedLibraries libraries.List, includeFo
237237
fmt.Println(err)
238238
}
239239

240-
if err := b.PreprocessSketch(includeFolders); err != nil {
240+
if err := b.preprocessSketch(includeFolders); err != nil {
241241
return err
242242
}
243243

arduino/builder/libraries.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ var (
3535
FpuCflag = "fpu"
3636
)
3737

38-
// BuildLibraries fixdoc
39-
func (b *Builder) BuildLibraries(includesFolders paths.PathList, importedLibraries libraries.List) error {
38+
// buildLibraries fixdoc
39+
func (b *Builder) buildLibraries(includesFolders paths.PathList, importedLibraries libraries.List) error {
4040
includes := f.Map(includesFolders.AsStrings(), cpp.WrapWithHyphenI)
4141
libs := importedLibraries
4242

@@ -254,8 +254,8 @@ func (b *Builder) compileLibrary(library *libraries.Library, includes []string)
254254
return objectFiles, nil
255255
}
256256

257-
// RemoveUnusedCompiledLibraries fixdoc
258-
func (b *Builder) RemoveUnusedCompiledLibraries(importedLibraries libraries.List) error {
257+
// removeUnusedCompiledLibraries fixdoc
258+
func (b *Builder) removeUnusedCompiledLibraries(importedLibraries libraries.List) error {
259259
if b.librariesBuildPath.NotExist() {
260260
return nil
261261
}
@@ -287,8 +287,8 @@ func (b *Builder) RemoveUnusedCompiledLibraries(importedLibraries libraries.List
287287
return nil
288288
}
289289

290-
// WarnAboutArchIncompatibleLibraries fixdoc
291-
func (b *Builder) WarnAboutArchIncompatibleLibraries(importedLibraries libraries.List) {
290+
// warnAboutArchIncompatibleLibraries fixdoc
291+
func (b *Builder) warnAboutArchIncompatibleLibraries(importedLibraries libraries.List) {
292292
archs := []string{b.targetPlatform.Platform.Architecture}
293293
overrides, _ := b.buildProperties.GetOk("architecture.override_check")
294294
if overrides != "" {
@@ -306,10 +306,10 @@ func (b *Builder) WarnAboutArchIncompatibleLibraries(importedLibraries libraries
306306
}
307307
}
308308

309-
// PrintUsedLibraries fixdoc
309+
// printUsedLibraries fixdoc
310310
// TODO here we can completly remove this part as it's duplicated in what we can
311311
// read in the gRPC response
312-
func (b *Builder) PrintUsedLibraries(importedLibraries libraries.List) {
312+
func (b *Builder) printUsedLibraries(importedLibraries libraries.List) {
313313
if !b.logger.Verbose() || len(importedLibraries) == 0 {
314314
return
315315
}

arduino/builder/linker.go

+7-12
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import (
2424
"github.com/pkg/errors"
2525
)
2626

27-
// Link fixdoc
28-
func (b *Builder) Link() error {
27+
// link fixdoc
28+
func (b *Builder) link() error {
2929
if b.onlyUpdateCompilationDatabase {
3030
if b.logger.Verbose() {
3131
b.logger.Info(tr("Skip linking of final executable."))
@@ -43,14 +43,6 @@ func (b *Builder) Link() error {
4343
return errors.WithStack(err)
4444
}
4545

46-
if err := b.link(objectFiles, coreDotARelPath, b.buildArtifacts.coreArchiveFilePath); err != nil {
47-
return errors.WithStack(err)
48-
}
49-
50-
return nil
51-
}
52-
53-
func (b *Builder) link(objectFiles paths.PathList, coreDotARelPath *paths.Path, coreArchiveFilePath *paths.Path) error {
5446
wrapWithDoubleQuotes := func(value string) string { return "\"" + value + "\"" }
5547
objectFileList := strings.Join(f.Map(objectFiles.AsStrings(), wrapWithDoubleQuotes), " ")
5648

@@ -101,7 +93,7 @@ func (b *Builder) link(objectFiles paths.PathList, coreDotARelPath *paths.Path,
10193
properties.Set("compiler.c.elf.flags", properties.Get("compiler.c.elf.flags"))
10294
properties.Set("compiler.warning_flags", properties.Get("compiler.warning_flags."+b.logger.WarningsLevel()))
10395
properties.Set("archive_file", coreDotARelPath.String())
104-
properties.Set("archive_file_path", coreArchiveFilePath.String())
96+
properties.Set("archive_file_path", b.buildArtifacts.coreArchiveFilePath.String())
10597
properties.Set("object_files", objectFileList)
10698

10799
command, err := utils.PrepareCommandForRecipe(properties, "recipe.c.combine.pattern", false)
@@ -113,5 +105,8 @@ func (b *Builder) link(objectFiles paths.PathList, coreDotARelPath *paths.Path,
113105
if b.logger.Verbose() {
114106
b.logger.Info(string(verboseInfo))
115107
}
116-
return err
108+
if err != nil {
109+
return err
110+
}
111+
return nil
117112
}

arduino/builder/preprocess_sketch.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020
"github.com/arduino/go-paths-helper"
2121
)
2222

23-
// PreprocessSketch fixdoc
24-
func (b *Builder) PreprocessSketch(includes paths.PathList) error {
23+
// preprocessSketch fixdoc
24+
func (b *Builder) preprocessSketch(includes paths.PathList) error {
2525
// In the future we might change the preprocessor
2626
normalOutput, verboseOutput, err := preprocessor.PreprocessSketchWithCtags(
2727
b.sketch, b.buildPath, includes, b.lineOffset,

arduino/builder/recipe.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ import (
2727
)
2828

2929
// RunRecipe fixdoc
30-
func (b *Builder) RunRecipe(
31-
prefix, suffix string,
32-
skipIfOnlyUpdatingCompilationDatabase bool,
33-
) error {
30+
func (b *Builder) RunRecipe(prefix, suffix string, skipIfOnlyUpdatingCompilationDatabase bool) error {
3431
logrus.Debugf(fmt.Sprintf("Looking for recipes like %s", prefix+"*"+suffix))
3532

3633
// TODO is it necessary to use Clone?

arduino/builder/sizer.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ func (s ExecutablesFileSections) ToRPCExecutableSectionSizeArray() []*rpc.Execut
5050
return res
5151
}
5252

53-
// Size fixdoc
54-
func (b *Builder) Size() error {
53+
// size fixdoc
54+
func (b *Builder) size() error {
5555
if b.onlyUpdateCompilationDatabase {
5656
return nil
5757
}

arduino/builder/sketch.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ var (
3838
tr = i18n.Tr
3939
)
4040

41-
// PrepareSketchBuildPath copies the sketch source files in the build path.
41+
// prepareSketchBuildPath copies the sketch source files in the build path.
4242
// The .ino files are merged together to create a .cpp file (by the way, the
4343
// .cpp file still needs to be Arduino-preprocessed to compile).
44-
func (b *Builder) PrepareSketchBuildPath() error {
44+
func (b *Builder) prepareSketchBuildPath() error {
4545
if err := b.sketchBuildPath.MkdirAll(); err != nil {
4646
return errors.Wrap(err, tr("unable to create a folder to save the sketch"))
4747
}

0 commit comments

Comments
 (0)