mirror of
https://github.com/servo/servo.git
synced 2025-06-06 00:25:37 +00:00
48 lines
1.8 KiB
Bash
Executable file
48 lines
1.8 KiB
Bash
Executable file
#!/bin/sh
|
|
# 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 https://mozilla.org/MPL/2.0/.
|
|
|
|
# The beginning of this script is both valid shell and valid python,
|
|
# such that the script starts with the shell and is reexecuted with
|
|
# the right python.
|
|
''':' && if [ ! -z "$MSYSTEM" ] ; then exec python "$0" "$@" ; else which python3 > /dev/null 2> /dev/null && exec python3 "$0" "$@" || exec python "$0" "$@" ; fi
|
|
'''
|
|
|
|
from __future__ import print_function, unicode_literals
|
|
|
|
import os
|
|
import sys
|
|
|
|
if sys.version_info < (3, 5):
|
|
print("mach does not support python < 3.5, please install python 3 >= 3.5")
|
|
sys.exit(1)
|
|
|
|
|
|
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
|
|
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__':
|
|
sys.dont_write_bytecode = True
|
|
|
|
if os.path.exists('/etc/NIXOS') and not 'IN_NIX_SHELL' in os.environ: # we're on a nixOS system, need to run mach in nix-shell
|
|
import subprocess
|
|
from shlex import quote
|
|
mach_dir = os.path.abspath(os.path.dirname(__file__))
|
|
print('NOTE: Entering nix-shell etc/shell.nix')
|
|
try:
|
|
# sys argv already contains the ./mach part, so we just need to pass it as-is
|
|
result = subprocess.run(['nix-shell', mach_dir + '/etc/shell.nix', '--run', ' '.join(map(quote, sys.argv))])
|
|
sys.exit(result.returncode)
|
|
except KeyboardInterrupt:
|
|
sys.exit(0)
|
|
else:
|
|
main(sys.argv)
|