Skip to content

Commit a5c79c7

Browse files
committed
Allow dep-file generation in GCC preprocessor
1 parent 13a7b1b commit a5c79c7

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

internal/arduino/builder/internal/detector/detector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ func (l *SketchLibrariesDetector) gccPreprocessTask(sourceFile *sourceFile, buil
360360
includeFolders = append(includeFolders, extraInclude)
361361
}
362362

363-
return preprocessor.GCC(sourceFile.SourcePath, paths.NullPath(), includeFolders, buildProperties)
363+
return preprocessor.GCC(sourceFile.SourcePath, paths.NullPath(), includeFolders, buildProperties, nil)
364364
}
365365

366366
func (l *SketchLibrariesDetector) findMissingIncludesInCompilationUnit(

internal/arduino/builder/internal/preprocessor/arduino_preprocessor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func PreprocessSketchWithArduinoPreprocessor(
4545

4646
sourceFile := buildPath.Join("sketch", sk.MainFile.Base()+".cpp")
4747
targetFile := buildPath.Join("preproc", "sketch_merged.cpp")
48-
gccResult := GCC(sourceFile, targetFile, includeFolders, buildProperties).Run(ctx)
48+
gccResult := GCC(sourceFile, targetFile, includeFolders, buildProperties, nil).Run(ctx)
4949
verboseOut.Write(gccResult.Stdout)
5050
verboseOut.Write(gccResult.Stderr)
5151
if gccResult.Error != nil {

internal/arduino/builder/internal/preprocessor/ctags.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func PreprocessSketchWithCtags(
6767
}
6868

6969
// Run GCC preprocessor
70-
result := GCC(unpreprocessedSourceFile, ctagsTarget, includes, buildProperties).Run(ctx)
70+
result := GCC(unpreprocessedSourceFile, ctagsTarget, includes, buildProperties, nil).Run(ctx)
7171
stdout.Write(result.Stdout)
7272
stderr.Write(result.Stderr)
7373
if err := result.Error; err != nil {

internal/arduino/builder/internal/preprocessor/gcc.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
func GCC(
3131
sourceFilePath, targetFilePath *paths.Path,
3232
includes paths.PathList, buildProperties *properties.Map,
33+
depFile *paths.Path,
3334
) *runner.Task {
3435
gccBuildProperties := properties.NewMap()
3536
gccBuildProperties.Set("preproc.macros.flags", "-w -x c++ -E -CC")
@@ -62,6 +63,11 @@ func GCC(
6263
// to create a /dev/null.d dependency file, which won't work.
6364
args = f.Filter(args, f.NotEquals("-MMD"))
6465

66+
// If a depFile has been specified add the necessary arguments to generate it
67+
if depFile != nil {
68+
args = append(args, "-MMD", "-MF", depFile.String())
69+
}
70+
6571
// Limit the stderr output to 100 KiB
6672
// https://github.com/arduino/arduino-cli/pull/2883
6773
return runner.NewTaskWithLimitedStderr(100*1024, args...)

0 commit comments

Comments
 (0)