Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a --nightly | -n flag to mach run commands for linux #19947

Merged
merged 1 commit into from Mar 7, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Add a --nightly | -n flag to download and extract a specific nightly …

…version to run mach commands against. This currently only work on linux, but windows and mac os support will follow in subsequent PRs.
  • Loading branch information
o0Ignition0o committed Mar 6, 2018
commit 10822ce7307bec2c5f1533173ae6880e64ccc122
@@ -21,6 +21,9 @@
from subprocess import PIPE
import sys
import tarfile
from xml.etree.ElementTree import XML
from servo.util import download_file
import urllib2

from mach.registrar import Registrar
import toml
@@ -29,6 +32,7 @@
from servo.util import host_triple

BIN_SUFFIX = ".exe" if sys.platform == "win32" else ""
NIGHTLY_REPOSITORY_URL = "https://servo-builds.s3.amazonaws.com/"


@contextlib.contextmanager
@@ -388,6 +392,77 @@ def get_binary_path(self, release, dev, android=False):
" --release" if release else ""))
sys.exit()

def get_nightly_binary_path(self, nightly_date):
if nightly_date is None:
return
if not nightly_date:
print(
"No nightly date has been provided although the --nightly or -n flag has been passed.")
sys.exit(1)
# Will alow us to fetch the relevant builds from the nightly repository
os_prefix = "linux"
if is_windows():
print("The nightly flag is not supported on windows yet.")
sys.exit(1)
if is_macosx():
print("The nightly flag is not supported on mac yet.")
sys.exit(1)
nightly_date = nightly_date.strip()
# Fetch the filename to download from the build list
repository_index = NIGHTLY_REPOSITORY_URL + "?list-type=2&prefix=nightly"
req = urllib2.Request(
"{}/{}/{}".format(repository_index, os_prefix, nightly_date))
try:
response = urllib2.urlopen(req).read()
tree = XML(response)
namespaces = {'ns': tree.tag[1:tree.tag.index('}')]}
file_to_download = tree.find('ns:Contents', namespaces).find(
'ns:Key', namespaces).text
except urllib2.URLError as e:
print("Could not fetch the available nightly versions from the repository : {}".format(
e.reason))
sys.exit(1)
except AttributeError as e:
print("Could not fetch a nightly version for date {} and platform {}".format(
nightly_date, os_prefix))
sys.exit(1)

nightly_target_directory = path.join(self.context.topdir, "target")
# Once extracted, the nightly folder name is the tar name without the extension
# (eg /foo/bar/baz.tar.gz extracts to /foo/bar/baz)
destination_file = path.join(
nightly_target_directory, file_to_download)
destination_folder = os.path.splitext(destination_file)[0]
nightlies_folder = path.join(
nightly_target_directory, 'nightly', os_prefix)

# Make sure the target directory exists
if not os.path.isdir(nightlies_folder):
print("The nightly folder for the target does not exist yet. Creating {}".format(
nightlies_folder))
os.makedirs(nightlies_folder)

# Download the nightly version
if os.path.isfile(path.join(nightlies_folder, destination_file)):
print("The nightly file {} has already been downloaded.".format(
destination_file))
else:
print("The nightly {} does not exist yet, downloading it.".format(
destination_file))
download_file(destination_file, NIGHTLY_REPOSITORY_URL +
file_to_download, destination_file)

# Extract the downloaded nightly version
if os.path.isdir(destination_folder):
print("The nightly file {} has already been extracted.".format(
destination_folder))
else:
print("Extracting to {}...".format(destination_folder))
with tarfile.open(os.path.join(nightlies_folder, destination_file), "r") as tar:
tar.extractall(destination_folder)

return path.join(destination_folder, "servo", "servo")

def build_env(self, hosts_file_path=None, target=None, is_build=False, geckolib=False, test_unit=False):
"""Return an extended environment dictionary."""
env = os.environ.copy()
@@ -58,11 +58,13 @@ class PostBuildCommands(CommandBase):
help='Launch with software rendering')
@CommandArgument('--bin', default=None,
help='Launch with specific binary')
@CommandArgument('--nightly', '-n', default=None,
help='Specify a YYYY-MM-DD nightly build to run')
@CommandArgument(
'params', nargs='...',
help="Command-line arguments to be passed through to Servo")
def run(self, params, release=False, dev=False, android=None, debug=False, debugger=None,
headless=False, software=False, bin=None):
headless=False, software=False, bin=None, nightly=None):
env = self.build_env()
env["RUST_BACKTRACE"] = "1"

@@ -95,7 +97,7 @@ def run(self, params, release=False, dev=False, android=None, debug=False, debug
shell.communicate("\n".join(script) + "\n")
return shell.wait()

args = [bin or self.get_binary_path(release, dev)]
args = [bin or self.get_nightly_binary_path(nightly) or self.get_binary_path(release, dev)]

if headless:
set_osmesa_env(args[0], env)
@@ -160,14 +162,17 @@ def run(self, params, release=False, dev=False, android=None, debug=False, debug
help='Use dev build')
@CommandArgument('--bin', default=None,
help='Launch with specific binary')
@CommandArgument('--nightly', '-n', default=None,
help='Specify a YYYY-MM-DD nightly build to run')
@CommandArgument(
'params', nargs='...',
help="Command-line arguments to be passed through to Servo")
def rr_record(self, release=False, dev=False, bin=None, params=[]):
def rr_record(self, release=False, dev=False, bin=None, nightly=None, params=[]):
env = self.build_env()
env["RUST_BACKTRACE"] = "1"

servo_cmd = [bin or self.get_binary_path(release, dev)] + params
servo_cmd = [bin or self.get_nightly_binary_path(nightly) or
self.get_binary_path(release, dev)] + params
rr_cmd = ['rr', '--fatal-errors', 'record']
try:
check_call(rr_cmd + servo_cmd)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.