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

This commit is contained in:
2026-04-11 14:45:14 +03:00
parent 7f9f6a0a6e
commit 55ab95b62e
3 changed files with 10 additions and 67 deletions

View File

@@ -109,9 +109,6 @@ func parseSuite(path string) *dsl.File {
return f return f
} }
// runListBuilds prints a JSON array of build names for CI matrix discovery.
// A legacy suite without structured builds reports ["default"] so workflows
// can always iterate `fromJSON` and have exactly one cell.
func runListBuilds(args []string) { func runListBuilds(args []string) {
positional := positionalArgs(args) positional := positionalArgs(args)
if len(positional) < 1 { if len(positional) < 1 {

View File

@@ -1,8 +1,5 @@
package dsl 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 type BuildProfile int
const ( const (
@@ -25,7 +22,6 @@ func (p BuildProfile) String() string {
} }
} }
// WarningLevel describes how strict the compiler should be about warnings.
type WarningLevel int type WarningLevel int
const ( 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 { type BuildConfig struct {
// Name of the variant. Empty on BuildDefaults and on OS-override sub-blocks.
Name string Name string
Language string // e.g. "c", "c++" Language string
Standard string // e.g. "c11", "c++17" Standard string
Sources []string // globs, relative to work dir Sources []string
Includes []string // include search paths Includes []string
Output string // binary name (OS-specific extension added automatically) Output string
Profile BuildProfile Profile BuildProfile
Warnings WarningLevel Warnings WarningLevel
Sanitize []string Sanitize []string
Wrapper string // e.g. "address", "undefined", "thread" Wrapper string
Defines map[string]string Defines map[string]string
Link []string // libraries to link against (e.g. "pthread", "m") Link []string
Extra []string // raw passthrough flags Extra []string
// Filters — empty means "applies to any". A build is skipped at runtime Platforms []string
// if the current OS or compiler is not in the list. Compilers []string
Platforms []string // "linux", "windows", "darwin"
Compilers []string // "gcc", "clang", "msvc"
// OS-specific overrides. Only one level of nesting is allowed: these
// sub-configs must not themselves contain Linux/Windows/Darwin blocks.
Linux *BuildConfig Linux *BuildConfig
Windows *BuildConfig Windows *BuildConfig
Darwin *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) { func (dst *BuildConfig) MergeFrom(src *BuildConfig) {
if src == nil { if src == nil {
return 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 { func (b *BuildConfig) Resolve(defaults *BuildConfig, os string) BuildConfig {
var out BuildConfig var out BuildConfig
out.MergeFrom(defaults) out.MergeFrom(defaults)
@@ -158,8 +131,6 @@ func (b *BuildConfig) Resolve(defaults *BuildConfig, os string) BuildConfig {
return out 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 { func (b *BuildConfig) AppliesTo(os, compiler string) bool {
if len(b.Platforms) > 0 && !contains(b.Platforms, os) { if len(b.Platforms) > 0 && !contains(b.Platforms, os) {
return false return false

View File

@@ -76,9 +76,6 @@ func (r *Runner) Run() *SuiteResult {
return result return result
} }
// runLegacyBuild handles the classic `build "shell-string"` form. It produces
// a single BuildRun named "default" so that downstream consumers always see
// the same shape.
func (r *Runner) runLegacyBuild() *BuildRun { func (r *Runner) runLegacyBuild() *BuildRun {
run := &BuildRun{Name: "default"} run := &BuildRun{Name: "default"}
@@ -100,9 +97,6 @@ func (r *Runner) runLegacyBuild() *BuildRun {
return run return run
} }
// runStructuredBuilds handles the new DSL form with one or more named builds.
// Each build is resolved against the current OS and toolchain, compiled via
// the structured translator, and then exercised against every group.
func (r *Runner) resolveRuntimeToolchain() (Toolchain, string) { func (r *Runner) resolveRuntimeToolchain() (Toolchain, string) {
goos := runtime.GOOS goos := runtime.GOOS
wanted := os.Getenv("JUDGE_TOOLCHAIN") wanted := os.Getenv("JUDGE_TOOLCHAIN")
@@ -125,9 +119,6 @@ func (r *Runner) runStructuredBuilds() []*BuildRun {
run := &BuildRun{Name: b.Name, Toolchain: tc.Name} run := &BuildRun{Name: b.Name, Toolchain: tc.Name}
if r.cfg.TargetBuild != "" && r.cfg.TargetBuild != b.Name { if r.cfg.TargetBuild != "" && r.cfg.TargetBuild != b.Name {
// User asked for a different build. Don't include this one
// in the result at all — discovery via --list-builds is the
// caller's responsibility.
continue continue
} }
@@ -164,8 +155,6 @@ func (r *Runner) runStructuredBuilds() []*BuildRun {
return runs return runs
} }
// runGroups exercises every group/test in the suite against the currently
// selected binary (r.binary) and records the outcome into run.
func (r *Runner) runGroups(run *BuildRun) { func (r *Runner) runGroups(run *BuildRun) {
for _, g := range r.file.Groups { for _, g := range r.file.Groups {
gr := r.runGroup(g) gr := r.runGroup(g)
@@ -174,9 +163,6 @@ func (r *Runner) runGroups(run *BuildRun) {
} }
} }
// fillBuildError populates a BuildRun with one failing synthetic test per
// group when the build itself failed. This keeps the reported totals at 0
// and matches the legacy behaviour.
func (r *Runner) fillBuildError(run *BuildRun) { func (r *Runner) fillBuildError(run *BuildRun) {
run.Groups = r.synthesizeBuildError() run.Groups = r.synthesizeBuildError()
} }
@@ -205,8 +191,6 @@ func (r *Runner) synthesizeBuildError() []*GroupResult {
return out return out
} }
// legacyBuild runs the free-form shell build command. Kept under the old
// name so reviewers can diff against the previous implementation easily.
func (r *Runner) legacyBuild() (string, error) { func (r *Runner) legacyBuild() (string, error) {
buildCmd := r.buildCommand() buildCmd := r.buildCommand()
@@ -241,11 +225,7 @@ func (r *Runner) legacyBuild() (string, error) {
return out.String(), nil return out.String(), nil
} }
// compileStructured compiles one structured build via the translator and
// returns the build log plus the absolute path to the produced binary.
// The compiler is invoked via exec.Command directly — no shell involved.
func (r *Runner) compileStructured(name string, cfg dsl.BuildConfig, tc Toolchain) (string, string, error) { func (r *Runner) compileStructured(name string, cfg dsl.BuildConfig, tc Toolchain) (string, string, error) {
// Expand source globs against the work dir.
sources, err := expandSources(r.cfg.WorkDir, cfg.Sources) sources, err := expandSources(r.cfg.WorkDir, cfg.Sources)
if err != nil { if err != nil {
return "", "", err return "", "", err
@@ -255,7 +235,6 @@ func (r *Runner) compileStructured(name string, cfg dsl.BuildConfig, tc Toolchai
} }
cfg.Sources = sources cfg.Sources = sources
// Decide output path: <workdir>/build/<name>/<output>[.exe].
outputName := cfg.Output outputName := cfg.Output
if outputName == "" { if outputName == "" {
outputName = "solution" outputName = "solution"
@@ -298,9 +277,6 @@ func (r *Runner) compileStructured(name string, cfg dsl.BuildConfig, tc Toolchai
return logPrefix + out.String(), outputPath, nil return logPrefix + out.String(), outputPath, nil
} }
// expandSources expands each glob in patterns against workDir and returns
// a slice of paths relative to workDir. Globs that match no files cause an
// error — silent zero matches are almost always a typo.
func expandSources(workDir string, patterns []string) ([]string, error) { func expandSources(workDir string, patterns []string) ([]string, error) {
var out []string var out []string
seen := map[string]bool{} seen := map[string]bool{}
@@ -310,7 +286,6 @@ func expandSources(workDir string, patterns []string) ([]string, error) {
return nil, fmt.Errorf("glob %q: %w", pat, err) return nil, fmt.Errorf("glob %q: %w", pat, err)
} }
if len(matches) == 0 { if len(matches) == 0 {
// Fall back to treating it as a literal path.
if _, statErr := os.Stat(filepath.Join(workDir, pat)); statErr == nil { if _, statErr := os.Stat(filepath.Join(workDir, pat)); statErr == nil {
matches = []string{filepath.Join(workDir, pat)} matches = []string{filepath.Join(workDir, pat)}
} else { } else {