spotify / XCRemoteCache

Other
835 stars 52 forks source link

Support using swiftinterface to determine whether invalidate binary cache. #170

Open CharlieSuP1 opened 2 years ago

CharlieSuP1 commented 2 years ago

Let's say module A depends on module B,so in A's meta file(which all A's dependencies are listed), line "B.swiftmodule.md5" is contained.

So in consumer mode, if any code change in B module occurs, module B.swiftmodule.md5 is changed, thus triggers A's cache invalidation. And module A is compiled locally(other than use remote cache).

Is there any possibility that:if module B is compiled with "build_library_for_distribution",then A use B's swiftinterface(other than swiftmodule.md5) to be its dependency. If so, is module changes are constrained internally ( no public or open api changes), module A can still use remote cache.

CharlieSuP1 commented 2 years ago

I think main code change to achieve this is here (In file DependencyProcessor.swift):

        return files.map { file -> Dependency in
            let filePath = file.resolvingSymlinksInPath().path
//.........
             if filePath.hasPrefix(sourcePath) {
                #return Dependency(url: file, type: .source)
                if module's swiftinterface is produced {
                        return module's swiftinterface
                 } else {
                       return Dependency(url: file, type: .source)
                }
            }
//.........
        }
    }
polac24 commented 2 years ago

Yes, that could potentially. I am not sure if the location of the pseudocode is correct, but the idea seems valid.

CharlieSuP1 commented 2 years ago

Yes, after second thought, pseudocode is not correct, but the whole idea is still potential. I’ll try to implement and see if can submit a merge request.

CharlieSuP1 commented 2 years ago

Another question is that is there any way to check if a swiftinterface file's change is backward compatible? If we can check that, then any backward compatible api changes in module B, will not trigger module A cache invalidation.

Coder-Star commented 2 months ago

Yes, after second thought, pseudocode is not correct, but the whole idea is still potential. I’ll try to implement and see if can submit a merge request.

Is there any progress?