All checks were successful
build-dsl-smoke / Build judge (push) Successful in 16s
build-dsl-smoke / debug / clang / linux (push) Successful in 6s
build-dsl-smoke / debug / gcc / linux (push) Successful in 7s
build-dsl-smoke / release / clang / linux (push) Successful in 8s
build-dsl-smoke / release / gcc / linux (push) Successful in 9s
build-dsl-smoke / sanitized / gcc / linux (push) Successful in 6s
build-dsl-smoke / sanitized / clang / linux (push) Successful in 9s
build-dsl-smoke / debug-valgrind / gcc / linux (push) Successful in 15s
build-dsl-smoke / debug / clang / windows (push) Successful in 15s
build-dsl-smoke / debug / msvc / windows (push) Successful in 19s
build-dsl-smoke / release / clang / windows (push) Successful in 18s
build-dsl-smoke / release / msvc / windows (push) Successful in 18s
build-dsl-smoke / SUMMARY (push) Successful in 4s
- Move Matcher types and matching logic from runner/matcher.go into the dsl package as methods on the Matcher types. Runner now calls t.Stdout.Match(label, actual) instead of type-switching via a package-level applyMatcher helper. - Replace custom contains/containsString helpers with slices.Contains in dsl/build.go and runner/compiler.go. - Use maps.Copy instead of manual map copy in BuildConfig.MergeFrom. - Adopt strings.SplitSeq, strings.CutPrefix and the `for range N` loop form in runner/limiter_linux.go. - Ignore example/imdb build artifact.
153 lines
2.7 KiB
Go
153 lines
2.7 KiB
Go
package dsl
|
|
|
|
import (
|
|
"maps"
|
|
"slices"
|
|
)
|
|
|
|
type BuildProfile int
|
|
|
|
const (
|
|
ProfileUnset BuildProfile = iota
|
|
ProfileRelease
|
|
ProfileDebug
|
|
ProfileSanitized
|
|
)
|
|
|
|
func (p BuildProfile) String() string {
|
|
switch p {
|
|
case ProfileRelease:
|
|
return "release"
|
|
case ProfileDebug:
|
|
return "debug"
|
|
case ProfileSanitized:
|
|
return "sanitized"
|
|
default:
|
|
return "unset"
|
|
}
|
|
}
|
|
|
|
type WarningLevel int
|
|
|
|
const (
|
|
WarningsUnset WarningLevel = iota
|
|
WarningsDefault
|
|
WarningsStrict
|
|
WarningsPedantic
|
|
)
|
|
|
|
func (w WarningLevel) String() string {
|
|
switch w {
|
|
case WarningsDefault:
|
|
return "default"
|
|
case WarningsStrict:
|
|
return "strict"
|
|
case WarningsPedantic:
|
|
return "pedantic"
|
|
default:
|
|
return "unset"
|
|
}
|
|
}
|
|
|
|
type BuildConfig struct {
|
|
Name string
|
|
|
|
Language string
|
|
Standard string
|
|
Sources []string
|
|
Includes []string
|
|
Output string
|
|
|
|
Profile BuildProfile
|
|
Warnings WarningLevel
|
|
Sanitize []string
|
|
Wrapper string
|
|
|
|
Defines map[string]string
|
|
Link []string
|
|
Extra []string
|
|
|
|
Platforms []string
|
|
Compilers []string
|
|
|
|
Linux *BuildConfig
|
|
Windows *BuildConfig
|
|
Darwin *BuildConfig
|
|
}
|
|
|
|
func (dst *BuildConfig) MergeFrom(src *BuildConfig) {
|
|
if src == nil {
|
|
return
|
|
}
|
|
if src.Language != "" {
|
|
dst.Language = src.Language
|
|
}
|
|
if src.Standard != "" {
|
|
dst.Standard = src.Standard
|
|
}
|
|
if src.Output != "" {
|
|
dst.Output = src.Output
|
|
}
|
|
if src.Profile != ProfileUnset {
|
|
dst.Profile = src.Profile
|
|
}
|
|
if src.Warnings != WarningsUnset {
|
|
dst.Warnings = src.Warnings
|
|
}
|
|
if src.Wrapper != "" {
|
|
dst.Wrapper = src.Wrapper
|
|
}
|
|
|
|
dst.Sources = append(dst.Sources, src.Sources...)
|
|
dst.Includes = append(dst.Includes, src.Includes...)
|
|
dst.Sanitize = append(dst.Sanitize, src.Sanitize...)
|
|
dst.Link = append(dst.Link, src.Link...)
|
|
dst.Extra = append(dst.Extra, src.Extra...)
|
|
dst.Platforms = append(dst.Platforms, src.Platforms...)
|
|
dst.Compilers = append(dst.Compilers, src.Compilers...)
|
|
|
|
if len(src.Defines) > 0 {
|
|
if dst.Defines == nil {
|
|
dst.Defines = map[string]string{}
|
|
}
|
|
maps.Copy(dst.Defines, src.Defines)
|
|
}
|
|
}
|
|
|
|
func (b *BuildConfig) Resolve(defaults *BuildConfig, os string) BuildConfig {
|
|
var out BuildConfig
|
|
out.MergeFrom(defaults)
|
|
out.MergeFrom(b)
|
|
out.Name = b.Name
|
|
|
|
var osOverride *BuildConfig
|
|
switch os {
|
|
case "linux":
|
|
osOverride = b.Linux
|
|
case "windows":
|
|
osOverride = b.Windows
|
|
case "darwin":
|
|
osOverride = b.Darwin
|
|
}
|
|
out.MergeFrom(osOverride)
|
|
|
|
return out
|
|
}
|
|
|
|
func (b *BuildConfig) AppliesTo(os, compiler string) bool {
|
|
if len(b.Platforms) > 0 && !slices.Contains(b.Platforms, os) {
|
|
return false
|
|
}
|
|
if len(b.Compilers) > 0 && !slices.Contains(b.Compilers, compiler) {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
type ToolchainSpec struct {
|
|
Name string
|
|
Platforms []string
|
|
Binary string
|
|
Class string
|
|
}
|