Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed compiler-cache on Windows when there are non-ASCII characters in file path #2733

Merged
merged 4 commits into from
Oct 16, 2024

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented Oct 15, 2024

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?

As reported in #2671, the compile cache is not reused on a Windows machine if a non-ASCII character is present in the path.
EDIT: This is due to a weird encoding used by GCC in writing the .d file. It seems the file is written the default encoding with ANSI "codepages". This patch leverages the MultiByteToWideChar API to properly decode the .d files.

What is the current behavior?

Already compiled files are not reused on a Windows machine if a non-ASCII character is present in the path.

What is the new behavior?

Already compiled files are reused on a Windows machine if a non-ASCII character is present in the path.

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

No

Other information

Fix #2671

@cmaglie cmaglie self-assigned this Oct 15, 2024
@cmaglie cmaglie added type: imperfection Perceived defect in any part of project topic: build-process Related to the sketch build process labels Oct 15, 2024
Copy link

codecov bot commented Oct 15, 2024

Codecov Report

Attention: Patch coverage is 58.82353% with 28 lines in your changes missing coverage. Please review.

Project coverage is 67.67%. Comparing base (ea09108) to head (91c7fb3).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
internal/arduino/builder/internal/utils/utils.go 67.30% 14 Missing and 3 partials ⚠️
...nal/arduino/builder/internal/utils/ansi_windows.go 35.71% 6 Missing and 3 partials ⚠️
...rnal/arduino/builder/internal/utils/ansi_others.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2733      +/-   ##
==========================================
- Coverage   67.68%   67.67%   -0.02%     
==========================================
  Files         234      236       +2     
  Lines       22285    22327      +42     
==========================================
+ Hits        15083    15109      +26     
- Misses       6017     6030      +13     
- Partials     1185     1188       +3     
Flag Coverage Δ
unit 67.67% <58.82%> (-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.

@cmaglie
Copy link
Member Author

cmaglie commented Oct 15, 2024

Note for the future me: https://stackoverflow.com/a/921981/1655275

Also many API calls (such as MultiByteToWideChar) accept the constant value CP_ACP (zero) which always means "use the system code page". So you may not actually need to know the current code page, depending on what you want to do with it.

@cmaglie cmaglie marked this pull request as ready for review October 16, 2024 11:30
Copy link
Contributor

@alessio-perugini alessio-perugini left a comment

Choose a reason for hiding this comment

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

🤯 Our test suite is becomings stronger and stronger 🚀

@cmaglie
Copy link
Member Author

cmaglie commented Oct 16, 2024

🤯 Our test suite is becoming stronger and stronger 🚀

Still, it doesn't catch exactly the bug reported in the issue, but YES

@cmaglie cmaglie merged commit a527c7c into arduino:master Oct 16, 2024
101 checks passed
@cmaglie cmaglie deleted the fix_caching_detection branch October 16, 2024 12:38
@per1234 per1234 added the topic: code Related to content of the project itself label Oct 16, 2024
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: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Non-ASCII characters in library installation or cache path breaks library compilation caching
3 participants