Skip to content

Commit

Permalink
Do not require setting PKG_CONFIG_PATH on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ferjm committed Aug 20, 2019
1 parent 00a9f30 commit 72e28df
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 28 deletions.
19 changes: 1 addition & 18 deletions python/servo/build_commands.py
Expand Up @@ -30,7 +30,7 @@
from mach.registrar import Registrar

from mach_bootstrap import _get_exec_path
from servo.command_base import CommandBase, cd, call, check_call, BIN_SUFFIX, append_to_path_env
from servo.command_base import CommandBase, cd, call, check_call, BIN_SUFFIX, append_to_path_env, gstreamer_root
from servo.util import host_triple


Expand Down Expand Up @@ -776,23 +776,6 @@ def package_openxr_dlls(self, env, servo_exe_dir, target):
return True


def gstreamer_root(target, env):
arch = {
"x86_64": "X86_64",
"x86": "X86",
"aarch64": "ARM64",
}
gst_x64 = arch[target.split('-')[0]]
gst_default_path = path.join("C:\\gstreamer\\1.0", gst_x64)
gst_env = "GSTREAMER_1_0_ROOT_" + gst_x64
if env.get(gst_env) is not None:
return env.get(gst_env)
elif os.path.exists(path.join(gst_default_path, "bin", "ffi-7.dll")):
return gst_default_path
else:
return None


def package_gstreamer_dlls(env, servo_exe_dir, target, uwp):
gst_root = gstreamer_root(target, env)
if not gst_root:
Expand Down
38 changes: 28 additions & 10 deletions python/servo/command_base.py
Expand Up @@ -239,6 +239,25 @@ def set_osmesa_env(bin_path, env):
return env


def gstreamer_root(target, env, topdir=None):
if is_windows:
arch = {
"x86_64": "X86_64",
"x86": "X86",
"aarch64": "ARM64",
}
gst_x64 = arch[target.split('-')[0]]
gst_default_path = path.join("C:\\gstreamer\\1.0", gst_x64)
gst_env = "GSTREAMER_1_0_ROOT_" + gst_x64
if env.get(gst_env) is not None:
return env.get(gst_env)
elif os.path.exists(path.join(gst_default_path, "bin", "ffi-7.dll")):
return gst_default_path
elif sys.platform == "linux2":
return path.join(topdir, "support", "linux", "gstreamer", "gst")
return None


class BuildNotFound(Exception):
def __init__(self, message):
self.message = message
Expand Down Expand Up @@ -365,9 +384,6 @@ def get_apk_path(self, release):
build_type = "release" if release else "debug"
return path.join(base_path, build_type, apk_name)

def get_gstreamer_path(self):
return path.join(self.context.topdir, "support", "linux", "gstreamer", "gst")

def get_binary_path(self, release, dev, target=None, android=False, magicleap=False, simpleservo=False):
# TODO(autrilla): this function could still use work - it shouldn't
# handle quitting, or printing. It should return the path, or an error.
Expand Down Expand Up @@ -542,7 +558,7 @@ def get_nightly_binary_path(self, nightly_date):

return self.get_executable(destination_folder)

def needs_gstreamer_env(self, target):
def needs_gstreamer_env(self, target, env):
try:
if check_gstreamer_lib():
return False
Expand All @@ -554,8 +570,8 @@ def needs_gstreamer_env(self, target):
if "x86_64" not in effective_target or "android" in effective_target:
# We don't build gstreamer for non-x86_64 / android yet
return False
if sys.platform == "linux2":
if path.isdir(self.get_gstreamer_path()):
if sys.platform == "linux2" or is_windows:
if path.isdir(gstreamer_root(effective_target, env, self.get_top_dir)):
return True
else:
raise Exception("Your system's gstreamer libraries are out of date \
Expand All @@ -569,8 +585,10 @@ def needs_gstreamer_env(self, target):
def set_run_env(self, android=False):
"""Some commands, like test-wpt, don't use a full build env,
but may still need dynamic search paths. This command sets that up"""
if not android and self.needs_gstreamer_env(None):
gstpath = self.get_gstreamer_path()
if not android and self.needs_gstreamer_env(None, os.environ):
gstpath = gstreamer_root(host_triple(), os.environ, self.get_top_dir)
if gstpath is None:
return
os.environ["LD_LIBRARY_PATH"] = path.join(gstpath, "lib")
os.environ["GST_PLUGIN_SYSTEM_PATH"] = path.join(gstpath, "lib", "gstreamer-1.0")
os.environ["PKG_CONFIG_PATH"] = path.join(gstpath, "lib", "pkgconfig")
Expand Down Expand Up @@ -624,8 +642,8 @@ def build_env(self, hosts_file_path=None, target=None, is_build=False, test_unit
# Always build harfbuzz from source
env["HARFBUZZ_SYS_NO_PKG_CONFIG"] = "true"

if self.needs_gstreamer_env(target):
gstpath = self.get_gstreamer_path()
if self.needs_gstreamer_env(target or host_triple(), env):
gstpath = gstreamer_root(target or host_triple(), env, self.get_top_dir())
extra_path += [path.join(gstpath, "bin")]
libpath = path.join(gstpath, "lib")
# we append in the reverse order so that system gstreamer libraries
Expand Down

0 comments on commit 72e28df

Please sign in to comment.