Scons缓存是否支持硬链接?含--cache=nolinked参数使用场景
Let's break down your questions clearly, as someone who's worked with SCons caching quite a bit:
Question 1: Does SCons cache support hardlinks?
Absolutely! Hardlinks are actually the default behavior for SCons caching when you don't explicitly disable them. When a build artifact exists in the cache, SCons will create a hardlink from the cache directory to your build directory by default—this is faster than copying and saves disk space since hardlinks point to the same underlying file data.
Question 2: Can I make SCons create hardlinks from the cache to build directory when using --cache=nolinked --cache-dir=<path>?
Hold on, let's clarify what that --cache=nolinked flag does first: this option explicitly tells SCons not to use hardlinks (or symlinks) and instead copy files from the cache. So if you're passing that flag, you're overriding the default hardlink behavior you want.
If your goal is to get hardlinks from cache to build directory, you should drop the --cache=nolinked flag. Instead, use a command like this:
scons --cache=yes --cache-dir=/path/to/your/cache
Or if you want to force using the cache even if the build environment has changed (use cautiously):
scons --cache=force --cache-dir=/path/to/your/cache
One quick caveat: Hardlinks only work if your cache directory and build directory are on the same filesystem. If they're on different filesystems, SCons will automatically fall back to copying files, since hardlinks can't cross filesystem boundaries.
内容的提问来源于stack exchange,提问作者igor.sol




