Skip to content

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

Merged
giulio93 merged 25 commits into
arduino:masterfrom
giulio93:master
Mar 10, 2026
Merged

Skip GCC pre-process task if sketch and dependencies do not change.#3112
giulio93 merged 25 commits into
arduino:masterfrom
giulio93:master

Conversation

@giulio93

@giulio93 giulio93 commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

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 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

codecov Bot commented Feb 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.60%. Comparing base (ea956a3) to head (3b96959).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3112      +/-   ##
==========================================
+ Coverage   69.57%   69.60%   +0.02%     
==========================================
  Files         253      253              
  Lines       19280    19284       +4     
==========================================
+ Hits        13414    13422       +8     
+ Misses       4628     4626       -2     
+ Partials     1238     1236       -2     
Flag Coverage Δ
unit 69.60% <100.00%> (+0.02%) ⬆️

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 Mar 3, 2026
@giulio93 giulio93 changed the title Skip GCC pre-process if sketch and dependencies do not change. Mar 3, 2026

@lucarin91 lucarin91 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would avoid using paths if you really just need a filename. In the comments below, I suggest some updates to clarify that

Comment thread internal/arduino/builder/internal/utils/utils.go Outdated
Comment thread internal/arduino/builder/internal/utils/utils.go Outdated
Comment thread internal/arduino/builder/internal/detector/source_file.go Outdated
Comment thread internal/arduino/builder/internal/detector/detector.go Outdated
Comment thread internal/arduino/builder/internal/detector/detector.go Outdated
Comment thread internal/arduino/builder/internal/detector/detector.go Outdated
Comment thread internal/arduino/builder/internal/detector/detector.go Outdated
Comment thread internal/arduino/builder/internal/detector/source_file.go Outdated
Comment thread internal/arduino/builder/internal/utils/utils.go Outdated
Comment thread internal/arduino/builder/builder.go
giulio93 and others added 8 commits March 9, 2026 12:03
Co-authored-by: Cristian Maglie <c.maglie@bug.st>
Co-authored-by: Luca Rinaldi <to@lucar.in>
Co-authored-by: Luca Rinaldi <to@lucar.in>
Co-authored-by: Luca Rinaldi <to@lucar.in>
Co-authored-by: Luca Rinaldi <to@lucar.in>
Co-authored-by: Luca Rinaldi <to@lucar.in>
Co-authored-by: Cristian Maglie <c.maglie@bug.st>
Co-authored-by: Cristian Maglie <c.maglie@bug.st>
@giulio93 giulio93 requested review from cmaglie and lucarin91 March 9, 2026 11:22

@dido18 dido18 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, I did not test on real board

@giulio93 giulio93 merged commit 3e1b3b6 into arduino:master Mar 10, 2026
101 checks passed
cmaglie added a commit that referenced this pull request Apr 10, 2026
…the target file is missing (#3149)

This is a regression introduced in #3112, but not yet released.

* Move sketch-unchanged check down one level

* fix: Arduino Preprocessor must always run if the target file is missing

* Slight refactor for readability

* Added integration test

* Refactoring and modernization of the if condition
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

5 participants