add new build system
All checks were successful
build-dsl-smoke / Discover matrix (push) Successful in 8s
build-dsl-smoke / Build judge (push) Successful in 11s
build-dsl-smoke / ${{ matrix.cell.build }} / ${{ matrix.cell.toolchain }} / ${{ matrix.cell.platform }} (push) Successful in 5s
memory-limit / Build judge (pull_request) Successful in 10s
build-dsl-smoke / SUMMARY (push) Successful in 3s
memory-limit / Linux / gcc (pull_request) Successful in 9s
memory-limit / Linux / clang (pull_request) Successful in 13s
memory-limit / Windows / clang (pull_request) Successful in 16s
memory-limit / Windows / msvc (pull_request) Successful in 17s

This commit is contained in:
2026-04-11 01:51:38 +03:00
parent 358e3146bc
commit 128a64a609
15 changed files with 2448 additions and 150 deletions

View File

@@ -91,7 +91,31 @@ func (p *Parser) parseFile() (*File, error) {
if err != nil {
return nil, err
}
f.Build = s.Value
if p.peek().Type == TOKEN_LBRACE {
bc, err := p.parseBuildBlock(s.Value)
if err != nil {
return nil, err
}
f.Builds = append(f.Builds, bc)
} else {
f.Build = s.Value
}
case "build_defaults":
p.advance()
bc, err := p.parseBuildBlock("")
if err != nil {
return nil, err
}
f.BuildDefaults = bc
case "toolchains":
p.advance()
specs, err := p.parseToolchainsBlock()
if err != nil {
return nil, err
}
f.Toolchains = specs
case "build_linux":
p.advance()
@@ -195,10 +219,34 @@ func (p *Parser) parseFile() (*File, error) {
if err := p.validateWeights(f); err != nil {
return nil, err
}
if err := validateBuilds(f); err != nil {
return nil, err
}
return f, nil
}
func validateBuilds(f *File) error {
hasLegacy := f.Build != "" || f.BuildLinux != "" || f.BuildWindows != "" || f.BuildDarwin != ""
hasStructured := f.BuildDefaults != nil || len(f.Builds) > 0
if hasLegacy && hasStructured {
return fmt.Errorf("cannot mix legacy `build \"shell\"` with structured `build \"name\" { ... }` in the same suite")
}
seen := map[string]bool{}
for _, b := range f.Builds {
if b.Name == "" {
return fmt.Errorf("structured build must have a name")
}
if seen[b.Name] {
return fmt.Errorf("duplicate build name %q", b.Name)
}
seen[b.Name] = true
}
return nil
}
func (p *Parser) validateWeights(f *File) error {
if len(f.Groups) == 0 {
return nil
@@ -715,8 +763,6 @@ func (p *Parser) parseInt() (int, error) {
return n, nil
}
// parseSize accepts either a TOKEN_SIZE (e.g. "256MB", "1GiB", "512K") or a bare
// TOKEN_INT interpreted as bytes. MiB/MB are both 1024² — we use IEC semantics.
func (p *Parser) parseSize() (int64, error) {
t := p.peek()
switch t.Type {