"mozconfig" -- a play in two acts

Today while trying to figure out a strange build error with a student (mozconfig doesn't like CR as much as CRLF), Ted decided to share a bit about the inner life of mozconfig.  I repeat it with permission for your reading pleasure.

Act I

  • You run "make -f client.mk"

  • The run_for_side_effects line runs [mozconfig2client-mk](see http://mxr.mozilla.org/mozilla-central/source/build/autoconf/mozconfig2client-mk)

  • This uses mozconfig-find to find the mozconfig to use

  • Your mozconfig is sourced as a shell script

  • In mozconfig2client-mk, "mk_add_options" is defined as a shell function that does some escaping and echoes whatever is listed after it to a temp file (ac_add_options in that file is defined as a no-op)

  • client.mk then includes that temp file, so anything in it is treated as makefile source

  • mk_add_options FOO=bar just winds up as the makefile assignment "FOO=bar"
    Act II

  • configure repeats this dance, but uses mozconfig2configure instead

  • this does the reverse: ac_add_options does some quoting and echoes the result, mk_add_options is a no-op

  • finally, configure sources the result as a shell script (with some hackery in there)


Show Comments