Skip to content


Windows: Add missing dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
UK992 committed Dec 1, 2018
1 parent a011682 commit f4d3d8e
Showing 1 changed file with 100 additions and 0 deletions.
100 changes: 100 additions & 0 deletions python/servo/
Expand Up @@ -18,6 +18,7 @@
import sys
import urllib
import zipfile
import stat

from time import time

Expand Down Expand Up @@ -587,6 +588,105 @@ def build(self, target=None, release=False, dev=False, jobs=None,
for ssl_lib in ["libcryptoMD.dll", "libsslMD.dll"]:
shutil.copy(path.join(env['OPENSSL_LIB_DIR'], "../bin" + msvc_x64, ssl_lib),
# Search for the generated nspr4.dll
build_path = path.join(servo_exe_dir, "build")
nspr4 = "nspr4.dll"
nspr4_path = None
for root, dirs, files in os.walk(build_path):
if nspr4 in files:
nspr4_path = path.join(root, nspr4)
if nspr4_path is None:
print("WARNING: could not find nspr4.dll")
shutil.copy(nspr4_path, servo_exe_dir)
# copy needed gstreamer DLLs in to servo.exe dir
gst_x64 = "X86_64" if msvc_x64 == "64" else "X86"
gst_root = ""
gst_default_path = path.join("C:\\gstreamer\\1.0", gst_x64)
gst_env = "GSTREAMER_1_0_ROOT_" + gst_x64
if os.path.exists(path.join(gst_default_path, "bin", "libz.dll")):
gst_root = gst_default_path
elif os.environ.get(gst_env) is not None:
gst_root = os.environ.get(gst_env)
print("Could not found GStreamer installation directory.")
status = 1
gst_dlls = [
if gst_root:
for gst_lib in gst_dlls:
shutil.copy(path.join(gst_root, "bin", gst_lib),
# copy some MSVC DLLs to servo.exe dir
msvc_redist_dir = None
vs_platform = os.environ.get("PLATFORM", "").lower()
vc_dir = os.environ.get("VCINSTALLDIR", "")
vs_version = os.environ.get("VisualStudioVersion", "")
msvc_deps = [
# Check if it's Visual C++ Build Tools or Visual Studio 2015
vs14_vcvars = path.join(vc_dir, "vcvarsall.bat")
is_vs14 = True if os.path.isfile(vs14_vcvars) or vs_version == "14.0" else False
if is_vs14:
msvc_redist_dir = path.join(vc_dir, "redist", vs_platform, "Microsoft.VC140.CRT")
elif vs_version == "15.0":
redist_dir = path.join(os.environ.get("VCINSTALLDIR", ""), "Redist", "MSVC")
if os.path.isdir(redist_dir):
for p in os.listdir(redist_dir)[::-1]:
redist_path = path.join(redist_dir, p)
for v in ["VC141", "VC150"]:
# there are two possible paths
# `x64\Microsoft.VC*.CRT` or `onecore\x64\Microsoft.VC*.CRT`
redist1 = path.join(redist_path, vs_platform, "Microsoft.{}.CRT".format(v))
redist2 = path.join(redist_path, "onecore", vs_platform, "Microsoft.{}.CRT".format(v))
if os.path.isdir(redist1):
msvc_redist_dir = redist1
elif os.path.isdir(redist2):
msvc_redist_dir = redist2
if msvc_redist_dir:
if msvc_redist_dir:
redist_dirs = [
path.join(os.environ["WindowsSdkDir"], "Redist", "ucrt", "DLLs", vs_platform),
for msvc_dll in msvc_deps:
dll_found = False
for dll_dir in redist_dirs:
dll = path.join(dll_dir, msvc_dll)
servo_dir_dll = path.join(servo_exe_dir, msvc_dll)
if os.path.isfile(dll):
if os.path.isfile(servo_dir_dll):
# avoid permission denied error when overwrite dll in servo build directory
os.chmod(servo_dir_dll, stat.S_IWUSR)
shutil.copy(dll, servo_exe_dir)
dll_found = True
if not dll_found:
print("DLL file `{}` not found!".format(msvc_dll))
status = 1

elif sys.platform == "darwin":
# On the Mac, set a lovely icon. This makes it easier to pick out the Servo binary in tools
Expand Down

0 comments on commit f4d3d8e

Please sign in to comment.