Skip to content

Conversation

@davidungar
Copy link
Contributor

@davidungar davidungar commented Oct 10, 2020

Adds BuildRecordInfo to hold information needed to read and write build records. Writes build records whether incremental or not. Reads when incremental. Tests reading and writing.

@davidungar
Copy link
Contributor Author

@swift-ci please test

@davidungar davidungar force-pushed the incremental-10-9c-write-build-rec branch from 9adcb5d to 81d55fa Compare October 10, 2020 03:55
@davidungar davidungar force-pushed the incremental-10-9c-write-build-rec branch from a9c7850 to 9bc4730 Compare October 10, 2020 05:39
@davidungar davidungar changed the title [Incremental, DNM] First cut at writing build record; needs a test and also polish [Incremental] Write build record & test Oct 10, 2020
@davidungar
Copy link
Contributor Author

@swift-ci please test

@davidungar davidungar force-pushed the incremental-10-9c-write-build-rec branch from 87fe8ca to 07b2b17 Compare October 10, 2020 07:55
@davidungar
Copy link
Contributor Author

@swift-ci please test

@davidungar davidungar requested review from CodaFi and owenv October 10, 2020 16:49
Copy link
Contributor

@owenv owenv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I added a handful of comments, nothing major.

Comment on lines +37 to +45
public init?(identifier: String) {
switch identifier {
case "": self = .upToDate
case "!dirty": self = .needsCascadingBuild
case "!private": self = .needsNonCascadingBuild
default: return nil
}
assert(self.identifier == identifier, "Ensure reversibility")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd lose the nicer argument label, but making Status a string-backed enum might be worth it to maintain consistency with the identifier property below

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how to do that, given that there are two statuses with the same string:

 case .needsCascadingBuild, .newlyAdded: return "!dirty" 
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, I missed that, thanks! This looks good to me 👍

Comment on lines 115 to 119
catch let InputInfoMap.Errors.notAbsolutePath(p) {
diagnosticEngine.emit(
.warning_could_not_write_build_record_not_absolutePath(p))
return
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any build systems that rely on using a relative build record path in the output file path right now? (Bazel comes to mind as a possibility, but I'm not sure) Instead of failing here, we could try to resolve the path against the file system's cwd

Copy link
Contributor Author

@davidungar davidungar Oct 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, but I think it's OK.

If I read the following code correctly (in Driver.swift):

 if let workingDirectory = self.workingDirectory { self.outputFileMap = outputFileMap?.resolveRelativePaths(relativeTo: workingDirectory) } else { self.outputFileMap = outputFileMap } 

the warning will only happen if there is no working directory and the map contains a relative path.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Driver.workingDirectory will only be non-nil if the user explicitly passes one with -working-directory, so we can still end up in this situation if the file system has one but the user didn't pass the command line option. That said, this is a pretty rare edge case and I don't think we need to handle it perfectly right now, so I'm fine with leaving this as-is

@davidungar
Copy link
Contributor Author

@swift-ci please test

@davidungar
Copy link
Contributor Author

@swift-ci Thanks, @owenv , for your help. I think I've fixed the problems. Would you like to take another look?

@davidungar
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@owenv owenv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidungar Looks good to me, thanks!

Sorry if I sound like a broken record about the CMake stuff, I've broken the build more times than I'd care to admit by forgetting to update it 🙂

@@ -0,0 +1,245 @@
//===--------------- BuildRecord.swift - Swift Input File Info Map -------===//
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CMakeLists.txt entry for InputInfoMap will need to be renamed to BuildRecord

@@ -0,0 +1,148 @@
//===--------------- BuildRecordInfo.swift --------------------------------===//
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need a new entry in CMakeLists.txt

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you--yes, I remembered that too late, and I really appreciate the reminder. I will fix those.

@davidungar
Copy link
Contributor Author

@swift-ci please test

@davidungar davidungar merged commit ac4af7a into swiftlang:main Oct 11, 2020
@davidungar davidungar removed the request for review from DougGregor October 11, 2020 21:57
@davidungar davidungar deleted the incremental-10-9c-write-build-rec branch October 28, 2020 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants