Skip to content

Commit e42a1f6

Browse files
committed
Final cleanup of the code for leftovers
1 parent bccc8f4 commit e42a1f6

File tree

7 files changed

+12
-34
lines changed

7 files changed

+12
-34
lines changed

docs/Configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ Note that some env variables may need sccache server restart to take effect.
154154

155155
* `SCCACHE_ALLOW_CORE_DUMPS` to enable core dumps by the server
156156
* `SCCACHE_CONF` configuration file path
157-
* `SCCACHE_BASEDIRS` base directory (or directories) to strip from paths for cache key computation. This is similar to ccache's `CCACHE_BASEDIR` and enables cache hits across different absolute paths when compiling the same source code. Multiple directories can be separated by `;` on Windows hosts and by `:` on any other. When multiple directories are specified, the longest matching prefix is used. Path matching is **case-insensitive** on Windows and **case-sensitive** on other operating systems. Environment variable takes precedence over file configuration. Only absolute paths are supported; relative paths will be ignored with a warning.
157+
* `SCCACHE_BASEDIRS` base directory (or directories) to strip from paths for cache key computation. This is similar to ccache's `CCACHE_BASEDIR` and enables cache hits across different absolute paths when compiling the same source code. Multiple directories can be separated by `;` on Windows hosts and by `:` on any other. When multiple directories are specified, the longest matching prefix is used. Path matching is **case-insensitive** on Windows and **case-sensitive** on other operating systems. Environment variable takes precedence over file configuration. Only absolute paths are supported; relative paths will cause an error and prevent the server from start.
158158
* `SCCACHE_CACHED_CONF`
159159
* `SCCACHE_IDLE_TIMEOUT` how long the local daemon process waits for more client requests before exiting, in seconds. Set to `0` to run sccache permanently
160160
* `SCCACHE_STARTUP_NOTIFY` specify a path to a socket which will be used for server completion notification

