build

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

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

Go to latest
Published: Apr 12, 2026 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPredefinedCompilers

func GetPredefinedCompilers() map[string]CompilerPreset

GetPredefinedCompilers returns a map of predefined compiler configurations

Types

type CompilerConfig

type CompilerConfig struct {
	Site    string `json:"site,omitempty" yaml:"site,omitempty"`       // The site hosting the repo
	User    string `json:"user,omitempty" yaml:"user,omitempty"`       // Name of the github user
	Repo    string `json:"repo,omitempty" yaml:"repo,omitempty"`       // Name of the github repository
	Version string `json:"version,omitempty" yaml:"version,omitempty"` // The version of the compiler to use
	Path    string `json:"path,omitempty" yaml:"path,omitempty"`       // Local path to a compiler instance
	Preset  string `json:"preset,omitempty" yaml:"preset,omitempty"`   // Predefined compiler preset (pawn-lang, openmp, etc.)
}

CompilerConfig represents a configuration for a compiler repository

func (*CompilerConfig) ResolveCompilerConfig

func (cc *CompilerConfig) ResolveCompilerConfig() CompilerConfig

ResolveCompilerConfig resolves the final compiler configuration by applying presets

func (CompilerConfig) Validate

func (cc CompilerConfig) Validate() error

Validate ensures mutually exclusive parameters are respected.

type CompilerOptions

type CompilerOptions struct {
	DebugLevel             *int    `json:"debug_level,omitempty" yaml:"debug_level,omitempty"`                           // -d<level> | 0=none, 1=minimal, 2=full, 3=extended | default=3
	RequireSemicolons      *bool   `json:"require_semicolons,omitempty" yaml:"require_semicolons,omitempty"`             // -;+ <enforce> | -;- <relax> | default=true
	RequireParentheses     *bool   `json:"require_parentheses,omitempty" yaml:"require_parentheses,omitempty"`           // -(+ <enforce> | -(- <relax> | default=true
	RequireEscapeSequences *bool   `json:"require_escape_sequences,omitempty" yaml:"require_escape_sequences,omitempty"` // -\\+ <enforce> | -\\- <relax> | default=true
	CompatibilityMode      *bool   `json:"compatibility_mode,omitempty" yaml:"compatibility_mode,omitempty"`             // -Z+ <enable> | -Z- <disable> | default=true
	OptimizationLevel      *int    `json:"optimization_level,omitempty" yaml:"optimization_level,omitempty"`             // -O<level> | 0=none, 1=basic, 2=full | default=none
	ShowListing            *bool   `json:"show_listing,omitempty" yaml:"show_listing,omitempty"`                         // -l <enable> | -l- <disable> | default=false
	ShowAnnotatedAssembly  *bool   `json:"show_annotated_assembly,omitempty" yaml:"show_annotated_assembly,omitempty"`   // -a <enable> | -a- <disable> | default=false
	ShowErrorFile          *string `json:"show_error_file,omitempty" yaml:"show_error_file,omitempty"`                   // -e<filename> | default=""
	ShowWarnings           *bool   `json:"show_warnings,omitempty" yaml:"show_warnings,omitempty"`                       // -w+ to enable, -w- to disable | default=enabled
	CompactEncoding        *bool   `json:"compact_encoding,omitempty" yaml:"compact_encoding,omitempty"`                 // -C+ to enable, -C- to disable | default=disabled
	TabSize                *int    `json:"tab_size,omitempty" yaml:"tab_size,omitempty"`                                 // -t<spaces> | default=4
}

CompilerOptions represents human-readable compiler flags

func (*CompilerOptions) ToArgs

func (opts *CompilerOptions) ToArgs() []string

ToArgs converts CompilerOptions to a slice of command-line arguments

type CompilerPreset

type CompilerPreset struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Site        string `json:"site"`
	User        string `json:"user"`
	Repo        string `json:"repo"`
	Version     string `json:"version"`
}

