mozilla-b2g/B2G — pull request #138 by indygreg (2012-10-07 18:50:53+00:00)
Title: Initial mach integration

mach is a general purpose CLI tool I wrote for mozilla-central to facilitate easier developer interactions with the build system and source tree. This pull request provides initial integration with B2G.

Mach is really just a generic tool. The meat of mach is provided by command handlers which simply register actions with argparse and then get called to do stuff.

The initial commits in this pull request merely port existing code from mozilla-central to this repository. Following the convention of mozilla-central, I created a new directory, _python_ to hold Python packages. The import directory is mach. I also had to pull in mozprocess and mozinfo, both are required packages of mach.

Unfortunately, mach currently is tightly coupled with mozbuild, a Python package tailored towards mozilla-central's build system. Some of the commits in this pull request effectively port mozbuild code into mach's package. I also removed some code from mach (mainly settings) in order to make the port easier. Over time, mach will become totally generic. These changes will flow downstream from mozilla-central to B2G and both mach trees will become identical. Or, perhaps mach will be maintained as its own package somewhere. Time will tell. Either way, there is some divergence right now, but that shouldn't be a concern of B2G.

The final commits in this pull request add a few mach command handlers. I simply looked at a few existing .sh scripts in the root directory and created frontends for them. So, this pull request essentially adds action discovery via mach and nothing more.

In the long term, I advocate replacing the shell scripts with Python modules and then having the mach commands call directly into the Python API. Having everything written in Python is IMO better than shell for a number of reasons, including easier automated testing and more batteries included. Python is also arguably easier to write and debug, fostering more contributor engagement.

I held off porting the shell scripts to Python in this pull request because I want to be sure that is the path this project would like to take. Once this pull request is accepted, I'll start work on porting the shell scripts to Python. This is when mach will really show its potential as a useful tool.