aboutsummaryrefslogtreecommitdiffstats
path: root/lib/apiv1/make.go
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-05-22 23:58:31 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-05-25 00:17:51 +0200
commit66496d63e16635d72f15abe48dc3dadb473f0b6b (patch)
treef451ec49e07886168ac843fa564e55e97ade182c /lib/apiv1/make.go
parent7f1db509a2076311c280964715962df71a1631ce (diff)
Rework development page: Pre-build, Build, Populate.
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'lib/apiv1/make.go')
-rw-r--r--lib/apiv1/make.go31
1 files changed, 17 insertions, 14 deletions
diff --git a/lib/apiv1/make.go b/lib/apiv1/make.go
index fb6435e..098e41c 100644
--- a/lib/apiv1/make.go
+++ b/lib/apiv1/make.go
@@ -13,11 +13,12 @@ import (
// MakeArgs is the parameters (json format) of /make command
type MakeArgs struct {
- ID string `json:"id"`
- RPath string `json:"rpath"` // relative path into project
- Args string `json:"args"` // args to pass to make command
- SdkID string `json:"sdkid"` // sdk ID to use for setting env
- CmdTimeout int `json:"timeout"` // command completion timeout in Second
+ ID string `json:"id"`
+ SdkID string `json:"sdkid"` // sdk ID to use for setting env
+ Args []string `json:"args"` // args to pass to make command
+ Env []string `json:"env"`
+ RPath string `json:"rpath"` // relative path into project
+ CmdTimeout int `json:"timeout"` // command completion timeout in Second
}
// MakeOutMsg Message send on each output (stdout+stderr) of make command
@@ -85,14 +86,9 @@ func (s *APIService) buildMake(c *gin.Context) {
execTmo = 24 * 60 * 60 // 1 day
}
- cmd := "cd " + prj.GetFullPath(args.RPath) + " && make"
- if args.Args != "" {
- cmd += " " + args.Args
- }
-
// Define callback for output
var oCB common.EmitOutputCB
- oCB = func(sid string, id int, stdout, stderr string) {
+ oCB = func(sid string, id int, stdout, stderr string, data *map[string]interface{}) {
// IO socket can be nil when disconnected
so := s.sessions.IOSocketGet(sid)
if so == nil {
@@ -138,14 +134,21 @@ func (s *APIService) buildMake(c *gin.Context) {
cmdID := makeCommandID
makeCommandID++
+ cmd := []string{}
// Retrieve env command regarding Sdk ID
- if envCmd := s.sdks.GetEnvCmd(args.SdkID, prj.DefaultSdk); envCmd != "" {
- cmd = envCmd + " && " + cmd
+ if envCmd := s.sdks.GetEnvCmd(args.SdkID, prj.DefaultSdk); len(envCmd) > 0 {
+ cmd = append(cmd, envCmd...)
+ cmd = append(cmd, "&&")
+ }
+
+ cmd = append(cmd, "cd", prj.GetFullPath(args.RPath), "&&", "make")
+ if len(args.Args) > 0 {
+ cmd = append(cmd, args.Args...)
}
s.log.Debugf("Execute [Cmd ID %d]: %v", cmdID, cmd)
- err := common.ExecPipeWs(cmd, sop, sess.ID, cmdID, execTmo, s.log, oCB, eCB)
+ err := common.ExecPipeWs(cmd, args.Env, sop, sess.ID, cmdID, execTmo, s.log, oCB, eCB, nil)
if err != nil {
common.APIError(c, err.Error())
return