Documentation ¶
Index ¶
- func BuildPackageName(pkg *types.Package) string
- func BuildPlugin(ctx context.Context, le *logrus.Entry, ...) error
- func CleanupOldVersions(le *logrus.Entry, pluginOutputPath string) error
- func CodegenPluginWrapperFromAnalysis(le *logrus.Entry, a *Analysis, binaryID, binaryVersion string) (*gast.File, error)
- func CompilePluginFromFile(le *logrus.Entry, gfile *gast.File, intermediateGoFile string, outFile string, ...) error
- func FormatFile(gf *gast.File) ([]byte, error)
- func GeneratePluginWrapper(ctx context.Context, le *logrus.Entry, an *Analysis, ...) (*gast.File, error)
- func HashPluginForBuildID(hhBaseKey []byte, filePath string) (string, error)
- type Analysis
- type ModuleCompiler
- type Watcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildPackageName ¶
BuildPackageName builds the unique name for the package.
func BuildPlugin ¶
func BuildPlugin(ctx context.Context, le *logrus.Entry, packageSearchPath, outputPath, codegenDir string, packages []string) error
BuildPlugin builds a plugin using a temporary code-gen path.
Automates the end-to-end build process with reasonable defaults. If codegenDir is empty, uses a tmpdir in the user .cache directory.
func CleanupOldVersions ¶
CleanupOldVersions cleans up old versions from the target path.
func CodegenPluginWrapperFromAnalysis ¶
func CodegenPluginWrapperFromAnalysis( le *logrus.Entry, a *Analysis, binaryID, binaryVersion string, ) (*gast.File, error)
CodegenPluginWrapperFromAnalysis codegens a plugin wrapper from analysis.
func CompilePluginFromFile ¶
func CompilePluginFromFile( le *logrus.Entry, gfile *gast.File, intermediateGoFile string, outFile string, preWriteOutFileHook func(nextOutFilePath, nextOutFileContentsPath string) error, ) error
CompilePluginFromFile compiles the plugin from the gfile.
{buildHash} will be replaced with the build hash in the output filename.
func FormatFile ¶
FormatFile formats the output file.
Types ¶
type Analysis ¶
type Analysis struct {
// contains filtered or unexported fields
}
Analysis contains the result of code analysis.
func AnalyzePackages ¶
func AnalyzePackages( ctx context.Context, le *logrus.Entry, workDir string, packagePaths []string, ) (*Analysis, error)
AnalyzePackages analyzes code packages using Go module package resolution.
func (*Analysis) GetImportedModules ¶
GetImportedModules returns the list of modules imported in the packages.
func (*Analysis) GetLoadedPackages ¶
GetLoadedPackages returns the loaded packages.
type ModuleCompiler ¶
type ModuleCompiler struct {
// contains filtered or unexported fields
}
ModuleCompiler assembles a series of Go module files on disk to orchestrate "go build" commands and produce a plugin with unique import paths for the changed packages.
func NewModuleCompiler ¶
func NewModuleCompiler( ctx context.Context, le *logrus.Entry, buildPrefix string, pluginCodegenPath string, pluginBinaryID string, ) (*ModuleCompiler, error)
NewModuleCompiler constructs a new module compiler with paths.
packagesLookupPath is the working directory for "go build."
func (*ModuleCompiler) Cleanup ¶
func (m *ModuleCompiler) Cleanup()
Cleanup removes the codegen files, optionally with a build hash.
func (*ModuleCompiler) CompilePlugin ¶
func (m *ModuleCompiler) CompilePlugin(outFile string) error
CompilePlugin compiles the plugin once. The module structure should have been built already.
func (*ModuleCompiler) GenerateModules ¶
func (m *ModuleCompiler) GenerateModules(analysis *Analysis, pluginBinaryVersion string) error
GenerateModules builds the modules files in the codegen path.
buildPrefix should be something like cbus-plugin-abcdef (no slash)
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher watches a set of packages and re-generates an output plugin codegen and binary when the code files change.
func NewWatcher ¶
NewWatcher constructs a new watcher.
Recognizes and replaces {buildHash} in the output filename. The output path should be output-plugin-dir/output-plugin-{buildHash}.cbus.so
func (*Watcher) WatchCompilePlugin ¶
func (w *Watcher) WatchCompilePlugin( ctx context.Context, pluginCodegenPath string, pluginOutputPath string, pluginBinaryID string, pluginBinaryVersion string, compiledCb func(packages []string, outpPath string) error, ) error
WatchCompilePlugin watches and compiles package. Detects if the output with the same {buildHash} already exists. Replaces {buildHash} in output filename and in plugin binary version.