Documentation
¶
Index ¶
- Variables
- 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 ExecutableName() string
- func GetMainSourceFile(testSrcs []string) string
- func GetTestSources() []string
- type BuildFlags
- type BuildOptions
- type BuildResult
- type Config
- func ClangConfig() *Config
- func DebugConfig() *Config
- func DebugNoSanConfig() *Config
- func NewConfig() *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
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 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 ExecutableName ¶
func ExecutableName() string
func GetMainSourceFile ¶
GetMainSourceFile finds the main C/C++ source file in the current directory.
func GetTestSources ¶
func GetTestSources() []string
Types ¶
type BuildFlags ¶
type BuildFlags struct {
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
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
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
HasThreads bool
HasWin64 bool // detected from #include <windows.h>
HasGLFWVulkan bool // detected from #define GLFW_INCLUDE_VULKAN
HasDlopen bool // detected from #include <dlfcn.h>
}
Project holds all detected project information.
func DetectProject ¶
func DetectProject() Project