[ParseableInterface] Distinguish SDK and non-SDK dependencies

This allows the SDK to be relocated without automatically resulting in a
rebuild.

Based on an old patch from Jordan Rose.
This commit is contained in:
Nathan Hawes
2019-03-29 10:05:00 -07:00
parent f683373116
commit 58d0ee0888
9 changed files with 222 additions and 28 deletions

View File

@@ -39,11 +39,14 @@ namespace swift {
/// appropriate strategy for how to verify if it's up-to-date.
class FileDependency {
/// The size of the file on disk, in bytes.
uint64_t Size : 63;
uint64_t Size : 62;
/// A dependency can be either hash-based or modification-time-based.
bool IsHashBased : 1;
/// The dependency path can be absolute or relative to the SDK
bool IsSDKRelative : 1;
union {
/// The last modification time of the file.
uint64_t ModificationTime;
@@ -56,22 +59,22 @@ namespace swift {
std::string Path;
FileDependency(uint64_t size, bool isHash, uint64_t hashOrModTime,
StringRef path):
Size(size), IsHashBased(isHash), ModificationTime(hashOrModTime),
Path(path) {}
StringRef path, bool isSDKRelative):
Size(size), IsHashBased(isHash), IsSDKRelative(isSDKRelative),
ModificationTime(hashOrModTime), Path(path) {}
public:
FileDependency() = delete;
/// Creates a new hash-based file dependency.
static FileDependency
hashBased(StringRef path, uint64_t size, uint64_t hash) {
return FileDependency(size, /*isHash*/true, hash, path);
hashBased(StringRef path, bool isSDKRelative, uint64_t size, uint64_t hash) {
return FileDependency(size, /*isHash*/true, hash, path, isSDKRelative);
}
/// Creates a new modification time-based file dependency.
static FileDependency
modTimeBased(StringRef path, uint64_t size, uint64_t mtime) {
return FileDependency(size, /*isHash*/false, mtime, path);
modTimeBased(StringRef path, bool isSDKRelative, uint64_t size, uint64_t mtime) {
return FileDependency(size, /*isHash*/false, mtime, path, isSDKRelative);
}
/// Updates the last-modified time of this dependency.
@@ -94,6 +97,9 @@ namespace swift {
/// based on content hash.
bool isHashBased() const { return IsHashBased; }
/// Determines if this dependency is absolute or relative to the SDK.
bool isSDKRelative() const { return IsSDKRelative; }
/// Determines if this dependency is hash-based and should be validated
/// based on modification time.
bool isModificationTimeBased() const { return !IsHashBased; }