summaryrefslogtreecommitdiffstats
path: root/contrib/local/build-windows.expect
blob: 27ab7c0fe630b1fa5d4994a9a36f7279763c8450 (plain)
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/usr/bin/expect

set timeout 600
set USCXML_BUILD_HOST $::env(USCXML_BUILD_HOST)
set USCXML_BUILD_ARCH $::env(USCXML_BUILD_ARCH)


set local_prompt {sradomski$ }
set initial_remote_prompt "C*>"
# the default windows prompt is hard to recognize
set remote_prompt "easy_to_recognize"

eval spawn ping -c1 ${USCXML_BUILD_HOST}.local.
expect "cannot resolve"  { puts "Host ${USCXML_BUILD_HOST}.local. not found"; exit } \
       -re $local_prompt { }

eval cd ~/Documents/TK/Code/

##############################
# prepare and deploy archive

# check age of archive against modification date
eval spawn find ./uscxml -newer uscxml-win.tar
set redeploy 0;
expect {
	"find:*No such file"     { set redeploy 1; }
	-re ".cpp\r\n"           { set redeploy 1; }
	-re "package\r\n"        { set redeploy 1; }
	-re ".h\r\n"             { set redeploy 1; }
	-re "CMakeLists.txt\r\n" { set redeploy 1; }
	-re $local_prompt        { }
}
#set redeploy 0;

if {$redeploy} {
# eval spawn rm uscxml-win.tar
# eval spawn tar --exclude='__*' --exclude=uscxml/contrib/prebuilt/darwin --exclude=uscxml/docs/html --exclude=uscxml/examples/ios --exclude=uscxml/contrib/archives --exclude=uscxml/.git --exclude=uscxml/build* --exclude=uscxml/lib/ios-5.0 --exclude=uscxml/lib/linux* --exclude=uscxml/lib/darwin* --exclude=uscxml/installer/uMundo* --exclude=uscxml/contrib/prebuilt/linux* --exclude=uscxml/contrib/prebuilt/ios -cf uscxml-win.tar uscxml/
eval spawn rm uscxml-win.zip
eval spawn zip -r uscxml-win.zip uscxml/ --exclude __\* uscxml/contrib/prebuilt/darwin\* uscxml/contrib/prebuilt/ios\* uscxml/contrib/prebuilt/linux\* uscxml/docs/html\* uscxml/examples/ios uscxml/contrib/archives\* uscxml/.git/\* uscxml/build\* uscxml/installer/uMundo* uscxml/contrib/prebuilt/linux*
	expect {
		"a uscxml/"        { exp_continue }
		timeout            { puts "Timeout when packaging source code"; exit; }
		-re $local_prompt  { }
	}

#	eval spawn scp -4 uscxml-win.tar sradomski@${USCXML_BUILD_HOST}.local:\\uscxml-win.tar
	eval spawn scp -4 uscxml-win.zip sradomski@${USCXML_BUILD_HOST}.local:\\uscxml-win.zip
	expect {
		"ETA"              { exp_continue }
		"The authenticity" { send "yes\n"; exp_continue; }
		timeout            { puts "Timeout when uploading source code"; exit;  }
		-re $local_prompt  { }
	}
}

##############################
# ssh into remote host

eval spawn ssh -4 sradomski@${USCXML_BUILD_HOST}.local.
expect {
	timeout            { puts "Timeout when connecting to windows"; exit;  }
	"The authenticity" { send "yes\n"; }
	-re $local_prompt  { puts "Could not connect to remote host"; exit; }
	-re $initial_remote_prompt { }
}

send "set prompt=easy_to_recognize \r"
expect -re $remote_prompt

# unpack archive if required
if {$redeploy} {
	send "rmdir \/S \/Q uscxml\r"
	expect -re $remote_prompt

#	send "tar xf uscxml-win.tar\r"
	send "unzip uscxml-win.zip\r"
	expect "uscxml/"          { exp_continue } \
	       -re $remote_prompt { }

}

# setup directories
send "rmdir \/S \/Q build-uscxml\r"
expect -re $remote_prompt
send "mkdir build-uscxml\r"
expect -re $remote_prompt
send "cd build-uscxml\r"
expect -re $remote_prompt

