forked from mirrors/gecko-dev
		
	 7ae32f7f97
			
		
	
	
		7ae32f7f97
		
	
	
	
	
		
			
			Borrows two python modules from mozilla-central to give mach the ability to detect and pass arguments to a system's preferred debugger, and adds `--debug` and `--debugger` flags to `./mach run`. This works almost like the functionality described [here](https://developer.mozilla.org/en-US/docs/Debugging_Mozilla_with_gdb), but at the moment it lacks a `--debugparams` argument. Links to borrowed files: http://hg.mozilla.org/mozilla-central/file/c9cfa9b91dea/testing/mozbase/mozinfo/mozinfo/mozinfo.py http://hg.mozilla.org/mozilla-central/file/c9cfa9b91dea/testing/mozbase/mozdebug/mozdebug/mozdebug.py Source-Repo: https://github.com/servo/servo Source-Revision: 989efd5a2820a152c5d5a2d42c9be3c30d79f469
		
			
				
	
	
		
			102 lines
		
	
	
	
		
			3 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			102 lines
		
	
	
	
		
			3 KiB
		
	
	
	
		
			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 platform
 | |
| import sys
 | |
| 
 | |
| SEARCH_PATHS = [
 | |
|     "python/mach",
 | |
|     "python/toml",
 | |
|     "python/mozinfo",
 | |
|     "python/mozdebug",
 | |
| ]
 | |
| 
 | |
| # Individual files providing mach commands.
 | |
| MACH_MODULES = [
 | |
|     'python/servo/bootstrap_commands.py',
 | |
|     'python/servo/build_commands.py',
 | |
|     'python/servo/testing_commands.py',
 | |
|     'python/servo/post_build_commands.py',
 | |
|     'python/servo/devenv_commands.py',
 | |
| ]
 | |
| 
 | |
| 
 | |
| CATEGORIES = {
 | |
|     'bootstrap': {
 | |
|         'short': 'Bootstrap Commands',
 | |
|         'long': 'Bootstrap the build system',
 | |
|         'priority': 90,
 | |
|     },
 | |
|     'build': {
 | |
|         'short': 'Build Commands',
 | |
|         'long': 'Interact with the build system',
 | |
|         'priority': 80,
 | |
|     },
 | |
|     'post-build': {
 | |
|         'short': 'Post-build Commands',
 | |
|         'long': 'Common actions performed after completing a build.',
 | |
|         'priority': 70,
 | |
|     },
 | |
|     'testing': {
 | |
|         'short': 'Testing',
 | |
|         'long': 'Run tests.',
 | |
|         'priority': 60,
 | |
|     },
 | |
|     'devenv': {
 | |
|         'short': 'Development Environment',
 | |
|         'long': 'Set up and configure your development environment.',
 | |
|         'priority': 50,
 | |
|     },
 | |
|     'build-dev': {
 | |
|         'short': 'Low-level Build System Interaction',
 | |
|         'long': 'Interact with specific parts of the build system.',
 | |
|         'priority': 20,
 | |
|     },
 | |
|     'misc': {
 | |
|         'short': 'Potpourri',
 | |
|         'long': 'Potent potables and assorted snacks.',
 | |
|         'priority': 10,
 | |
|     },
 | |
|     'disabled': {
 | |
|         'short': 'Disabled',
 | |
|         'long': 'The disabled commands are hidden by default. Use -v to display them. These commands are unavailable for your current context, run "mach <command>" to see why.',
 | |
|         'priority': 0,
 | |
|     }
 | |
| }
 | |
| 
 | |
| 
 | |
| def bootstrap(topdir):
 | |
|     topdir = os.path.abspath(topdir)
 | |
| 
 | |
|     # Ensure we are running Python 2.7+. We put this check here so we generate a
 | |
|     # user-friendly error message rather than a cryptic stack trace on module
 | |
|     # import.
 | |
|     if sys.version_info[0] != 2 or sys.version_info[1] < 7:
 | |
|         print('Python 2.7 or above (but not Python 3) is required to run mach.')
 | |
|         print('You are running Python', platform.python_version())
 | |
|         sys.exit(1)
 | |
| 
 | |
|     def populate_context(context, key=None):
 | |
|         if key is None:
 | |
|             return
 | |
|         if key == 'topdir':
 | |
|             return topdir
 | |
|         raise AttributeError(key)
 | |
| 
 | |
|     sys.path[0:0] = [os.path.join(topdir, path) for path in SEARCH_PATHS]
 | |
|     import mach.main
 | |
|     mach = mach.main.Mach(os.getcwd())
 | |
|     mach.populate_context_handler = populate_context
 | |
| 
 | |
|     for category, meta in CATEGORIES.items():
 | |
|         mach.define_category(category, meta['short'], meta['long'],
 | |
|             meta['priority'])
 | |
| 
 | |
|     for path in MACH_MODULES:
 | |
|         mach.load_commands_from_file(os.path.join(topdir, path))
 | |
| 
 | |
|     return mach
 |