compiler

package
v1.22.1 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package compiler defines the common interface for language-specific compilers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MergeImportPaths added in v1.0.0

func MergeImportPaths(opts CompileOptions, file ProtoFile) []string

MergeImportPaths merges import paths from options and file, removing duplicates

Types

type CompileOptions

type CompileOptions struct {
	// OutputDir is the directory where generated files will be placed
	OutputDir string

	// ImportPaths are additional import paths for proto files
	ImportPaths []string

	// Plugins are additional plugins to use (e.g., "grpc")
	Plugins []string

	// CustomOptions are compiler-specific options
	CustomOptions map[string]string

	// Verbose enables detailed logging
	Verbose bool

	// PreserveProtoStructure preserves the proto directory structure in output
	PreserveProtoStructure bool
}

CompileOptions contains options for compilation

type CompileResult

type CompileResult struct {
	// GeneratedFiles are the paths to generated files
	GeneratedFiles []string

	// Warnings are non-fatal issues encountered during compilation
	Warnings []string

	// Success indicates whether compilation was successful
	Success bool
}

CompileResult contains the results of compilation

type Compiler

type Compiler interface {
	// Name returns the name of the compiler (e.g., "python", "go", "rust")
	Name() string

	// Compile compiles the given proto files
	Compile(ctx context.Context, files []ProtoFile, opts CompileOptions) (*CompileResult, error)

	// Validate checks if the compiler is properly configured and available
	Validate() error

	// GetOutputPath returns the output path for the given proto file
	GetOutputPath(protoFile ProtoFile, opts CompileOptions) string

	// RequiredTools returns a list of external tools required by this compiler
	RequiredTools() []string
}

Compiler is the interface that all language-specific compilers must implement

type ProtoFile

type ProtoFile struct {
	Path        string   // Absolute path to the proto file
	Package     string   // Proto package name
	ImportPaths []string // Import paths for dependencies
}

ProtoFile represents a protobuf file to compile

Directories

Path Synopsis
Package python implements the Python protobuf compiler.
Package python implements the Python protobuf compiler.
Package typescript implements the TypeScript protobuf compiler.
Package typescript implements the TypeScript protobuf compiler.

Jump to

Keyboard shortcuts

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