##############################
# start cmd.exe and prepare for compiling
# send "cmd\n"
# expect -re $cmd_prompt

# "c:\Program Files\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
# send "\"c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\vcvarsall.bat x86_amd64\"\n"
if { [string compare $USCXML_BUILD_ARCH 32] == 0 } {
	send "\"c:\\Program Files\\Microsoft Visual Studio 10.0\\VC\\bin\\vcvars32.bat\"\r"
	expect -re $remote_prompt
} else {
	send "\"c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\vcvarsall.bat\" x86_amd64\r"
	expect -re $remote_prompt
}
##############################
# compile in debug configuration

send "\"cmake.exe\" -G \"NMake Makefiles\" -DCMAKE_BUILD_TYPE=Debug -DDIST_PREPARE=ON ..\\uscxml\r"

expect "download" { exp_continue } \
       -re $remote_prompt { }

send "nmake\r"
expect {
	"Building" { exp_continue; }
	"Linking" { exp_continue; }
	"fatal error"      { exit }
  -re $remote_prompt      { }
}

# send "nmake java\r"
# expect {
# 	"Building" { exp_continue; }
# 	"Linking" { exp_continue; }
# 	"fatal error"      { exit }
#   -re $remote_prompt      { }
# }
# 
# send "nmake csharp\r"
# expect {
# 	"Building" { exp_continue; }
# 	"Linking" { exp_continue; }
# 	"fatal error"      { exit }
#   -re $remote_prompt      { }
# }

##############################
# compile in release configuration

send "\"cmake\" -G \"NMake Makefiles\" -DCMAKE_BUILD_TYPE=Release -DDIST_PREPARE=ON ..\\uscxml\r"
expect -re $remote_prompt

send "nmake\n\r"
expect {
	timeout            { puts "Timeout when building"; exit;  }
	"Building" { puts "Building"; exp_continue; }
	"Scanning" { puts "Scanning"; exp_continue; }
	"Linking" { puts "Linking"; exp_continue; }
	"fatal error"      { puts "Dying"; exit; }
  -re $remote_prompt { puts "Continuing";  }
}

# send "nmake java\n\r"
# expect {
# 	timeout            { puts "Timeout when building"; exit;  }
# 	"Building" { puts "Building"; exp_continue; }
# 	"Scanning" { puts "Scanning"; exp_continue; }
# 	"Linking" { puts "Linking"; exp_continue; }
# 	"fatal error"      { puts "Dying"; exit; }
#   -re $remote_prompt { puts "Continuing";  }
# }
# 
# send "nmake csharp\n\r"
# expect {
# 	timeout            { puts "Timeout when building"; exit;  }
# 	"Building" { puts "Building"; exp_continue; }
# 	"Scanning" { puts "Scanning"; exp_continue; }
# 	"Linking" { puts "Linking"; exp_continue; }
# 	"fatal error"      { puts "Dying"; exit; }
#   -re $remote_prompt { puts "Continuing";  }
# }

send "cd ..\r"
expect -re $remote_prompt

if { [string compare $USCXML_BUILD_ARCH 32] == 0 } {
  send "zip -r win-package-x86.zip uscxml\\package\\windows-x86\r"
} else {
  send "zip -r win-package-x86_64.zip uscxml\\package\\windows-x86_64\r"
}

send "exit\r"
expect -re $local_prompt
eval cd ~/Documents/TK/Code/

if { [string compare $USCXML_BUILD_ARCH 32] == 0 } {
  eval spawn "scp epikur-win7.local:win-package-x86.zip ."
  expect -re $local_prompt
  eval spawn "unzip -o win-package-x86.zip"
  expect -re $local_prompt
  eval spawn "rm win-package-x86.zip"
  expect -re $local_prompt

} else {
  eval spawn "scp epikur-win7-64.local:win-package-x86_64.zip ."
  expect -re $local_prompt
  eval spawn "unzip -o win-package-x86_64.zip"
  expect -re $local_prompt
  eval spawn "rm win-package-x86_64.zip"
  expect -re $local_prompt
}

exit