Skip to content

[6.0][CompilerPlugin] Remove Foundation dependency #2619

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 31 commits into from
Apr 25, 2024

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Apr 23, 2024

cherry-pick https://github.com/apple/swift-syntax/pull/2598/commits

  • Explanation: When we want to use swift-foundation as a package dependency, since Foundation uses macros, it depends on SwiftCompilerPlugin. So swift-syntax should not depends on Foundation. Implement its own JSON coder, and use read(2), write(2), etc. for standard I/O communication
  • Scope: Executable macro plugins
  • Risk: Mid. New JSON coder is somewhat risky
  • Testing: Added JSON encoding/decoding unit test cases. Passes current test-suite
  • Issue: rdar://126714084
  • Reviewer: Hamish Knight (@hamishknight) Alex Hoppen (@ahoppen)

rintaro added 30 commits April 23, 2024 10:11
Inspired by swift-foundation's JSONEncoder/JSONDecoder. But basically a
re-implementation of Encoder / Decoder.

(cherry picked from commit 61c7338)
Instead, use read(2) and write(2) via Darin/Glibc/UCRT

(cherry picked from commit e20a65c)
* Rename PluginMessageJSON to JSON
* Make JSON encoder/decoder SPI
* Make encoding/decoding internals private

(cherry picked from commit 29032ed)
Use DecodingError / EcodingError properly

(cherry picked from commit 3d676d0)
(cherry picked from commit 39acd5a)
If read(2) returned 0, STDIN is closed. So return nil from
'waitForNextMessage()' so the caller can exit cleanly.

(cherry picked from commit adb2fb0)
(cherry picked from commit 4edb04a)
(cherry picked from commit d6f5327)
(cherry picked from commit c986761)
(cherry picked from commit 6b594b8)
Add _CShims module. For CMake it's a INTERFACE library.

(cherry picked from commit 10cc964)
Speculative fix for Windows

(cherry picked from commit 3b36bde)
(cherry picked from commit b3494aa)
Back to read(2)/write(2). Some cleanups.

(cherry picked from commit 278aea7)
(cherry picked from commit 488c434)
In some platforms memcmp don't accept optional value

(cherry picked from commit 401229c)
There's no reason to '- 2'/'+ 2'.

(cherry picked from commit c0fc9b5)
* typo
* Remove unnecessary withExtendedLifetime()
* remove JSONObject.subscript(_:) as it's not O(1)
* Use 'LosslessStringConvertible'

(cherry picked from commit 4c84edb)
* Don't use UTF8 decoder for decoding escaped strings
* Only memcmp ASCII non-escaped strings

(cherry picked from commit 5ab0c7e)
Update for review comments

(cherry picked from commit 197a45c)
Update for review comments

(cherry picked from commit 17a0c6b)
Use 'for' look instead of 'while cursor != end { cursor += 1 }'

(cherry picked from commit cf4f3e4)
The source JSON buffer is not guaranteed to be null terminated. If a
number is at top-level, 'strtod'/'strtof' tries to read past the buffer
which is not great

(cherry picked from commit 679b929)
Avoid possible module name collision

(cherry picked from commit 1e2c3bd)
@rintaro
Copy link
Member Author

rintaro commented Apr 23, 2024

@swift-ci Please test

@rintaro
Copy link
Member Author

rintaro commented Apr 23, 2024

@swift-ci Please test macOS

@rintaro
Copy link
Member Author

rintaro commented Apr 23, 2024

@swift-ci Please test Linux

2 similar comments
@rintaro
Copy link
Member Author

rintaro commented Apr 23, 2024

@swift-ci Please test Linux

@rintaro
Copy link
Member Author

rintaro commented Apr 24, 2024

@swift-ci Please test Linux

@rintaro
Copy link
Member Author

rintaro commented Apr 24, 2024

@swift-ci Please test macOS

@rintaro
Copy link
Member Author

rintaro commented Apr 24, 2024

@swift-ci Please test Linux

@rintaro
Copy link
Member Author

rintaro commented Apr 24, 2024

@swift-ci Please test macOS

1 similar comment
@rintaro
Copy link
Member Author

rintaro commented Apr 25, 2024

@swift-ci Please test macOS

@rintaro
Copy link
Member Author

rintaro commented Apr 25, 2024

@swift-ci Please test Linux

@rintaro rintaro merged commit ed7021d into swiftlang:release/6.0 Apr 25, 2024
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