CommonConfiguration.swift 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright 2024, gRPC Authors All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /// The configuration common to the build and command plugins.
  17. struct CommonConfiguration: Codable {
  18. /// The visibility of the generated files.
  19. enum Visibility: String, Codable {
  20. /// The generated files should have `internal` access level.
  21. case `internal` = "Internal"
  22. /// The generated files should have `public` access level.
  23. case `public` = "Public"
  24. /// The generated files should have `package` access level.
  25. case `package` = "Package"
  26. }
  27. /// The naming of output files with respect to the path of the source file.
  28. ///
  29. /// For an input of `foo/bar/baz.proto` the following output file will be generated:
  30. /// - `FullPath`: `foo/bar/baz.grpc.swift`
  31. /// - `PathToUnderscore`: `foo_bar_baz.grpc.swift`
  32. /// - `DropPath`: `baz.grpc.swift`
  33. enum FileNaming: String, Codable {
  34. /// Replicate the input file path with the output file(s).
  35. case fullPath = "FullPath"
  36. /// Convert path directory delimiters to underscores.
  37. case pathToUnderscores = "PathToUnderscores"
  38. /// Generate output files using only the base name of the inout file, ignoring the path.
  39. case dropPath = "DropPath"
  40. }
  41. /// The visibility of the generated files.
  42. var visibility: Visibility?
  43. /// Whether server code is generated.
  44. var server: Bool?
  45. /// Whether client code is generated.
  46. var client: Bool?
  47. /// Whether message code is generated.
  48. var message: Bool?
  49. // /// Whether reflection data is generated.
  50. // var reflectionData: Bool?
  51. /// The naming of output files with respect to the path of the source file.
  52. var fileNaming: FileNaming?
  53. /// Path to module map .asciipb file.
  54. var protoPathModuleMappings: String?
  55. /// Whether imports should have explicit access levels.
  56. var useAccessLevelOnImports: Bool?
  57. /// Specify the directory in which to search for
  58. /// imports. May be specified multiple times;
  59. /// directories will be searched in order.
  60. /// The target source directory is always appended
  61. /// to the import paths.
  62. var importPaths: [String]?
  63. /// The path to the `protoc` binary.
  64. ///
  65. /// If this is not set, SPM will try to find the tool itself.
  66. var protocPath: String?
  67. /// The path into which the generated source files are created.
  68. ///
  69. /// If this is not set, the plugin will use a default path (see plugin for details).
  70. var outputPath: String?
  71. }