remove comments
All checks were successful
build-dsl-smoke / Build judge (push) Successful in 12s
build-dsl-smoke / debug / clang / linux (push) Successful in 7s
build-dsl-smoke / debug / gcc / linux (push) Successful in 6s
build-dsl-smoke / release / clang / linux (push) Successful in 6s
build-dsl-smoke / release / gcc / linux (push) Successful in 7s
build-dsl-smoke / sanitized / clang / linux (push) Successful in 6s
build-dsl-smoke / sanitized / gcc / linux (push) Successful in 7s
build-dsl-smoke / debug / clang / windows (push) Successful in 14s
build-dsl-smoke / debug-valgrind / gcc / linux (push) Successful in 15s
build-dsl-smoke / release / clang / windows (push) Successful in 15s
build-dsl-smoke / debug / msvc / windows (push) Successful in 17s
build-dsl-smoke / release / msvc / windows (push) Successful in 16s
build-dsl-smoke / SUMMARY (push) Successful in 4s
All checks were successful
build-dsl-smoke / Build judge (push) Successful in 12s
build-dsl-smoke / debug / clang / linux (push) Successful in 7s
build-dsl-smoke / debug / gcc / linux (push) Successful in 6s
build-dsl-smoke / release / clang / linux (push) Successful in 6s
build-dsl-smoke / release / gcc / linux (push) Successful in 7s
build-dsl-smoke / sanitized / clang / linux (push) Successful in 6s
build-dsl-smoke / sanitized / gcc / linux (push) Successful in 7s
build-dsl-smoke / debug / clang / windows (push) Successful in 14s
build-dsl-smoke / debug-valgrind / gcc / linux (push) Successful in 15s
build-dsl-smoke / release / clang / windows (push) Successful in 15s
build-dsl-smoke / debug / msvc / windows (push) Successful in 17s
build-dsl-smoke / release / msvc / windows (push) Successful in 16s
build-dsl-smoke / SUMMARY (push) Successful in 4s
This commit is contained in:
49
dsl/build.go
49
dsl/build.go
@@ -1,8 +1,5 @@
|
||||
package dsl
|
||||
|
||||
// BuildProfile is a named compilation profile. The translator maps it into
|
||||
// compiler-specific flag sets at execution time (e.g. ProfileRelease → "-O2"
|
||||
// on gnu-like compilers, "/O2" on msvc).
|
||||
type BuildProfile int
|
||||
|
||||
const (
|
||||
@@ -25,7 +22,6 @@ func (p BuildProfile) String() string {
|
||||
}
|
||||
}
|
||||
|
||||
// WarningLevel describes how strict the compiler should be about warnings.
|
||||
type WarningLevel int
|
||||
|
||||
const (
|
||||
@@ -48,52 +44,32 @@ func (w WarningLevel) String() string {
|
||||
}
|
||||
}
|
||||
|
||||
// BuildConfig describes one structured build variant. It is the new-style
|
||||
// replacement for the free-form `build "shell-string"` field.
|
||||
//
|
||||
// A top-level `build_defaults { ... }` in the suite file produces a
|
||||
// BuildConfig stored on File.BuildDefaults. Each `build "name" { ... }`
|
||||
// block produces an entry in File.Builds; the effective configuration used
|
||||
// by the runner is BuildDefaults merged with the named block, then merged
|
||||
// with the OS-specific override (Linux / Windows / Darwin) when present.
|
||||
//
|
||||
// Zero-valued fields inherit from the parent during merge. Slice and map
|
||||
// fields accumulate rather than replace.
|
||||
type BuildConfig struct {
|
||||
// Name of the variant. Empty on BuildDefaults and on OS-override sub-blocks.
|
||||
Name string
|
||||
|
||||
Language string // e.g. "c", "c++"
|
||||
Standard string // e.g. "c11", "c++17"
|
||||
Sources []string // globs, relative to work dir
|
||||
Includes []string // include search paths
|
||||
Output string // binary name (OS-specific extension added automatically)
|
||||
Language string
|
||||
Standard string
|
||||
Sources []string
|
||||
Includes []string
|
||||
Output string
|
||||
|
||||
Profile BuildProfile
|
||||
Warnings WarningLevel
|
||||
Sanitize []string
|
||||
Wrapper string // e.g. "address", "undefined", "thread"
|
||||
Wrapper string
|
||||
|
||||
Defines map[string]string
|
||||
Link []string // libraries to link against (e.g. "pthread", "m")
|
||||
Extra []string // raw passthrough flags
|
||||
Link []string
|
||||
Extra []string
|
||||
|
||||
// Filters — empty means "applies to any". A build is skipped at runtime
|
||||
// if the current OS or compiler is not in the list.
|
||||
Platforms []string // "linux", "windows", "darwin"
|
||||
Compilers []string // "gcc", "clang", "msvc"
|
||||
Platforms []string
|
||||
Compilers []string
|
||||
|
||||
// OS-specific overrides. Only one level of nesting is allowed: these
|
||||
// sub-configs must not themselves contain Linux/Windows/Darwin blocks.
|
||||
Linux *BuildConfig
|
||||
Windows *BuildConfig
|
||||
Darwin *BuildConfig
|
||||
}
|
||||
|
||||
// MergeFrom layers src on top of dst in place. Non-zero scalar fields in src
|
||||
// overwrite dst; slices and maps accumulate. The Name and OS override fields
|
||||
// on src are intentionally ignored — merging never copies the hierarchy,
|
||||
// only the leaves.
|
||||
func (dst *BuildConfig) MergeFrom(src *BuildConfig) {
|
||||
if src == nil {
|
||||
return
|
||||
@@ -135,9 +111,6 @@ func (dst *BuildConfig) MergeFrom(src *BuildConfig) {
|
||||
}
|
||||
}
|
||||
|
||||
// Resolve returns the effective BuildConfig for the given OS by merging
|
||||
// BuildDefaults → this block → the matching OS override. The result is a
|
||||
// fresh value; the receiver is not mutated.
|
||||
func (b *BuildConfig) Resolve(defaults *BuildConfig, os string) BuildConfig {
|
||||
var out BuildConfig
|
||||
out.MergeFrom(defaults)
|
||||
@@ -158,8 +131,6 @@ func (b *BuildConfig) Resolve(defaults *BuildConfig, os string) BuildConfig {
|
||||
return out
|
||||
}
|
||||
|
||||
// AppliesTo reports whether this build should run on (os, compiler).
|
||||
// An empty Platforms/Compilers list means no filter on that axis.
|
||||
func (b *BuildConfig) AppliesTo(os, compiler string) bool {
|
||||
if len(b.Platforms) > 0 && !contains(b.Platforms, os) {
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user