compiler: move Config struct to compileopts

Этот коммит содержится в:
Ayke van Laethem 2019-10-31 15:54:28 +01:00 коммит произвёл Ron Evans
родитель e7cf75030c
коммит ef600965aa
3 изменённых файлов: 36 добавлений и 32 удалений

31
compileopts/config.go Обычный файл
Просмотреть файл

@ -0,0 +1,31 @@
// Package compileopts contains the configuration for a single to-be-built
// binary.
package compileopts
// Config keeps all configuration affecting the build in a single struct.
type Config struct {
Triple string // LLVM target triple, e.g. x86_64-unknown-linux-gnu (empty string means default)
CPU string // LLVM CPU name, e.g. atmega328p (empty string means default)
Features []string // LLVM CPU features
GOOS string //
GOARCH string //
GC string // garbage collection strategy
Scheduler string // scheduler implementation ("coroutines" or "tasks")
PanicStrategy string // panic strategy ("print" or "trap")
CFlags []string // cflags to pass to cgo
LDFlags []string // ldflags to pass to cgo
ClangHeaders string // Clang built-in header include path
DumpSSA bool // dump Go SSA, for compiler debugging
VerifyIR bool // run extra checks on the IR
Debug bool // add debug symbols for gdb
GOROOT string // GOROOT
TINYGOROOT string // GOROOT for TinyGo
GOPATH string // GOPATH, like `go env GOPATH`
BuildTags []string // build tags for TinyGo (empty means {Config.GOOS/Config.GOARCH})
TestConfig TestConfig
}
type TestConfig struct {
CompileTestBinary bool
// TODO: Filter the test functions to run, include verbose flag, etc
}

Просмотреть файл

@ -14,6 +14,7 @@ import (
"strconv"
"strings"
"github.com/tinygo-org/tinygo/compileopts"
"github.com/tinygo-org/tinygo/ir"
"github.com/tinygo-org/tinygo/loader"
"golang.org/x/tools/go/ssa"
@ -57,36 +58,8 @@ var coroFunctionsUsedInTransforms = []string{
"runtime.llvmCoroRefHolder",
}
// Configure the compiler.
type Config struct {
Triple string // LLVM target triple, e.g. x86_64-unknown-linux-gnu (empty string means default)
CPU string // LLVM CPU name, e.g. atmega328p (empty string means default)
Features []string // LLVM CPU features
GOOS string //
GOARCH string //
GC string // garbage collection strategy
Scheduler string // scheduler implementation ("coroutines" or "tasks")
PanicStrategy string // panic strategy ("print" or "trap")
CFlags []string // cflags to pass to cgo
LDFlags []string // ldflags to pass to cgo
ClangHeaders string // Clang built-in header include path
DumpSSA bool // dump Go SSA, for compiler debugging
VerifyIR bool // run extra checks on the IR
Debug bool // add debug symbols for gdb
GOROOT string // GOROOT
TINYGOROOT string // GOROOT for TinyGo
GOPATH string // GOPATH, like `go env GOPATH`
BuildTags []string // build tags for TinyGo (empty means {Config.GOOS/Config.GOARCH})
TestConfig TestConfig
}
type TestConfig struct {
CompileTestBinary bool
// TODO: Filter the test functions to run, include verbose flag, etc
}
type Compiler struct {
Config
*compileopts.Config
mod llvm.Module
ctx llvm.Context
builder llvm.Builder
@ -129,7 +102,7 @@ type Phi struct {
llvm llvm.Value
}
func NewCompiler(pkgName string, config Config) (*Compiler, error) {
func NewCompiler(pkgName string, config *compileopts.Config) (*Compiler, error) {
if config.Triple == "" {
config.Triple = llvm.DefaultTargetTriple()
}

Просмотреть файл

@ -63,7 +63,7 @@ type BuildConfig struct {
tags string
wasmAbi string
heapSize int64
testConfig compiler.TestConfig
testConfig compileopts.TestConfig
}
// Helper function for Compiler object.
@ -108,7 +108,7 @@ func Compile(pkgName, outpath string, spec *compileopts.TargetSpec, config *Buil
if config.scheduler != "" {
scheduler = config.scheduler
}
compilerConfig := compiler.Config{
compilerConfig := &compileopts.Config{
Triple: spec.Triple,
CPU: spec.CPU,
Features: spec.Features,