src/cache/cache.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -880,8 +880,6 @@ mod test {
880880
#[test]
881881
#[cfg(feature = "s3")]
882882
fn test_operator_storage_s3_with_basedirs() {
883-
use std::path::PathBuf;
884-
885883
// Create S3 operator (doesn't need real credentials for this test)
886884
let operator = crate::cache::s3::S3Cache::new(
887885
"test-bucket".to_string(),
@@ -910,8 +908,6 @@ mod test {
910908
#[test]
911909
#[cfg(feature = "redis")]
912910
fn test_operator_storage_redis_with_basedirs() {
913-
use std::path::PathBuf;
914-
915911
// Create Redis operator
916912
let operator = crate::cache::redis::RedisCache::build_single(
917913
"redis://localhost:6379",

src/cache/readonly.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,16 @@ mod test {
143143
std::fs::create_dir(&cache_dir).unwrap();
144144

145145
let basedirs = vec![
146-
std::path::PathBuf::from("/home/user/project"),
147-
std::path::PathBuf::from("/home/user/workspace"),
146+
PathBuf::from("/home/user/project"),
147+
PathBuf::from("/home/user/workspace"),
148148
];
149149

150150
let disk_cache = crate::cache::disk::DiskCache::new(
151151
&cache_dir,
152152
1024 * 1024,
153153
runtime.handle(),
154-
super::super::PreprocessorCacheModeConfig::default(),
155-
super::super::CacheMode::ReadWrite,
154+
super::PreprocessorCacheModeConfig::default(),
155+
super::CacheMode::ReadWrite,
156156
basedirs.clone(),
157157
);
158158

src/compiler/c.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::dist::pkg;
2626
use crate::mock_command::CommandCreatorSync;
2727
use crate::util::{
2828
Digest, HashToDigest, MetadataCtimeExt, TimeMacroFinder, Timestamp, decode_path, encode_path,
29-
hash_all,
29+
hash_all, strip_basedirs,
3030
};
3131
use async_trait::async_trait;
3232
use fs_err as fs;
@@ -1486,7 +1486,6 @@ pub fn hash_key(
14861486

14871487
// Strip basedirs from preprocessor output if configured
14881488
let preprocessor_output_to_hash = if !basedirs.is_empty() {
1489-
use crate::util::strip_basedirs;
14901489
Cow::Owned(strip_basedirs(preprocessor_output, basedirs))
14911490
} else {
14921491
Cow::Borrowed(preprocessor_output)
@@ -1805,8 +1804,6 @@ mod test {
18051804

18061805
#[test]
18071806
fn test_hash_key_basedirs() {
1808-
use std::path::PathBuf;
1809-
18101807
let args = ovec!["a", "b", "c"];
18111808
let digest = "abcd";
18121809

src/compiler/preprocessor_cache.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use serde::{Deserialize, Serialize};
3434

3535
use crate::{
3636
cache::PreprocessorCacheModeConfig,
37-
util::{Digest, HashToDigest, MetadataCtimeExt, Timestamp, encode_path},
37+
util::{Digest, HashToDigest, MetadataCtimeExt, Timestamp, encode_path, strip_basedirs},
3838
};
3939

4040
use super::Language;
@@ -418,7 +418,6 @@ pub fn preprocessor_cache_entry_hash_key(
418418

419419
// Strip basedirs from the input file path if configured
420420
let buf_to_hash = if !basedirs.is_empty() {
421-
use crate::util::strip_basedirs;
422421
strip_basedirs(&buf, basedirs)
423422
} else {
424423
buf.clone()

src/config.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -952,11 +952,10 @@ fn config_from_env() -> Result<EnvConfig> {
952952
// ======= Base directory =======
953953
// Support multiple paths separated by ';' on Windows and ':' on other platforms
954954
// to match PATH behavior.
955-
let split_symbol = if cfg!(target_os = "windows") {
956-
';'
957-
} else {
958-
':'
959-
};
955+
#[cfg(target_os = "windows")]
956+
let split_symbol = ';';
957+
#[cfg(not(target_os = "windows"))]
958+
let split_symbol = ':';
960959
let basedirs = env::var_os("SCCACHE_BASEDIRS")
961960
.map(|s| {
962961
s.to_string_lossy()

src/util.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,7 @@ fn normalize_path(path: &[u8]) -> Vec<u8> {
11291129
mod tests {
11301130
use super::{OsStrExt, TimeMacroFinder};
11311131
use std::ffi::{OsStr, OsString};
1132+
use std::path::PathBuf;
11321133

11331134
#[test]
11341135
fn simple_starts_with() {
@@ -1280,8 +1281,6 @@ mod tests {
12801281

12811282
#[test]
12821283
fn test_strip_basedir_simple() {
1283-
use std::path::PathBuf;
1284-
12851284
// Simple cases
12861285
let basedir = PathBuf::from("/home/user/project");
12871286
let input = b"# 1 \"/home/user/project/src/main.c\"\nint main() { return 0; }";
@@ -1304,8 +1303,6 @@ mod tests {
13041303

13051304
#[test]
13061305
fn test_strip_basedir_empty() {
1307-
use std::path::PathBuf;
1308-
13091306
// Empty basedir slice
13101307
let input = b"# 1 \"/home/user/project/src/main.c\"";
13111308
let output = super::strip_basedirs(input, &[]);
@@ -1320,8 +1317,6 @@ mod tests {
13201317

13211318
#[test]
13221319
fn test_strip_basedir_not_at_boundary() {
1323-
use std::path::PathBuf;
1324-
13251320
// basedir should only match at word boundaries
13261321
let basedir = PathBuf::from("/home/user");
13271322
let input = b"text/home/user/file.c and \"/home/user/other.c\"";
@@ -1333,8 +1328,6 @@ mod tests {
13331328

13341329
#[test]
13351330
fn test_strip_basedir_trailing_slashes() {
1336-
use std::path::PathBuf;
1337-
13381331
// Without trailing slash
13391332
let basedir = PathBuf::from("/home/user/project");
13401333
let input = b"# 1 \"/home/user/project/src/main.c\"";
@@ -1359,8 +1352,6 @@ mod tests {
13591352

13601353
#[test]
13611354
fn test_strip_basedirs_multiple() {
1362-
use std::path::PathBuf;
1363-
13641355
// Multiple basedirs - should match longest first
13651356
let basedirs = vec![
13661357
PathBuf::from("/home/user1/project"),
@@ -1386,8 +1377,6 @@ mod tests {
13861377
#[cfg(target_os = "windows")]
13871378
#[test]
13881379
fn test_strip_basedir_windows_backslashes() {
1389-
use std::path::PathBuf;
1390-
13911380
// Without trailing backslash
13921381
let basedir = PathBuf::from("C:\\Users\\test\\project");
13931382
let input = b"# 1 \"C:\\Users\\test\\project\\src\\main.c\"";
@@ -1407,8 +1396,6 @@ mod tests {
14071396
#[cfg(target_os = "windows")]
14081397
#[test]
14091398
fn test_strip_basedir_windows_mixed_slashes() {
1410-
use std::path::PathBuf;
1411-
14121399
// Mixed forward and backslashes in input (common from certain build systems)
14131400
let basedir = PathBuf::from("C:\\Users\\test\\project");
14141401
let input = b"# 1 \"C:/Users\\test\\project\\src/main.c\"";

0 commit comments

Comments
 (0)