Skip to content

Conversation

@Felixoid
Copy link
Contributor

@Felixoid Felixoid commented Dec 18, 2025

This is an attempt to fix #35.

The ENV variable SCCACHE_BASEDIRS and configuration parameter basedirs are added.

As well as new tests to validate the behavior.

@codecov-commenter
Copy link

codecov-commenter commented Dec 18, 2025

Codecov Report

❌ Patch coverage is 97.06110% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.00%. Comparing base (d38e9a3) to head (8bc4ca5).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/cache/cache.rs 74.02% 20 Missing ⚠️
src/util.rs 96.13% 10 Missing ⚠️
src/compiler/preprocessor_cache.rs 97.47% 3 Missing ⚠️
src/server.rs 78.57% 3 Missing ⚠️
tests/oauth.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2521      +/-   ##
==========================================
+ Coverage   71.07%   72.00%   +0.93%     
==========================================
  Files          65       65              
  Lines       35737    36894    +1157     
==========================================
+ Hits        25400    26566    +1166     
+ Misses      10337    10328       -9     

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

@Felixoid Felixoid force-pushed the add-basedir-configuration branch from bfba6ec to 9eb3241 Compare December 18, 2025 23:45
@Felixoid Felixoid force-pushed the add-basedir-configuration branch from e818064 to d2e6edd Compare December 22, 2025 10:47
@Felixoid
Copy link
Contributor Author

I got an idea, that basedirs should be added to the stats command as well

@Felixoid Felixoid force-pushed the add-basedir-configuration branch from ca0a0db to 6f47f36 Compare December 23, 2025 13:57
@Felixoid Felixoid changed the title Add SCCACHE_BASEDIR support Add SCCACHE_BASEDIRS support Dec 23, 2025
@Felixoid Felixoid force-pushed the add-basedir-configuration branch from b5a7d22 to cf0b871 Compare December 23, 2025 23:03
@AJIOB
Copy link
Contributor

AJIOB commented Dec 24, 2025

I got an idea, that basedirs should be added to the stats command as well

I think we can also provide the stat about base dir usage translation:

  • Number of base dir applied requests
  • Number of base dir skipped requests

In this case we can see, do we need to provide more/better base dirs or not

@Felixoid
Copy link
Contributor Author

  • Number of base dir applied requests
  • Number of base dir skipped requests

It's a tricky one. After taking a look, the number of successful substitutions is relatively easy to implement, although the counter should be threaded to the ServerStats.

But how to count the number of skipped directories? What is it? If a base_directory didn't match any of the output at all?

@AJIOB
Copy link
Contributor

AJIOB commented Dec 24, 2025

  • Number of base dir applied requests
  • Number of base dir skipped requests

It's a tricky one. After taking a look, the number of successful substitutions is relatively easy to implement, although the counter should be threaded to the ServerStats.

But how to count the number of skipped directories? What is it? If a base_directory didn't match any of the output at all?

No, just to check what number of cache requests has been converted using any of base dirs and what number was kept as an absolute one

@AJIOB
Copy link
Contributor

AJIOB commented Dec 24, 2025

About paths: we can try to normalize paths via https://docs.rs/normpath/latest/normpath/ or something similar instead of doing one more implementation.

@Felixoid
Copy link
Contributor Author

About paths: we can try to normalize paths via https://docs.rs/normpath/latest/normpath/ or something similar instead of doing one more implementation.

It looks like https://doc.rust-lang.org/stable/std/path/fn.absolute.html is what I should use for both cases. It normalizes slashes, but keeps the cases as is.

Although see my comment regarding the preprocessor_output. normalize_path is used not only to needles from basedirs, but to a haystack as well. Both https://doc.rust-lang.org/stable/std/path/fn.absolute.html and https://docs.rs/normpath/latest/normpath/trait.PathExt.html#tymethod.normalize_virtually work on Path-like objects. They don't fit the purpose of the plaintext normalization, as far as I can tell.

@Felixoid Felixoid force-pushed the add-basedir-configuration branch 2 times, most recently from a97218c to bccc8f4 Compare December 29, 2025 23:13
@Felixoid
Copy link
Contributor Author

No, just to check what number of cache requests has been converted using any of base dirs and what number was kept as an absolute one

I am afraid it causes changes in too many places, including the signatures of hash_key and other significant components. I want to cut this task from the PR, if you don't mind; it's already quite huge.

@Felixoid Felixoid force-pushed the add-basedir-configuration branch 2 times, most recently from 0887cea to e42a1f6 Compare December 30, 2025 12:12
src/util.rs Outdated
for basedir_path in basedirs.iter() {
let basedir_str = basedir_path.to_string_lossy();
let basedir = basedir_str
.trim_end_matches(|c| c == '/' || c == '\\')
Copy link
Contributor

Choose a reason for hiding this comment

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

\ should not be trimmed on non-Windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#2521 (comment)

so, stripping \|/ on windows, / on other OSes, and then adding the trailing /

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll use https://docs.rs/typed-path/latest/typed_path/ here.

Then, the trailing / will be added explicitly and completely stripped from the preprocessor_output instead of being replaced by ..

The last question is whether ./ should be treated as a special case. Because ./test.c and test.c won't match

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In 87151ba, I implemented this logic. The basedir is stripped completely to match /dir/test.c and test.c in the cache.

The ./test.c is still not covered by the code.

@Felixoid Felixoid force-pushed the add-basedir-configuration branch 2 times, most recently from 6529696 to fae67f8 Compare December 30, 2025 21:50
@Felixoid Felixoid force-pushed the add-basedir-configuration branch from 61c6747 to 861d150 Compare January 21, 2026 09:38
@Felixoid
Copy link
Contributor Author

Another rebase:

  • The COS backend was added
  • Added integration tests for basedirs for each already tested backend

@Felixoid Felixoid force-pushed the add-basedir-configuration branch from 861d150 to ebbd0fb Compare January 21, 2026 09:44
- Use autotools
- Add __FILE__ macros
- Use includes to get complex command line
@Felixoid Felixoid force-pushed the add-basedir-configuration branch from 2d2be61 to f8e0ecb Compare January 22, 2026 20:01
@Felixoid
Copy link
Contributor Author

Felixoid commented Jan 22, 2026

I am pretty sure I didn't touch anything related to the TimeMacroFinder::find_time_macros in this PR

upd: yes, it's the same in another PR

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement an equivalent to CCACHE_BASEDIR

6 participants