Documentation
¶
Overview ¶
Package builder provides builder implementations.
Index ¶
- Constants
- func GenerateGoreleaserConfig(cfg *GoreleaserConfig) string
- type BuildOptions
- type BuildResult
- type Builder
- func (b *Builder) Build(ctx context.Context, opts BuildOptions) (*BuildResult, error)
- func (b *Builder) BuildToCache(ctx context.Context, opts BuildOptions, binaryCache *cache.BinaryCache) (*cache.CachedBinary, error)
- func (b *Builder) GetBinaryPath() string
- func (b *Builder) IsBinaryBuilt(ref string) (string, bool)
- func (b *Builder) ResolveCommitHash(ctx context.Context, ref string) (string, error)
- type BuilderAdapter
- func (a *BuilderAdapter) Build(ctx context.Context, opts ports.BuildOptions) (*ports.BuildResult, error)
- func (a *BuilderAdapter) BuildToCache(ctx context.Context, opts ports.BuildOptions) (*ports.BuildResult, error)
- func (a *BuilderAdapter) GetBinaryPath() string
- func (a *BuilderAdapter) IsBinaryBuilt(ref string) (string, bool)
- func (a *BuilderAdapter) ResolveCommitHash(ctx context.Context, ref string) (string, error)
- type BuilderError
- type GoreleaserConfig
- type NoModuleError
Constants ¶
const (
// DefaultBinaryName is the fallback binary name when no network module is available.
DefaultBinaryName = "binary"
)
Variables ¶
This section is empty.
Functions ¶
func GenerateGoreleaserConfig ¶
func GenerateGoreleaserConfig(cfg *GoreleaserConfig) string
GenerateGoreleaserConfig generates a goreleaser config file content.
Types ¶
type BuildOptions ¶
type BuildOptions struct {
Ref string // Git ref (branch, tag, commit hash)
OutputDir string // Directory to place the built binary
Network string // Network type (mainnet, testnet) - determines EVMChainID
}
BuildOptions configures the build process.
type BuildResult ¶
type BuildResult struct {
BinaryPath string // Path to the built binary
Ref string // The ref that was built
CommitHash string // The commit hash that was built
}
BuildResult contains the result of a build.
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder handles building binaries from source.
func NewBuilder ¶
func NewBuilder(homeDir string, logger *output.Logger, networkModule network.NetworkModule) *Builder
NewBuilder creates a new Builder with the specified NetworkModule. A NetworkModule is required for building - use network plugins to provide one.
func (*Builder) Build ¶
func (b *Builder) Build(ctx context.Context, opts BuildOptions) (*BuildResult, error)
Build builds a binary from the given ref, stores it in cache, and updates the symlink at ~/.devnet-builder/bin/{binaryName} to point to it.
This is used by `start` command where the binary should be used immediately. For `upgrade` command, use BuildToCache() which only caches without symlink change.
func (*Builder) BuildToCache ¶
func (b *Builder) BuildToCache(ctx context.Context, opts BuildOptions, binaryCache *cache.BinaryCache) (*cache.CachedBinary, error)
BuildToCache builds a binary and stores it in the cache. Returns the cached binary entry if successful. This method should be called BEFORE chain halt to pre-build the upgrade binary.
func (*Builder) GetBinaryPath ¶
GetBinaryPath returns the path where the binary would be for a given ref.
func (*Builder) IsBinaryBuilt ¶
IsBinaryBuilt checks if a binary exists for the given ref.
func (*Builder) ResolveCommitHash ¶
ResolveCommitHash resolves a ref to a commit hash without cloning. This is useful for checking the cache before building.
Resolution priority: 1. Annotated tag's actual commit (refs/tags/ref^{}) 2. Lightweight tag (refs/tags/ref) 3. Branch (refs/heads/ref)
This ensures tags are preferred over branches when both exist with similar names (e.g., v1.1.4 tag vs benchmark/v1.1.4 branch).
type BuilderAdapter ¶
type BuilderAdapter struct {
// contains filtered or unexported fields
}
BuilderAdapter implements ports.Builder.
func NewBuilderAdapter ¶
func NewBuilderAdapter(homeDir string, logger *output.Logger, module network.NetworkModule) *BuilderAdapter
NewBuilderAdapter creates a new BuilderAdapter.
func (*BuilderAdapter) Build ¶
func (a *BuilderAdapter) Build(ctx context.Context, opts ports.BuildOptions) (*ports.BuildResult, error)
Build builds a binary from source.
func (*BuilderAdapter) BuildToCache ¶
func (a *BuilderAdapter) BuildToCache(ctx context.Context, opts ports.BuildOptions) (*ports.BuildResult, error)
BuildToCache builds and stores in cache WITHOUT updating the symlink. The symlink should only be updated after the upgrade is complete.
func (*BuilderAdapter) GetBinaryPath ¶
func (a *BuilderAdapter) GetBinaryPath() string
GetBinaryPath returns the path where the binary would be.
func (*BuilderAdapter) IsBinaryBuilt ¶
func (a *BuilderAdapter) IsBinaryBuilt(ref string) (string, bool)
IsBinaryBuilt checks if a binary exists for the given ref.
func (*BuilderAdapter) ResolveCommitHash ¶
ResolveCommitHash resolves a ref to a commit hash.
type BuilderError ¶
BuilderError is returned when builder operations fail.
func (*BuilderError) Error ¶
func (e *BuilderError) Error() string
type GoreleaserConfig ¶
type GoreleaserConfig struct {
ProjectName string
BinaryName string
MainPath string
Toolchain string
LDFlags []string
Tags []string
}
GoreleaserConfig contains network-specific goreleaser configuration.
func DefaultGoreleaserConfig ¶
func DefaultGoreleaserConfig(binaryName, toolchain string) *GoreleaserConfig
DefaultGoreleaserConfig returns a default goreleaser configuration.
type NoModuleError ¶
type NoModuleError struct{}
NoModuleError is returned when no network module is configured.
func (*NoModuleError) Error ¶
func (e *NoModuleError) Error() string