Bug 886173 - Preserve playbackRate across pause/play. r=cpearce
[gecko.git] / mach
blob9aba2825387eb5a4d29fcf56e17b3566597499bc
1 #!/usr/bin/env python
2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 from __future__ import print_function, unicode_literals
8 import os
9 import sys
11 def ancestors(path):
12 while path:
13 yield path
14 (path, child) = os.path.split(path)
15 if child == "":
16 break
18 def load_mach(topsrcdir):
19 sys.path[0:0] = [os.path.join(topsrcdir, "build")]
20 import mach_bootstrap
21 return mach_bootstrap.bootstrap(topsrcdir)
23 # Check whether the current directory is within a mach src or obj dir.
24 for dir_path in ancestors(os.getcwd()):
25 # If we find a "mozinfo.json" file, we are in the objdir.
26 mozinfo_path = os.path.join(dir_path, "mozinfo.json")
27 if os.path.isfile(mozinfo_path):
28 import json
29 info = json.load(open(mozinfo_path))
30 if "mozconfig" in info and "MOZCONFIG" not in os.environ:
31 # If the MOZCONFIG environment variable is not already set, set it
32 # to the value from mozinfo.json. This will tell the build system
33 # to look for a config file at the path in $MOZCONFIG rather than
34 # its default locations.
36 # Note: subprocess requires native strings in os.environ Python
37 # 2.7.2 and earlier on Windows.
38 os.environ[b"MOZCONFIG"] = str(info["mozconfig"])
40 if "topsrcdir" in info:
41 # Continue searching for mach_bootstrap in the source directory.
42 dir_path = info["topsrcdir"]
44 # If we find the mach bootstrap module, we are in the srcdir.
45 mach_path = os.path.join(dir_path, "build/mach_bootstrap.py")
46 if os.path.isfile(mach_path):
47 mach = load_mach(dir_path)
48 sys.exit(mach.run(sys.argv[1:]))
50 print("Could not run mach: No mach source directory found")
51 sys.exit(1)