From 11209c9fee52bab9eff850e96fc7711a4ec26dab Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 3 Sep 2018 12:06:27 +0530 Subject: [PATCH 01/18] Add gstreamer setup script; use --- python/servo/command_base.py | 17 ++++++++++++++++- support/linux/gstreamer/.gitignore | 2 ++ support/linux/gstreamer/gstreamer.sh | 4 ++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 support/linux/gstreamer/.gitignore create mode 100644 support/linux/gstreamer/gstreamer.sh diff --git a/python/servo/command_base.py b/python/servo/command_base.py index 7d81b5a29ef..e8c43b07595 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -476,6 +476,10 @@ class CommandBase(object): bin_folder = path.join(destination_folder, "PFiles", "Mozilla research", "Servo Tech Demo") return path.join(bin_folder, "servo{}".format(BIN_SUFFIX)) + def check_gstreamer_lib(self): + return subprocess.call(["pkg-config", "gstreamer-1.0 >= 1.12"], + stdout=PIPE, stderr=PIPE) == 0 + def build_env(self, hosts_file_path=None, target=None, is_build=False, test_unit=False): """Return an extended environment dictionary.""" env = os.environ.copy() @@ -513,12 +517,23 @@ class CommandBase(object): # Link LLVM env["LIBCLANG_PATH"] = path.join(package_dir("llvm"), "lib") - if is_windows(): if not os.environ.get("NATIVE_WIN32_PYTHON"): env["NATIVE_WIN32_PYTHON"] = sys.executable # Always build harfbuzz from source env["HARFBUZZ_SYS_NO_PKG_CONFIG"] = "true" + gstpath = path.join(os.getcwd(), "support", "linux", "gstreamer", "gstreamer") + if sys.platform == "linux2" and path.isdir(gstpath): + if True: + if "x86_64" not in (target or host_triple()): + raise Exception("We don't currently support using local gstreamer builds \ + for non-x86_64, please file a bug") + extra_path += [path.join(gstpath, "bin")] + libpath = path.join(gstpath, "lib", "x86_64-linux-gnu") + extra_path += [libpath] + extra_lib += [libpath] + append_to_path_env(path.join(libpath, "pkgconfig"), env, "PKG_CONFIG_PATH") + if extra_path: env["PATH"] = "%s%s%s" % (os.pathsep.join(extra_path), os.pathsep, env["PATH"]) diff --git a/support/linux/gstreamer/.gitignore b/support/linux/gstreamer/.gitignore new file mode 100644 index 00000000000..3b805050af7 --- /dev/null +++ b/support/linux/gstreamer/.gitignore @@ -0,0 +1,2 @@ +gstreamer/ + diff --git a/support/linux/gstreamer/gstreamer.sh b/support/linux/gstreamer/gstreamer.sh new file mode 100644 index 00000000000..436f926b535 --- /dev/null +++ b/support/linux/gstreamer/gstreamer.sh @@ -0,0 +1,4 @@ +wget https://github.com/ferjm/gstreamer-1.14.1-ubuntu-trusty/raw/master/gstreamer.tar.gz +tar -zxvf gstreamer.tar.gz +rm gstreamer.tar.gz +sed -i "s;prefix=/root/gstreamer;prefix=$PWD/gstreamer;g" $PWD/gstreamer/lib/x86_64-linux-gnu/pkgconfig/*.pc From 1913ac706cef91125fa8e50629548826c60a66d3 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 3 Sep 2018 13:18:25 +0530 Subject: [PATCH 02/18] Make ./mach bootstrap into a full-fledged linux dependency installer --- README.md | 6 +++ python/servo/bootstrap.py | 69 +++++++++++++++++++++++++++--- python/servo/bootstrap_commands.py | 9 ++++ python/servo/command_base.py | 7 +-- 4 files changed, 79 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index db98506d280..54d8c8fc793 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,8 @@ If you've already partially compiled servo but forgot to do this step, run `./ma #### On Debian-based Linuxes +Simply running `./mach bootstrap` should be enough. If not, run the commands below: + ``` sh sudo apt install git curl autoconf libx11-dev \ libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \ @@ -98,6 +100,8 @@ If `virtualenv` does not exist, try `python-virtualenv`. #### On Fedora +Simply running `./mach bootstrap` should be enough. If not, run the commands below: + ``` sh sudo dnf install curl libtool gcc-c++ libXi-devel \ freetype-devel mesa-libGL-devel mesa-libEGL-devel glib2-devel libX11-devel libXrandr-devel gperf \ @@ -108,6 +112,8 @@ sudo dnf install curl libtool gcc-c++ libXi-devel \ ``` #### On CentOS +Simply running `./mach bootstrap` should be enough. If not, run the commands below: + ``` sh sudo yum install curl libtool gcc-c++ libXi-devel \ freetype-devel mesa-libGL-devel mesa-libEGL-devel glib2-devel libX11-devel libXrandr-devel gperf \ diff --git a/python/servo/bootstrap.py b/python/servo/bootstrap.py index e20fda210a6..7bfa80bd8f4 100644 --- a/python/servo/bootstrap.py +++ b/python/servo/bootstrap.py @@ -17,22 +17,27 @@ import servo.packages as packages from servo.util import extract, download_file, host_triple +def check_gstreamer_lib(): + subprocess.call(["pkg-config", "gstreamer-1.0 >= 1.12"], + stdout=PIPE, stderr=PIPE) == 0 + def run_as_root(command): if os.geteuid() != 0: command.insert(0, 'sudo') return subprocess.call(command) -def install_salt_dependencies(context, force): +def install_linux_deps(context, pkgs_ubuntu, pkgs_fedora, force): install = False + pkgs = [] if context.distro == 'Ubuntu': - pkgs = ['build-essential', 'libssl-dev', 'libffi-dev', 'python-dev'] command = ['apt-get', 'install'] + pkgs = pkgs_ubuntu if subprocess.call(['dpkg', '-s'] + pkgs, stdout=PIPE, stderr=PIPE) != 0: install = True elif context.distro in ['CentOS', 'CentOS Linux', 'Fedora']: installed_pkgs = str(subprocess.check_output(['rpm', '-qa'])).replace('\n', '|') - pkgs = ['gcc', 'libffi-devel', 'python-devel', 'openssl-devel'] + pkgs = pkgs_fedora for p in pkgs: command = ['dnf', 'install'] if "|{}".format(p) not in installed_pkgs: @@ -42,9 +47,52 @@ def install_salt_dependencies(context, force): if install: if force: command.append('-y') - print("Installing missing Salt dependencies...") + print("Installing missing dependencies...") run_as_root(command + pkgs) +def install_salt_dependencies(context, force): + pkgs_apt = ['build-essential', 'libssl-dev', 'libffi-dev', 'python-dev'] + pkgs_dnf = ['gcc', 'libffi-devel', 'python-devel', 'openssl-devel'] + install_linux_deps(context, pkgs_apt, pkgs_dnf, force) + +def gstreamer(context, force=False): + pass + +def linux(context, force=False): + # Please keep these in sync with the packages in README.md + pkgs_apt = ['git', 'curl', 'autoconf', 'libx11-dev', 'libfreetype6-dev', + 'libgl1-mesa-dri', 'libglib2.0-dev', 'xorg-dev', 'gperf', 'g++', + 'build-essential', 'cmake', 'virtualenv', 'python-pip', + 'libbz2-dev', 'libosmesa6-dev', 'libxmu6', 'libxmu-dev', 'libglu1-mesa-dev', + 'libgles2-mesa-dev', 'libegl1-mesa-dev', 'libdbus-1-dev', 'libharfbuzz-dev', + 'ccache', 'clang', 'libgstreamer1.0-dev', 'libgstreamer-plugins-base1.0-dev', + 'libgstreamer-plugins-bad1.0-dev', 'autoconf2.13'] + pkgs_dnf = ['libtool', 'gcc-c++', 'libXi-devel', 'freetype-devel', + 'mesa-libGL-devel', 'mesa-libEGL-devel', 'glib2-devel', 'libX11-devel', + 'libXrandr-devel', 'gperf', 'fontconfig-devel', 'cabextract', 'ttmkfdir', + 'python2', 'python2-virtualenv', 'python2-pip', 'expat-devel', 'rpm-build', + 'openssl-devel', 'cmake', 'bzip2-devel', 'libXcursor-devel', 'libXmu-devel', + 'mesa-libOSMesa-devel', 'dbus-devel', 'ncurses-devel', 'harfbuzz-devel', + 'ccache', 'mesa-libGLU-devel', 'clang', 'clang-libs', 'gstreamer1-devel', + 'gstreamer1-plugins-base-devel', 'gstreamer1-plugins-bad-free-devel', 'autoconf213'] + if context.distro == "Ubuntu": + if context.distro_version == "17.04": + pkgs_apt += ["libssl-dev"] + elif int(context.distro_version.split(".")[0]) < 17: + pkgs_apt += ["libssl-dev"] + else: + pkgs_apt += ["libssl1.0-dev"] + elif context.distro == "Debian" and context.distro_version == "Sid": + pkgs_apt += ["libssl-dev"] + else: + pkgs_apt += ["libssl1.0-dev"] + + install_linux_deps(context, pkgs_apt, pkgs_dnf, force) + + if not check_gstreamer_lib(): + gstreamer(context, force) + + def salt(context, force=False): # Ensure Salt dependencies are installed @@ -226,11 +274,10 @@ def windows_msvc(context, force=False): return 0 -def bootstrap(context, force=False): +def bootstrap(context, force=False, specific=None): '''Dispatches to the right bootstrapping function for the OS.''' bootstrapper = None - if "windows-msvc" in host_triple(): bootstrapper = windows_msvc elif "linux-gnu" in host_triple(): @@ -243,7 +290,15 @@ def bootstrap(context, force=False): 'ubuntu', ]: context.distro = distro - bootstrapper = salt + context.distro_version = version + if specific == "salt": + bootstrapper = salt + elif specific == "gstreamer": + bootstrapper = gstreamer + else: + bootstrapper = linux + else: + raise Exception("mach bootstrap does not support %s, please file a bug" % distro) if bootstrapper is None: print('Bootstrap support is not yet available for your OS.') diff --git a/python/servo/bootstrap_commands.py b/python/servo/bootstrap_commands.py index 28e39916f39..66508c5b959 100644 --- a/python/servo/bootstrap_commands.py +++ b/python/servo/bootstrap_commands.py @@ -55,6 +55,15 @@ class MachCommands(CommandBase): def bootstrap(self, force=False): return bootstrap.bootstrap(self.context, force=force) + @Command('bootstrap-salt', + description='Install and set up the salt environment.', + category='bootstrap') + @CommandArgument('--force', '-f', + action='store_true', + help='Boostrap without confirmation') + def bootstrap_salt(self, force=False): + return bootstrap.bootstrap(self.context, force=force, specific="salt") + @Command('bootstrap-android', description='Install the Android SDK and NDK.', category='bootstrap') diff --git a/python/servo/command_base.py b/python/servo/command_base.py index e8c43b07595..c997b0bcc80 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -24,6 +24,7 @@ import tarfile from xml.etree.ElementTree import XML from servo.util import download_file import urllib2 +from bootstrap import check_gstreamer_lib from mach.registrar import Registrar import toml @@ -476,10 +477,6 @@ class CommandBase(object): bin_folder = path.join(destination_folder, "PFiles", "Mozilla research", "Servo Tech Demo") return path.join(bin_folder, "servo{}".format(BIN_SUFFIX)) - def check_gstreamer_lib(self): - return subprocess.call(["pkg-config", "gstreamer-1.0 >= 1.12"], - stdout=PIPE, stderr=PIPE) == 0 - def build_env(self, hosts_file_path=None, target=None, is_build=False, test_unit=False): """Return an extended environment dictionary.""" env = os.environ.copy() @@ -524,7 +521,7 @@ class CommandBase(object): gstpath = path.join(os.getcwd(), "support", "linux", "gstreamer", "gstreamer") if sys.platform == "linux2" and path.isdir(gstpath): - if True: + if not check_gstreamer_lib(): if "x86_64" not in (target or host_triple()): raise Exception("We don't currently support using local gstreamer builds \ for non-x86_64, please file a bug") From eba68a1a4947b29bcc58fbc502cb70dcc0ac71c0 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 3 Sep 2018 13:34:24 +0530 Subject: [PATCH 03/18] Add mach bootstrap-gstreamer --- README.md | 1 + python/servo/bootstrap.py | 11 ++++++++--- python/servo/bootstrap_commands.py | 9 +++++++++ servo-tidy.toml | 1 + support/linux/gstreamer/gstreamer.sh | 14 +++++++++++--- 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 54d8c8fc793..07c0883b69f 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,7 @@ sudo apt install git curl autoconf libx11-dev \ ``` If you using a version prior to **Ubuntu 17.04** or **Debian Sid**, replace `libssl1.0-dev` with `libssl-dev`. +Additionally, you'll need a local copy of GStreamer with a version later than 12.0. You can place it in `support/linux/gstreamer/gstreamer`, or run `./mach bootstrap-gstreamer` to set it up. If you are using **Ubuntu 16.04** run `export HARFBUZZ_SYS_NO_PKG_CONFIG=1` before building to avoid an error with harfbuzz. diff --git a/python/servo/bootstrap.py b/python/servo/bootstrap.py index 7bfa80bd8f4..d6d9dc1d1e6 100644 --- a/python/servo/bootstrap.py +++ b/python/servo/bootstrap.py @@ -18,8 +18,8 @@ from servo.util import extract, download_file, host_triple def check_gstreamer_lib(): - subprocess.call(["pkg-config", "gstreamer-1.0 >= 1.12"], - stdout=PIPE, stderr=PIPE) == 0 + return subprocess.call(["pkg-config", "gstreamer-1.0 >= 1.12"], + stdout=PIPE, stderr=PIPE) == 0 def run_as_root(command): if os.geteuid() != 0: @@ -56,7 +56,12 @@ def install_salt_dependencies(context, force): install_linux_deps(context, pkgs_apt, pkgs_dnf, force) def gstreamer(context, force=False): - pass + cur = os.curdir + gstdir = os.path.join(cur, "support", "linux", "gstreamer") + if not os.path.isdir(os.path.join(gstdir, "gstreamer", "lib")): + os.chdir(gstdir) + subprocess.call(["bash", "gstreamer.sh"]) + os.chdir(cur) def linux(context, force=False): # Please keep these in sync with the packages in README.md diff --git a/python/servo/bootstrap_commands.py b/python/servo/bootstrap_commands.py index 66508c5b959..84978737b64 100644 --- a/python/servo/bootstrap_commands.py +++ b/python/servo/bootstrap_commands.py @@ -64,6 +64,15 @@ class MachCommands(CommandBase): def bootstrap_salt(self, force=False): return bootstrap.bootstrap(self.context, force=force, specific="salt") + @Command('bootstrap-gstreamer', + description='Set up a local copy of the gstreamer libraries (linux only).', + category='bootstrap') + @CommandArgument('--force', '-f', + action='store_true', + help='Boostrap without confirmation') + def bootstrap_gstreamer(self, force=False): + return bootstrap.bootstrap(self.context, force=force, specific="gstreamer") + @Command('bootstrap-android', description='Install the Android SDK and NDK.', category='bootstrap') diff --git a/servo-tidy.toml b/servo-tidy.toml index 2645cf31588..bf1dd489553 100644 --- a/servo-tidy.toml +++ b/servo-tidy.toml @@ -65,6 +65,7 @@ files = [ "./resources/hsts_preload.json", "./tests/wpt/metadata/MANIFEST.json", "./support/android/openssl.sh", + "./support/linux/gstreamer/gstreamer.sh", # Upstream code from Khronos/WebGL uses tabs for indentation "./tests/wpt/webgl/tests", # Our import script is not currently respecting the lint. diff --git a/support/linux/gstreamer/gstreamer.sh b/support/linux/gstreamer/gstreamer.sh index 436f926b535..8b18babc9ec 100644 --- a/support/linux/gstreamer/gstreamer.sh +++ b/support/linux/gstreamer/gstreamer.sh @@ -1,4 +1,12 @@ -wget https://github.com/ferjm/gstreamer-1.14.1-ubuntu-trusty/raw/master/gstreamer.tar.gz -tar -zxvf gstreamer.tar.gz +#!/usr/bin/env bash + +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +set -o errexit + +wget https://github.com/ferjm/gstreamer-1.14.1-ubuntu-trusty/raw/master/gstreamer.tar.gz -O gstreamer.tar.gz +tar -zxf gstreamer.tar.gz rm gstreamer.tar.gz -sed -i "s;prefix=/root/gstreamer;prefix=$PWD/gstreamer;g" $PWD/gstreamer/lib/x86_64-linux-gnu/pkgconfig/*.pc +sed -i "s;prefix=/root/gstreamer;prefix=${PWD}/gstreamer;g" ${PWD}/gstreamer/lib/x86_64-linux-gnu/pkgconfig/*.pc From 36797801e9eda3405444cd55201104072a55a099 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 3 Sep 2018 13:54:20 +0530 Subject: [PATCH 04/18] Allow WPT to be run with local gstreamer --- python/servo/command_base.py | 35 ++++++++++++++++++++++---------- python/servo/testing_commands.py | 1 + 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/python/servo/command_base.py b/python/servo/command_base.py index c997b0bcc80..cedfeb626f3 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -477,6 +477,23 @@ class CommandBase(object): bin_folder = path.join(destination_folder, "PFiles", "Mozilla research", "Servo Tech Demo") return path.join(bin_folder, "servo{}".format(BIN_SUFFIX)) + def needs_gstreamer_env(self, target): + gstpath = path.join(self.context.topdir, "support", "linux", "gstreamer", "gstreamer") + if sys.platform == "linux2" and path.isdir(gstpath): + if not check_gstreamer_lib(): + if "x86_64" not in (target or host_triple()): + raise Exception("We don't currently support using local gstreamer builds \ + for non-x86_64, please file a bug") + return True + return False + + def set_run_env(self): + """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 self.needs_gstreamer_env(None): + gstpath = path.join(self.context.topdir, "support", "linux", "gstreamer", "gstreamer") + os.environ["LD_LIBRARY_PATH"] = path.join(gstpath, "lib", "x86_64-linux-gnu") + def build_env(self, hosts_file_path=None, target=None, is_build=False, test_unit=False): """Return an extended environment dictionary.""" env = os.environ.copy() @@ -519,17 +536,13 @@ class CommandBase(object): # Always build harfbuzz from source env["HARFBUZZ_SYS_NO_PKG_CONFIG"] = "true" - gstpath = path.join(os.getcwd(), "support", "linux", "gstreamer", "gstreamer") - if sys.platform == "linux2" and path.isdir(gstpath): - if not check_gstreamer_lib(): - if "x86_64" not in (target or host_triple()): - raise Exception("We don't currently support using local gstreamer builds \ - for non-x86_64, please file a bug") - extra_path += [path.join(gstpath, "bin")] - libpath = path.join(gstpath, "lib", "x86_64-linux-gnu") - extra_path += [libpath] - extra_lib += [libpath] - append_to_path_env(path.join(libpath, "pkgconfig"), env, "PKG_CONFIG_PATH") + if self.needs_gstreamer_env(target): + gstpath = path.join(self.context.topdir, "support", "linux", "gstreamer", "gstreamer") + extra_path += [path.join(gstpath, "bin")] + libpath = path.join(gstpath, "lib", "x86_64-linux-gnu") + extra_path += [libpath] + extra_lib += [libpath] + append_to_path_env(path.join(libpath, "pkgconfig"), env, "PKG_CONFIG_PATH") if extra_path: env["PATH"] = "%s%s%s" % (os.pathsep.join(extra_path), os.pathsep, env["PATH"]) diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py index 1cfddcc1ac7..957dfca22ae 100644 --- a/python/servo/testing_commands.py +++ b/python/servo/testing_commands.py @@ -383,6 +383,7 @@ class MachCommands(CommandBase): return self._test_wpt(**kwargs) def _test_wpt(self, **kwargs): + self.set_run_env() hosts_file_path = path.join(self.context.topdir, 'tests', 'wpt', 'hosts') os.environ["hosts_file_path"] = hosts_file_path run_file = path.abspath(path.join(self.context.topdir, "tests", "wpt", "run.py")) From fcc06b5a1696f3ac01f20ed2a1a84363f379a95c Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 3 Sep 2018 14:04:53 +0530 Subject: [PATCH 05/18] Better error reporting for missing gstreamer --- python/servo/command_base.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/python/servo/command_base.py b/python/servo/command_base.py index cedfeb626f3..952e4d692c4 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -478,13 +478,22 @@ class CommandBase(object): return path.join(bin_folder, "servo{}".format(BIN_SUFFIX)) def needs_gstreamer_env(self, target): + if check_gstreamer_lib(): + return False gstpath = path.join(self.context.topdir, "support", "linux", "gstreamer", "gstreamer") - if sys.platform == "linux2" and path.isdir(gstpath): - if not check_gstreamer_lib(): - if "x86_64" not in (target or host_triple()): - raise Exception("We don't currently support using local gstreamer builds \ + if sys.platform == "linux2": + if "x86_64" not in (target or host_triple()): + raise Exception("We don't currently support using local gstreamer builds \ for non-x86_64, please file a bug") + if path.isdir(gstpath): return True + else: + raise Exception("Your system's gstreamer libraries are out of date \ + (we need at least 1.12). Please run ./mach bootstrap-gstreamer") + else: + raise Exception("Your system's gstreamer libraries are out of date \ + (we need at least 1.12). If you're unable to \ + install them, let us know by filing a bug!") return False def set_run_env(self): From 6b75aa47cb6c34c6e34051ecd126e0982fc669e7 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 3 Sep 2018 14:25:59 +0530 Subject: [PATCH 06/18] Properly handle virtualenv --- README.md | 13 ++++++++++--- python/servo/bootstrap.py | 8 +++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 07c0883b69f..16d2533ebc0 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,9 @@ If you've already partially compiled servo but forgot to do this step, run `./ma #### On Debian-based Linuxes -Simply running `./mach bootstrap` should be enough. If not, run the commands below: +Please run `sudo apt install python-virtualenv build-essential libssl-dev libffi-dev python-dev` followed by `./mach bootstrap`. + +If this doesn't work, file a bug, and, run the commands below: ``` sh sudo apt install git curl autoconf libx11-dev \ @@ -101,7 +103,9 @@ If `virtualenv` does not exist, try `python-virtualenv`. #### On Fedora -Simply running `./mach bootstrap` should be enough. If not, run the commands below: +Please run `sudo dnf install python2-virtualenv gcc libffi-devel python-devel openssl-devel` followed by `./mach bootstrap`. + +If this doesn't work, file a bug, and, run the commands below: ``` sh sudo dnf install curl libtool gcc-c++ libXi-devel \ @@ -113,7 +117,10 @@ sudo dnf install curl libtool gcc-c++ libXi-devel \ ``` #### On CentOS -Simply running `./mach bootstrap` should be enough. If not, run the commands below: + +Please run `sudo yum install python2-virtualenv gcc libffi-devel python-devel openssl-devel` followed by `./mach bootstrap`. + +If this doesn't work, file a bug, and, run the commands below: ``` sh sudo yum install curl libtool gcc-c++ libXi-devel \ diff --git a/python/servo/bootstrap.py b/python/servo/bootstrap.py index d6d9dc1d1e6..c2c046d2609 100644 --- a/python/servo/bootstrap.py +++ b/python/servo/bootstrap.py @@ -67,7 +67,7 @@ def linux(context, force=False): # Please keep these in sync with the packages in README.md pkgs_apt = ['git', 'curl', 'autoconf', 'libx11-dev', 'libfreetype6-dev', 'libgl1-mesa-dri', 'libglib2.0-dev', 'xorg-dev', 'gperf', 'g++', - 'build-essential', 'cmake', 'virtualenv', 'python-pip', + 'build-essential', 'cmake', 'python-pip', 'libbz2-dev', 'libosmesa6-dev', 'libxmu6', 'libxmu-dev', 'libglu1-mesa-dev', 'libgles2-mesa-dev', 'libegl1-mesa-dev', 'libdbus-1-dev', 'libharfbuzz-dev', 'ccache', 'clang', 'libgstreamer1.0-dev', 'libgstreamer-plugins-base1.0-dev', @@ -87,6 +87,12 @@ def linux(context, force=False): pkgs_apt += ["libssl-dev"] else: pkgs_apt += ["libssl1.0-dev"] + + if context.distro_version == "14.04": + pkgs_apt += ["python-virtualenv"] + else: + pkgs_apt += ["virtualenv"] + elif context.distro == "Debian" and context.distro_version == "Sid": pkgs_apt += ["libssl-dev"] else: From e72e08ea9c7ed2f19ec7539984a3740db056fdba Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 3 Sep 2018 15:05:21 +0530 Subject: [PATCH 07/18] Allow bootstrap to be run before anything else is installed --- README.md | 6 +++--- mach | 7 +++++-- python/mach_bootstrap.py | 18 ++++++++++++++++++ python/servo/bootstrap.py | 16 +++++++++++++--- python/servo/util.py | 2 +- 5 files changed, 40 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 16d2533ebc0..20e60b885c1 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ If you've already partially compiled servo but forgot to do this step, run `./ma #### On Debian-based Linuxes -Please run `sudo apt install python-virtualenv build-essential libssl-dev libffi-dev python-dev` followed by `./mach bootstrap`. +Please run `./mach bootstrap`. If this doesn't work, file a bug, and, run the commands below: @@ -103,7 +103,7 @@ If `virtualenv` does not exist, try `python-virtualenv`. #### On Fedora -Please run `sudo dnf install python2-virtualenv gcc libffi-devel python-devel openssl-devel` followed by `./mach bootstrap`. +Please run `./mach bootstrap`. If this doesn't work, file a bug, and, run the commands below: @@ -118,7 +118,7 @@ sudo dnf install curl libtool gcc-c++ libXi-devel \ #### On CentOS -Please run `sudo yum install python2-virtualenv gcc libffi-devel python-devel openssl-devel` followed by `./mach bootstrap`. +Please run `./mach bootstrap`. If this doesn't work, file a bug, and, run the commands below: diff --git a/mach b/mach index c328f6b08fa..c9ae9fc2b40 100755 --- a/mach +++ b/mach @@ -20,8 +20,11 @@ def main(args): topdir = os.path.abspath(os.path.dirname(sys.argv[0])) sys.path.insert(0, os.path.join(topdir, "python")) import mach_bootstrap - mach = mach_bootstrap.bootstrap(topdir) - sys.exit(mach.run(sys.argv[1:])) + if len(sys.argv) > 1 and sys.argv[1] == "bootstrap": + sys.exit(mach_bootstrap.bootstrap_command_only(topdir)) + else: + mach = mach_bootstrap.bootstrap(topdir) + sys.exit(mach.run(sys.argv[1:])) if __name__ == '__main__': diff --git a/python/mach_bootstrap.py b/python/mach_bootstrap.py index 2db4bf01c30..3435b39f06a 100644 --- a/python/mach_bootstrap.py +++ b/python/mach_bootstrap.py @@ -224,11 +224,29 @@ def _is_windows(): return sys.platform == 'win32' +class DummyContext(object): + pass + + +def bootstrap_command_only(topdir): + from servo.bootstrap import bootstrap + + context = DummyContext() + context.topdir = topdir + force = False + if len(sys.argv) == 3 and sys.argv[2] == "-f": + force = True + bootstrap(context, force) + return 0 + + def bootstrap(topdir): _ensure_case_insensitive_if_windows() topdir = os.path.abspath(topdir) + len(sys.argv) > 1 and sys.argv[1] == "bootstrap" + # We don't support paths with Unicode characters for now # https://github.com/servo/servo/issues/10002 try: diff --git a/python/servo/bootstrap.py b/python/servo/bootstrap.py index c2c046d2609..2bbc3836012 100644 --- a/python/servo/bootstrap.py +++ b/python/servo/bootstrap.py @@ -49,11 +49,16 @@ def install_linux_deps(context, pkgs_ubuntu, pkgs_fedora, force): command.append('-y') print("Installing missing dependencies...") run_as_root(command + pkgs) + return True + return False + def install_salt_dependencies(context, force): pkgs_apt = ['build-essential', 'libssl-dev', 'libffi-dev', 'python-dev'] pkgs_dnf = ['gcc', 'libffi-devel', 'python-devel', 'openssl-devel'] - install_linux_deps(context, pkgs_apt, pkgs_dnf, force) + if not install_linux_deps(context, pkgs_apt, pkgs_dnf, force): + print("Dependencies are already installed") + def gstreamer(context, force=False): cur = os.curdir @@ -62,6 +67,9 @@ def gstreamer(context, force=False): os.chdir(gstdir) subprocess.call(["bash", "gstreamer.sh"]) os.chdir(cur) + return True + return False + def linux(context, force=False): # Please keep these in sync with the packages in README.md @@ -98,11 +106,13 @@ def linux(context, force=False): else: pkgs_apt += ["libssl1.0-dev"] - install_linux_deps(context, pkgs_apt, pkgs_dnf, force) + installed_something = install_linux_deps(context, pkgs_apt, pkgs_dnf, force) if not check_gstreamer_lib(): - gstreamer(context, force) + installed_something |= gstreamer(context, force) + if not installed_something: + print("Dependencies were already installed!") def salt(context, force=False): diff --git a/python/servo/util.py b/python/servo/util.py index d71cffe27da..c093978e631 100644 --- a/python/servo/util.py +++ b/python/servo/util.py @@ -20,7 +20,6 @@ import StringIO import sys import zipfile import urllib2 -import certifi try: @@ -30,6 +29,7 @@ except ImportError: # The cafile parameter was added in 2.7.9 if HAS_SNI and sys.version_info >= (2, 7, 9): + import certifi STATIC_RUST_LANG_ORG_DIST = "https://static.rust-lang.org/dist" URLOPEN_KWARGS = {"cafile": certifi.where()} else: From 10970be612abadc953dd26e2b5d375cd714fa99f Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 3 Sep 2018 16:37:47 +0530 Subject: [PATCH 08/18] Note that trusty needs some extra deps --- README.md | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 20e60b885c1..9211b7703a1 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,37 @@ Additionally, you'll need a local copy of GStreamer with a version later than 12 If you are using **Ubuntu 16.04** run `export HARFBUZZ_SYS_NO_PKG_CONFIG=1` before building to avoid an error with harfbuzz. -If you are on **Ubuntu 14.04** and encountered errors on installing these dependencies involving `libcheese`, see [#6158](https://github.com/servo/servo/issues/6158) for a workaround. +If you are on **Ubuntu 14.04** and encountered errors on installing these dependencies involving `libcheese`, see [#6158](https://github.com/servo/servo/issues/6158) for a workaround. You may also need to install gcc 4.9, clang 4.0, and cmake 3.2: + +
+gcc 4.9: + +```sh +sudo add-apt-repository ppa:ubuntu-toolchain-r/test +sudo apt-get update +sudo apt-get install gcc-4.9 g++-4.9 +sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9 +``` + +clang 4.0: + +```sh +wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - +sudo apt-add-repository "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-4.0 main" +sudo apt-get update +sudo apt-get install -y clang-4.0 +``` + +cmake 3.2: + +```sh +sudo apt-get install software-properties-common +sudo add-apt-repository ppa:george-edison55/cmake-3.x +sudo apt-get update +sudo apt-get install cmake +``` + +
If `virtualenv` does not exist, try `python-virtualenv`. From 6de148a7e5b03436da238ae8c38d67b9b0221821 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 3 Sep 2018 16:46:58 +0530 Subject: [PATCH 09/18] Have bootstrap script install trusty g++/clang deps --- python/servo/bootstrap.py | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/python/servo/bootstrap.py b/python/servo/bootstrap.py index 2bbc3836012..46b2f0f76aa 100644 --- a/python/servo/bootstrap.py +++ b/python/servo/bootstrap.py @@ -17,13 +17,43 @@ import servo.packages as packages from servo.util import extract, download_file, host_triple +def install_trusty_deps(force): + version = str(subprocess.check_output(['gcc', '-dumpversion'])).split('.') + gcc = True + if int(version[0]) > 4: + gcc = False + elif int(version[0]) == 4 and int(version[1]) >= 9: + gcc = False + + version = str(subprocess.check_output(['clang', '-dumpversion'])).split('.') + clang = int(version[0]) < 4 + + if gcc: + run_as_root(["add-apt-repository", "ppa:ubuntu-toolchain-r/test"], force) + run_as_root(["apt-get", "update"]) + run_as_root(["apt-get", "install", "gcc-4.9", "g++-4.9"], force) + run_as_root(['update-alternatives', '--install', '/usr/bin/gcc', 'gcc', + '/usr/bin/gcc-4.9', '60', '--slave', '/usr/bin/g++', 'g++', + '/usr/bin/g++-4.9']) + if clang: + run_as_root(["bash", "-c", 'wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -']) + run_as_root(["apt-add-repository" "deb http://apt.llvm.org/trusty/ llvm-toolchain-xenial-4.0 main"], force) + run_as_root(["apt-get", "update"]) + run_as_root(["apt-get", "install", "clang-4.0"], force) + + return gcc or clang + + def check_gstreamer_lib(): return subprocess.call(["pkg-config", "gstreamer-1.0 >= 1.12"], stdout=PIPE, stderr=PIPE) == 0 -def run_as_root(command): + +def run_as_root(command, force=False): if os.geteuid() != 0: command.insert(0, 'sudo') + if force: + command += "-y" return subprocess.call(command) @@ -111,6 +141,9 @@ def linux(context, force=False): if not check_gstreamer_lib(): installed_something |= gstreamer(context, force) + if context.distro == "Ubuntu" and context.distro_version == "14.04": + installed_something |= install_trusty_deps(force) + if not installed_something: print("Dependencies were already installed!") From a2344b326f2f98ea89308ee8b601dbb076cf7086 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 3 Sep 2018 17:26:04 +0530 Subject: [PATCH 10/18] Additional fixes for compiling on trusty --- python/servo/command_base.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/python/servo/command_base.py b/python/servo/command_base.py index 952e4d692c4..3e2369010a0 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -549,10 +549,17 @@ class CommandBase(object): gstpath = path.join(self.context.topdir, "support", "linux", "gstreamer", "gstreamer") extra_path += [path.join(gstpath, "bin")] libpath = path.join(gstpath, "lib", "x86_64-linux-gnu") - extra_path += [libpath] - extra_lib += [libpath] + # we append in the reverse order so that system gstreamer libraries + # do not get precedence + extra_path = [libpath] + extra_path + extra_lib = [libpath] + extra_path append_to_path_env(path.join(libpath, "pkgconfig"), env, "PKG_CONFIG_PATH") + if sys.platform == "linux2": + distro, version, _ = platform.linux_distribution() + if distro == "Ubuntu" and (version == "16.04" or version == "14.04"): + env["HARFBUZZ_SYS_NO_PKG_CONFIG"] = "true" + if extra_path: env["PATH"] = "%s%s%s" % (os.pathsep.join(extra_path), os.pathsep, env["PATH"]) From fc322182c41813b269d497e872e3e95b5a6e00eb Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 3 Sep 2018 18:18:52 +0530 Subject: [PATCH 11/18] Don't even try installing gstreamer on trusty --- python/servo/bootstrap.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/servo/bootstrap.py b/python/servo/bootstrap.py index 46b2f0f76aa..5e6f9fba5a3 100644 --- a/python/servo/bootstrap.py +++ b/python/servo/bootstrap.py @@ -108,8 +108,7 @@ def linux(context, force=False): 'build-essential', 'cmake', 'python-pip', 'libbz2-dev', 'libosmesa6-dev', 'libxmu6', 'libxmu-dev', 'libglu1-mesa-dev', 'libgles2-mesa-dev', 'libegl1-mesa-dev', 'libdbus-1-dev', 'libharfbuzz-dev', - 'ccache', 'clang', 'libgstreamer1.0-dev', 'libgstreamer-plugins-base1.0-dev', - 'libgstreamer-plugins-bad1.0-dev', 'autoconf2.13'] + 'ccache', 'clang', 'autoconf2.13'] pkgs_dnf = ['libtool', 'gcc-c++', 'libXi-devel', 'freetype-devel', 'mesa-libGL-devel', 'mesa-libEGL-devel', 'glib2-devel', 'libX11-devel', 'libXrandr-devel', 'gperf', 'fontconfig-devel', 'cabextract', 'ttmkfdir', @@ -130,6 +129,8 @@ def linux(context, force=False): pkgs_apt += ["python-virtualenv"] else: pkgs_apt += ["virtualenv"] + pkgs_apt += ['libgstreamer1.0-dev', 'libgstreamer-plugins-base1.0-dev', + 'libgstreamer-plugins-bad1.0-dev'] elif context.distro == "Debian" and context.distro_version == "Sid": pkgs_apt += ["libssl-dev"] From f270f3798d67553e7d83e0f461940210ddfad938 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 4 Sep 2018 12:52:49 +0530 Subject: [PATCH 12/18] Comment on ./mach bootstrap --- python/servo/bootstrap_commands.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/servo/bootstrap_commands.py b/python/servo/bootstrap_commands.py index 84978737b64..0650f943278 100644 --- a/python/servo/bootstrap_commands.py +++ b/python/servo/bootstrap_commands.py @@ -53,6 +53,9 @@ class MachCommands(CommandBase): action='store_true', help='Boostrap without confirmation') def bootstrap(self, force=False): + # This entry point isn't actually invoked, ./mach bootstrap is directly + # called by mach (see mach_bootstrap.bootstrap_command_only) so that + # it can install dependencies without needing mach's dependencies return bootstrap.bootstrap(self.context, force=force) @Command('bootstrap-salt', From d3ece2bc494103ecbd619327abd8f751a29a5c34 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 6 Sep 2018 12:24:11 +0530 Subject: [PATCH 13/18] Review fixes --- python/servo/bootstrap.py | 17 +++++++---------- python/servo/command_base.py | 9 ++++++--- support/linux/gstreamer/gstreamer.sh | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/python/servo/bootstrap.py b/python/servo/bootstrap.py index 5e6f9fba5a3..24725f6382f 100644 --- a/python/servo/bootstrap.py +++ b/python/servo/bootstrap.py @@ -37,7 +37,7 @@ def install_trusty_deps(force): '/usr/bin/g++-4.9']) if clang: run_as_root(["bash", "-c", 'wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -']) - run_as_root(["apt-add-repository" "deb http://apt.llvm.org/trusty/ llvm-toolchain-xenial-4.0 main"], force) + run_as_root(["apt-add-repository", "deb http://apt.llvm.org/trusty/ llvm-toolchain-xenial-4.0 main"], force) run_as_root(["apt-get", "update"]) run_as_root(["apt-get", "install", "clang-4.0"], force) @@ -94,9 +94,7 @@ def gstreamer(context, force=False): cur = os.curdir gstdir = os.path.join(cur, "support", "linux", "gstreamer") if not os.path.isdir(os.path.join(gstdir, "gstreamer", "lib")): - os.chdir(gstdir) - subprocess.call(["bash", "gstreamer.sh"]) - os.chdir(cur) + subprocess.check_call(["bash", "gstreamer.sh"], cwd=gstdir) return True return False @@ -328,6 +326,10 @@ def windows_msvc(context, force=False): return 0 +LINUX_SPECIFIC_BOOTSTRAPPERS = { + "salt": salt, + "gstreamer": gstreamer, +} def bootstrap(context, force=False, specific=None): '''Dispatches to the right bootstrapping function for the OS.''' @@ -346,12 +348,7 @@ def bootstrap(context, force=False, specific=None): ]: context.distro = distro context.distro_version = version - if specific == "salt": - bootstrapper = salt - elif specific == "gstreamer": - bootstrapper = gstreamer - else: - bootstrapper = linux + bootstrapper = LINUX_SPECIFIC_BOOTSTRAPPERS.get(specific, linux) else: raise Exception("mach bootstrap does not support %s, please file a bug" % distro) diff --git a/python/servo/command_base.py b/python/servo/command_base.py index 3e2369010a0..fa224763a0e 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -348,6 +348,9 @@ class CommandBase(object): 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", "gstreamer") + def get_binary_path(self, release, dev, android=False): # TODO(autrilla): this function could still use work - it shouldn't # handle quitting, or printing. It should return the path, or an error. @@ -480,7 +483,7 @@ class CommandBase(object): def needs_gstreamer_env(self, target): if check_gstreamer_lib(): return False - gstpath = path.join(self.context.topdir, "support", "linux", "gstreamer", "gstreamer") + gstpath = self.get_gstreamer_path() if sys.platform == "linux2": if "x86_64" not in (target or host_triple()): raise Exception("We don't currently support using local gstreamer builds \ @@ -500,7 +503,7 @@ class CommandBase(object): """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 self.needs_gstreamer_env(None): - gstpath = path.join(self.context.topdir, "support", "linux", "gstreamer", "gstreamer") + gstpath = self.get_gstreamer_path() os.environ["LD_LIBRARY_PATH"] = path.join(gstpath, "lib", "x86_64-linux-gnu") def build_env(self, hosts_file_path=None, target=None, is_build=False, test_unit=False): @@ -546,7 +549,7 @@ class CommandBase(object): env["HARFBUZZ_SYS_NO_PKG_CONFIG"] = "true" if self.needs_gstreamer_env(target): - gstpath = path.join(self.context.topdir, "support", "linux", "gstreamer", "gstreamer") + gstpath = self.get_gstreamer_path() extra_path += [path.join(gstpath, "bin")] libpath = path.join(gstpath, "lib", "x86_64-linux-gnu") # we append in the reverse order so that system gstreamer libraries diff --git a/support/linux/gstreamer/gstreamer.sh b/support/linux/gstreamer/gstreamer.sh index 8b18babc9ec..1f7e92b4086 100644 --- a/support/linux/gstreamer/gstreamer.sh +++ b/support/linux/gstreamer/gstreamer.sh @@ -6,7 +6,7 @@ set -o errexit -wget https://github.com/ferjm/gstreamer-1.14.1-ubuntu-trusty/raw/master/gstreamer.tar.gz -O gstreamer.tar.gz +wget http://servo-deps.s3.amazonaws.com/gstreamer/gstreamer-x86_64-linux-gnu.tar.gz -O gstreamer.tar.gz tar -zxf gstreamer.tar.gz rm gstreamer.tar.gz sed -i "s;prefix=/root/gstreamer;prefix=${PWD}/gstreamer;g" ${PWD}/gstreamer/lib/x86_64-linux-gnu/pkgconfig/*.pc From a380c5fd6e5e9eb2e6c54a77ce3d88f30dc4089d Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 7 Sep 2018 14:42:19 +0530 Subject: [PATCH 14/18] Don't try to load gstreamer on non-x86 --- python/servo/bootstrap.py | 2 ++ python/servo/command_base.py | 15 +++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/python/servo/bootstrap.py b/python/servo/bootstrap.py index 24725f6382f..0e128d2826e 100644 --- a/python/servo/bootstrap.py +++ b/python/servo/bootstrap.py @@ -326,11 +326,13 @@ def windows_msvc(context, force=False): return 0 + LINUX_SPECIFIC_BOOTSTRAPPERS = { "salt": salt, "gstreamer": gstreamer, } + def bootstrap(context, force=False, specific=None): '''Dispatches to the right bootstrapping function for the OS.''' diff --git a/python/servo/command_base.py b/python/servo/command_base.py index fa224763a0e..57865bac55d 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -483,20 +483,19 @@ class CommandBase(object): def needs_gstreamer_env(self, target): if check_gstreamer_lib(): return False - gstpath = self.get_gstreamer_path() + if "x86_64" not in (target or host_triple()): + # We don't build gstreamer for non-x86_64 yet + return False if sys.platform == "linux2": - if "x86_64" not in (target or host_triple()): - raise Exception("We don't currently support using local gstreamer builds \ - for non-x86_64, please file a bug") - if path.isdir(gstpath): + if path.isdir(self.get_gstreamer_path()): return True else: raise Exception("Your system's gstreamer libraries are out of date \ - (we need at least 1.12). Please run ./mach bootstrap-gstreamer") +(we need at least 1.12). Please run ./mach bootstrap-gstreamer") else: raise Exception("Your system's gstreamer libraries are out of date \ - (we need at least 1.12). If you're unable to \ - install them, let us know by filing a bug!") +(we need at least 1.12). If you're unable to \ +install them, let us know by filing a bug!") return False def set_run_env(self): From 4d7d63ea95faf8f996cd947171adfe8c68a7af13 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 7 Sep 2018 17:17:11 +0530 Subject: [PATCH 15/18] Hande systems without pkg-config --- python/servo/command_base.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/python/servo/command_base.py b/python/servo/command_base.py index 57865bac55d..d5269de42d2 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -481,7 +481,12 @@ class CommandBase(object): return path.join(bin_folder, "servo{}".format(BIN_SUFFIX)) def needs_gstreamer_env(self, target): - if check_gstreamer_lib(): + try: + if check_gstreamer_lib(): + return False + except: + # Some systems don't have pkg-config; we can't probe in this case + # and must hope for the best return False if "x86_64" not in (target or host_triple()): # We don't build gstreamer for non-x86_64 yet From 0e252a179f105eb10b4235a50aee693648f48188 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 11 Sep 2018 19:41:44 +0530 Subject: [PATCH 16/18] ./mach package should respect target argument --- python/servo/package_commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/servo/package_commands.py b/python/servo/package_commands.py index 9a3c8f62d63..dc2d10daf3d 100644 --- a/python/servo/package_commands.py +++ b/python/servo/package_commands.py @@ -184,7 +184,7 @@ class PackageCommands(CommandBase): default=None, help='Package using the given Gradle flavor') def package(self, release=False, dev=False, android=None, debug=False, debugger=None, target=None, flavor=None): - env = self.build_env() + env = self.build_env(target=target) if android is None: android = self.config["build"]["android"] if target and android: From 5d6701179c71abcd6a020091ec7d2cb6d47351ed Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 11 Sep 2018 21:26:58 +0530 Subject: [PATCH 17/18] Bypass gstreamer check for test-wpt-android --- python/servo/command_base.py | 4 ++-- python/servo/testing_commands.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/python/servo/command_base.py b/python/servo/command_base.py index d5269de42d2..c813242f85d 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -503,10 +503,10 @@ class CommandBase(object): install them, let us know by filing a bug!") return False - def set_run_env(self): + 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 self.needs_gstreamer_env(None): + if not android and self.needs_gstreamer_env(None): gstpath = self.get_gstreamer_path() os.environ["LD_LIBRARY_PATH"] = path.join(gstpath, "lib", "x86_64-linux-gnu") diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py index 957dfca22ae..8e18fce5437 100644 --- a/python/servo/testing_commands.py +++ b/python/servo/testing_commands.py @@ -380,10 +380,10 @@ class MachCommands(CommandBase): binary_args=self.in_android_emulator(release, dev) + (binary_args or []), binary=sys.executable, ) - return self._test_wpt(**kwargs) + return self._test_wpt(android=True, **kwargs) - def _test_wpt(self, **kwargs): - self.set_run_env() + def _test_wpt(self, android=False, **kwargs): + self.set_run_env(android) hosts_file_path = path.join(self.context.topdir, 'tests', 'wpt', 'hosts') os.environ["hosts_file_path"] = hosts_file_path run_file = path.abspath(path.join(self.context.topdir, "tests", "wpt", "run.py")) From 2cc4e1dcdcdee9505d4d790386b1df0a680549d5 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 11 Sep 2018 22:14:31 +0530 Subject: [PATCH 18/18] mach package should work on android --- python/servo/command_base.py | 5 +++-- python/servo/package_commands.py | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/python/servo/command_base.py b/python/servo/command_base.py index c813242f85d..b335dcd69eb 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -488,8 +488,9 @@ class CommandBase(object): # Some systems don't have pkg-config; we can't probe in this case # and must hope for the best return False - if "x86_64" not in (target or host_triple()): - # We don't build gstreamer for non-x86_64 yet + effective_target = target or host_triple() + 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()): diff --git a/python/servo/package_commands.py b/python/servo/package_commands.py index dc2d10daf3d..1e91032dea6 100644 --- a/python/servo/package_commands.py +++ b/python/servo/package_commands.py @@ -184,7 +184,6 @@ class PackageCommands(CommandBase): default=None, help='Package using the given Gradle flavor') def package(self, release=False, dev=False, android=None, debug=False, debugger=None, target=None, flavor=None): - env = self.build_env(target=target) if android is None: android = self.config["build"]["android"] if target and android: @@ -192,6 +191,9 @@ class PackageCommands(CommandBase): sys.exit(1) if not android: android = self.handle_android_target(target) + else: + target = self.config["android"]["target"] + env = self.build_env(target=target) binary_path = self.get_binary_path(release, dev, android=android) dir_to_root = self.get_top_dir() target_dir = path.dirname(binary_path)