diff options
Diffstat (limited to 'lib/crosssdk/sdks.go')
-rw-r--r-- | lib/crosssdk/sdks.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/crosssdk/sdks.go b/lib/crosssdk/sdks.go new file mode 100644 index 0000000..435aae6 --- /dev/null +++ b/lib/crosssdk/sdks.go @@ -0,0 +1,39 @@ +package crosssdk + +import ( + "path" + "path/filepath" + + "github.com/Sirupsen/logrus" + "github.com/iotbzh/xds-server/lib/common" + "github.com/iotbzh/xds-server/lib/xdsconfig" +) + +// SDKs List of installed SDK +type SDKs []*SDK + +// Init creates a new instance of Syncthing +func Init(cfg *xdsconfig.Config, log *logrus.Logger) (*SDKs, error) { + s := SDKs{} + + // Retrieve installed sdks + sdkRD := cfg.FileConf.SdkRootDir + + if common.Exists(sdkRD) { + + // Assume that SDK install tree is <rootdir>/<profile>/<version>/<arch> + dirs, err := filepath.Glob(path.Join(sdkRD, "*", "*", "*")) + if err != nil { + log.Debugf("Error while retrieving SDKs: dir=%s, error=%s", sdkRD, err.Error()) + return &s, err + } + for _, d := range dirs { + sdk, err := NewCrossSDK(d) + if err != nil { + log.Debugf("Error while processing SDK dir=%s, err=%s", d, err.Error()) + } + s = append(s, sdk) + } + } + return &s, nil +} |