From 40a7183f3b4aa32379aa8b4949f5f9c5e32f79f6 Mon Sep 17 00:00:00 2001 From: Sebastien Douheret Date: Wed, 17 May 2017 11:28:57 +0200 Subject: Add SDKs support. Don't allow to install SDKs through XDS for now. Only probe existing SDKs that have been manually installed using scripts/agl/install-agl-sdks.sh. Signed-off-by: Sebastien Douheret --- lib/crosssdk/sdk.go | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 lib/crosssdk/sdk.go (limited to 'lib/crosssdk/sdk.go') diff --git a/lib/crosssdk/sdk.go b/lib/crosssdk/sdk.go new file mode 100644 index 0000000..2f22f22 --- /dev/null +++ b/lib/crosssdk/sdk.go @@ -0,0 +1,47 @@ +package crosssdk + +import ( + "fmt" + "path" + "path/filepath" +) + +// SDK Define a cross tool chain used to build application +type SDK struct { + Profile string + Version string + Arch string + Path string + EnvFile string +} + +// NewCrossSDK creates a new instance of Syncthing +func NewCrossSDK(path string) (*SDK, error) { + // Assume that we have .../// + s := SDK{Path: path} + + s.Arch = filepath.Base(path) + + d := filepath.Dir(path) + s.Version = filepath.Base(d) + + d = filepath.Dir(d) + s.Profile = filepath.Base(d) + + envFile := filepath.Join(path, "environment-setup*") + ef, err := filepath.Glob(envFile) + if err != nil { + return nil, fmt.Errorf("Cannot retrieve environment setup file: %v", err) + } + if len(ef) != 1 { + return nil, fmt.Errorf("No environment setup file found match %s", envFile) + } + s.EnvFile = ef[0] + + return &s, nil +} + +// GetEnvCmd returns the command to initialized the environment to use a cross SDK +func (s *SDK) GetEnvCmd() string { + return ". " + path.Join(s.Path, s.EnvFile) +} -- cgit 1.2.3-korg