Skip to content

[Driver] Move some string definitions around (NFC) #4493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 2, 2016

Conversation

modocache
Copy link
Contributor

@modocache modocache commented Aug 25, 2016

What's in this pull request?

I've been poking around what .swiftdeps files are and how they work, and noticed a small amount of duplication, across Driver.cpp and Compilation.cpp, in some strings used in the files.

I'm not sure how much of an improvement this is, but these two commits "centralize" the duplication. YAML keys like version and inputs now exist in CompilationRecord.h. Input status identifiers like !dirty and !private are now defined as part of the CompileJobAction::InputInfo struct.

Is it worth making the change? I'm not sure. Feel free to close this pull request if you don't think it is. :)

Resolved bug number: None


Before merging this pull request to apple/swift repository:

  • Test pull request on Swift continuous integration.

Triggering Swift CI

The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:

Smoke Testing

Platform Comment
All supported platforms @swift-ci Please smoke test
All supported platforms @swift-ci Please smoke test and merge
OS X platform @swift-ci Please smoke test OS X platform
Linux platform @swift-ci Please smoke test Linux platform

A smoke test on macOS does the following:

  1. Builds the compiler incrementally.
  2. Builds the standard library only for macOS. Simulator standard libraries and
    device standard libraries are not built.
  3. lldb is not built.
  4. The test and validation-test targets are run only for macOS. The optimized
    version of these tests are not run.

A smoke test on Linux does the following:

  1. Builds the compiler incrementally.
  2. Builds the standard library incrementally.
  3. lldb is built incrementally.
  4. The swift test and validation-test targets are run. The optimized version of these
    tests are not run.
  5. lldb is tested.

Validation Testing

Platform Comment
All supported platforms @swift-ci Please test
All supported platforms @swift-ci Please test and merge
OS X platform @swift-ci Please test OS X platform
OS X platform @swift-ci Please benchmark
Linux platform @swift-ci Please test Linux platform

Lint Testing

Language Comment
Python @swift-ci Please Python lint

Note: Only members of the Apple organization can trigger swift-ci.

};

/// \returns A string representation of the given key.
inline StringRef getName(TopLevelKey Key) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please mark this static. Non-static inlines have weird rules that we just avoid.

@jrose-apple
Copy link
Contributor

I do feel a little weird putting the build record tags in Action.h, which is theoretically a "public" header. Maybe those belong in CompilationRecord.h as well.

@jrose-apple
Copy link
Contributor

But eliminating duplication of magic constants is a good idea. The !private for .swiftdeps files is probably next, and we can change them all to !noncascading at that point.

@modocache modocache force-pushed the driver-compilation-record branch from 8e21ac3 to 4456b93 Compare August 30, 2016 01:43
@modocache
Copy link
Contributor Author

@jrose-apple Hopefully I've addressed your comments: I moved everything to CompilationRecord.h, did some slight renaming, and fixed up the indentation.

}

/// \returns The string identifier used to represent the given status in a
/// compilation record file (.swiftdeps file).
Copy link
Contributor

Choose a reason for hiding this comment

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

Last nitpick: can you add a note here pointing out that this will not round-trip?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I was actually confused when you mentioned that earlier. By "not round-trip", you mean that getInfoStatusForIdentifier(getIdentifierForInputInfoStatus(Status)) != Status, is that right? Since the left-hand side would be an Optional<Status>?

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 added a note to the function below, based on my interpretation of "round trip" 😇

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, no, I mostly meant that there was no dedicated identifier for NewlyAdded, and that in general not every input status will necessarily have a unique compilation record identifier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aha, gotcha. My bad! Updating now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! Let me know if that's what you had in mind.

Copy link
Contributor

Choose a reason for hiding this comment

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

Works for me. Thanks, Brian!

@modocache modocache force-pushed the driver-compilation-record branch from 4456b93 to d9ea330 Compare August 30, 2016 16:08
Define compilation record (.swiftdeps) top-level keys, as well as string
identifiers used in compilation record files (like "!dirty" and "!private"), in
a single location. NFC.
@modocache modocache force-pushed the driver-compilation-record branch from d9ea330 to 2b3647e Compare August 30, 2016 16:30
@jrose-apple
Copy link
Contributor

@swift-ci Please smoke test

@jrose-apple
Copy link
Contributor

@swift-ci Please smoke test Linux platform

2 similar comments
@jrose-apple
Copy link
Contributor

@swift-ci Please smoke test Linux platform

@jrose-apple
Copy link
Contributor

@swift-ci Please smoke test Linux platform

@modocache
Copy link
Contributor Author

Looks like all the tests passed, and according to #4585 (comment) my merge permissions have been restored. So I'll go ahead and merge this myself. :)

@modocache modocache merged commit d08fe89 into swiftlang:master Sep 2, 2016
@modocache modocache deleted the driver-compilation-record branch September 2, 2016 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants