forked from mozilla-b2g/B2G
-
Notifications
You must be signed in to change notification settings - Fork 17
/
mach
executable file
·32 lines (26 loc) · 1.02 KB
/
mach
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python
# 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/.
from __future__ import print_function, unicode_literals
import os
import sys
def ancestors(path):
while path:
yield path
(path, child) = os.path.split(path)
if child == "":
break
def load_mach(b2g_home):
sys.path[0:0] = [os.path.join(b2g_home, "tools")]
import mach_b2g_bootstrap
return mach_b2g_bootstrap.bootstrap(b2g_home)
# Check whether the current directory is within a mach src or obj dir.
for dir_path in ancestors(os.getcwd()):
# If we find the mach bootstrap module, we are in the b2g_home dir.
mach_path = os.path.join(dir_path, "tools/mach_b2g_bootstrap.py")
if os.path.isfile(mach_path):
mach = load_mach(dir_path)
sys.exit(mach.run(sys.argv[1:]))
print("Could not run mach: No mach source directory found")
sys.exit(1)