mozilla

Revision 296853 of myrules.mk

  • Revision slug: myrules.mk
  • Revision title: myrules.mk
  • Revision id: 296853
  • Created:
  • Creator: Wladimir_Palant
  • Is current revision? No
  • Comment

Revision Content

Developers can add arbitrary makefile changes to the entire tree using special files <tt>myconfig.mk</tt> and <tt>myrules.mk</tt>:

 

objdir/config/myconfig.mk
If present, this file is included near the end of config.mk, after build variables have been configured.

 

objdir/config/myrules.mk
If present, this file is included near the end of rules.mk, after all of the default rules.

Example: altering build variables using myconfig.mk

This is example is taken from the XPCOMGC project gcobject-config.mk.

 

Objective:
Run a special Dehydra script over the C++ codebase which writes analysis output to a file.
Plan:
Replace the normal variable which specifies a static analysis script with a different value: write the output to <tt>sourcefile.gcobject-results</tt>.
Implementation:
Create the following file in objdir/config/myconfig.mk:
DEHYDRA_FLAGS = -fplugin=$(DEHYDRA_PATH) -fplugin-arg="$(topsrcdir)/.hg/patches/gcobject.js $(@F).gcobject-results"

 

Example: Adding a new target using myrules.mk

This example taken from the XPCOMGC project pork-rules.mk.

 

Objective:
Collect a list of every preprocessed C++ file in Mozilla, for later processing using automatic rewriting tools.
Plan:
Create a target which will dump the list of files
Usage:
Run <tt>make echo-iifiles IIFILES_LIST=/path/to/store-list</tt>.
Implementation:
Create the following file in objdir/config/myrules.mk:
relativesrcdir = $(subst $(topsrcdir)/,,$(srcdir))

IIFILES_LIST = $(error Please specify IIFILES_LIST)

echo-iifiles_tier_%:
	@echo "$@"
	@$(MAKE_TIER_SUBMAKEFILES)
	@$(EXIT_ON_ERROR) \
	  $(foreach dir,$(tier_$*_dirs),$(MAKE) -C $(dir) echo-iifiles; ) true

echo-iifiles::
	@($(foreach f,$(patsubst %.cc,%.ii,$(CPPSRCS:.cpp=.ii)),printf "$(relativesrcdir)/$(f)\n";) true) >> $(IIFILES_LIST)
	+$(LOOP_OVER_DIRS)
	+$(LOOP_OVER_TOOL_DIRS)

# PSM build rules don't use DIRS... recurse manually
ifeq (security/manager,$(relativesrcdir))
echo-iifiles::
	@$(EXIT_ON_ERROR) \
	  $(foreach dir,boot ssl locales pki,$(MAKE) -C $(dir) echo-iifiles; )
endif

 

Revision Source

<p>Developers can add arbitrary makefile changes to the entire tree using special files <tt>myconfig.mk</tt> and <tt>myrules.mk</tt>:</p>
<p>&nbsp;</p>
<dl>
  <dt>
    <var>objdir</var>/config/myconfig.mk</dt>
  <dd>
    If present, this file is included near the end of <a href="en/Config.mk">config.mk</a>, after build variables have been configured.
    <p>&nbsp;</p>
  </dd>
  <dt>
    <var>objdir</var>/config/myrules.mk</dt>
  <dd>
    If present, this file is included near the end of <a href="en/Rules.mk">rules.mk</a>, after all of the default rules.</dd>
</dl>
<h3 id="Example:_altering_build_variables_using_myconfig.mk" name="Example:_altering_build_variables_using_myconfig.mk">Example: altering build variables using myconfig.mk</h3>
<p>This is example is taken from the XPCOMGC project <a class="external" href="http://hg.mozilla.org/users/bsmedberg_mozilla.com/xpcomgc-patches/index.cgi/file/1cf47cdb0feb/gcobject-config.mk">gcobject-config.mk</a>.</p>
<p>&nbsp;</p>
<dl>
  <dt>
    Objective:</dt>
  <dd>
    Run a special <a href="en/Dehydra">Dehydra</a> script over the C++ codebase which writes analysis output to a file.</dd>
  <dt>
    Plan:</dt>
  <dd>
    Replace the normal variable which specifies a static analysis script with a different value: write the output to <tt><var>sourcefile</var>.gcobject-results</tt>.</dd>
  <dt>
    Implementation:</dt>
  <dd>
    Create the following file in <var>objdir</var>/config/myconfig.mk:
    <pre>
DEHYDRA_FLAGS = -fplugin=$(DEHYDRA_PATH) -fplugin-arg="$(topsrcdir)/.hg/patches/gcobject.js $(@F).gcobject-results"
</pre>
    <p>&nbsp;</p>
  </dd>
</dl>
<h3 id="Example:_Adding_a_new_target_using_myrules.mk" name="Example:_Adding_a_new_target_using_myrules.mk">Example: Adding a new target using myrules.mk</h3>
<p>This example taken from the XPCOMGC project <a class="external" href="http://hg.mozilla.org/users/bsmedberg_mozilla.com/xpcomgc-patches/index.cgi/file/1cf47cdb0feb/pork-rules.mk">pork-rules.mk</a>.</p>
<p>&nbsp;</p>
<dl>
  <dt>
    Objective:</dt>
  <dd>
    Collect a list of every preprocessed C++ file in Mozilla, for later processing using automatic rewriting tools.</dd>
  <dt>
    Plan:</dt>
  <dd>
    Create a target which will dump the list of files</dd>
  <dt>
    Usage:</dt>
  <dd>
    Run <tt>make echo-iifiles IIFILES_LIST=/path/to/store-list</tt>.</dd>
  <dt>
    Implementation:</dt>
  <dd>
    Create the following file in <var>objdir</var>/config/myrules.mk:
    <pre>
relativesrcdir = $(subst $(topsrcdir)/,,$(srcdir))

IIFILES_LIST = $(error Please specify IIFILES_LIST)

echo-iifiles_tier_%:
	@echo "$@"
	@$(MAKE_TIER_SUBMAKEFILES)
	@$(EXIT_ON_ERROR) \
	  $(foreach dir,$(tier_$*_dirs),$(MAKE) -C $(dir) echo-iifiles; ) true

echo-iifiles::
	@($(foreach f,$(patsubst&nbsp;%.cc,%.ii,$(CPPSRCS:.cpp=.ii)),printf "$(relativesrcdir)/$(f)\n";) true) &gt;&gt; $(IIFILES_LIST)
	+$(LOOP_OVER_DIRS)
	+$(LOOP_OVER_TOOL_DIRS)

# PSM build rules don't use DIRS... recurse manually
ifeq (security/manager,$(relativesrcdir))
echo-iifiles::
	@$(EXIT_ON_ERROR) \
	  $(foreach dir,boot ssl locales pki,$(MAKE) -C $(dir) echo-iifiles; )
endif
</pre>
    <p>&nbsp;</p>
  </dd>
</dl>
Revert to this revision