Skip to content

Commit 7048a2f

Browse files
committed
Package: Create ZIP on Windows
1 parent f838944 commit 7048a2f

File tree

2 files changed

+49
-40
lines changed

2 files changed

+49
-40
lines changed

python/servo/package_commands.py

+43-5
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,32 @@ def copy_dependencies(binary_path, lib_path):
106106
need_checked.difference_update(checked)
107107

108108

109+
def copy_windows_dependencies(binary_path, destination):
110+
try:
111+
[shutil.copy(path.join(binary_path, d), destination) for d in ["libeay32md.dll", "ssleay32md.dll"]]
112+
except:
113+
deps = [
114+
"libstdc++-6.dll",
115+
"libwinpthread-1.dll",
116+
"libbz2-1.dll",
117+
"libgcc_s_seh-1.dll",
118+
"libexpat-1.dll",
119+
"zlib1.dll",
120+
"libpng16-16.dll",
121+
"libiconv-2.dll",
122+
"libglib-2.0-0.dll",
123+
"libgraphite2.dll",
124+
"libfreetype-6.dll",
125+
"libfontconfig-1.dll",
126+
"libintl-8.dll",
127+
"libpcre-1.dll",
128+
"libeay32.dll",
129+
"ssleay32.dll",
130+
"libharfbuzz-0.dll",
131+
]
132+
[shutil.copy(path.join("C:\\msys64\\mingw64\\bin", d), path.join(destination, d)) for d in deps]
133+
134+
109135
def change_prefs(resources_path, platform):
110136
print("Swapping prefs")
111137
prefs_path = path.join(resources_path, "prefs.json")
@@ -264,8 +290,14 @@ def package(self, release=False, dev=False, android=None, debug=False, debugger=
264290
browserhtml_path = get_browserhtml_path(binary_path)
265291

266292
print("Copying files")
267-
dir_to_resources = path.join(dir_to_msi, 'resources')
293+
dir_to_temp = path.join(dir_to_msi, 'temp')
294+
dir_to_temp_servo = path.join(dir_to_temp, 'servo')
295+
dir_to_resources = path.join(dir_to_temp_servo, 'resources')
268296
shutil.copytree(path.join(dir_to_root, 'resources'), dir_to_resources)
297+
shutil.copytree(browserhtml_path, path.join(dir_to_temp_servo, 'browserhtml'))
298+
shutil.copy(binary_path, dir_to_temp_servo)
299+
shutil.copy("{}.manifest".format(binary_path), dir_to_temp_servo)
300+
copy_windows_dependencies(target_dir, dir_to_temp_servo)
269301

270302
change_prefs(dir_to_resources, "windows")
271303

@@ -275,8 +307,8 @@ def package(self, release=False, dev=False, android=None, debug=False, debugger=
275307
wxs_path = path.join(dir_to_msi, "Servo.wxs")
276308
open(wxs_path, "w").write(template.render(
277309
exe_path=target_dir,
278-
resources_path=dir_to_resources,
279-
browserhtml_path=browserhtml_path))
310+
dir_to_temp=dir_to_temp_servo,
311+
resources_path=dir_to_resources))
280312

281313
# run candle and light
282314
print("Creating MSI")
@@ -293,8 +325,14 @@ def package(self, release=False, dev=False, android=None, debug=False, debugger=
293325
except subprocess.CalledProcessError as e:
294326
print("WiX light exited with return value %d" % e.returncode)
295327
return e.returncode
296-
msi_path = path.join(dir_to_msi, "Servo.msi")
297-
print("Packaged Servo into {}".format(msi_path))
328+
print("Packaged Servo into " + path.join(dir_to_msi, "Servo.msi"))
329+
330+
print("Creating ZIP")
331+
shutil.make_archive(path.join(dir_to_msi, "Servo"), "zip", dir_to_temp)
332+
print("Packaged Servo into " + path.join(dir_to_msi, "Servo.zip"))
333+
334+
print("Cleaning up")
335+
delete(dir_to_temp)
298336
else:
299337
dir_to_temp = path.join(target_dir, 'packaging-temp')
300338
browserhtml_path = get_browserhtml_path(binary_path)

support/windows/Servo.wxs.mako

+6-35
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,11 @@
4040
IconIndex="0"
4141
Advertise="yes"/>
4242
</File>
43-
<File Id="ServoManifest"
44-
Name="servo.exe.manifest"
45-
Source="${windowize(exe_path)}\servo.exe.manifest"
46-
DiskId="1"/>
47-
4843
${include_dependencies()}
4944
</Component>
5045

5146
${include_directory(resources_path, "resources")}
52-
${include_directory(browserhtml_path, "browserhtml")}
47+
${include_directory(path.join(dir_to_temp, "browserhtml"), "browserhtml")}
5348
</Directory>
5449
</Directory>
5550
</Directory>
@@ -87,9 +82,7 @@ import uuid
8782
from servo.command_base import host_triple
8883
8984
def make_id(s):
90-
s = s.replace(os.getcwd(), "").replace("-", "_").replace("/", "_").replace("\\", "_")
91-
if "browserhtml" in s:
92-
s = "browserhtml_" + s[s.index("out") + 4:]
85+
s = s.replace("-", "_").replace("/", "_").replace("\\", "_")
9386
return "Id{}".format(s)
9487
9588
def listfiles(directory):
@@ -100,30 +93,8 @@ def listdirs(directory):
10093
return [f for f in os.listdir(directory)
10194
if path.isdir(path.join(directory, f))]
10295
103-
def listdeps(exe_path):
104-
if "msvc" in host_triple():
105-
return [path.join(windowize(exe_path), d) for d in ["libeay32md.dll", "ssleay32md.dll"]]
106-
elif "gnu" in host_triple():
107-
deps = [
108-
"libstdc++-6.dll",
109-
"libwinpthread-1.dll",
110-
"libbz2-1.dll",
111-
"libgcc_s_seh-1.dll",
112-
"libexpat-1.dll",
113-
"zlib1.dll",
114-
"libpng16-16.dll",
115-
"libiconv-2.dll",
116-
"libglib-2.0-0.dll",
117-
"libgraphite2.dll",
118-
"libfreetype-6.dll",
119-
"libfontconfig-1.dll",
120-
"libintl-8.dll",
121-
"libpcre-1.dll",
122-
"libeay32.dll",
123-
"ssleay32.dll",
124-
"libharfbuzz-0.dll",
125-
]
126-
return [path.join("C:\\msys64\\mingw64\\bin", d) for d in deps]
96+
def listdeps(temp_dir):
97+
return [path.join(temp_dir, f) for f in os.listdir(temp_dir) if os.path.isfile(path.join(temp_dir, f)) and f != "servo.exe"]
12798
12899
def windowize(p):
129100
if not p.startswith("/"):
@@ -134,7 +105,7 @@ components = []
134105
%>
135106

136107
<%def name="include_dependencies()">
137-
% for f in listdeps(exe_path):
108+
% for f in listdeps(dir_to_temp):
138109
<File Id="${make_id(path.basename(f)).replace(".","").replace("+","x")}"
139110
Name="${path.basename(f)}"
140111
Source="${f}"
@@ -150,7 +121,7 @@ components = []
150121
<CreateFolder/>
151122
<% components.append(make_id(path.basename(d))) %>
152123
% for f in listfiles(d):
153-
<File Id="${make_id(path.join(d, f))}"
124+
<File Id="${make_id(path.join(d, f).replace(dir_to_temp, ""))}"
154125
Name="${f}"
155126
Source="${windowize(path.join(d, f))}"
156127
DiskId="1"/>

0 commit comments

Comments
 (0)