Auto merge of #21968 - UK992:mach-package, r=jdm

Windows: Add missing dependencies

Rebased https://github.com/servo/servo/pull/16445 and updated with Gstreamer DLLs.

About msi installer, there is also included gstreamer installer, should be removed and replaced by needed gstreamer DLLs or keep it at is it?

Fixes #16422.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21968)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-02-01 18:02:59 -05:00 committed by GitHub
commit 363073568e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 139 additions and 55 deletions

View file

@ -18,6 +18,7 @@ import subprocess
import sys
import urllib
import zipfile
import stat
from time import time
@ -592,6 +593,105 @@ class MachCommands(CommandBase):
for ssl_lib in ["libcryptoMD.dll", "libsslMD.dll"]:
shutil.copy(path.join(env['OPENSSL_LIB_DIR'], "../bin" + msvc_x64, ssl_lib),
servo_exe_dir)
# 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)
break
if nspr4_path is None:
print("WARNING: could not find nspr4.dll")
else:
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)
else:
print("Could not found GStreamer installation directory.")
status = 1
gst_dlls = [
"libz.dll",
"libintl-8.dll",
"liborc-0.4-0.dll",
"libwinpthread-1.dll",
"libffi-7.dll",
"libgobject-2.0-0.dll",
"libglib-2.0-0.dll",
"libgmodule-2.0-0.dll",
"libgstreamer-1.0-0.dll",
"libgstplayer-1.0-0.dll",
"libgstapp-1.0-0.dll",
"libgstaudio-1.0-0.dll",
"libgstvideo-1.0-0.dll",
"libgsttag-1.0-0.dll",
"libgstbase-1.0-0.dll",
"libgstpbutils-1.0-0.dll",
]
if gst_root:
for gst_lib in gst_dlls:
shutil.copy(path.join(gst_root, "bin", gst_lib),
servo_exe_dir)
# 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 = [
"api-ms-win-crt-runtime-l1-1-0.dll",
"msvcp140.dll",
"vcruntime140.dll",
]
# 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
break
elif os.path.isdir(redist2):
msvc_redist_dir = redist2
break
if msvc_redist_dir:
break
if msvc_redist_dir:
redist_dirs = [
msvc_redist_dir,
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
break
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