Skip to content

Skip GCC pre-process task if sketch and dependencies do not change.#3112

Open
giulio93 wants to merge 10 commits intoarduino:masterfrom
giulio93:master
Open

Skip GCC pre-process task if sketch and dependencies do not change.#3112
giulio93 wants to merge 10 commits intoarduino:masterfrom
giulio93:master

Conversation

@giulio93
Copy link
Contributor

@giulio93 giulio93 commented Feb 24, 2026

Please check if the PR fulfills these requirements

See how to contribute

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)
  • configuration.schema.json updated if new parameters are added.

What kind of change does this PR introduce?

In an effort to optimize compilation times, this PR adds the ability to the Arduino CLI to detect whether the Arduino Preprocessing of the sketch could be skipped.

What is the current behavior?

The GCC task is run even if the Task did not changed

What is the new behavior?

The GCC task args are hashed and is stored in order to be able to compare it with prev/next recompile GCC task

Does this PR introduce a breaking change, and is titled accordingly?

Other information

@giulio93 giulio93 changed the title Hash the GCC task args to see if recompile is needed Hash the GCC task args to skip recompile if not needed Feb 24, 2026
@giulio93 giulio93 force-pushed the master branch 2 times, most recently from 9e0a18c to 0a0a741 Compare February 24, 2026 15:31
@per1234 per1234 added type: enhancement Proposed improvement topic: code Related to content of the project itself topic: build-process Related to the sketch build process labels Feb 25, 2026
@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

❌ Patch coverage is 90.90909% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.62%. Comparing base (ea956a3) to head (3ff2751).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
...rnal/arduino/builder/internal/detector/detector.go 77.77% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3112      +/-   ##
==========================================
+ Coverage   69.57%   69.62%   +0.04%     
==========================================
  Files         253      253              
  Lines       19280    19293      +13     
==========================================
+ Hits        13414    13432      +18     
+ Misses       4628     4625       -3     
+ Partials     1238     1236       -2     
Flag Coverage Δ
unit 69.62% <90.90%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@giulio93 giulio93 force-pushed the master branch 3 times, most recently from dca1c06 to 32b1aac Compare February 26, 2026 11:08
@giulio93 giulio93 force-pushed the master branch 2 times, most recently from 5d53241 to f2230ee Compare March 2, 2026 07:22
@giulio93 giulio93 requested review from cmaglie and lucarin91 March 2, 2026 11:21
@giulio93 giulio93 changed the title Hash the GCC task args to skip recompile if not needed Skip GCC pre-process if sketch and dependencies do not change. Mar 3, 2026
@giulio93 giulio93 changed the title Skip GCC pre-process if sketch and dependencies do not change. Skip GCC pre-process task if sketch and dependencies do not change. Mar 3, 2026
Comment on lines +315 to +318
preprocessedSketch, err := l.makeSourceFile(sketchBuildPath, sketchBuildPath, paths.New(sketch.MainFile.Base()+".cpp"))
if err != nil {
return err
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the preprocessedSketch seems not used in the code (the file is removed a few lines below)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file is removed from the queue, we add it here in order to be able to intercept it


b.logIfVerbose(false, i18n.Tr("Generating function prototypes..."))
if err := b.preprocessSketch(b.libsDetector.IncludeFolders()); err != nil {
if err := b.preprocessSketch(b.libsDetector.IncludeFolders(), b.libsDetector.IsSketchUnchanged()); err != nil {
Copy link

@dido18 dido18 Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not check the boolean of the sketch here instead of passing the boolean down the preprocessor?

Suggested change
if err := b.preprocessSketch(b.libsDetector.IncludeFolders(), b.libsDetector.IsSketchUnchanged()); err != nil {
if b.libsDetector.IsSketchUnchanged() {
// log skip unchanged
b.Progress.CompleteStep()
return nli
}
if err := b.preprocessSketch(b.libsDetector.IncludeFolders()); err != nil {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic: build-process Related to the sketch build process topic: code Related to content of the project itself type: enhancement Proposed improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants