Skip to content

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

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

Merged
merged 4 commits into from
Oct 16, 2024

Conversation

cmaglie
Copy link
Member

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

@cmagliecmaglie self-assigned this Oct 15, 2024
@cmagliecmaglie added type: imperfection Perceived defect in any part of project topic: build-process Related to the sketch build process labels Oct 15, 2024
@cmagliecmaglieforce-pushed the fix_caching_detection branch from 055f63b to 818ae83CompareOctober 15, 2024 10:36
@codecovCodecov
Copy link

codecovbot 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 linesPatch %Lines
internal/arduino/builder/internal/utils/utils.go67.30%14 Missing and 3 partials ⚠️
...nal/arduino/builder/internal/utils/ansi_windows.go35.71%6 Missing and 3 partials ⚠️
...rnal/arduino/builder/internal/utils/ansi_others.go0.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 
FlagCoverage Δ
unit67.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
MemberAuthor

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.

@cmagliecmaglieforce-pushed the fix_caching_detection branch from 7e878a8 to d594ab1CompareOctober 16, 2024 08:59
@cmagliecmaglieforce-pushed the fix_caching_detection branch from d594ab1 to cff613fCompareOctober 16, 2024 09:01
@cmagliecmaglie marked this pull request as ready for review October 16, 2024 11:30
Copy link
Contributor

@alessio-peruginialessio-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
MemberAuthor

🤯 Our test suite is becoming stronger and stronger 🚀

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

@cmagliecmaglie merged commit a527c7c into arduino:masterOct 16, 2024
101 checks passed
@cmagliecmaglie deleted the fix_caching_detection branch October 16, 2024 12:38
@per1234per1234 added the topic: code Related to content of the project itself label Oct 16, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: build-processRelated to the sketch build processtopic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project
3 participants
@cmaglie@alessio-perugini@per1234
close