7 "github.com/iotbzh/xds-server/lib/xsapiv1"
8 uuid "github.com/satori/go.uuid"
11 // CrossSDK Hold SDK config
12 type CrossSDK struct {
16 // NewCrossSDK creates a new instance of Syncthing
17 func NewCrossSDK(path string) (*CrossSDK, error) {
18 // Assume that we have .../<profile>/<version>/<arch>
20 sdk: xsapiv1.SDK{Path: path},
23 s.sdk.Arch = filepath.Base(path)
25 d := filepath.Dir(path)
26 s.sdk.Version = filepath.Base(d)
29 s.sdk.Profile = filepath.Base(d)
31 // Use V3 to ensure that we get same uuid on restart
32 s.sdk.ID = uuid.NewV3(uuid.FromStringOrNil("sdks"), s.sdk.Profile+"_"+s.sdk.Arch+"_"+s.sdk.Version).String()
33 s.sdk.Name = s.sdk.Arch + " (" + s.sdk.Version + ")"
35 envFile := filepath.Join(path, "environment-setup*")
36 ef, err := filepath.Glob(envFile)
38 return nil, fmt.Errorf("Cannot retrieve environment setup file: %v", err)
41 return nil, fmt.Errorf("No environment setup file found match %s", envFile)
48 // Get Return SDK definition
49 func (s *CrossSDK) Get() *xsapiv1.SDK {
53 // GetEnvCmd returns the command used to initialized the environment
54 func (s *CrossSDK) GetEnvCmd() []string {
55 return []string{"source", s.sdk.EnvFile}