builder

package
v1.0.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package builder provides builder implementations.

Index

Constants

View Source
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

func (b *Builder) GetBinaryPath() string

GetBinaryPath returns the path where the binary would be for a given ref.

func (*Builder) IsBinaryBuilt

func (b *Builder) IsBinaryBuilt(ref string) (string, bool)

IsBinaryBuilt checks if a binary exists for the given ref.

func (*Builder) ResolveCommitHash

func (b *Builder) ResolveCommitHash(ctx context.Context, ref string) (string, error)

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

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

func (a *BuilderAdapter) ResolveCommitHash(ctx context.Context, ref string) (string, error)

ResolveCommitHash resolves a ref to a commit hash.

type BuilderError

type BuilderError struct {
	Operation string
	Message   string
}

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

Jump to

Keyboard shortcuts

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