-
Notifications
You must be signed in to change notification settings - Fork 9
/
scriptgen.go
72 lines (62 loc) · 1.39 KB
/
scriptgen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// 24 september 2014
package main
import (
"path/filepath"
"strings"
)
var script []Stage
var nSteps int
func objectName(filename string, suffix string) string {
object := strings.Replace(filename, string(filepath.Separator), "_", -1) + suffix
object = filepath.Join(".qoobj", object)
return object
}
func mergeScript(s []Stage) {
var i int
// first append existing steps
for i = 0; i < len(s); i++ {
if i >= len(script) {
break
}
script[i] = append(script[i], s[i]...)
nSteps += len(s[i])
}
// now add new stages
for ; i < len(s); i++ {
script = append(script, s[i])
nSteps += len(s[i])
}
}
func buildScript() {
script = nil
nSteps = 0
objects := []string(nil)
for _, f := range cfiles {
s, obj := toolchain.BuildCFile(f, cflags)
mergeScript(s)
objects = append(objects, obj)
}
for _, f := range cppfiles {
s, obj := toolchain.BuildCXXFile(f, cxxflags)
mergeScript(s)
objects = append(objects, obj)
}
for _, f := range mfiles {
s, obj := toolchain.BuildMFile(f, cflags)
mergeScript(s)
objects = append(objects, obj)
}
for _, f := range mmfiles {
s, obj := toolchain.BuildMMFile(f, cxxflags)
mergeScript(s)
objects = append(objects, obj)
}
for _, f := range rcfiles {
s, obj := toolchain.BuildRCFile(f, nil)
mergeScript(s)
objects = append(objects, obj)
}
s := toolchain.Link(objects, ldflags, libs)
script = append(script, Stage{s})
nSteps++
}