Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

A new way to run mach

78 views
Skip to first unread message

Matt Brubeck

unread,
Mar 16, 2013, 3:48:00 PM3/16/13
to
I recently landed a new feature for the "mach" build tool [1]. You can
now run mach from anywhere in the mozilla source tree.

To get started, add mach to your $PATH. You can do this by changing the
PATH environment variable to include the mozilla source directory, or by
copying the "mach" script from your source directory to a location like
/usr/local/bin.

Then you can run mach commands from anywhere in your source directory,
and you can use paths within your current directory. For example, if
you are working on some devtools code you might run commands like:

cd browser/devtools

# Rebuild the code in browser/devtools/webconsole:
mach build webconsole
# Run browser-chrome tests from browser/devtools/webconsole/test:
mach mochitest-browser webconsole/test

# Most commands work the same no matter where you run them:
mach clobber
mach build # Do a full rebuild
mach package
mach install

You can also run "mach" within an objdir. If you have multiple objdirs
with different mozconfigs, mach automatically defaults to the mozconfig
that built the current objdir. This means you can switch between
configurations as easily as:

cd obj-debug
mach build
mach xpcshell-test

cd ../obj-optimized
mach build
mach xpcshell-test

(Note: the automatically-detected mozconfig is used as a default, but
you can still override it by explicitly setting the MOZCONFIG
environment variable.)

The "mach" script is now just a wrapper; it loads the actual mach code
and configuration from whichever source directory you run it in. So you
can add mach to your path once and it should work with any current or
future mozilla-central directory. (For older trees, like the current
aurora or beta repos, you still need to run mach the old way, using
"./mach" in the top source directory.)

For development details, please see bugs 840588 and 840690 (but note
that the feature changed a bit since those bugs were first filed). Huge
thanks to gps and all the other people who helped in the design and
implementation of this feature!

[1] https://developer.mozilla.org/en-US/docs/Developer_Guide/mach
[2] https://bugzilla.mozilla.org/show_bug.cgi?id=840588
[3] https://bugzilla.mozilla.org/show_bug.cgi?id=840690

Rob Campbell

unread,
Apr 15, 2013, 2:04:08 PM4/15/13
to Matt Brubeck, dev-pl...@lists.mozilla.org
Well this is pretty sweet.

On Mac, does mach do the right thing when you rebuild browser, does it also rebuild browser/app so your application bundle gets updated?

Thanks for doing this, Matt!
Rob
> _______________________________________________
> dev-platform mailing list
> dev-pl...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-platform

Rob Campbell

unread,
Apr 17, 2013, 11:44:23 AM4/17/13
to Matt Brubeck, dev-pl...@lists.mozilla.org
On 2013-04-17, at 11:42 , Matt Brubeck <mbru...@mozilla.com> wrote:

> On 4/15/2013 11:04 AM, Rob Campbell wrote:
>> On Mac, does mach do the right thing when you rebuild browser, does it also rebuild browser/app so your application bundle gets updated?

> "mach build browser" is the same as "make -C $objdir/browser" (literally, it just executes that "make" command to do all the work), so just like "make" it should rebuild all of the sub-directories too as long as the dependencies are correct.

On OS X, I believe we have to manually rebuild browser/app whenever making xul changes because we don't explicitly make changes in that directory so the app bundle doesn't get repackaged. That's my crude understanding of how that works anyway.

Thanks for the reply.

~ rob

Matt Brubeck

unread,
Apr 17, 2013, 11:42:38 AM4/17/13
to Rob Campbell, dev-pl...@lists.mozilla.org

Gavin Sharp

unread,
Apr 17, 2013, 1:50:13 PM4/17/13
to Matt Brubeck, dev-platform, Rob Campbell
I think Rob was talking about the case where you would call e.g.:

"mach build browser/base"

mach could know that on Mac, that also requires the equivalent of
"mach build browser/app" for those changes to actually be repackaged
into the bundle in objdir/dist/, because the build system doesn't. Of
course it would probably be better to actually just fix the build
system rather than trying to work around it with mach magic (which has
the potential to be confusing, if you're not expecting mach to behave
differently than the equivalent make invocation).

Gavin

Matt Brubeck

unread,
Apr 17, 2013, 2:06:19 PM4/17/13
to Gavin Sharp, dev-platform, Rob Campbell
On 4/17/2013 10:50 AM, Gavin Sharp wrote:
> I think Rob was talking about the case where you would call e.g.:
>
> "mach build browser/base"
>
> mach could know that on Mac, that also requires the equivalent of
> "mach build browser/app" for those changes to actually be repackaged
> into the bundle in objdir/dist/, because the build system doesn't.
The plan for cases like this is to integrate jdm's "smartmake" code into
the build system and allow "mach build" to use it:
https://bugzilla.mozilla.org/show_bug.cgi?id=677452
0 new messages