summaryrefslogtreecommitdiff
path: root/mach
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2022-04-01 03:14:50 -0500
committerMatt A. Tobin <email@mattatobin.com>2022-04-01 03:14:50 -0500
commit0231f7464fb13eb146a2d4f77f23d75c52a589e1 (patch)
tree3845a01934f5883395df266990c7769846bf2d47 /mach
parentc3dc8a1f81c2148a64bc99a194da4c10614e9b95 (diff)
downloadaura-central-0231f7464fb13eb146a2d4f77f23d75c52a589e1.tar.gz
Move BinOC Apps to apps/ and make navigator build .. also use a bash script for mach and chain to real-mach
Diffstat (limited to 'mach')
-rwxr-xr-xmach170
1 files changed, 30 insertions, 140 deletions
diff --git a/mach b/mach
index 1759179a3..a0497c66d 100755
--- a/mach
+++ b/mach
@@ -1,150 +1,40 @@
#!/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 http://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.
-'''which' python2.7 > /dev/null && exec python2.7 "$0" "$@" || exec python "$0" "$@"
-'''
+BINOC_MACH=real-mach
+BINOC_TARGET_OS=`uname | tr [:upper:] [:lower:]`
+BINOC_CONFIG_GUESS=`./platform/build/autoconf/config.guess 2>/dev/null`
+BINOC_PYTHON=`which python2.7 2>/dev/null`
+BINOC_GIT=`which git 2>/dev/null`
+BINOC_CURL=`which curl 2>/dev/null`
-from __future__ import print_function, unicode_literals
+# =====================================================================================================================
-import os
-import sys
+if [ -z "$BINOC_PYTHON" ]; then
+ printf "We could not find Python 2.7 which is required for just about everything!\n"
+ exit 1
+fi
-def ancestors(path):
- while path:
- yield path
- (path, child) = os.path.split(path)
- if child == "":
- break
+# =====================================================================================================================
-def load_mach(dir_path, mach_path):
- import imp
- with open(mach_path, 'r') as fh:
- imp.load_module('mach_bootstrap', fh, mach_path,
- ('.py', 'r', imp.PY_SOURCE))
- import mach_bootstrap
- return mach_bootstrap.bootstrap(dir_path)
+# Determine the current OS
+# This will also be exported so it can be picked up by .mozconfig
+if [[ "$BINOC_TARGET_OS" == "mingw32_nt-"* ]]; then
+ BINOC_TARGET_OS=windows
+
+ if [ "$BINOC_CONFIG_GUESS" == "x86_64-pc-mingw32" ]; then
+ BINOC_CONFIG_GUESS=win64
+ else
+ BINOC_CONFIG_GUESS=win32
+ fi
+fi
+export BINOC_TARGET_OS=$BINOC_TARGET_OS
+export BINOC_CONFIG_GUESS=$BINOC_CONFIG_GUESS
-def check_and_get_mach(dir_path):
- bootstrap_paths = (
- 'build/mach_bootstrap.py',
- # test package bootstrap
- 'tools/mach_bootstrap.py',
- )
- for bootstrap_path in bootstrap_paths:
- mach_path = os.path.join(dir_path, bootstrap_path)
- if os.path.isfile(mach_path):
- return load_mach(dir_path, mach_path)
- return None
+# =====================================================================================================================
+# We don't know what the command is but real-mach might so just pass
+# all the args to it
+$BINOC_MACH $@
-def get_mach():
- # Check whether the current directory is within a mach src or obj dir.
- for dir_path in ancestors(os.getcwd()):
- # If we find a "config.status" and "mozinfo.json" file, we are in the objdir.
- config_status_path = os.path.join(dir_path, 'config.status')
- mozinfo_path = os.path.join(dir_path, 'mozinfo.json')
- if os.path.isfile(config_status_path) and os.path.isfile(mozinfo_path):
- import json
- info = json.load(open(mozinfo_path))
- if 'mozconfig' in info and 'MOZCONFIG' not in os.environ:
- # If the MOZCONFIG environment variable is not already set, set it
- # to the value from mozinfo.json. This will tell the build system
- # to look for a config file at the path in $MOZCONFIG rather than
- # its default locations.
- #
- # Note: subprocess requires native strings in os.environ on Windows
- os.environ[b'MOZCONFIG'] = str(info['mozconfig'])
-
- if 'topsrcdir' in info:
- # Continue searching for mach_bootstrap in the source directory.
- dir_path = info['topsrcdir']
-
- mach = check_and_get_mach(dir_path)
- if mach:
- return mach
-
- # If we didn't find a source path by scanning for a mozinfo.json, check
- # whether the directory containing this script is a source directory. We
- # follow symlinks so mach can be run even if cwd is outside the srcdir.
- return check_and_get_mach(os.path.dirname(os.path.realpath(__file__)))
-
-def main(args):
- mach = get_mach()
- if not mach:
- print('Could not run mach: No mach source directory found.')
- sys.exit(1)
- sys.exit(mach.run(args))
-
-
-if __name__ == '__main__':
- if sys.platform == 'win32':
- # This is a complete hack to work around the fact that Windows
- # multiprocessing needs to import the original module (ie: this
- # file), but only works if it has a .py extension.
- #
- # We do this by a sort of two-level function interposing. The first
- # level interposes forking.get_command_line() with our version defined
- # in my_get_command_line(). Our version of get_command_line will
- # replace the command string with the contents of the fork_interpose()
- # function to be used in the subprocess.
- #
- # The subprocess then gets an interposed imp.find_module(), which we
- # hack up to find 'mach' without the .py extension, since we already
- # know where it is (it's us!). If we're not looking for 'mach', then
- # the original find_module will suffice.
- #
- # See also: http://bugs.python.org/issue19946
- # And: https://bugzilla.mozilla.org/show_bug.cgi?id=914563
- import inspect
- from multiprocessing import forking
- global orig_command_line
-
- def fork_interpose():
- import imp
- import os
- import sys
- orig_find_module = imp.find_module
- def my_find_module(name, dirs):
- if name == 'mach':
- path = os.path.join(dirs[0], 'mach')
- f = open(path)
- return (f, path, ('', 'r', imp.PY_SOURCE))
- return orig_find_module(name, dirs)
-
- # Don't allow writing bytecode file for mach module.
- orig_load_module = imp.load_module
- def my_load_module(name, file, path, description):
- # multiprocess.forking invokes imp.load_module manually and
- # hard-codes the name __parents_main__ as the module name.
- if name == '__parents_main__':
- old_bytecode = sys.dont_write_bytecode
- sys.dont_write_bytecode = True
- try:
- return orig_load_module(name, file, path, description)
- finally:
- sys.dont_write_bytecode = old_bytecode
-
- return orig_load_module(name, file, path, description)
-
- imp.find_module = my_find_module
- imp.load_module = my_load_module
- from multiprocessing.forking import main; main()
-
- def my_get_command_line():
- fork_code, lineno = inspect.getsourcelines(fork_interpose)
- # Remove the first line (for 'def fork_interpose():') and the three
- # levels of indentation (12 spaces).
- fork_string = ''.join(x[12:] for x in fork_code[1:])
- cmdline = orig_command_line()
- cmdline[2] = fork_string
- return cmdline
- orig_command_line = forking.get_command_line
- forking.get_command_line = my_get_command_line
-
- main(sys.argv[1:])
+# ===================================================================================================================== \ No newline at end of file