/
expect.go
112 lines (91 loc) · 2.12 KB
/
expect.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package buildercollection
import (
"io/ioutil"
"path"
"strings"
"github.com/AnimusPEXUS/aipsetup/basictypes"
"github.com/AnimusPEXUS/aipsetup/buildingtools"
"github.com/AnimusPEXUS/utils/logger"
"github.com/AnimusPEXUS/utils/tarballname"
)
func init() {
Index["expect"] = func(bs basictypes.BuildingSiteCtlI) (basictypes.BuilderI, error) {
return NewBuilder_expect(bs), nil
}
}
type Builder_expect struct {
*Builder_std
}
func NewBuilder_expect(bs basictypes.BuildingSiteCtlI) *Builder_expect {
self := new(Builder_expect)
self.Builder_std = NewBuilder_std(bs)
self.EditConfigureArgsCB = self.EditConfigureArgs
self.AfterExtractCB = self.AfterExtract
return self
}
func (self *Builder_expect) AfterExtract(log *logger.Logger, ret error) error {
log.Info("Looking for Tcl and Tk too extract them...")
tcl_found := ""
tk_found := ""
tarb_dir := self.GetBuildingSiteCtl().GetDIR_TARBALL()
tarb_dir_files, err := ioutil.ReadDir(tarb_dir)
if err != nil {
return err
}
for _, i := range tarb_dir_files {
i_name := i.Name()
if tarballname.IsPossibleTarballName(i_name) {
if strings.HasPrefix(i_name, "tcl") {
tcl_found = i_name
}
if strings.HasPrefix(i_name, "tk") {
tk_found = i_name
}
if tcl_found != "" && tk_found != "" {
break
}
}
}
a_tools := new(buildingtools.Autotools)
for _, i := range [][2]string{
[2]string{tcl_found, "tcl_tarball"},
[2]string{tk_found, "tk_tarball"},
} {
err = a_tools.Extract(
path.Join(tarb_dir, i[0]),
self.GetBuildingSiteCtl().GetPath(),
path.Join(self.GetBuildingSiteCtl().GetDIR_TEMP(), i[1]),
false,
false,
false,
log,
)
if err != nil {
return err
}
}
return nil
}
func (self *Builder_expect) EditConfigureArgs(log *logger.Logger, ret []string) ([]string, error) {
info, err := self.GetBuildingSiteCtl().ReadInfo()
if err != nil {
return nil, err
}
ret = append(
ret,
[]string{
"--enable-threads",
"--enable-wince",
}...,
)
if strings.HasPrefix(info.HostArch, "x86_64") {
ret = append(
ret,
[]string{
"--enable-64bit",
"--enable-64bit-vis",
}...,
)
}
return ret, nil
}