1. New build system
All checks were successful
build-dsl-smoke / Build judge (push) Successful in 12s
build-dsl-smoke / debug / clang / linux (push) Successful in 6s
build-dsl-smoke / debug / gcc / linux (push) Successful in 8s
build-dsl-smoke / release / clang / linux (push) Successful in 8s
build-dsl-smoke / release / gcc / linux (push) Successful in 6s
build-dsl-smoke / sanitized / clang / linux (push) Successful in 8s
build-dsl-smoke / sanitized / gcc / linux (push) Successful in 7s
build-dsl-smoke / debug / clang / windows (push) Successful in 13s
build-dsl-smoke / debug-valgrind / gcc / linux (push) Successful in 14s
build-dsl-smoke / release / clang / windows (push) Successful in 16s
build-dsl-smoke / debug / msvc / windows (push) Successful in 18s
build-dsl-smoke / release / msvc / windows (push) Successful in 17s
build-dsl-smoke / SUMMARY (push) Successful in 4s
Release / Build & publish (push) Successful in 48s
All checks were successful
build-dsl-smoke / Build judge (push) Successful in 12s
build-dsl-smoke / debug / clang / linux (push) Successful in 6s
build-dsl-smoke / debug / gcc / linux (push) Successful in 8s
build-dsl-smoke / release / clang / linux (push) Successful in 8s
build-dsl-smoke / release / gcc / linux (push) Successful in 6s
build-dsl-smoke / sanitized / clang / linux (push) Successful in 8s
build-dsl-smoke / sanitized / gcc / linux (push) Successful in 7s
build-dsl-smoke / debug / clang / windows (push) Successful in 13s
build-dsl-smoke / debug-valgrind / gcc / linux (push) Successful in 14s
build-dsl-smoke / release / clang / windows (push) Successful in 16s
build-dsl-smoke / debug / msvc / windows (push) Successful in 18s
build-dsl-smoke / release / msvc / windows (push) Successful in 17s
build-dsl-smoke / SUMMARY (push) Successful in 4s
Release / Build & publish (push) Successful in 48s
Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
158
dsl/build.go
Normal file
158
dsl/build.go
Normal file
@@ -0,0 +1,158 @@
|
||||
package dsl
|
||||
|
||||
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{}
|
||||
}
|
||||
for k, v := range src.Defines {
|
||||
dst.Defines[k] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 && !contains(b.Platforms, os) {
|
||||
return false
|
||||
}
|
||||
if len(b.Compilers) > 0 && !contains(b.Compilers, compiler) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func contains(xs []string, x string) bool {
|
||||
for _, v := range xs {
|
||||
if v == x {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type ToolchainSpec struct {
|
||||
Name string
|
||||
Platforms []string
|
||||
Binary string
|
||||
Class string
|
||||
}
|
||||
Reference in New Issue
Block a user