Documentation
¶
Index ¶
- Variables
- func AssemblyTarget(source string) string
- func C64EmulatorCommand(prg string, args ...string) *exec.Cmd
- func CBMEmulatorCommand(prg string, args ...string) *exec.Cmd
- func Chip8EmulatorCommand(rom string, args ...string) *exec.Cmd
- func CompileSources(srcs []string, output string, flags BuildFlags) error
- func DoBuild(opts BuildOptions) error
- func DoCMakeBuild(opts BuildOptions) error
- func DoExport() error
- func DoGenerate(opts BuildOptions) error
- func DoGenerateMakefile() error
- func DoInstall() error
- func DoMake() error
- func DoMakeClean()
- func DoMakeInstall() error
- func DoNinja() error
- func DoNinjaClean()
- func DoNinjaInstall() error
- func DoPkg() error
- func DoPro(opts BuildOptions) error
- func DoScript() error
- func DotSlash(name string) string
- func EmulatorCommand(rom string, args ...string) *exec.Cmd
- func ExecutableName() string
- func GBAEmulatorCommand(rom string, args ...string) *exec.Cmd
- func GetMainSourceFile(testSrcs []string) string
- func GetTestSources() []string
- func HostCarch() string
- func MakefileRunProgram(dir string) string
- func MakefileRunTargets(dir string) ([]string, bool)
- func NESEmulatorCommand(rom string, args ...string) *exec.Cmd
- func SNESEmulatorCommand(rom string, args ...string) *exec.Cmd
- func TinyPack(path string) ([]string, error)
- func ZXEmulatorCommand(program string, args ...string) *exec.Cmd
- type BuildFlags
- type BuildOptions
- type BuildResult
- type Config
- func ClangConfig() *Config
- func DebugConfig() *Config
- func DebugNoSanConfig() *Config
- func NewConfig() *Config
- func NewWatcom() *Config
- func OptConfig() *Config
- func SloppyConfig() *Config
- func SmallConfig() *Config
- func SmallWin64Config() *Config
- func StrictConfig() *Config
- func TinyConfig() *Config
- func TinyWin64Config() *Config
- func Win64Config() *Config
- func ZapConfig() *Config
- func (c *Config) Build() error
- func (c *Config) CMakeBuild() error
- func (c *Config) CMakeMakeClean()
- func (c *Config) CMakeMakeInstall() error
- func (c *Config) Clean()
- func (c *Config) Export() error
- func (c *Config) FastClean()
- func (c *Config) Fmt() error
- func (c *Config) Generate() error
- func (c *Config) GenerateMakefile() error
- func (c *Config) Install() error
- func (c *Config) LaunchDebugger() error
- func (c *Config) Make() error
- func (c *Config) Ninja() error
- func (c *Config) NinjaClean()
- func (c *Config) NinjaInstall() error
- func (c *Config) Pkg() error
- func (c *Config) Pro() error
- func (c *Config) Rebuild() error
- func (c *Config) Rec(args ...string) error
- func (c *Config) Run(args ...string) error
- func (c *Config) RunBuilt(args ...string) error
- func (c *Config) Script() error
- func (c *Config) Test() error
- func (c *Config) TestBuild() error
- func (c *Config) TinyBuild() error
- func (c *Config) Valgrind() error
- type Project
- type TinyBuilder
- type TinyInstall
- type TinyRecipe
- type TinySysroot
Constants ¶
This section is empty.
Variables ¶
var ( ProgName = "slay" ProgURL = "https://github.com/xyproto/slay" )
var SourceExts = []string{".cpp", ".cc", ".cxx", ".c"}
SourceExts are the recognized C/C++ source file extensions.
Functions ¶
func AssemblyTarget ¶ added in v1.3.12
AssemblyTarget returns the system that the given assembly source code looks like it is written for, with the ca65 assembler from cc65: "c64", "c128", "vic20", "nes" or "snes" (65816 assembly for a LoROM cartridge). Returns an empty string if it does not look like 6502 or 65816 assembly for any of these.
func C64EmulatorCommand ¶ added in v1.3.10
C64EmulatorCommand returns a command that runs the given C64 program in VICE, or nil if VICE is not installed
func CBMEmulatorCommand ¶ added in v1.3.12
CBMEmulatorCommand returns a command that runs the given Commodore program in the VICE emulator for the machine that the load address of the program is for (C64, C128 or VIC-20), or nil if that emulator is not installed
func Chip8EmulatorCommand ¶ added in v1.3.13
Chip8EmulatorCommand returns a command that runs the given CHIP-8 ROM in an installed emulator, or nil if no emulator was found.
func CompileSources ¶
func CompileSources(srcs []string, output string, flags BuildFlags) error
func DoBuild ¶
func DoBuild(opts BuildOptions) error
func DoCMakeBuild ¶
func DoCMakeBuild(opts BuildOptions) error
func DoGenerate ¶
func DoGenerate(opts BuildOptions) error
func DoGenerateMakefile ¶
func DoGenerateMakefile() error
func DoMakeClean ¶ added in v1.3.1
func DoMakeClean()
func DoMakeInstall ¶ added in v1.3.1
func DoMakeInstall() error
func DoNinjaClean ¶
func DoNinjaClean()
func DoNinjaInstall ¶
func DoNinjaInstall() error
func DoPro ¶
func DoPro(opts BuildOptions) error
func EmulatorCommand ¶ added in v1.3.12
EmulatorCommand returns a command that runs the given ROM or program in an installed emulator, chosen by the file extension (and the load address, for Commodore programs). Returns nil if the file type is unknown or if no suitable emulator is installed.
func ExecutableName ¶
func ExecutableName() string
func GBAEmulatorCommand ¶ added in v1.3.8
GBAEmulatorCommand returns a command that runs the given GBA ROM in an installed emulator, or nil if no emulator was found.
func GetMainSourceFile ¶
GetMainSourceFile finds the main C/C++ source file in the current directory.
func GetTestSources ¶
func GetTestSources() []string
func MakefileRunProgram ¶ added in v1.3.11
MakefileRunProgram returns the program that the recipe of the "run:" rule starts, like "preview" for a recipe that runs "./preview". If the recipe does not run a program from the current directory, the first existing run: target is returned instead.
func MakefileRunTargets ¶ added in v1.3.11
MakefileRunTargets returns the file targets that the "run:" rule of the Makefile in the current directory depends on. Returns ok=false when there is no Makefile with such a rule, in which case the default goal applies.
func NESEmulatorCommand ¶ added in v1.3.12
NESEmulatorCommand returns a command that runs the given NES ROM in an installed emulator, or nil if none is found
func SNESEmulatorCommand ¶ added in v1.3.10
Types ¶
type BuildFlags ¶
type BuildFlags struct {
Watcom bool
GBA bool
Compiler string
Std string
ContainerImage string // if set, compile via "docker run" or "podman run" with this image
CFlags []string
LDFlags []string
Defines []string
IncPaths []string
}
BuildFlags holds the assembled compiler and linker flags.
func AssembleFlags ¶
func AssembleFlags(proj Project, opts BuildOptions) BuildFlags
type BuildOptions ¶
type BuildOptions struct {
InstallPrefix string // If set, override dir defines with install paths
Debug bool
Opt bool
Strict bool
Sloppy bool
Small bool
Tiny bool
Clang bool
Zap bool
Win64 bool
Watcom bool
GBA bool
NoSanitizers bool
ProfileGenerate bool
ProfileUse bool
}
BuildOptions holds the configuration for a build.
type BuildResult ¶
type BuildResult struct {
OutputExecutable string // name of the produced executable (relative to sourceDir)
Output []byte // combined compiler output (stdout+stderr)
CommandsRun []string // shell-style command strings that were executed
}
BuildResult contains the results of a build operation.
func Build ¶
func Build(sourceDir string, opts BuildOptions) (BuildResult, error)
Build compiles the C/C++ project in the given directory. It detects sources, dependencies, and required flags automatically. The sourceDir is the directory containing the source files.
type Config ¶
type Config struct {
SourceDir string // if set, operate in this directory instead of the current one
BuildOptions
}
Config holds the full configuration for an slay operation.
func DebugConfig ¶
func DebugConfig() *Config
DebugConfig returns a Config for debug builds with sanitizers.
func DebugNoSanConfig ¶
func DebugNoSanConfig() *Config
DebugNoSanConfig returns a Config for debug builds without sanitizers.
func NewConfig ¶
func NewConfig() *Config
NewConfig returns a Config with default settings (standard build).
func OptConfig ¶
func OptConfig() *Config
OptConfig returns a Config for optimized builds (-Ofast/-O3, -flto).
func SloppyConfig ¶
func SloppyConfig() *Config
SloppyConfig returns a Config with permissive compilation flags.
func SmallConfig ¶
func SmallConfig() *Config
SmallConfig returns a Config for size-optimized builds (-Os).
func SmallWin64Config ¶
func SmallWin64Config() *Config
SmallWin64Config returns a Config for size-optimized Windows cross-compilation.
func StrictConfig ¶
func StrictConfig() *Config
StrictConfig returns a Config with strict warning flags.
func TinyConfig ¶
func TinyConfig() *Config
TinyConfig returns a Config for minimal-size builds (-Os + sstrip/upx).
func TinyWin64Config ¶
func TinyWin64Config() *Config
TinyWin64Config returns a Config for minimal-size Windows cross-compilation.
func Win64Config ¶
func Win64Config() *Config
Win64Config returns a Config for cross-compiling to 64-bit Windows.
func (*Config) CMakeBuild ¶
CMakeBuild builds using cmake, preferring ninja over make. Generates CMakeLists.txt first if it does not exist.
func (*Config) CMakeMakeClean ¶
func (c *Config) CMakeMakeClean()
CMakeMakeClean cleans a make or cmake+make build.
func (*Config) CMakeMakeInstall ¶
CMakeMakeInstall installs from a make or cmake+make build.
func (*Config) Clean ¶
func (c *Config) Clean()
Clean removes all build artifacts: runs make clean, ninja clean, removes the build/ directory, and cleans object files and executables.
func (*Config) FastClean ¶
func (c *Config) FastClean()
FastClean removes only the executable and object files.
func (*Config) GenerateMakefile ¶
GenerateMakefile generates a standalone Makefile.
func (*Config) Install ¶
Install builds and installs the project (using PREFIX and DESTDIR environment variables).
func (*Config) LaunchDebugger ¶
LaunchDebugger builds a debug version and launches the appropriate debugger. Uses lldb first when Clang is set, otherwise prefers cgdb/gdb.
func (*Config) Make ¶
Make builds using make. If a Makefile exists, runs make directly. Otherwise falls back to cmake+make if CMakeLists.txt exists.
func (*Config) Ninja ¶
Ninja builds using ninja. If build/build.ninja exists, runs ninja directly. Otherwise falls back to cmake+ninja if CMakeLists.txt exists.
func (*Config) NinjaClean ¶
func (c *Config) NinjaClean()
NinjaClean removes the ninja build directory.
func (*Config) NinjaInstall ¶
NinjaInstall installs from a ninja build.
func (*Config) Rec ¶
Rec performs profile-guided optimization: clean, build with profiling, run, rebuild with profile data.
func (*Config) TestBuild ¶
TestBuild builds the main executable and all test files without running them.
type Project ¶
type Project struct {
MainSource string
DepSources []string
ExtraMains []string // other sources in the project that contain main(), built as separate executables
TestSources []string
Includes []string // external includes from source files
BoostLibs []string
IsC bool // true if main source is a .c file
HasOpenMP bool
HasBoost bool
HasQt6 bool
HasMathLib bool
HasFS bool
HasExperimentalFS bool // detected from #include <experimental/filesystem>
HasThreads bool
HasWin64 bool // detected from #include <windows.h>
HasWatcom bool // detected from #include <i86.h>
HasGBA bool // detected from #include <tonc.h> or <gba.h>
CC65Target string // c64, c128, vic20 or nes for cc65, or snes for 65816 assembly built with ca65
Z88DKTarget string // zx for z88dk
HasSNES bool
HasChip8 bool // an Octo (.8o) source file and no C or C++ sources
HasGLFWVulkan bool // detected from #define GLFW_INCLUDE_VULKAN
HasDlopen bool // detected from #include <dlfcn.h>
GtkVersion int
}
Project holds all detected project information.
func DetectProject ¶
func DetectProject() Project
type TinyBuilder ¶ added in v1.3.14
type TinyBuilder struct {
R *TinyRecipe
T tinyTarget
HostT tinyTarget
Cross bool
Work string
SrcDir string
PkgDir string
BinDir string
HomeDir string
OutDir string
SrcDest string
PkgDest string
Sysroot string
Sys *TinySysroot
Repos []string
Jobs int
Epoch int64
Sandbox bool
// contains filtered or unexported fields
}
func NewTinyBuilder ¶ added in v1.3.14
func NewTinyBuilder(r *TinyRecipe) (*TinyBuilder, error)
func (*TinyBuilder) Run ¶ added in v1.3.14
func (b *TinyBuilder) Run() ([]string, error)
type TinyInstall ¶ added in v1.3.14
type TinyRecipe ¶ added in v1.3.14
type TinyRecipe struct {
File string
Dir string
Carch string
Name string
Version string
Release string
Epoch string
Desc string
URL string
License []string
Arch []string
Groups []string
Source []string
SHA256 []string
SHA512 []string
B2 []string
NoExtract []string
Depends []string
OptDepends []string
MakeDepends []string
LibDepends []string
Provides []string
Conflicts []string
Replaces []string
Backup []string
Options []string
Subpackages []string
Patches []string
InstallLicense []string
Install []TinyInstall
Style string
BuildDir string
Configure []string
MakeArgs []string
InstallArgs []string
GoPackages []string
GoLDFlags []string
GoFlags []string
GoCGO string
GoEnv map[string]string
CargoFeatures []string
SlayArgs []string
Cross string
Env map[string]string
L *lua.LState
Table *lua.LTable
}
func LoadTinyRecipe ¶ added in v1.3.14
func LoadTinyRecipe(path, carch string) (*TinyRecipe, error)
func (*TinyRecipe) Close ¶ added in v1.3.14
func (r *TinyRecipe) Close()
func (*TinyRecipe) FullVersion ¶ added in v1.3.14
func (r *TinyRecipe) FullVersion() string
func (*TinyRecipe) Function ¶ added in v1.3.14
func (r *TinyRecipe) Function(name string) *lua.LFunction
func (*TinyRecipe) HasOption ¶ added in v1.3.14
func (r *TinyRecipe) HasOption(name string, def bool) bool
func (*TinyRecipe) PkgArch ¶ added in v1.3.14
func (r *TinyRecipe) PkgArch() string
func (*TinyRecipe) SupportsArch ¶ added in v1.3.14
func (r *TinyRecipe) SupportsArch(carch string) bool
type TinySysroot ¶ added in v1.3.14
func BuildTinySysroot ¶ added in v1.3.14
Source Files
¶
- api.go
- build.go
- cc65.go
- chip8.go
- config.go
- detect.go
- dotslash_unix.go
- flags.go
- gba.go
- generate.go
- installhint.go
- makefile.go
- normpath_case.go
- platform.go
- platform_hints_other.go
- platform_linux.go
- platform_unix.go
- slay.go
- snes.go
- stamp.go
- tinypack.go
- tinypack_build.go
- tinypack_lua.go
- tinypack_package.go
- tinypack_sysroot.go
- watcom.go
- win64skip.go
- z88dk.go