scons icon indicating copy to clipboard operation
scons copied to clipboard

Allow specifying cachedir from cmdline

Open mwichmann opened this issue 5 years ago • 5 comments

After a brief mention on Discord (sadly can't link to those)

currently can only enable derived-file caching with a call to CacheDir(path) in an sconscript. It seems like a command-line option to enable caching globally, and set the path - in other words, equivalent to calling the global CacheDir (but not to calling env.CacheDir), would be useful. This would make the feature more equivalent to Repository / --repository=path

mwichmann avatar Apr 19 '20 18:04 mwichmann

While on the subject of the cachedir, should there be an option to prune the cache (flush old entries)?

mwichmann avatar Apr 22 '20 13:04 mwichmann

@mwichmann - Yes, pruning functionality for the cache is definitely needed. Otherwise you inevitably fill your storage with dead cached objects.

acmorrow avatar Apr 22 '20 16:04 acmorrow

@bdbaddog let's make a call on this one - implement or reject, no point in just leaving it sitting here. Use of a cachedir I'd expect to be a relatively permanent feature which you occasionally might want to bypass, so the existing combination of CacheDir in the build files and temporary overrides (--cache-disable and --cache-readonly) seems pretty natural. A --cache-dir or similarly-named option is conventient for testing - you don't have enable inside the test program - but maybe does not have as much real-world value?

mwichmann avatar Oct 28 '25 14:10 mwichmann

Should be pretty easy to implement a --cache-dir?

If so then let's add it.

I can see command line or shell env SCONSFLAGS setting this where it could be different per user instead of same path for every user.

bdbaddog avatar Oct 28 '25 18:10 bdbaddog

It shouldn't be hard. I just looked and the other cachedir cli args modify module-globals in CacheDir.py. There's one for cachedir enabled, which is implied, but there isn't one for path. A little bit of thinking whether to instantiate it right away or wait.

mwichmann avatar Oct 28 '25 19:10 mwichmann