CompilerPreset represents a predefined compiler configuration

type CompilerVersion

type CompilerVersion string

CompilerVersion represents a compiler version number

type Config

type Config struct {
	Name              string            `json:"name" yaml:"name"`                                 // name of the configuration
	Version           CompilerVersion   `json:"version,omitempty" yaml:"version,omitempty"`       // compiler version to use for this build
	WorkingDir        string            `json:"workingDir,omitempty" yaml:"workingDir,omitempty"` // working directory for the -D flag
	Args              []string          `json:"args,omitempty" yaml:"args,omitempty"`             // list of arguments to pass to the compiler (deprecated)
	Options           *CompilerOptions  `json:"options,omitempty" yaml:"options,omitempty"`       // human-readable compiler options (use this in future over args)
	Input             string            `json:"input,omitempty" yaml:"input,omitempty"`           // input .pwn file
	Output            string            `json:"output,omitempty" yaml:"output,omitempty"`         // output .amx file
	Includes          []string          `json:"includes,omitempty" yaml:"includes,omitempty"`     // list of include files to pass to compiler via -i flags
	Constants         map[string]string `json:"constants,omitempty" yaml:"constants,omitempty"`   // set of constant definitions to pass to the compiler
	Plugins           [][]string        `json:"plugins,omitempty" yaml:"plugins,omitempty"`       // set of commands to run before compilation
	Compiler          CompilerConfig    `json:"compiler,omitempty" yaml:"compiler,omitempty"`     // a set of configurations for using a compiler
	PreBuildCommands  [][]string        `json:"prebuild,omitempty" yaml:"prebuild,omitempty"`     // allows the execution of commands before a build is ran
	PostBuildCommands [][]string        `json:"postbuild,omitempty" yaml:"postbuild,omitempty"`   // allows the execution of commands after a build is ran
}

Config represents a configuration for compiling a file

func Default

func Default() *Config

Default defines and returns a default compiler configuration

type Problem

type Problem struct {
	File        string
	Line        int
	Severity    ProblemSeverity
	Description string
}

Problem represents an issue with a line in a file with a severity level, these have a full file path, a line number, a severity level (warnings, errors and fatal errors) and a short description of the problem.

func (Problem) String

func (bp Problem) String() string

String creates a structured representation of a problem, for editor integration

type ProblemSeverity

type ProblemSeverity int8

ProblemSeverity represents the severity of a problem, warning error or fatal

const (
	// ProblemWarning is an issue that does not stop compilation but is still a concern
	ProblemWarning ProblemSeverity = iota
	// ProblemError is an issue that prevents AMX generation and may or may not stop compilation
	ProblemError ProblemSeverity = iota
	// ProblemFatal is an issue that stops compilation completely
	ProblemFatal ProblemSeverity = iota
)

func (ProblemSeverity) String

func (ps ProblemSeverity) String() string

type Problems

type Problems []Problem

Problems is a slice of Problem objects with additional methods

func (Problems) Errors

func (bps Problems) Errors() (warnings []Problem)

Errors returns a slice of only errors from a Problems object

func (Problems) Fatal

func (bps Problems) Fatal() (fatal bool)

Fatal returns true if the build problems contain any fatal problems

func (Problems) IsValid

func (bps Problems) IsValid() bool

IsValid returns true if the Problems only contains warnings, if there are errors it's false

func (Problems) Warnings

func (bps Problems) Warnings() (warnings []Problem)

Warnings returns a slice of only warnings from a Problems object

type Result

type Result struct {
	Header    int
	Code      int
	Data      int
	StackHeap int
	Estimate  int
	Total     int
}

Result represents the final statistics (in bytes) of a successfully built .amx file.

Directories

Path Synopsis
Package compiler provides an API for acquiring the compiler binaries and compiling Pawn code
Package compiler provides an API for acquiring the compiler binaries and compiling Pawn code

Jump to

Keyboard shortcuts

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