Move compiler options to its own struct

Also add Clean attribute, to handle a future build clean method
This commit is contained in:
Ettore Di Giacinto
2020-01-05 14:32:26 +01:00
parent 9db9c1bf19
commit bcc6ce19ea
6 changed files with 51 additions and 31 deletions

View File

@@ -21,7 +21,6 @@ import (
"os"
"path/filepath"
"regexp"
"runtime"
"strings"
"sync"
@@ -37,15 +36,15 @@ const BuildFile = "build.yaml"
type LuetCompiler struct {
*tree.CompilerRecipe
Backend CompilerBackend
Database pkg.PackageDatabase
ImageRepository string
PullFirst, KeepImg bool
Concurrency int
CompressionType CompressionImplementation
Backend CompilerBackend
Database pkg.PackageDatabase
ImageRepository string
PullFirst, KeepImg, Clean bool
Concurrency int
CompressionType CompressionImplementation
}
func NewLuetCompiler(backend CompilerBackend, db pkg.PackageDatabase) Compiler {
func NewLuetCompiler(backend CompilerBackend, db pkg.PackageDatabase, opt CompilerOptions) Compiler {
// The CompilerRecipe will gives us a tree with only build deps listed.
return &LuetCompiler{
Backend: backend,
@@ -53,11 +52,12 @@ func NewLuetCompiler(backend CompilerBackend, db pkg.PackageDatabase) Compiler {
tree.Recipe{Database: db},
},
Database: db,
ImageRepository: "luet/cache",
PullFirst: true,
CompressionType: None,
KeepImg: true,
Concurrency: runtime.NumCPU(),
ImageRepository: opt.ImageRepository,
PullFirst: opt.PullFirst,
CompressionType: opt.CompressionType,
KeepImg: opt.KeepImg,
Concurrency: opt.Concurrency,
Clean: opt.Clean,
}
}