-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
48 lines (41 loc) · 1.26 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package bazelmake
import (
"os"
"github.com/goccy/go-yaml"
)
type Config struct {
Root string `yaml:"root"`
Targets []*BuildTargetLibraryConfig `yaml:"targets"`
Ignores []*IgnoreConfig `yaml:"ignores"`
Libraries []*LibraryConfig `yaml:"libraries"`
Output string `yaml:"output"`
Compiler string `yaml:"compiler"`
IncludePaths []string `yaml:"include_paths"`
Sources []string `yaml:"sources"`
CompilerOptions []string `yaml:"compiler_options"`
LinkerOptions []string `yaml:"linker_options"`
}
type BuildTargetLibraryConfig struct {
Library string `yaml:"library"`
Path string `yaml:"path"`
Name string `yaml:"name"`
}
type IgnoreConfig struct {
Path string `yaml:"path"`
Name string `yaml:"name"`
}
type LibraryConfig struct {
Name string `yaml:"name"`
Root string `yaml:"root"`
}
func LoadConfig(path string) (*Config, error) {
file, err := os.ReadFile(path)
if err != nil {
return nil, err
}
var cfg Config
if err := yaml.UnmarshalWithOptions(file, &cfg, yaml.Strict()); err != nil {
return nil, err
}
return &cfg, nil
}