mirror of
https://github.com/servo/servo.git
synced 2025-06-06 00:25:37 +00:00
Add Windows packaging to create an MSI installer
This commit is contained in:
parent
4ae0897175
commit
d8c0b87eb2
7 changed files with 312 additions and 7 deletions
|
@ -9,3 +9,6 @@ ar = "arm-linux-gnueabihf-ar"
|
||||||
[target.aarch64-unknown-linux-gnu]
|
[target.aarch64-unknown-linux-gnu]
|
||||||
linker = "aarch64-linux-gnu-gcc"
|
linker = "aarch64-linux-gnu-gcc"
|
||||||
ar = "aarch64-linux-gnu-ar"
|
ar = "aarch64-linux-gnu-ar"
|
||||||
|
|
||||||
|
[target.'cfg(target_os=windows)']
|
||||||
|
linker = "./fake-ld.cmd"
|
2
components/servo/fake-ld.cmd
Normal file
2
components/servo/fake-ld.cmd
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
@echo off
|
||||||
|
gcc -mwindows %*
|
|
@ -41,8 +41,8 @@ main() {
|
||||||
extension=dmg
|
extension=dmg
|
||||||
package=target/*."${extension}"
|
package=target/*."${extension}"
|
||||||
elif [[ "${platform}" == "windows" ]]; then
|
elif [[ "${platform}" == "windows" ]]; then
|
||||||
extension=tar.gz
|
extension=msi
|
||||||
package=target/*."${extension}"
|
package=target/msi/*.msi
|
||||||
else
|
else
|
||||||
usage >&2
|
usage >&2
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -9,8 +9,11 @@
|
||||||
|
|
||||||
from __future__ import print_function, unicode_literals
|
from __future__ import print_function, unicode_literals
|
||||||
|
|
||||||
import os
|
import sys
|
||||||
import os.path as path
|
import os.path as path
|
||||||
|
sys.path.append(path.join(path.dirname(sys.argv[0]), "components", "style", "properties", "Mako-0.9.1.zip"))
|
||||||
|
|
||||||
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import tarfile
|
import tarfile
|
||||||
|
@ -24,7 +27,9 @@ from mach.decorators import (
|
||||||
Command,
|
Command,
|
||||||
)
|
)
|
||||||
|
|
||||||
from servo.command_base import CommandBase, cd, BuildNotFound, is_macosx
|
from mako.template import Template
|
||||||
|
|
||||||
|
from servo.command_base import CommandBase, cd, BuildNotFound, is_macosx, is_windows
|
||||||
from servo.post_build_commands import find_dep_path_newest
|
from servo.post_build_commands import find_dep_path_newest
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,6 +47,11 @@ def otool(s):
|
||||||
yield l.split(' ', 1)[0][1:]
|
yield l.split(' ', 1)[0][1:]
|
||||||
|
|
||||||
|
|
||||||
|
def listfiles(directory):
|
||||||
|
return [f for f in os.listdir(directory)
|
||||||
|
if path.isfile(path.join(directory, f))]
|
||||||
|
|
||||||
|
|
||||||
def install_name_tool(old, new, binary):
|
def install_name_tool(old, new, binary):
|
||||||
try:
|
try:
|
||||||
subprocess.check_call(['install_name_tool', '-change', old, '@executable_path/' + new, binary])
|
subprocess.check_call(['install_name_tool', '-change', old, '@executable_path/' + new, binary])
|
||||||
|
@ -76,7 +86,7 @@ class PackageCommands(CommandBase):
|
||||||
env["ANT_FLAVOR"] = "release"
|
env["ANT_FLAVOR"] = "release"
|
||||||
dev_flag = ""
|
dev_flag = ""
|
||||||
|
|
||||||
target_dir = os.path.dirname(binary_path)
|
target_dir = path.dirname(binary_path)
|
||||||
output_apk = "{}.apk".format(binary_path)
|
output_apk = "{}.apk".format(binary_path)
|
||||||
try:
|
try:
|
||||||
with cd(path.join("support", "android", "build-apk")):
|
with cd(path.join("support", "android", "build-apk")):
|
||||||
|
@ -91,7 +101,7 @@ class PackageCommands(CommandBase):
|
||||||
dir_to_app = dir_to_dmg + '/Servo.app'
|
dir_to_app = dir_to_dmg + '/Servo.app'
|
||||||
dir_to_resources = dir_to_app + '/Contents/Resources/'
|
dir_to_resources = dir_to_app + '/Contents/Resources/'
|
||||||
dir_to_root = '/'.join(binary_path.split('/')[:-3])
|
dir_to_root = '/'.join(binary_path.split('/')[:-3])
|
||||||
if os.path.exists(dir_to_dmg):
|
if path.exists(dir_to_dmg):
|
||||||
print("Cleaning up from previous packaging")
|
print("Cleaning up from previous packaging")
|
||||||
delete(dir_to_dmg)
|
delete(dir_to_dmg)
|
||||||
browserhtml_path = find_dep_path_newest('browserhtml', binary_path)
|
browserhtml_path = find_dep_path_newest('browserhtml', binary_path)
|
||||||
|
@ -123,7 +133,7 @@ class PackageCommands(CommandBase):
|
||||||
continue
|
continue
|
||||||
need_relinked = set(otool(f))
|
need_relinked = set(otool(f))
|
||||||
new_path = dir_to_app + '/Contents/MacOS/' + f.split('/')[-1]
|
new_path = dir_to_app + '/Contents/MacOS/' + f.split('/')[-1]
|
||||||
if not os.path.exists(new_path):
|
if not path.exists(new_path):
|
||||||
shutil.copyfile(f, new_path)
|
shutil.copyfile(f, new_path)
|
||||||
for dylib in need_relinked:
|
for dylib in need_relinked:
|
||||||
if '/System/Library' in dylib or '/usr/lib' in dylib or 'servo' in dylib:
|
if '/System/Library' in dylib or '/usr/lib' in dylib or 'servo' in dylib:
|
||||||
|
@ -153,6 +163,45 @@ class PackageCommands(CommandBase):
|
||||||
print("Cleaning up")
|
print("Cleaning up")
|
||||||
delete(dir_to_dmg)
|
delete(dir_to_dmg)
|
||||||
print("Packaged Servo into " + dmg_path)
|
print("Packaged Servo into " + dmg_path)
|
||||||
|
elif is_windows():
|
||||||
|
dir_to_package = path.dirname(binary_path)
|
||||||
|
dir_to_root = self.get_top_dir()
|
||||||
|
dir_to_msi = path.join(dir_to_package, 'msi')
|
||||||
|
if path.exists(dir_to_msi):
|
||||||
|
print("Cleaning up from previous packaging")
|
||||||
|
delete(dir_to_msi)
|
||||||
|
os.makedirs(dir_to_msi)
|
||||||
|
top_path = dir_to_root
|
||||||
|
browserhtml_path = find_dep_path_newest('browserhtml', binary_path)
|
||||||
|
if browserhtml_path is None:
|
||||||
|
print("Could not find browserhtml package; perhaps you haven't built Servo.")
|
||||||
|
return 1
|
||||||
|
browserhtml_path = path.join(browserhtml_path, "out")
|
||||||
|
# generate Servo.wxs
|
||||||
|
template_path = path.join(dir_to_root, "support", "windows", "Servo.wxs.mako")
|
||||||
|
template = Template(open(template_path).read())
|
||||||
|
wxs_path = path.join(dir_to_msi, "Servo.wxs")
|
||||||
|
open(wxs_path, "w").write(template.render(
|
||||||
|
exe_path=dir_to_package,
|
||||||
|
top_path=top_path,
|
||||||
|
browserhtml_path=browserhtml_path))
|
||||||
|
# run candle and light
|
||||||
|
print("Creating MSI")
|
||||||
|
try:
|
||||||
|
with cd(dir_to_msi):
|
||||||
|
subprocess.check_call(['candle', wxs_path])
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
print("WiX candle exited with return value %d" % e.returncode)
|
||||||
|
return e.returncode
|
||||||
|
try:
|
||||||
|
wxsobj_path = "{}.wixobj".format(path.splitext(wxs_path)[0])
|
||||||
|
with cd(dir_to_msi):
|
||||||
|
subprocess.check_call(['light', wxsobj_path])
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
print("WiX light exited with return value %d" % e.returncode)
|
||||||
|
return e.returncode
|
||||||
|
msi_path = path.join(dir_to_msi, "Servo.msi")
|
||||||
|
print("Packaged Servo into {}".format(msi_path))
|
||||||
else:
|
else:
|
||||||
dir_to_package = '/'.join(binary_path.split('/')[:-1])
|
dir_to_package = '/'.join(binary_path.split('/')[:-1])
|
||||||
dir_to_root = '/'.join(binary_path.split('/')[:-3])
|
dir_to_root = '/'.join(binary_path.split('/')[:-3])
|
||||||
|
|
BIN
resources/Servo.ico
Normal file
BIN
resources/Servo.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
207
support/windows/Servo.wxs.mako
Normal file
207
support/windows/Servo.wxs.mako
Normal file
|
@ -0,0 +1,207 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
|
||||||
|
<Product Name="Servo Tech Demo"
|
||||||
|
Manufacturer="Mozilla Research"
|
||||||
|
Id="5807391a-3a17-476b-a5d2-5f1912569762"
|
||||||
|
UpgradeCode="060cd15d-eab1-4614-b438-3988e3efdcf1"
|
||||||
|
Language="1033"
|
||||||
|
Codepage="1252"
|
||||||
|
Version="1.0.0">
|
||||||
|
<Package Id="*"
|
||||||
|
Keywords="Installer"
|
||||||
|
Description="Servo Tech Demo Installer"
|
||||||
|
Manufacturer="Mozilla Research"
|
||||||
|
InstallerVersion="200"
|
||||||
|
Platform="x64"
|
||||||
|
Languages="1033"
|
||||||
|
SummaryCodepage="1252"
|
||||||
|
Compressed="yes"/>
|
||||||
|
<Media Id="1"
|
||||||
|
Cabinet="Servo.cab"
|
||||||
|
EmbedCab="yes"/>
|
||||||
|
<Directory Id="TARGETDIR" Name="SourceDir">
|
||||||
|
<Directory Id="ProgramFiles64Folder" Name="PFiles">
|
||||||
|
<Directory Id="MozResearch" Name="Mozilla Research">
|
||||||
|
<Directory Id="INSTALLDIR" Name="Servo Tech Demo">
|
||||||
|
<Component Id="Servo"
|
||||||
|
Guid="95bcea71-78bb-4ec8-9766-44bc01443840"
|
||||||
|
Win64="yes">
|
||||||
|
<File Id="ServoEXE"
|
||||||
|
Name="servo.exe"
|
||||||
|
DiskId="1"
|
||||||
|
Source="${windowize(exe_path)}\servo.exe"
|
||||||
|
KeyPath="yes">
|
||||||
|
<Shortcut Id="StartMenuServoTechDemo"
|
||||||
|
Directory="ProgramMenuDir"
|
||||||
|
Name="Servo Tech Demo"
|
||||||
|
WorkingDirectory="INSTALLDIR"
|
||||||
|
Icon="Servo.ico"
|
||||||
|
IconIndex="0"
|
||||||
|
Arguments="-w --pref dom.mozbrowser.enabled --pref shell.builtin-key-shortcuts.enabled=false browserhtml\index.html"
|
||||||
|
Advertise="yes"/>
|
||||||
|
</File>
|
||||||
|
<File Id="ServoManifest"
|
||||||
|
Name="servo.exe.manifest"
|
||||||
|
Source="${windowize(exe_path)}\servo.exe.manifest"
|
||||||
|
DiskId="1"/>
|
||||||
|
|
||||||
|
<File Id="StdcxxDLL"
|
||||||
|
Name="libstdc++-6.dll"
|
||||||
|
Source="C:\msys64\mingw64\bin\libstdc++-6.dll"
|
||||||
|
DiskId="1"/>
|
||||||
|
<File Id="WinpthreadDll"
|
||||||
|
Name="libwinpthread-1.dll"
|
||||||
|
Source="C:\msys64\mingw64\bin\libwinpthread-1.dll"
|
||||||
|
DiskId="1"/>
|
||||||
|
<File Id="Bzip2Dll"
|
||||||
|
Name="libbz2-1.dll"
|
||||||
|
Source="C:\msys64\mingw64\bin\libbz2-1.dll"
|
||||||
|
DiskId="1"/>
|
||||||
|
<File Id="GccsehDll"
|
||||||
|
Name="libgcc_s_seh-1.dll"
|
||||||
|
Source="C:\msys64\mingw64\bin\libgcc_s_seh-1.dll"
|
||||||
|
DiskId="1"/>
|
||||||
|
<File Id="ExpatDll"
|
||||||
|
Name="libexpat-1.dll"
|
||||||
|
Source="C:\msys64\mingw64\bin\libexpat-1.dll"
|
||||||
|
DiskId="1"/>
|
||||||
|
<File Id="ZlibDll"
|
||||||
|
Name="zlib1.dll"
|
||||||
|
Source="C:\msys64\mingw64\bin\zlib1.dll"
|
||||||
|
DiskId="1"/>
|
||||||
|
<File Id="PngDll"
|
||||||
|
Name="libpng16-16.dll"
|
||||||
|
Source="C:\msys64\mingw64\bin\libpng16-16.dll"
|
||||||
|
DiskId="1"/>
|
||||||
|
<File Id="IconvDll"
|
||||||
|
Name="libiconv-2.dll"
|
||||||
|
Source="C:\msys64\mingw64\bin\libiconv-2.dll"
|
||||||
|
DiskId="1"/>
|
||||||
|
<File Id="GlibDll"
|
||||||
|
Name="libglib-2.0-0.dll"
|
||||||
|
Source="C:\msys64\mingw64\bin\libglib-2.0-0.dll"
|
||||||
|
DiskId="1"/>
|
||||||
|
<File Id="GraphiteDll"
|
||||||
|
Name="libgraphite2.dll"
|
||||||
|
Source="C:\msys64\mingw64\bin\libgraphite2.dll"
|
||||||
|
DiskId="1"/>
|
||||||
|
<File Id="IntlDll"
|
||||||
|
Name="libintl-8.dll"
|
||||||
|
Source="C:\msys64\mingw64\bin\libintl-8.dll"
|
||||||
|
DiskId="1"/>
|
||||||
|
<File Id="PcreDll"
|
||||||
|
Name="libpcre-1.dll"
|
||||||
|
Source="C:\msys64\mingw64\bin\libpcre-1.dll"
|
||||||
|
DiskId="1"/>
|
||||||
|
<File Id="Eay32Dll"
|
||||||
|
Name="libeay32.dll"
|
||||||
|
Source="C:\msys64\mingw64\bin\libeay32.dll"
|
||||||
|
DiskId="1"/>
|
||||||
|
<File Id="Ssleay32Dll"
|
||||||
|
Name="ssleay32.dll"
|
||||||
|
Source="C:\msys64\mingw64\bin\ssleay32.dll"
|
||||||
|
DiskId="1"/>
|
||||||
|
<File Id="HarfbuzzDll"
|
||||||
|
Name="libharfbuzz-0.dll"
|
||||||
|
Source="C:\msys64\mingw64\bin\libharfbuzz-0.dll"
|
||||||
|
DiskId="1"/>
|
||||||
|
<File Id="FreetypeDll"
|
||||||
|
Name="libfreetype-6.dll"
|
||||||
|
Source="C:\msys64\mingw64\bin\libfreetype-6.dll"
|
||||||
|
DiskId="1"/>
|
||||||
|
<File Id="FontconfigDll"
|
||||||
|
Name="libfontconfig-1.dll"
|
||||||
|
Source="C:\msys64\mingw64\bin\libfontconfig-1.dll"
|
||||||
|
DiskId="1"/>
|
||||||
|
</Component>
|
||||||
|
|
||||||
|
<Directory Id="EtcDir" Name="etc">
|
||||||
|
<Directory Id="FontsDir" Name="fonts">
|
||||||
|
<Component Id="FontsDir"
|
||||||
|
Guid="8d37ee61-9237-438d-b976-f163bd6b0578"
|
||||||
|
Win64="yes">
|
||||||
|
<File Id="ServoFontsConfig"
|
||||||
|
KeyPath="yes"
|
||||||
|
Name="fonts.conf"
|
||||||
|
Source="${windowize(top_path)}\support\windows\fonts.conf"
|
||||||
|
DiskId="1"/>
|
||||||
|
</Component>
|
||||||
|
</Directory>
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
${include_directory(path.join(top_path, "resources"), "resources")}
|
||||||
|
${include_directory(browserhtml_path, "browserhtml")}
|
||||||
|
</Directory>
|
||||||
|
</Directory>
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
<Directory Id="ProgramMenuFolder" Name="Programs">
|
||||||
|
<Directory Id="ProgramMenuDir" Name="Servo Tech Demo">
|
||||||
|
<Component Id="ProgramMenuDir" Guid="e04737ce-16eb-4977-9b4c-ed2db8a5a77d">
|
||||||
|
<RemoveFolder Id="ProgramMenuDir" On="uninstall"/>
|
||||||
|
<RegistryValue Root="HKCU"
|
||||||
|
Key="Software\Mozilla Research\Servo Tech Demo"
|
||||||
|
Type="string"
|
||||||
|
Value=""
|
||||||
|
KeyPath="yes"/>
|
||||||
|
</Component>
|
||||||
|
</Directory>
|
||||||
|
</Directory>
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
<Feature Id="Complete" Level="1">
|
||||||
|
<ComponentRef Id="Servo"/>
|
||||||
|
<ComponentRef Id="FontsDir"/>
|
||||||
|
% for c in components:
|
||||||
|
<ComponentRef Id="${c}"/>
|
||||||
|
% endfor
|
||||||
|
<ComponentRef Id="ProgramMenuDir"/>
|
||||||
|
</Feature>
|
||||||
|
|
||||||
|
<Icon Id="Servo.ico" SourceFile="${windowize(top_path)}\resources\Servo.ico"/>
|
||||||
|
</Product>
|
||||||
|
</Wix>
|
||||||
|
<%!
|
||||||
|
import os
|
||||||
|
import os.path as path
|
||||||
|
import re
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
def make_id(s):
|
||||||
|
return "Id{}".format(s.replace("-", "_").replace("/", "_"))
|
||||||
|
|
||||||
|
def listfiles(directory):
|
||||||
|
return [f for f in os.listdir(directory)
|
||||||
|
if path.isfile(path.join(directory, f))]
|
||||||
|
|
||||||
|
def listdirs(directory):
|
||||||
|
return [f for f in os.listdir(directory)
|
||||||
|
if path.isdir(path.join(directory, f))]
|
||||||
|
|
||||||
|
def windowize(p):
|
||||||
|
if not p.startswith("/"):
|
||||||
|
return p
|
||||||
|
return re.sub("^/([^/])+", "\\1:", p)
|
||||||
|
|
||||||
|
components = []
|
||||||
|
%>
|
||||||
|
<%def name="include_directory(d, n)">
|
||||||
|
<Directory Id="${make_id(path.basename(d))}" Name="${n}">
|
||||||
|
<Component Id="${make_id(path.basename(d))}"
|
||||||
|
Guid="${uuid.uuid4()}"
|
||||||
|
Win64="yes">
|
||||||
|
<CreateFolder/>
|
||||||
|
<% components.append(make_id(path.basename(d))) %>
|
||||||
|
% for f in listfiles(d):
|
||||||
|
<File Id="${make_id(path.join(d, f))}"
|
||||||
|
Name="${f}"
|
||||||
|
Source="${windowize(path.join(d, f))}"
|
||||||
|
DiskId="1"/>
|
||||||
|
% endfor
|
||||||
|
</Component>
|
||||||
|
|
||||||
|
% for f in listdirs(d):
|
||||||
|
${include_directory(path.join(d, f), f)}
|
||||||
|
% endfor
|
||||||
|
</Directory>
|
||||||
|
</%def>
|
44
support/windows/fonts.conf
Normal file
44
support/windows/fonts.conf
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
|
||||||
|
<fontconfig>
|
||||||
|
<dir>C:\Windows\Fonts</dir>
|
||||||
|
<!--
|
||||||
|
Accept deprecated 'mono' alias, replacing it with 'monospace'
|
||||||
|
-->
|
||||||
|
<match target="pattern">
|
||||||
|
<test qual="any" name="family">
|
||||||
|
<string>mono</string>
|
||||||
|
</test>
|
||||||
|
<edit name="family" mode="assign" binding="same">
|
||||||
|
<string>monospace</string>
|
||||||
|
</edit>
|
||||||
|
</match>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Accept alternate 'sans serif' spelling, replacing it with 'sans-serif'
|
||||||
|
-->
|
||||||
|
<match target="pattern">
|
||||||
|
<test qual="any" name="family">
|
||||||
|
<string>sans serif</string>
|
||||||
|
</test>
|
||||||
|
<edit name="family" mode="assign" binding="same">
|
||||||
|
<string>sans-serif</string>
|
||||||
|
</edit>
|
||||||
|
</match>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Accept deprecated 'sans' alias, replacing it with 'sans-serif'
|
||||||
|
-->
|
||||||
|
<match target="pattern">
|
||||||
|
<test qual="any" name="family">
|
||||||
|
<string>sans</string>
|
||||||
|
</test>
|
||||||
|
<edit name="family" mode="assign" binding="same">
|
||||||
|
<string>sans-serif</string>
|
||||||
|
</edit>
|
||||||
|
</match>
|
||||||
|
|
||||||
|
<!-- Font cache directory list -->
|
||||||
|
|
||||||
|
<cachedir>~/.fontconfig</cachedir>
|
||||||
|
</fontconfig>
|
Loading…
Add table
Add a link
Reference in a new issue