Skip to content

Commit 78620b0

Browse files
authored
Merge branch 'main' into build_plugin_integration_tests
2 parents 6c3f38a + 7695d98 commit 78620b0

File tree

5 files changed

+78
-13
lines changed

5 files changed

+78
-13
lines changed

Plugins/GRPCProtobufGenerator/BuildPluginConfig.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,16 @@ struct BuildPluginConfig: Codable {
5757
/// Whether imports should have explicit access levels.
5858
///
5959
/// Defaults to `false`.
60-
var useAccessLevelOnImports: Bool
60+
var accessLevelOnImports: Bool
6161

6262
static let defaults = Self(
6363
accessLevel: .internal,
64-
useAccessLevelOnImports: false
64+
accessLevelOnImports: false
6565
)
6666

67-
private init(accessLevel: GenerationConfig.AccessLevel, useAccessLevelOnImports: Bool) {
67+
private init(accessLevel: GenerationConfig.AccessLevel, accessLevelOnImports: Bool) {
6868
self.accessLevel = accessLevel
69-
self.useAccessLevelOnImports = useAccessLevelOnImports
69+
self.accessLevelOnImports = accessLevelOnImports
7070
}
7171
}
7272

@@ -159,7 +159,7 @@ extension BuildPluginConfig.GeneratedSource: Codable {
159159
// Codable conformance with defaults
160160
enum CodingKeys: String, CodingKey {
161161
case accessLevel
162-
case useAccessLevelOnImports
162+
case accessLevelOnImports
163163
}
164164

165165
init(from decoder: any Decoder) throws {
@@ -168,9 +168,9 @@ extension BuildPluginConfig.GeneratedSource: Codable {
168168
self.accessLevel =
169169
try container.decodeIfPresent(GenerationConfig.AccessLevel.self, forKey: .accessLevel)
170170
?? Self.defaults.accessLevel
171-
self.useAccessLevelOnImports =
172-
try container.decodeIfPresent(Bool.self, forKey: .useAccessLevelOnImports)
173-
?? Self.defaults.useAccessLevelOnImports
171+
self.accessLevelOnImports =
172+
try container.decodeIfPresent(Bool.self, forKey: .accessLevelOnImports)
173+
?? Self.defaults.accessLevelOnImports
174174
}
175175
}
176176

@@ -199,7 +199,7 @@ extension GenerationConfig {
199199
// hard-code full-path to avoid collisions since this goes into a temporary directory anyway
200200
self.fileNaming = .fullPath
201201
self.visibility = buildPluginConfig.generatedSource.accessLevel
202-
self.useAccessLevelOnImports = buildPluginConfig.generatedSource.useAccessLevelOnImports
202+
self.accessLevelOnImports = buildPluginConfig.generatedSource.accessLevelOnImports
203203
// Generate absolute paths for the imports relative to the config file in which they are specified
204204
self.importPaths = buildPluginConfig.protoc.importPaths.map { relativePath in
205205
configFilePath.deletingLastPathComponent().absoluteStringNoScheme + "/" + relativePath

Plugins/PluginsShared/GenerationConfig.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct GenerationConfig {
5252
/// The naming of output files with respect to the path of the source file.
5353
var fileNaming: FileNaming
5454
/// Whether imports should have explicit access levels.
55-
var useAccessLevelOnImports: Bool
55+
var accessLevelOnImports: Bool
5656

5757
/// Specify the directory in which to search for imports.
5858
///

Plugins/PluginsShared/PluginUtils.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func constructProtocGenSwiftArguments(
6565

6666
protocArgs.append("--swift_opt=Visibility=\(config.visibility.rawValue)")
6767
protocArgs.append("--swift_opt=FileNaming=\(config.fileNaming.rawValue)")
68-
protocArgs.append("--swift_opt=UseAccessLevelOnImports=\(config.useAccessLevelOnImports)")
68+
protocArgs.append("--swift_opt=UseAccessLevelOnImports=\(config.accessLevelOnImports)")
6969
protocArgs.append(contentsOf: inputFiles.map { $0.absoluteStringNoScheme })
7070

7171
return protocArgs
@@ -101,7 +101,7 @@ func constructProtocGenGRPCSwiftArguments(
101101
protocArgs.append("--grpc-swift_opt=Server=\(config.server)")
102102
protocArgs.append("--grpc-swift_opt=Client=\(config.client)")
103103
protocArgs.append("--grpc-swift_opt=FileNaming=\(config.fileNaming.rawValue)")
104-
protocArgs.append("--grpc-swift_opt=UseAccessLevelOnImports=\(config.useAccessLevelOnImports)")
104+
protocArgs.append("--grpc-swift_opt=UseAccessLevelOnImports=\(config.accessLevelOnImports)")
105105
protocArgs.append(contentsOf: inputFiles.map { $0.absoluteStringNoScheme })
106106

107107
return protocArgs
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Installing protoc
2+
3+
Learn how to install `protoc`, the Protocol Buffers compiler.
4+
5+
## Overview
6+
7+
The Protocol Buffers compiler is a command line tool for generating source code from `.proto`
8+
files and is required to generate gRPC stubs and messages. You can learn more about it on the
9+
[Protocol Buffers website](https://protobuf.dev/).
10+
11+
You can install `protoc` in a number of ways including:
12+
13+
1. Via a package manager,
14+
2. By downloading the binary.
15+
16+
### Install via a package manager
17+
18+
Using a package manager is the easiest way to install `protoc`.
19+
20+
On macOS you can use [Homebrew](https://brew.sh):
21+
22+
```sh
23+
brew install protobuf
24+
```
25+
26+
On Ubuntu and Debian you can use `apt`:
27+
28+
```sh
29+
apt update && apt install -y protobuf-compiler
30+
```
31+
32+
On Fedora you can use `dnf`:
33+
34+
```sh
35+
dnf install -y protobuf-compiler
36+
```
37+
38+
### Installing a pre-built binary
39+
40+
If you're unable to use a package manager to install `protoc` then you may be able
41+
to download a pre-built binary from the [Protocol Buffers GitHub
42+
repository](https://github.com/protocolbuffers/protobuf).
43+
44+
First, find and download the appropriate binary for your system from the
45+
[releases](https://github.com/protocolbuffers/protobuf/releases) page.
46+
47+
Next, unzip the artifact to a directory called `protoc`:
48+
49+
```sh
50+
unzip /path/to/downloaded/protoc-{VERSION}-{OS}.zip -d protoc
51+
```
52+
53+
Finally, move `protoc/bin/protoc` to somewhere in your `$PATH` such as `/usr/local/bin`:
54+
55+
```sh
56+
mv protoc/bin/protoc /usr/local/bin
57+
```
58+
59+
You can now remove the `protoc` directory.

Sources/GRPCProtobuf/Documentation.docc/Documentation.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,19 @@ A package integrating Swift Protobuf with gRPC Swift.
44

55
## Overview
66

7-
This package provides two products:
7+
This package provides three products:
88
- ``GRPCProtobuf``, a module providing runtime serialization and deserialization components for
99
[SwiftProtobuf](https://github.com/apple/swift-protobuf).
1010
- `protoc-gen-grpc-swift`, an executable which is a plugin for `protoc`, the Protocol Buffers
1111
compiler. An article describing how to generate gRPC Swift stubs using it is available with the
1212
`grpc-swift` documentation on the [Swift Package
1313
Index](https://swiftpackageindex.com/grpc/grpc-swift/documentation).
14+
- `GRPCProtobufGenerator`, a Swift Package build plugin for generating stubs as part of the build
15+
process.
16+
17+
## Essentials
18+
19+
- <doc:Installing-protoc>
1420

1521
## Topics
1622

0 commit comments

Comments
 (0)