7 uuid "github.com/satori/go.uuid"
10 // SDK Define a cross tool chain used to build application
12 ID string `json:"id" binding:"required"`
13 Name string `json:"name"`
14 Profile string `json:"profile"`
15 Version string `json:"version"`
16 Arch string `json:"arch"`
17 Path string `json:"path"`
19 // Not exported fields
20 EnvFile string `json:"-"`
23 // NewCrossSDK creates a new instance of Syncthing
24 func NewCrossSDK(path string) (*SDK, error) {
25 // Assume that we have .../<profile>/<version>/<arch>
28 s.Arch = filepath.Base(path)
30 d := filepath.Dir(path)
31 s.Version = filepath.Base(d)
34 s.Profile = filepath.Base(d)
36 // Use V3 to ensure that we get same uuid on restart
37 s.ID = uuid.NewV3(uuid.FromStringOrNil("sdks"), s.Profile+"_"+s.Arch+"_"+s.Version).String()
38 s.Name = s.Arch + " (" + s.Version + ")"
40 envFile := filepath.Join(path, "environment-setup*")
41 ef, err := filepath.Glob(envFile)
43 return nil, fmt.Errorf("Cannot retrieve environment setup file: %v", err)
46 return nil, fmt.Errorf("No environment setup file found match %s", envFile)
53 // GetEnvCmd returns the command used to initialized the environment
54 func (s *SDK) GetEnvCmd() []string {
55 return []string{"source", s.EnvFile}