-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
phixzip.exw
183 lines (162 loc) · 6.24 KB
/
phixzip.exw
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
--
-- phixzip.exw
-- ===========
--
constant v = version(),
num_zips = 4 -- see also C:\Program Files (x86)\Phix\demo\pGUI\pdemo\installation.e
printf(1,"Build using version %s?(Y/N or 6 to build p64.exe only):",{v})
integer ch = upper(getc(0))
printf(1,"%c\n",ch)
if ch!='Y' and ch!='6' then sleep(1) abort(1) end if
procedure compile(string lc, integer mode = 0)
integer c_res
while true do
?lc
c_res = system_exec(lc,mode)
if c_res=0 then exit end if
if mode=0 then
printf(1,"\n\nError, %s failed with error code %d\n",{lc,c_res})
{} = wait_key()
abort(0)
end if
puts(1,"sleep...\n")
sleep(0.4)
end while
end procedure
--p -c -norun p32.exu
--p -c -norun p64.exu
compile("p -c -norun p64") -- (somewhat duff, eg PI is 3.14159265358979311600, 1.2246e-16 out)
compile("copy /Y p64.exe p64b.exe",4)
compile("p64b -c -norun p64") -- (properly built -- PI is 3.14159265358979323851, 0.0005e-16 out)
if ch='6' then ?"ok" sleep(1) abort(1) end if
compile("p -c -norun p32.exu")
compile("p64 -c -norun p64.exu")
--printf(1,"Continue?(Y/N):",{v})
--ch = upper(getc(0))
--printf(1,"%c\n",ch)
--if ch!='Y' then sleep(1) abort(1) end if
include builtins\LiteZip.e
--sequence phix7zip = get_text("sfx/phix7zip.lst",GT_LF_STRIPPED)
sequence phix7zip = remove_all("",get_text("sfx/phix7zip.lst",GT_LF_STRIPPED))
integer l = length(phix7zip)
printf(1,"phix7zip.lst contains %d entries\n",l)
integer last_lm = 0
procedure progress(object m)
if not string(m) then
if m='\n' then puts(1,"\n") end if
last_lm = 0
else
puts(1,m&repeat(' ',max(0,last_lm-length(m)))&"\r")
last_lm = length(m)
end if
end procedure
function in_file(string zi)
if zi="" then ?"zi=\"\"" return 0 end if
if zi="bench\\Big_e" then return 0 end if
-- if zi!="copyright.txt" then return 0 end if
if match("bench",zi)=1
or match("demo",zi)=1 then
if match("demo\\pGUI\\win32",zi)=1
or match("demo\\pGUI\\win64",zi)=1 then
return 2
end if
if (match("demo\\Arwen",zi)!=1 or
match("demo\\Arwen32dibdemo",zi)=1)
-- and match("demo\\edita",zi)!=1
and match("demo\\pGUI",zi)!=1
and match("demo\\combo.exw",zi)!=1
and match("demo\\mandle.exw",zi)!=1
and match("demo\\takeuchi.exw",zi)!=1 then
return 3
end if
elsif match("docs",zi)=1 then
--DEV/SUG we might need to put pwa in here (3 aka phix.ver.2.zip) too...
if match("Phix.chm",zi) then
--?zi -- `docs/phix/Phix.chm`
return 5
end if
-- if match("docs\\phix\\images",zi)=1 then
-- return 3
-- end if
--?zi
return 4
end if
return 1
end function
atom hzip, t1 = time()+1
object res
sequence hzips = {},
hznames = {sprintf("sfx/phix.%s.zip",{v})}
for i=1 to num_zips do
hznames = append(hznames,sprintf("sfx/phix.%s.%d.zip",{v,i}))
end for
for i=1 to length(hznames) do
hzip = ZipCreateFile(hznames[i])
hzips = append(hzips,hzip)
end for
for i=1 to l do
string zi = phix7zip[i]
if zi="sfx\\phix\\Phix\\*" then
-- I think I had a problem with 7-zip here...
-- hopefully not a problem with LiteZip.
res = ZipAddDir(hzips[1],"sfx\\phix\\Phix")
if res!=ZR_OK then ?9/0 end if
else
integer fileno = in_file(zi)
if time()>t1 or i=l then
progress(sprintf("adding file %d of %d (%3.2f%%) - %s",{i,l,i/l*100,zi}))
t1 = time()+1
end if
if fileno!=0 then
res = ZipAddFile(hzips[fileno],zi)
if res!=ZR_OK then
?{"fatal error:",res}
?{"zi:",zi}
?9/0
end if
end if
end if
end for
progress('\n')
ZipClose(hzips)
constant makesfx = `sfx\makesfx.exe /zip="sfx\phix.%s.zip" /sfx="sfx\phix.%s.setup.exe" `&
`/title="Install Phix" /website="http://phix.x10.mx" `&
`/intro="This program installs the Phix Programming Language, version %s" `&
`/defaultpath="$programfiles$\Phix" /exec="$targetdir$\ppw.bat" /overwrite `
puts(1,"\nmakesfx:\n")
res = system_exec(sprintf(makesfx,{v,v,v}))
if res!=1 then
printf(1,"Error, makesfx failed with error code %d\n",res)
end if
hznames = append(hznames,sprintf("sfx/phix.%s.setup.exe",{v}))
constant doczip = sprintf("sfx/phix.docs.%s.zip",{v})
printf(1,"\nCreating %s (for the web docs upload)\n",{doczip})
if not copy_file("docs\\phix\\Combined.css","docs\\phix\\html\\Combined.css",true) then ?9/0 end if
if not copy_file("docs\\phix\\Common.js","docs\\phix\\html\\Common.js",true) then ?9/0 end if
hzip = ZipCreateFile(doczip)
--(note: this replaces a separate sfx/docs.lst)
res = ZipAddFile(hzip,"docs\\phix\\Combined.css") if res!=ZR_OK then ?9/0 end if
res = ZipAddFile(hzip,"docs\\phix\\Common.js") if res!=ZR_OK then ?9/0 end if
res = ZipAddFile(hzip,"docs\\phix\\header_01.jpg") if res!=ZR_OK then ?9/0 end if
res = ZipAddFile(hzip,"docs\\phix\\header_02.jpg") if res!=ZR_OK then ?9/0 end if
res = ZipAddFile(hzip,"docs\\phix\\phix.htm") if res!=ZR_OK then ?9/0 end if
res = ZipAddFile(hzip,"docs\\phix\\phix.txt") if res!=ZR_OK then ?9/0 end if
progress("adding images")
res = ZipAddDir(hzip,"docs\\phix\\images") if res!=ZR_OK then ?9/0 end if
progress("adding phix\\html directory")
res = ZipAddDir(hzip,"docs\\phix\\html") if res!=ZR_OK then ?9/0 end if
progress("")
ZipClose(hzip)
hznames = append(hznames,doczip)
constant TENMB = 10*1024*1024
function get_file_info(string filename)
integer size = get_file_size(filename)
string ss = file_size_k(size),
ok = iff(size<TENMB?"(ok)":iff(match("docs",filename)?"(temp anyway)":"*** TOO BIG ***"))
return sprintf("%-26s %s %s",{filename,ss,ok})
end function
printf(1,"\nFinished. See\n%s\n\n",{join(apply(hznames,get_file_info),"\n")})
--sfx/phix.%v%.zip[and .001/2] and sfx/phix.%v%.setup.exe
?"done"
{} = wait_key()
--abort(0)