/
config.go
42 lines (37 loc) · 1.09 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
package defaultadapter
import (
"gopkg.in/yaml.v2"
)
// Config holds the config for the builtin adapter
type Config struct {
// Sources lists the project's source files.
Sources []string `yaml:"sources"`
// Headers lists the project's header files.
Headers []string `yaml:"headers"`
// TestSources lists the project's tests source files
TestSources []string `yaml:"test_sources"`
// TestHeaders list the tests' header files
TestHeaders []string `yaml:"test_headers"`
// IncludeDirs lists the projects additional header directories.
IncludeDirs []string `yaml:"include_dirs"`
// LinuxConfig holds Linux specific configuration
LinuxConfig *LinuxConfig `yaml:"linux,omitempty"`
}
// LinuxConfig holds specific configuration on Linux operating systems.
type LinuxConfig struct {
UsePthread bool `yaml:"use_pthread"`
}
// Parse parses a Config
func Parse(c interface{}) (*Config, error) {
// TODO: is there a better way to do that?
out, err := yaml.Marshal(c)
if err != nil {
return nil, err
}
cfg := &Config{}
err = yaml.Unmarshal(out, cfg)
if err != nil {
return nil, err
}
return cfg, nil
}