swiftcfg

package
v0.0.0-...-4f56d51 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package swiftcfg defines the types for the Swift-specific config used in the Gazelle extension.

Index

Constants

View Source
const (
	MatchCaseModuleNamingConvention  string = "match_case"
	PascalCaseModuleNamingConvention string = "pascal_case"
	MatchProtoGenerationMode         string = "match"
	PackageProtoGenerationMode       string = "package"
)
View Source
const SwiftConfigName = "swift"

Variables

This section is empty.

Functions

func SetSwiftConfig

func SetSwiftConfig(c *config.Config, sc *SwiftConfig)

SetSwiftConfig stores the Swift configuration in the Gazelle configuration.

Types

type GenerateRulesMode

type GenerateRulesMode int

A GenerateRulesMode is an enum for the mode for build file generation.

const (
	SkipGenRulesMode GenerateRulesMode = iota
	SwiftPkgGenRulesMode
	SrcFileGenRulesMode
)

type ModuleFilesCollector

type ModuleFilesCollector map[string][]string

A ModuleFilesCollector organizes source files by the directory where the module/target should be defined.

func NewModuleFilesCollector

func NewModuleFilesCollector() ModuleFilesCollector

func (ModuleFilesCollector) AppendModuleFiles

func (mfc ModuleFilesCollector) AppendModuleFiles(moduleDir string, paths []string)

AppendModuleFiles adds the paths under the specified module directory.

func (ModuleFilesCollector) GetModuleFiles

func (mfc ModuleFilesCollector) GetModuleFiles(moduleDir string) []string

GetModuleFiles returns the files for a module directory.

type SwiftConfig

type SwiftConfig struct {
	SwiftBinPath         string
	ModuleFilesCollector ModuleFilesCollector
	DependencyIndex      *swift.DependencyIndex
	// DependencyIndexRel is the path relative to the RepoRoot to the dependency index
	DependencyIndexRel string
	// DependencyIndexPath is the full path to the dependency index
	DependencyIndexPath string

	ResolutionLogPath string
	ResolutionLogFile *os.File
	ResolutionLogger  reslog.ResolutionLogger

	// The naming convention to apply to the module names derived from the directory names.
	// The default behavior uses the name verbatim while PascalCase will convert snake_case to PascalCase.
	ModuleNamingConvention string

	// Whether or not the generated proto targets should omit the "Proto" suffix from their module names.
	OmitProtoSuffixFromModuleNames bool

	// The set of tags to apply to generated swift library targets.
	// Defaults to ["manual"]
	SwiftLibraryTags []string

	// The mode to use when generating swift_proto_library targets in a BUILD file with multiple proto_library targets.
	//
	// match: One swift_proto_library per proto_library target in the BUILD file. This is the default.
	// Its module name will be derived from the proto library name.
	//
	// package: If multiple proto_library targets share the same proto package,
	// they will be merged into a single swift_proto_library target.
	// Its module name will be derived from the proto package name.
	//
	SwiftProtoGenerationMode string

	// Whether or not to generate swift_proto_library targets for proto_library targets without services.
	// Defaults to true.
	GenerateSwiftProtoLibraries bool

	// The set of GRPC flavors for which swift_proto_library targets will be generated from proto libraries with services.
	// Defaults to:
	// [
	//  "swift_client_proto",
	//  "swift_server_proto"
	// ]
	GenerateSwiftProtoLibraryGRPCFlavors []string

	// The swift_proto_compiler targets to use for generated swift_proto_library targets.
	// The keys should match the GRPC flavors above, or "proto" for the base proto compiler.
	// Defaults to:
	// {
	// 	"swift_proto":       "@build_bazel_rules_swift//proto/compilers:swift_proto",
	// 	"swift_client_proto": "@build_bazel_rules_swift//proto/compilers:swift_client_proto",
	// 	"swift_server_proto": "@build_bazel_rules_swift//proto/compilers:swift_server_proto",
	// }
	SwiftProtoCompilers map[string]string

	// Mapping of relative path to default module name. These values are populated from directives
	// that can be applied to
	DefaultModuleNames map[string]string

	// StripImportPrefix The prefix to strip from the paths of the .proto files.
	// If set, Gazelle will apply this value to the strip_import_prefix attribute
	// within the proto_library_rule.
	StripImportPrefix string

	// ImportPrefix The prefix to add to the paths of the .proto files.
	// If set, Gazelle will apply this value to the import_prefix attribute
	// within the proto_library_rule.
	ImportPrefix string
}

A SwiftConfig represents the Swift-specific configuration for the Gazelle extension.

func GetSwiftConfig

func GetSwiftConfig(c *config.Config) *SwiftConfig

GetSwiftConfig extracts the Swift configuration from the Gazelle configuration.

func NewSwiftConfig

func NewSwiftConfig() *SwiftConfig

func (*SwiftConfig) ConfigModulePaths

func (sc *SwiftConfig) ConfigModulePaths() []string

func (*SwiftConfig) GenerateRulesMode

func (sc *SwiftConfig) GenerateRulesMode(args language.GenerateArgs) GenerateRulesMode

GenerateRulesMode determines how the specified directory should be processed.

func (*SwiftConfig) LoadDependencyIndex

func (sc *SwiftConfig) LoadDependencyIndex() error

LoadDependencyIndex reads the dependency index from disk.

func (*SwiftConfig) SwiftBin

func (sc *SwiftConfig) SwiftBin() *swiftbin.SwiftBin

SwiftBin returns the Swift binary.

func (*SwiftConfig) WriteDependencyIndex

func (sc *SwiftConfig) WriteDependencyIndex() error

WriteDependencyIndex writes the dependency index to disk.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL