Skip to content

Commit 17efbaa

Browse files
committed
AST: Fix source and generates operation in taskfiles.
Signed-off-by: Timothy Rule (VM/EMT3) <Timothy.Rule@de.bosch.com>
1 parent e76f159 commit 17efbaa

2 files changed

Lines changed: 22 additions & 15 deletions

File tree

ast/internal/app/generate/taskfile_common.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,10 @@ fi`},
200200
}
201201

202202
func buildSimulationTasks(simSpec ast.SimulationSpec) map[string]Task {
203+
// Build the _sequential_ build commands.
203204
buildCmds := []Cmd{
204-
{Cmd: "mkdir -p {{.SIMDIR}}/data"},
205-
{Cmd: "cp {{.ENTRYDIR}}/simulation.yaml {{.SIMDIR}}/data/simulation.yaml"},
205+
{Task: "build-setup-sim"},
206206
}
207-
208-
// Sequential stack execution
209207
for _, stack := range simSpec.Stacks {
210208
if stack.Name == "external" {
211209
continue
@@ -215,16 +213,25 @@ func buildSimulationTasks(simSpec ast.SimulationSpec) map[string]Task {
215213
})
216214
}
217215

216+
// Construct the simulation tasks.
218217
simulationTasks := map[string]Task{
219218
"default": {
220219
Cmds: &[]Cmd{
221220
{Task: "build"},
222221
},
223222
},
224223
"build": {
225-
Dir: util.StringPtr("{{.OUTDIR}}"),
226-
Label: util.StringPtr("build"),
227-
Cmds: &buildCmds,
224+
Dir: util.StringPtr("{{.OUTDIR}}"),
225+
Label: util.StringPtr("build"),
226+
Cmds: &buildCmds,
227+
},
228+
"build-setup-sim": {
229+
Dir: util.StringPtr("{{.OUTDIR}}"),
230+
Label: util.StringPtr("build-setup-sim"),
231+
Cmds: &[]Cmd{
232+
{Cmd: "mkdir -p {{.SIMDIR}}/data"},
233+
{Cmd: "cp {{.ENTRYDIR}}/simulation.yaml {{.SIMDIR}}/data/simulation.yaml"},
234+
},
228235
Sources: &[]string{"{{.ENTRYDIR}}/simulation.yaml"},
229236
Generates: &[]string{"{{.SIMDIR}}/data/simulation.yaml"},
230237
},

ast/internal/app/generate/taskfile_model.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ func genericModelTask(model ast.Model, modelUses ast.Uses) Task {
322322
sources := []string{}
323323
generates := func() []string {
324324
return []string{
325-
"downloads/{{base .PACKAGE_URL}}",
325+
//"downloads/{{base .PACKAGE_URL}}", // TODO: handled by deps
326326
}
327327
}()
328328
md := map[string]interface{}{}
@@ -532,16 +532,16 @@ func buildModel(model ast.Model, simSpec ast.SimulationSpec) (Task, error) {
532532
})
533533
*task.Sources = append(*task.Sources, fmt.Sprintf("%s", downloadFile))
534534
} else {
535+
sourcePath := ""
535536
if filepath.IsAbs(f.Value) {
536-
*task.Cmds = append(*task.Cmds, Cmd{
537-
Cmd: fmt.Sprintf("cp %s %s", f.Value, filePath),
538-
})
537+
sourcePath = f.Value
539538
} else {
540-
*task.Cmds = append(*task.Cmds, Cmd{
541-
Cmd: fmt.Sprintf("cp {{.ENTRYDIR}}/%s %s", f.Value, filePath),
542-
})
539+
sourcePath = fmt.Sprintf("{{.ENTRYDIR}}/%s", f.Value)
543540
}
544-
*task.Sources = append(*task.Sources, fmt.Sprintf("%s", f.Name))
541+
*task.Cmds = append(*task.Cmds, Cmd{
542+
Cmd: fmt.Sprintf("cp %s %s", sourcePath, filePath),
543+
})
544+
*task.Sources = append(*task.Sources, sourcePath)
545545
}
546546
}
547547
}

0 commit comments

Comments
 (0)