Bug 1041941 - Use templates for programs, simple programs, libraries and C++ unit tests. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 03 Sep 2014 14:10:54 +0900
changeset 226686 01a0e2c9c595e983605cb0aa5c12c9eceeb8ae7f
parent 226685 4f68377242c12a38015dc55d880ceb437dc59b8b
child 226687 17bee965226aac3bfc80ac19b513467ae61c8609
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1041941
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1041941 - Use templates for programs, simple programs, libraries and C++ unit tests. r=gps
accessible/interfaces/ia2/moz.build
accessible/interfaces/msaa/moz.build
b2g/app/moz.build
b2g/gaia/moz.build
browser/app/moz.build
browser/metro/shell/commandexecutehandler/moz.build
browser/metro/shell/linktool/moz.build
browser/metro/shell/testing/moz.build
build/docs/defining-binaries.rst
build/stlport/moz.build
build/templates.mozbuild
build/unix/elfhack/moz.build
build/unix/stdc++compat/moz.build
build/win32/crashinjectdll/moz.build
build/win32/moz.build
build/win32/vmwarerecordinghelper/moz.build
config/external/ffi/moz.build
config/external/freetype2/moz.build
config/external/icu/moz.build
config/external/nspr/moz.build
config/external/nss/crmf/moz.build
config/external/nss/moz.build
config/external/sqlite/moz.build
config/external/zlib/moz.build
config/moz.build
content/base/test/moz.build
content/media/compiledtest/moz.build
content/media/webaudio/compiledtest/moz.build
dom/audiochannel/tests/moz.build
dom/bindings/test/moz.build
dom/canvas/compiledtest/moz.build
dom/media/gmp-plugin/moz.build
dom/plugins/ipc/hangui/moz.build
dom/plugins/ipc/interpose/moz.build
dom/plugins/test/testplugin/javaplugin/moz.build
dom/plugins/test/testplugin/moz.build
dom/plugins/test/testplugin/secondplugin/moz.build
editor/txmgr/tests/moz.build
embedding/tests/winEmbed/moz.build
gfx/angle/src/libEGL/moz.build
gfx/angle/src/libGLESv2/moz.build
intl/lwbrk/tests/moz.build
intl/uconv/tools/moz.build
intl/unicharutil/tests/moz.build
intl/unicharutil/tools/moz.build
intl/unicharutil/util/moz.build
ipc/app/moz.build
ipc/contentproc/moz.build
ipc/ipdl/test/cxx/app/moz.build
js/src/editline/moz.build
js/src/gdb/moz.build
js/src/jsapi-tests/moz.build
js/src/moz.build
js/src/shell/moz.build
js/xpconnect/shell/moz.build
layout/media/moz.build
layout/media/webrtc/moz.build
layout/style/test/moz.build
media/libcubeb/src/moz.build
media/libcubeb/tests/moz.build
media/libpng/moz.build
media/libspeex_resampler/src/moz.build
media/libvpx/moz.build
media/mtransport/standalone/moz.build
media/mtransport/test/moz.build
media/omx-plugin/froyo/moz.build
media/omx-plugin/gb/moz.build
media/omx-plugin/gb235/moz.build
media/omx-plugin/hc/moz.build
media/omx-plugin/kk/moz.build
media/omx-plugin/lib/froyo/libstagefright/moz.build
media/omx-plugin/lib/gb/libstagefright/moz.build
media/omx-plugin/lib/gb/libstagefright_color_conversion/moz.build
media/omx-plugin/lib/gb/libutils/moz.build
media/omx-plugin/lib/gb235/libstagefright/moz.build
media/omx-plugin/lib/hc/libstagefright/moz.build
media/omx-plugin/lib/ics/libstagefright/moz.build
media/omx-plugin/lib/ics/libutils/moz.build
media/omx-plugin/lib/ics/libvideoeditorplayer/moz.build
media/omx-plugin/moz.build
media/webrtc/signaling/test/moz.build
memory/build/moz.build
memory/jemalloc/moz.build
memory/mozalloc/moz.build
memory/mozalloc/tests/moz.build
memory/mozjemalloc/moz.build
memory/replace/dmd/moz.build
memory/replace/dummy/moz.build
memory/replace/jemalloc/moz.build
mfbt/moz.build
mfbt/tests/moz.build
modules/libbz2/src/moz.build
modules/libmar/sign/moz.build
modules/libmar/src/moz.build
modules/libmar/tool/moz.build
modules/libmar/verify/moz.build
mozglue/build/moz.build
mozglue/linker/moz.build
mozglue/linker/tests/moz.build
mozglue/tests/moz.build
netwerk/sctp/src/moz.build
netwerk/srtp/src/moz.build
netwerk/streamconv/test/moz.build
netwerk/test/moz.build
other-licenses/bsdiff/moz.build
profile/dirserviceprovider/moz.build
python/mozbuild/mozbuild/frontend/context.py
python/mozbuild/mozbuild/frontend/gyp_reader.py
python/mozbuild/mozbuild/frontend/reader.py
python/mozbuild/mozbuild/test/backend/data/visual-studio/moz.build
python/mozbuild/mozbuild/test/frontend/data/program/moz.build
rdf/tests/rdfcat/moz.build
rdf/tests/rdfpoll/moz.build
rdf/tests/triplescat/moz.build
rdf/util/moz.build
security/manager/ssl/tests/compiled/moz.build
security/manager/ssl/tests/unit/pkcs11testmodule/moz.build
security/manager/ssl/tests/unit/tlsserver/cmd/moz.build
security/manager/ssl/tests/unit/tlsserver/lib/moz.build
security/pkix/moz.build
security/pkix/test/lib/moz.build
security/sandbox/linux/moz.build
security/sandbox/moz.build
security/sandbox/staticruntime/moz.build
security/sandbox/win/src/sandboxbroker/moz.build
startupcache/test/moz.build
storage/test/moz.build
testing/gtest/moz.build
testing/mochitest/ssltunnel/moz.build
testing/tools/screenshot/moz.build
toolkit/components/ctypes/tests/moz.build
toolkit/components/maintenanceservice/moz.build
toolkit/components/places/tests/cpp/moz.build
toolkit/crashreporter/breakpad-windows-libxul/moz.build
toolkit/crashreporter/breakpad-windows-libxul/staticruntime/moz.build
toolkit/crashreporter/client/moz.build
toolkit/crashreporter/google-breakpad/src/common/dwarf/moz.build
toolkit/crashreporter/google-breakpad/src/common/linux/moz.build
toolkit/crashreporter/google-breakpad/src/common/mac/moz.build
toolkit/crashreporter/google-breakpad/src/common/moz.build
toolkit/crashreporter/google-breakpad/src/common/solaris/moz.build
toolkit/crashreporter/google-breakpad/src/tools/linux/dump_syms/moz.build
toolkit/crashreporter/google-breakpad/src/tools/mac/dump_syms/moz.build
toolkit/crashreporter/google-breakpad/src/tools/solaris/dump_syms/moz.build
toolkit/crashreporter/injector/moz.build
toolkit/crashreporter/test/moz.build
toolkit/library/StaticXULComponentsEnd/moz.build
toolkit/library/gtest/moz.build
toolkit/library/moz.build
toolkit/mozapps/plugins/tests/moz.build
toolkit/mozapps/update/common-standalone/moz.build
toolkit/mozapps/update/common/moz.build
toolkit/mozapps/update/tests/moz.build
toolkit/mozapps/update/updater/moz.build
toolkit/webapps/tests/moz.build
toolkit/xre/test/win/moz.build
tools/jprof/moz.build
tools/jprof/stub/moz.build
tools/trace-malloc/moz.build
uriloader/exthandler/tests/moz.build
webapprt/gtk/moz.build
webapprt/mac/moz.build
webapprt/win/moz.build
widget/gonk/libdisplay/moz.build
widget/gtk/mozgtk/gtk2/moz.build
widget/gtk/mozgtk/gtk3/moz.build
widget/gtk/mozgtk/stub/moz.build
widget/tests/moz.build
widget/xremoteclient/moz.build
xpcom/glue/moz.build
xpcom/glue/nomozalloc/moz.build
xpcom/glue/standalone/moz.build
xpcom/glue/standalone/staticruntime/moz.build
xpcom/glue/staticruntime/moz.build
xpcom/reflect/xptcall/md/test/moz.build
xpcom/reflect/xptcall/tests/moz.build
xpcom/reflect/xptinfo/tests/moz.build
xpcom/sample/program/moz.build
xpcom/tests/external/moz.build
xpcom/tests/moz.build
xpcom/tests/windows/moz.build
xpcom/typelib/xpt/moz.build
xpcom/typelib/xpt/tests/moz.build
xpcom/windbgdlg/moz.build
xulrunner/app/moz.build
xulrunner/stub/moz.build
xulrunner/tools/redit/moz.build
--- a/accessible/interfaces/ia2/moz.build
+++ b/accessible/interfaces/ia2/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-LIBRARY_NAME = 'IA2Marshal'
+Library('IA2Marshal')
 
 FORCE_SHARED_LIB = True
 
 DEFINES['REGISTER_PROXY_DLL'] = True
 
 DEFFILE = SRCDIR + '/IA2Marshal.def'
 
 OS_LIBS += [
--- a/accessible/interfaces/msaa/moz.build
+++ b/accessible/interfaces/msaa/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-LIBRARY_NAME = 'AccessibleMarshal'
+Library('AccessibleMarshal')
 
 GENERATED_SOURCES += [
     'dlldata.c',
     'ISimpleDOMDocument_i.c',
     'ISimpleDOMDocument_p.c',
     'ISimpleDOMNode_i.c',
     'ISimpleDOMNode_p.c',
     'ISimpleDOMText_i.c',
--- a/b2g/app/moz.build
+++ b/b2g/app/moz.build
@@ -1,19 +1,19 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
 if not CONFIG['LIBXUL_SDK']:
     if CONFIG['GAIADIR']:
-        PROGRAM = CONFIG['MOZ_APP_NAME'] + "-bin"
+        Program(CONFIG['MOZ_APP_NAME'] + "-bin")
     else:
-        PROGRAM = CONFIG['MOZ_APP_NAME']
+        Program(CONFIG['MOZ_APP_NAME'])
     if CONFIG['MOZ_B2G_LOADER']:
         SOURCES += [
             'B2GLoader.cpp',
         ]
 
     SOURCES += [
         'nsBrowserApp.cpp',
     ]
--- a/b2g/gaia/moz.build
+++ b/b2g/gaia/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-PROGRAM = CONFIG['MOZ_APP_NAME']
+Program(CONFIG['MOZ_APP_NAME'])
 
 if CONFIG['OS_ARCH'] == 'WINNT':
     SOURCES += [
         'run-b2g.cpp',
     ]
     DEFINES['B2G_NAME'] = 'L"%s-bin%s"' % (PROGRAM, CONFIG['BIN_SUFFIX'])
     DEFINES['GAIA_PATH'] = 'L"gaia\\\\profile"'
 else:
--- a/browser/app/moz.build
+++ b/browser/app/moz.build
@@ -1,17 +1,17 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
 DIRS += ['profile/extensions']
 
-PROGRAM = CONFIG['MOZ_APP_NAME']
+Program(CONFIG['MOZ_APP_NAME'])
 
 SOURCES += [
     'nsBrowserApp.cpp',
 ]
 
 DEFINES['APP_VERSION'] = CONFIG['MOZ_APP_VERSION']
 
 for var in ('MOZILLA_OFFICIAL', 'LIBXUL_SDK'):
--- a/browser/metro/shell/commandexecutehandler/moz.build
+++ b/browser/metro/shell/commandexecutehandler/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-PROGRAM = 'CommandExecuteHandler'
+Program('CommandExecuteHandler')
 
 SOURCES += [
     'CEHHelper.cpp',
     'CommandExecuteHandler.cpp',
 ]
 
 # We want this exe in dist/bin
 DIST_SUBDIR = ''
--- a/browser/metro/shell/linktool/moz.build
+++ b/browser/metro/shell/linktool/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-PROGRAM = 'linktool'
+Program('linktool')
 
 SOURCES += [
     'linktool.cpp',
 ]
 
 DIST_SUBDIR = 'metro/install'
 
 for var in ('UNICODE', '_UNICODE'):
--- a/browser/metro/shell/testing/moz.build
+++ b/browser/metro/shell/testing/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-PROGRAM = 'metrotestharness'
+Program('metrotestharness')
 
 SOURCES += [
     'metrotestharness.cpp',
 ]
 
 # We want this exe in dist/bin
 DIST_SUBDIR = ''
 
--- a/build/docs/defining-binaries.rst
+++ b/build/docs/defining-binaries.rst
@@ -34,39 +34,39 @@ each append requires the given list to b
 ``SOURCES`` and ``UNIFIED_SOURCES`` can contain a mix of different file types,
 for C, C++, and Objective C.
 
 
 Static Libraries
 ================
 
 To build a static library, other than defining the source files (see above), one
-just needs to define a library name with the ``LIBRARY_NAME`` variable.
+just needs to define a library name with the ``Library`` template.
 
-   LIBRARY_NAME = 'foo'
+   Library('foo')
 
 The library file name will be ``libfoo.a`` on UNIX systems and ``foo.lib`` on
 Windows.
 
 If the static library needs to aggregate other static libraries, a list of
-``LIBRARY_NAME`` can be added to the ``USE_LIBS`` variable. Like ``SOURCES``, it
+``Library`` names can be added to the ``USE_LIBS`` variable. Like ``SOURCES``, it
 requires the appended list to be alphanumerically ordered.
 
    USE_LIBS += ['bar', 'baz']
 
-If there are multiple directories containing the same ``LIBRARY_NAME``, it is
+If there are multiple directories containing the same ``Library`` name, it is
 possible to disambiguate by prefixing with the path to the wanted one (relative
 or absolute):
 
    USE_LIBS += [
        '/path/from/topsrcdir/to/bar',
        '../relative/baz',
    ]
 
-Note that the leaf name in those paths is the ``LIBRARY_NAME``, not an actual
+Note that the leaf name in those paths is the ``Library`` name, not an actual
 file name.
 
 Note that currently, the build system may not create an actual library for
 static libraries. It is an implementation detail that shouldn't need to be
 worried about.
 
 As a special rule, ``USE_LIBS`` is allowed to contain references to shared
 libraries. In such cases, programs and shared libraries linking this static
@@ -79,88 +79,89 @@ Intermediate (Static) Libraries
 In many cases in the tree, static libraries are built with the only purpose
 of being linked into another, bigger one (like libxul). Instead of adding all
 required libraries to ``USE_LIBS`` for the bigger one, it is possible to tell
 the build system that the library built in the current directory is meant to
 be linked to that bigger library, with the ``FINAL_LIBRARY`` variable.
 
    FINAL_LIBRARY = 'xul'
 
-The ``FINAL_LIBRARY`` value must match a unique ``LIBRARY_NAME`` somewhere
+The ``FINAL_LIBRARY`` value must match a unique ``Library`` name somewhere
 in the tree.
 
-As a special rule, those intermediate libraries don't need a ``LIBRARY_NAME``
+As a special rule, those intermediate libraries don't need a ``Library`` name
 for themselves.
 
 
 Shared Libraries
 ================
 
 Sometimes, we want shared libraries, a.k.a. dynamic libraries. Such libraries
 are defined with the same variables as static libraries, with the addition of
 the ``FORCE_SHARED_LIB`` boolean variable:
 
    FORCE_SHARED_LIB = True
 
 When this variable is set, no static library is built. See further below to
 build both types of libraries.
 
-With a ``LIBRARY_NAME`` of ``foo``, the library file name will be
+With a ``Library`` name of ``foo``, the library file name will be
 ``libfoo.dylib`` on OSX, ``libfoo.so`` on ELF systems (Linux, etc.), and
 ``foo.dll`` on Windows. On Windows, there is also an import library named
 ``foo.lib``, used on the linker command line. ``libfoo.dylib`` and
 ``libfoo.so`` are considered the import library name for, resp. OSX and ELF
 systems.
 
 On OSX, one may want to create a special kind of dynamic library: frameworks.
 This is done with the ``IS_FRAMEWORK`` boolean variable.
 
    IS_FRAMEWORK = True
 
-With a ``LIBRARY_NAME`` of ``foo``, the framework file name will be ``foo``.
+With a ``Library`` name of ``foo``, the framework file name will be ``foo``.
 This variable however affects the behavior on all platforms, so it needs to
 be set only on OSX.
 
 Another special kind of library, XPCOM-specific, are XPCOM components. One can
 build such a component with the ``IS_COMPONENT`` boolean variable.
 
    IS_COMPONENT = True
 
 
 Executables
 ===========
 
 Executables, a.k.a. programs, are, in the simplest form, defined with the
-``PROGRAM`` variable.
+``Program`` template.
 
-   PROGRAM = 'foobar'
+   Program('foobar')
 
 On UNIX systems, the executable file name will be ``foobar``, while on Windows,
 it will be ``foobar.exe``.
 
 Like static and shared libraries, the build system can be instructed to link
-libraries to the executable with ``USE_LIBS``, listing various ``LIBRARY_NAME``.
+libraries to the executable with ``USE_LIBS``, listing various ``Library``
+names.
 
 In some cases, we want to create an executable per source file in the current
-directory, in which case we can use the ``SIMPLE_PROGRAMS`` list:
+directory, in which case we can use the ``SimplePrograms`` template
 
-   SIMPLE_PROGRAMS = [
+   SimplePrograms([
        'FirstProgram',
        'SecondProgram',
-   ]
+   ])
 
 The corresponding ``SOURCES`` must match:
 
    SOURCES += [
        'FirstProgram.cpp',
        'SecondProgram.c',
    ]
 
-Similar to ``SIMPLE_PROGRAMS``, is ``CPP_UNIT_TESTS``, which defines, with the
-same rules, C++ unit tests programs.
+Similar to ``SimplePrograms``, is the ``CppUnitTests`` template, which defines,
+with the same rules, C++ unit tests programs.
 
 
 Linking with system libraries
 =============================
 
 Programs and libraries usually need to link with system libraries, such as a
 widget toolkit, etc. Those required dependencies can be given with the
 ``OS_LIBS`` variable.
@@ -184,20 +185,20 @@ assign ``LIBS`` variables from ``CONFIG`
 Like ``USE_LIBS``, this variable applies to static and shared libraries, as
 well as programs.
 
 
 Libraries from third party build system
 =======================================
 
 Some libraries in the tree are not built by the moz.build-governed build
-system, and there is no ``LIBRARY_NAME`` corresponding to them.
+system, and there is no ``Library`` corresponding to them.
 
 However, ``USE_LIBS`` allows to reference such libraries by giving a full
-path (like when disambiguating identical ``LIBRARY_NAME``). The same naming
+path (like when disambiguating identical ``Library`` names). The same naming
 rules apply as other uses of ``USE_LIBS``, so only the library name without
 prefix and suffix shall be given.
 
    USE_LIBS += [
        '/path/from/topsrcdir/to/third-party/bar',
        '../relative/third-party/baz',
    ]
 
@@ -212,73 +213,73 @@ Building both static and shared librarie
 When both types of libraries are required, one needs to set both
 ``FORCE_SHARED_LIB`` and ``FORCE_STATIC_LIB`` boolean variables.
 
    FORCE_SHARED_LIB = True
    FORCE_STATIC_LIB = True
 
 But because static libraries and Windows import libraries have the same file
 names, either the static or the shared library name needs to be different
-than ``LIBRARY_NAME``.
+than the name given to the ``Library`` template.
 
 The ``STATIC_LIBRARY_NAME`` and ``SHARED_LIBRARY_NAME`` variables can be used
 to change either the static or the shared library name.
 
-  LIBRARY_NAME = 'foo'
+  Library('foo')
   STATIC_LIBRARY_NAME = 'foo_s'
 
 With the above, on Windows, ``foo_s.lib`` will be the static library,
 ``foo.dll`` the shared library, and ``foo.lib`` the import library.
 
 In some cases, for convenience, it is possible to set both
 ``STATIC_LIBRARY_NAME`` and ``SHARED_LIBRARY_NAME``. For example:
 
-  LIBRARY_NAME = 'mylib'
+  Library('mylib')
   STATIC_LIBRARY_NAME = 'mylib_s'
   SHARED_LIBRARY_NAME = CONFIG['SHARED_NAME']
 
 This allows to use ``mylib`` in the ``USE_LIBS`` of another library or
 executable.
 
-When refering to a ``LIBRARY_NAME`` building both types of libraries in
+When refering to a ``Library`` name building both types of libraries in
 ``USE_LIBS``, the shared library is chosen to be linked. But sometimes,
-it is wanted to link the static version, in which case the ``LIBRARY_NAME``
+it is wanted to link the static version, in which case the ``Library`` name
 needs to be prefixed with ``static:`` in ``USE_LIBS``
 
    a/moz.build:
-      LIBRARY_NAME = 'mylib'
+      Library('mylib')
       FORCE_SHARED_LIB = True
       FORCE_STATIC_LIB = True
       STATIC_LIBRARY_NAME = 'mylib_s'
    b/moz.build:
-      PROGRAM = 'myprog'
+      Program('myprog')
       USE_LIBS += [
           'static:mylib',
       ]
 
 
 Miscellaneous
 =============
 
 The ``SDK_LIBRARY`` boolean variable defines whether the library in the current
 directory is going to be installed in the SDK.
 
 The ``SONAME`` variable declares a "shared object name" for the library. It
-defaults to the ``LIBRARY_NAME`` or the ``SHARED_LIBRARY_NAME`` if set. When
+defaults to the ``Library`` name or the ``SHARED_LIBRARY_NAME`` if set. When
 linking to a library with a ``SONAME``, the resulting library or program will
 have a dependency on the library with the name corresponding to the ``SONAME``
-instead of ``LIBRARY_NAME``. This only impacts ELF systems.
+instead of the ``Library`` name. This only impacts ELF systems.
 
    a/moz.build:
-      LIBRARY_NAME = 'mylib'
+      Library('mylib')
    b/moz.build:
-      LIBRARY_NAME = 'otherlib'
+      Library('otherlib')
       SONAME = 'foo'
    c/moz.build:
-      PROGRAM = 'myprog'
+      Program('myprog')
       USE_LIBS += [
           'mylib',
           'otherlib',
       ]
 
 On e.g. Linux, the above ``myprog`` will have DT_NEEDED markers for
 ``libmylib.so`` and ``libfoo.so`` instead of ``libmylib.so`` and
 ``libotherlib.so`` if there weren't a ``SONAME``. This means the runtime
--- a/build/stlport/moz.build
+++ b/build/stlport/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-LIBRARY_NAME = 'stlport_static'
+Library('stlport_static')
 
 FORCE_STATIC_LIB = True
 
 SOURCES += [
     'src/allocators.cpp',
     'src/bitset.cpp',
     'src/codecvt.cpp',
     'src/collate.cpp',
--- a/build/templates.mozbuild
+++ b/build/templates.mozbuild
@@ -1,15 +1,66 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
 @template
+def Program(name):
+    '''Template for program executables.'''
+    PROGRAM = name
+
+
+@template
+def SimplePrograms(names):
+    '''Template for simple program executables.
+
+    Those have a single source with the same base name as the executable.
+    '''
+    SIMPLE_PROGRAMS += names
+
+
+@template
+def CppUnitTests(names):
+    '''Template for C++ unit tests.
+
+    Those have a single source with the same base name as the executable.
+    '''
+    CPP_UNIT_TESTS += names
+
+
+@template
+def Library(name):
+    '''Template for libraries.'''
+    LIBRARY_NAME = name
+
+
+@template
+def HostProgram(name):
+    '''Template for build tools executables.'''
+    HOST_PROGRAM = name
+
+
+@template
+def HostSimplePrograms(names):
+    '''Template for simple build tools executables.
+
+    Those have a single source with the same base name as the executable.
+    '''
+    HOST_SIMPLE_PROGRAMS += names
+
+
+@template
+def HostLibrary(name):
+    '''Template for build tools libraries.'''
+    HOST_LIBRARY_NAME = name
+
+
+@template
 def GeckoBinary():
     '''Template for binaries using Gecko.
 
     This template is meant to be used in other templates.
     '''
     USE_LIBS += [
         'mozalloc',
         'nspr',
--- a/build/unix/elfhack/moz.build
+++ b/build/unix/elfhack/moz.build
@@ -14,13 +14,13 @@ if not CONFIG['CROSS_COMPILE']:
         'test-ctors.c',
     ]
 
 HOST_SOURCES += [
     'elf.cpp',
     'elfhack.cpp',
 ]
 
-HOST_PROGRAM = 'elfhack'
+HostProgram('elfhack')
 
 DEFINES['ELFHACK_BUILD'] = True
 
 NO_PGO = True
--- a/build/unix/stdc++compat/moz.build
+++ b/build/unix/stdc++compat/moz.build
@@ -1,20 +1,20 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
 if CONFIG['MOZ_LIBSTDCXX_TARGET_VERSION']:
-    LIBRARY_NAME = 'stdc++compat'
+    Library('stdc++compat')
     SOURCES += ['stdc++compat.cpp']
 
 if CONFIG['MOZ_LIBSTDCXX_HOST_VERSION']:
-    HOST_LIBRARY_NAME = 'host_stdc++compat'
+    HostLibrary('host_stdc++compat')
     HOST_SOURCES += [
         'stdc++compat.cpp',
     ]
 
 FORCE_STATIC_LIB = True
 
 NO_PGO = True
 
--- a/build/win32/crashinjectdll/moz.build
+++ b/build/win32/crashinjectdll/moz.build
@@ -3,15 +3,15 @@
 # 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/.
 
 SOURCES += [
     'crashinjectdll.cpp',
 ]
 
-LIBRARY_NAME = 'crashinjectdll'
+Library('crashinjectdll')
 
 FORCE_SHARED_LIB = True
 
 DEFFILE = SRCDIR + '/crashinjectdll.def'
 
 USE_STATIC_LIBS = True
--- a/build/win32/moz.build
+++ b/build/win32/moz.build
@@ -5,15 +5,15 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 if CONFIG['_MSC_VER'] and CONFIG['OS_TEST'] != 'x86_64':
     TEST_DIRS += ['vmwarerecordinghelper']
 
 TEST_DIRS += ['crashinjectdll']
 
 if CONFIG['ENABLE_TESTS']:
-    PROGRAM = 'crashinject'
+    Program('crashinject')
     SOURCES += [
         'crashinject.cpp',
     ]
     USE_STATIC_LIBS = True
 
 NO_PGO = True
--- a/build/win32/vmwarerecordinghelper/moz.build
+++ b/build/win32/vmwarerecordinghelper/moz.build
@@ -3,15 +3,15 @@
 # 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/.
 
 SOURCES += [
     'vmwarerecordinghelper.cpp',
 ]
 
-LIBRARY_NAME = 'vmwarerecordinghelper'
+Library('vmwarerecordinghelper')
 
 FORCE_SHARED_LIB = True
 
 DEFFILE = '%s/%s.def' % (SRCDIR, LIBRARY_NAME)
 
 USE_STATIC_LIBS = True
--- a/config/external/ffi/moz.build
+++ b/config/external/ffi/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-LIBRARY_NAME = 'ffi'
+Library('ffi')
 
 if CONFIG['MOZ_NATIVE_FFI']:
     OS_LIBS += CONFIG['MOZ_FFI_LIBS']
 else:
     if CONFIG['_MSC_VER']:
         prefix = 'lib'
     else:
         prefix = ''
--- a/config/external/freetype2/moz.build
+++ b/config/external/freetype2/moz.build
@@ -1,14 +1,14 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-LIBRARY_NAME = 'freetype'
+Library('freetype')
 
 if CONFIG['MOZ_TREE_FREETYPE']:
     USE_LIBS += [
         'static:/modules/freetype2/.libs/freetype',
     ]
 else:
     OS_LIBS += CONFIG['FT2_LIBS']
--- a/config/external/icu/moz.build
+++ b/config/external/icu/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-LIBRARY_NAME = 'icu'
+Library('icu')
 
 if CONFIG['MOZ_NATIVE_ICU']:
     OS_LIBS += CONFIG['MOZ_ICU_LIBS']
 else:
     # Order needs to be preserved
     for l in CONFIG['ICU_LIB_NAMES']:
         USE_LIBS += ['%s/intl/icu/target/lib/%s%s' % (
             'static:' if not CONFIG['MOZ_SHARED_ICU'] else '',
--- a/config/external/nspr/moz.build
+++ b/config/external/nspr/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-LIBRARY_NAME = 'nspr'
+Library('nspr')
 
 if CONFIG['MOZ_FOLD_LIBS']:
     # When folding libraries, nspr is actually in the nss library.
     USE_LIBS += [
         'nss',
     ]
 elif CONFIG['MOZ_BUILD_NSPR']:
     USE_LIBS += [
--- a/config/external/nss/crmf/moz.build
+++ b/config/external/nss/crmf/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-LIBRARY_NAME = 'crmf'
+Library('crmf')
 
 if CONFIG['MOZ_NATIVE_NSS']:
     OS_LIBS += [l for l in CONFIG['NSS_LIBS'] if l.startswith('-L')]
     OS_LIBS += ['-lcrmf']
 else:
     USE_LIBS += [
         # The dependency on nss is not real, but is required to force the
         # parent directory being built before this one. This has no
--- a/config/external/nss/moz.build
+++ b/config/external/nss/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-LIBRARY_NAME = 'nss'
+Library('nss')
 
 DIRS += ['crmf']
 
 if CONFIG['MOZ_NATIVE_NSS']:
     OS_LIBS += CONFIG['NSS_LIBS']
 elif CONFIG['MOZ_FOLD_LIBS']:
     # TODO: The library name can be changed when bug 845217 is fixed.
     SHARED_LIBRARY_NAME = 'nss3'
--- a/config/external/sqlite/moz.build
+++ b/config/external/sqlite/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-LIBRARY_NAME = 'sqlite'
+Library('sqlite')
 
 if CONFIG['MOZ_NATIVE_SQLITE']:
     OS_LIBS += CONFIG['SQLITE_LIBS']
 else:
     DIRS += ['../../../db/sqlite3/src']
     if CONFIG['MOZ_FOLD_LIBS']:
         # When folding libraries, sqlite is actually in the nss library.
         USE_LIBS += [
--- a/config/external/zlib/moz.build
+++ b/config/external/zlib/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-LIBRARY_NAME = 'zlib'
+Library('zlib')
 
 if CONFIG['MOZ_NATIVE_ZLIB']:
     OS_LIBS += CONFIG['MOZ_ZLIB_LIBS']
 else:
     if CONFIG['ZLIB_IN_MOZGLUE']:
         # Can't do this until mozglue is handled by moz.build instead of
         # config/rules.mk.
         # USE_LIBS += [
--- a/config/moz.build
+++ b/config/moz.build
@@ -16,17 +16,17 @@ CONFIGURE_SUBST_FILES += [
     'tests/src-simple/Makefile',
 ]
 
 if CONFIG['HOST_OS_ARCH'] != 'WINNT':
     HOST_SOURCES += [
         'nsinstall.c',
         'pathsub.c',
     ]
-    HOST_PROGRAM = 'nsinstall_real'
+    HostProgram('nsinstall_real')
 
 if CONFIG['GKMEDIAS_SHARED_LIBRARY']:
     DEFINES['GKMEDIAS_SHARED_LIBRARY'] = True
 
 if CONFIG['MOZ_SHARED_ICU']:
     DEFINES['MOZ_SHARED_ICU'] = True
 
 PYTHON_UNIT_TESTS += [
--- a/content/base/test/moz.build
+++ b/content/base/test/moz.build
@@ -5,22 +5,22 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
 
 # FIXME/bug 575918: out-of-process xpcshell is broken on OS X
 if CONFIG['OS_ARCH'] != 'Darwin':
     XPCSHELL_TESTS_MANIFESTS += ['unit_ipc/xpcshell.ini']
 
-CPP_UNIT_TESTS += [
+CppUnitTests([
     'TestCSPParser',
     'TestGetURL',
     'TestNativeXMLHttpRequest',
     'TestPlainTextSerializer',
-]
+])
 
 SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
 
 MOCHITEST_MANIFESTS += [
     'chrome/mochitest.ini',
     'csp/mochitest.ini',
     'mochitest.ini',
     'websocket_hybi/mochitest.ini',
--- a/content/media/compiledtest/moz.build
+++ b/content/media/compiledtest/moz.build
@@ -1,18 +1,18 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-CPP_UNIT_TESTS += [
+CppUnitTests([
     'TestAudioBuffers',
     'TestAudioMixer'
-]
+])
 
 SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
 
 FAIL_ON_WARNINGS = True
 
 LOCAL_INCLUDES += [
     '..',
 ]
--- a/content/media/webaudio/compiledtest/moz.build
+++ b/content/media/webaudio/compiledtest/moz.build
@@ -1,17 +1,17 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-CPP_UNIT_TESTS += [
+CppUnitTests([
     'TestAudioEventTimeline',
-]
+])
 
 SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
 
 FAIL_ON_WARNINGS = True
 
 LOCAL_INCLUDES += [
     '..',
 ]
--- a/dom/audiochannel/tests/moz.build
+++ b/dom/audiochannel/tests/moz.build
@@ -1,17 +1,17 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-CPP_UNIT_TESTS += [
+CppUnitTests([
     'TestAudioChannelService',
-]
+])
 
 SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
 
 if CONFIG['OS_ARCH'] == 'WINNT':
     DEFINES['NOMINMAX'] = True
 
 MOCHITEST_MANIFESTS += ['mochitest.ini']
 
--- a/dom/bindings/test/moz.build
+++ b/dom/bindings/test/moz.build
@@ -7,17 +7,17 @@
 DEFINES.update({
     'IMPL_LIBXUL': True,
     'MOZILLA_INTERNAL_API': True,
 })
 
 # Do NOT export this library.  We don't actually want our test code
 # being added to libxul or anything.
 
-LIBRARY_NAME = 'dombindings_test_s'
+Library('dombindings_test_s')
 
 EXTRA_COMPONENTS += [
     'TestInterfaceJS.js',
     'TestInterfaceJS.manifest',
 ]
 
 MOCHITEST_MANIFESTS += ['mochitest.ini']
 
--- a/dom/canvas/compiledtest/moz.build
+++ b/dom/canvas/compiledtest/moz.build
@@ -1,17 +1,17 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-CPP_UNIT_TESTS += [
+CppUnitTests([
     'TestWebGLElementArrayCache',
-]
+])
 
 SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
 
 FAIL_ON_WARNINGS = True
 
 LOCAL_INCLUDES += [
     '../',
 ]
--- a/dom/media/gmp-plugin/moz.build
+++ b/dom/media/gmp-plugin/moz.build
@@ -4,15 +4,15 @@
 # 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/.
 
 NO_DIST_INSTALL = True
 SOURCES += [
         'gmp-fake.cpp'
 ]
 
-LIBRARY_NAME = "fake"
+Library("fake")
 
 USE_STATIC_LIBS = True
 FORCE_SHARED_LIB = True
 NO_VISIBILITY_FLAGS = True
 # Don't use STL wrappers; this isn't Gecko code
 DISABLE_STL_WRAPPING = True
--- a/dom/plugins/ipc/hangui/moz.build
+++ b/dom/plugins/ipc/hangui/moz.build
@@ -1,17 +1,17 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
 FAIL_ON_WARNINGS = True
 
-PROGRAM = 'plugin-hang-ui'
+Program('plugin-hang-ui')
 
 UNIFIED_SOURCES += [
     'MiniShmChild.cpp',
     'PluginHangUIChild.cpp',
 ]
 include('/ipc/chromium/chromium-config.mozbuild')
 
 DEFINES['NS_NO_XPCOM'] = True
--- a/dom/plugins/ipc/interpose/moz.build
+++ b/dom/plugins/ipc/interpose/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-LIBRARY_NAME = 'plugin_child_interpose'
+Library('plugin_child_interpose')
 
 UNIFIED_SOURCES += [ "%s.mm" % (LIBRARY_NAME) ]
 
 UNIFIED_SOURCES += [
     'plugin_child_quirks.mm',
 ]
 
 FORCE_SHARED_LIB = True
--- a/dom/plugins/test/testplugin/javaplugin/moz.build
+++ b/dom/plugins/test/testplugin/javaplugin/moz.build
@@ -1,10 +1,10 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-LIBRARY_NAME = 'nptestjava'
+Library('nptestjava')
 
 relative_path = '..'
 include('../testplugin.mozbuild')
--- a/dom/plugins/test/testplugin/moz.build
+++ b/dom/plugins/test/testplugin/moz.build
@@ -1,14 +1,14 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
 DIRS += ['secondplugin', 'javaplugin']
 
-LIBRARY_NAME = 'nptest'
+Library('nptest')
 
 FAIL_ON_WARNINGS = not CONFIG['_MSC_VER']
 
 relative_path = '.'
 include('testplugin.mozbuild')
--- a/dom/plugins/test/testplugin/secondplugin/moz.build
+++ b/dom/plugins/test/testplugin/secondplugin/moz.build
@@ -1,10 +1,10 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-LIBRARY_NAME = 'npsecondtest'
+Library('npsecondtest')
 
 relative_path = '..'
 include('../testplugin.mozbuild')
--- a/editor/txmgr/tests/moz.build
+++ b/editor/txmgr/tests/moz.build
@@ -1,17 +1,17 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-CPP_UNIT_TESTS += [
+CppUnitTests([
     'TestTXMgr',
-]
+])
 
 SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
 
 FAIL_ON_WARNINGS = True
 
 USE_LIBS += [
     'mozalloc',
     'nspr',
--- a/embedding/tests/winEmbed/moz.build
+++ b/embedding/tests/winEmbed/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-PROGRAM = 'winEmbed'
+Program('winEmbed')
 
 SOURCES += [
     'WebBrowserChrome.cpp',
     'WindowCreator.cpp',
     'winEmbed.cpp',
 ]
 
 XPI_NAME = 'winembed'
--- a/gfx/angle/src/libEGL/moz.build
+++ b/gfx/angle/src/libEGL/moz.build
@@ -49,13 +49,13 @@ DEFINES['EGLAPI'] = ""
 
 # ANGLE uses the STL, so we can't use our derpy STL wrappers.
 DISABLE_STL_WRAPPING = True
 
 
 LOCAL_INCLUDES += [ '../../include', '../../src' ]
 USE_LIBS += [ 'libGLESv2' ]
 
-LIBRARY_NAME = 'libEGL'
+Library('libEGL')
 FORCE_SHARED_LIB = True
 
 RCFILE = SRCDIR + '/libEGL.rc'
 DEFFILE = SRCDIR + '/libEGL.def'
--- a/gfx/angle/src/libGLESv2/moz.build
+++ b/gfx/angle/src/libGLESv2/moz.build
@@ -199,16 +199,16 @@ LOCAL_INCLUDES += [ '../../include', '..
 if CONFIG['MOZ_HAS_WINSDK_WITH_D3D']:
   EXTRA_DSO_LDOPTS += [ 'd3d9.lib', 'dxguid.lib' ]
 else:
   EXTRA_DSO_LDOPTS += [
     '\'%s/lib/%s/d3d9.lib\'' % (CONFIG['MOZ_DIRECTX_SDK_PATH'], CONFIG['MOZ_D3D_CPU_SUFFIX']),
     '\'%s/lib/%s/dxguid.lib\'' % (CONFIG['MOZ_DIRECTX_SDK_PATH'], CONFIG['MOZ_D3D_CPU_SUFFIX']),
   ]
 
-LIBRARY_NAME = 'libGLESv2'
+Library('libGLESv2')
 FORCE_SHARED_LIB = True
 
 RCFILE = SRCDIR + '/libGLESv2.rc'
 DEFFILE = SRCDIR + '/libGLESv2.def'
 
 DEFINES['ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES'] = '{ TEXT("d3dcompiler_47.dll"), TEXT("d3dcompiler_46.dll"), TEXT("d3dcompiler_43.dll") }'
 
--- a/intl/lwbrk/tests/moz.build
+++ b/intl/lwbrk/tests/moz.build
@@ -1,17 +1,17 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-CPP_UNIT_TESTS += [
+CppUnitTests([
     'TestLineBreak',
-]
+])
 
 SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
 
 USE_LIBS += [
     'mozalloc',
     'nspr',
     'xpcomglue_s',
     'xul',
--- a/intl/uconv/tools/moz.build
+++ b/intl/uconv/tools/moz.build
@@ -1,13 +1,13 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-SIMPLE_PROGRAMS += [
+SimplePrograms([
     'umaptable',
-]
+])
 
 SOURCES += [
     '%s.c' % s for s in SIMPLE_PROGRAMS
 ]
--- a/intl/unicharutil/tests/moz.build
+++ b/intl/unicharutil/tests/moz.build
@@ -6,19 +6,19 @@
 
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
 
 SOURCES += [
     'NormalizationTest.cpp',
     'UnicharSelfTest.cpp',
 ]
 
-SIMPLE_PROGRAMS += [
+SimplePrograms([
     "%s" % (fyl[0:-4]) for fyl in SOURCES
-]
+])
 
 USE_STATIC_LIBS = True
 
 USE_LIBS += [
     'mozalloc',
     'nspr',
     'unicharutil_external_s',
     'xul',
--- a/intl/unicharutil/tools/moz.build
+++ b/intl/unicharutil/tools/moz.build
@@ -1,12 +1,12 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-PROGRAM = 'ucgendat'
+Program('ucgendat')
 
 SOURCES += [
     'ucgendat.c',
 ]
 
--- a/intl/unicharutil/util/moz.build
+++ b/intl/unicharutil/util/moz.build
@@ -16,17 +16,17 @@ EXPORTS += [
     'nsUnicodeProperties.h',
     'nsUnicodeScriptCodes.h',
 ]
 
 include('objs.mozbuild')
 
 UNIFIED_SOURCES += intl_unicharutil_util_cppsrcs
 
-LIBRARY_NAME = 'unicharutil_external_s'
+Library('unicharutil_external_s')
 
 FORCE_STATIC_LIB = True
 
 SDK_LIBRARY = True
 
 USE_STATIC_LIBS = True
 
 if CONFIG['_MSC_VER']:
--- a/ipc/app/moz.build
+++ b/ipc/app/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-PROGRAM = CONFIG['MOZ_CHILD_PROCESS_NAME']
+Program(CONFIG['MOZ_CHILD_PROCESS_NAME'])
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
     SOURCES += [
         'MozillaRuntimeMainAndroid.cpp',
     ]
     FINAL_TARGET = 'dist/bin/lib'
 else:
     SOURCES += [
--- a/ipc/contentproc/moz.build
+++ b/ipc/contentproc/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-LIBRARY_NAME = 'plugin-container'
+Library('plugin-container')
 if CONFIG['MOZ_B2G_LOADER']:
     FINAL_LIBRARY = 'xul'
 
 SOURCES += [
     'plugin-container.cpp',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
--- a/ipc/ipdl/test/cxx/app/moz.build
+++ b/ipc/ipdl/test/cxx/app/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-PROGRAM = 'ipdlunittest'
+Program('ipdlunittest')
 
 SOURCES += [
     'TestIPDL.cpp',
 ]
 include('/ipc/chromium/chromium-config.mozbuild')
 
 LOCAL_INCLUDES += [
     '/toolkit/xre',
--- a/js/src/editline/moz.build
+++ b/js/src/editline/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-LIBRARY_NAME = 'editline'
+Library('editline')
 
 UNIFIED_SOURCES += [
     'editline.c',
     'sysunix.c',
 ]
 
 FORCE_STATIC_LIB = True
 
--- a/js/src/gdb/moz.build
+++ b/js/src/gdb/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-PROGRAM = 'gdb-tests'
+Program('gdb-tests')
 
 UNIFIED_SOURCES += [
     'gdb-tests.cpp',
     'tests/test-jsid.cpp',
     'tests/test-JSObject.cpp',
     'tests/test-JSString.cpp',
     'tests/test-JSSymbol.cpp',
     'tests/test-jsval.cpp',
--- a/js/src/jsapi-tests/moz.build
+++ b/js/src/jsapi-tests/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-PROGRAM = 'jsapi-tests'
+Program('jsapi-tests')
 
 UNIFIED_SOURCES += [
     'selfTest.cpp',
     'testAddPropertyPropcache.cpp',
     'testArgumentsObject.cpp',
     'testArrayBuffer.cpp',
     'testBindCallable.cpp',
     'testBug604087.cpp',
--- a/js/src/moz.build
+++ b/js/src/moz.build
@@ -422,29 +422,29 @@ else:
 # bug 1030706.
 if CONFIG['_MSC_VER'] != '1600':
     MSVC_ENABLE_PGO = True
 
 HOST_SOURCES += [
     'jskwgen.cpp',
 ]
 
-HOST_SIMPLE_PROGRAMS += [
+HostSimplePrograms([
     'host_%s' % f.replace('.cpp', '') for f in HOST_SOURCES
-]
+])
 
 # JavaScript must be built shared, even for static builds, as it is used by
 # other modules which are always built shared. Failure to do so results in
 # the js code getting copied into xpinstall and jsd as well as mozilla-bin,
 # and then the static data cells used for locking no longer work.
 #
 # In fact, we now build both a static and a shared library, as the
 # JS shell would like to link to the static library.
 
-LIBRARY_NAME = 'js'
+Library('js')
 
 if CONFIG['JS_SHARED_LIBRARY']:
     FORCE_SHARED_LIB = True
     SHARED_LIBRARY_NAME = CONFIG['JS_LIBRARY_NAME']
     SDK_LIBRARY = True
 
 FORCE_STATIC_LIB = True
 STATIC_LIBRARY_NAME = 'js_static'
--- a/js/src/shell/moz.build
+++ b/js/src/shell/moz.build
@@ -1,16 +1,16 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
 if CONFIG['JS_SHELL_NAME']:
-    PROGRAM = CONFIG['JS_SHELL_NAME']
+    Program(CONFIG['JS_SHELL_NAME'])
     if CONFIG['JS_BUNDLED_EDITLINE']:
         USE_LIBS += ['editline']
     USE_LIBS += ['static:js']
 
 UNIFIED_SOURCES += [
     'js.cpp',
     'jsheaptools.cpp',
     'jsoptparse.cpp',
--- a/js/xpconnect/shell/moz.build
+++ b/js/xpconnect/shell/moz.build
@@ -1,17 +1,17 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
 FAIL_ON_WARNINGS = True
 
-PROGRAM = 'xpcshell'
+Program('xpcshell')
 
 SOURCES += [
     'xpcshell.cpp',
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     SOURCES += [
         'xpcshellMacUtils.mm',
--- a/layout/media/moz.build
+++ b/layout/media/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-LIBRARY_NAME = 'gkmedias'
+Library('gkmedias')
 
 if CONFIG['GKMEDIAS_SHARED_LIBRARY']:
     FORCE_SHARED_LIB = True
     USE_LIBS += [
         'mozalloc',
         'nspr',
     ]
 
--- a/layout/media/webrtc/moz.build
+++ b/layout/media/webrtc/moz.build
@@ -1,8 +1,8 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-LIBRARY_NAME = 'webrtc'
+Library('webrtc')
 FINAL_LIBRARY = 'xul'
--- a/layout/style/test/moz.build
+++ b/layout/style/test/moz.build
@@ -3,19 +3,19 @@
 # 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/.
 
 HOST_SOURCES += [
     'ListCSSProperties.cpp',
 ]
 
-HOST_SIMPLE_PROGRAMS += [
+HostSimplePrograms([
     'host_%s' % f.replace('.cpp', '') for f in HOST_SOURCES
-]
+])
 
 MOCHITEST_MANIFESTS += [
     'chrome/mochitest.ini',
     'css-visited/mochitest.ini',
     'mochitest.ini',
 ]
 BROWSER_CHROME_MANIFESTS += ['browser.ini']
 MOCHITEST_CHROME_MANIFESTS += ['chrome/chrome.ini']
--- a/media/libcubeb/src/moz.build
+++ b/media/libcubeb/src/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-LIBRARY_NAME = 'cubeb'
+Library('cubeb')
 
 SOURCES += [
     'cubeb.c',
     'cubeb_panner.cpp'
 ]
 
 if CONFIG['MOZ_ALSA']:
     SOURCES += [
--- a/media/libcubeb/tests/moz.build
+++ b/media/libcubeb/tests/moz.build
@@ -1,24 +1,24 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-CPP_UNIT_TESTS += [
+CppUnitTests([
   'test_tone'
-]
+])
 
 if CONFIG['OS_TARGET'] != 'Android':
-  CPP_UNIT_TESTS += [
+  CppUnitTests([
     'test_audio',
     'test_latency',
     'test_sanity'
-  ]
+  ])
 
 SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
 
 LOCAL_INCLUDES += [
     '../include'
 ]
 
 FAIL_ON_WARNINGS = True
--- a/media/libpng/moz.build
+++ b/media/libpng/moz.build
@@ -33,16 +33,16 @@ if CONFIG['MOZ_PNG_ARM_NEON']:
         'arm/arm_init.c',
         'arm/filter_neon_intrinsics.c'
     ]
 
     SOURCES += [
         'arm/filter_neon.S'
     ]
 
-LIBRARY_NAME = 'mozpng'
+Library('mozpng')
 
 MSVC_ENABLE_PGO = True
 
 if CONFIG['GKMEDIAS_SHARED_LIBRARY']:
     NO_VISIBILITY_FLAGS = True
 
 FINAL_LIBRARY = 'gkmedias'
--- a/media/libspeex_resampler/src/moz.build
+++ b/media/libspeex_resampler/src/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-LIBRARY_NAME = 'speex'
+Library('speex')
 
 EXPORTS.speex += [
     'speex_resampler.h',
 ]
 
 SOURCES += [
     'resample.c',
     'simd_detect.cpp',
--- a/media/libvpx/moz.build
+++ b/media/libvpx/moz.build
@@ -8,17 +8,17 @@ include('sources.mozbuild')
 
 EXPORTS.vpx += files['EXPORTS']
 
 if CONFIG['VPX_NEED_OBJ_INT_EXTRACT']:
     HOST_SOURCES += [
         'build/make/obj_int_extract.c',
     ]
 
-    HOST_PROGRAM = 'host_obj_int_extract'
+    HostProgram('host_obj_int_extract')
 
 # Unify fewer files together to reduce the chance of name collision
 FILES_PER_UNIFIED_FILE = 8
 
 SOURCES += files['SOURCES']
 UNIFIED_SOURCES += files['UNIFIED_SOURCES']
 
 if CONFIG['MOZ_VPX_ERROR_CONCEALMENT']:
--- a/media/mtransport/standalone/moz.build
+++ b/media/mtransport/standalone/moz.build
@@ -4,17 +4,17 @@
 # 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/.
 
 include('../objs.mozbuild')
 
 # These files cannot be built in unified mode because they force NSPR logging.
 SOURCES += mtransport_cppsrcs
 
-LIBRARY_NAME = 'mtransport_s'
+Library('mtransport_s')
 
 LOCAL_INCLUDES += [
     '/media/mtransport/',
     '/media/mtransport/third_party/',
     '/media/mtransport/third_party/nICEr/src/crypto',
     '/media/mtransport/third_party/nICEr/src/ice',
     '/media/mtransport/third_party/nICEr/src/net',
     '/media/mtransport/third_party/nICEr/src/stun',
--- a/media/mtransport/test/moz.build
+++ b/media/mtransport/test/moz.build
@@ -1,32 +1,32 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
 if CONFIG['OS_TARGET'] != 'WINNT' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
-    CPP_UNIT_TESTS += [
+    CppUnitTests([
         'buffered_stun_socket_unittest',
         'ice_unittest',
         'nrappkit_unittest',
         'rlogringbuffer_unittest',
         'runnable_utils_unittest',
         'simpletokenbucket_unittest',
         'sockettransportservice_unittest',
         'TestSyncRunnable',
         'transport_unittests',
         'turn_unittest',
-    ]
+    ])
 
     if CONFIG['MOZ_SCTP']:
-        CPP_UNIT_TESTS += [
+        CppUnitTests([
             'sctp_unittest',
-        ]
+        ])
 
     SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
 
 FAIL_ON_WARNINGS = True
 
 for var in ('HAVE_STRDUP', 'NR_SOCKET_IS_VOID_PTR', 'SCTP_DEBUG', 'INET'):
     DEFINES[var] = True
 
--- a/media/omx-plugin/froyo/moz.build
+++ b/media/omx-plugin/froyo/moz.build
@@ -3,17 +3,17 @@
 # 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/.
 
 SOURCES += [
     'OmxPluginFroyo.cpp',
 ]
 
-LIBRARY_NAME = 'omxpluginfroyo'
+Library('omxpluginfroyo')
 
 FORCE_SHARED_LIB = True
 
 LOCAL_INCLUDES += [
     '../include/froyo',
     '../include/froyo/media/stagefright/openmax',
 ]
 
--- a/media/omx-plugin/gb/moz.build
+++ b/media/omx-plugin/gb/moz.build
@@ -3,17 +3,17 @@
 # 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/.
 
 SOURCES += [
     'OmxPlugin236.cpp',
 ]
 
-LIBRARY_NAME = 'omxplugingb'
+Library('omxplugingb')
 
 FORCE_SHARED_LIB = True
 
 LOCAL_INCLUDES += [
     '../include/gb',
     '../include/gb/media/stagefright/openmax',
 ]
 
--- a/media/omx-plugin/gb235/moz.build
+++ b/media/omx-plugin/gb235/moz.build
@@ -3,17 +3,17 @@
 # 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/.
 
 SOURCES += [
     'OmxPlugin235.cpp',
 ]
 
-LIBRARY_NAME = 'omxplugingb235'
+Library('omxplugingb235')
 
 FORCE_SHARED_LIB = True
 
 LOCAL_INCLUDES += [
     '../include/gb',
     '../include/gb/media/stagefright/openmax',
 ]
 
--- a/media/omx-plugin/hc/moz.build
+++ b/media/omx-plugin/hc/moz.build
@@ -3,17 +3,17 @@
 # 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/.
 
 SOURCES += [
     'OmxPluginHoneycomb.cpp',
 ]
 
-LIBRARY_NAME = 'omxpluginhc'
+Library('omxpluginhc')
 
 FORCE_SHARED_LIB = True
 
 LOCAL_INCLUDES += [
     '../include/gb',
     '../include/gb/media/stagefright/openmax',
 ]
 
--- a/media/omx-plugin/kk/moz.build
+++ b/media/omx-plugin/kk/moz.build
@@ -3,17 +3,17 @@
 # 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/.
 
 SOURCES += [
     'OmxPluginKitKat.cpp',
 ]
 
-LIBRARY_NAME = 'omxpluginkk'
+Library('omxpluginkk')
 
 FORCE_SHARED_LIB = True
 
 LOCAL_INCLUDES += [
     '../include/ics',
     '../include/ics/media/stagefright/openmax',
 ]
 
--- a/media/omx-plugin/lib/froyo/libstagefright/moz.build
+++ b/media/omx-plugin/lib/froyo/libstagefright/moz.build
@@ -5,17 +5,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 NO_DIST_INSTALL = True
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
     SOURCES += [
         'libstagefright.cpp',
     ]
 
-LIBRARY_NAME = 'stagefright'
+Library('stagefright')
 
 FORCE_SHARED_LIB = True
 
 LOCAL_INCLUDES += [
     '/media/omx-plugin/include/froyo',
     '/media/omx-plugin/include/froyo/media/stagefright/openmax',
 ]
 
--- a/media/omx-plugin/lib/gb/libstagefright/moz.build
+++ b/media/omx-plugin/lib/gb/libstagefright/moz.build
@@ -5,17 +5,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 NO_DIST_INSTALL = True
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
     SOURCES += [
         'libstagefright.cpp',
     ]
 
-LIBRARY_NAME = 'stagefright'
+Library('stagefright')
 
 FORCE_SHARED_LIB = True
 
 LOCAL_INCLUDES += [
     '/media/omx-plugin/include/gb',
     '/media/omx-plugin/include/gb/media/stagefright/openmax',
 ]
 
--- a/media/omx-plugin/lib/gb/libstagefright_color_conversion/moz.build
+++ b/media/omx-plugin/lib/gb/libstagefright_color_conversion/moz.build
@@ -5,17 +5,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 NO_DIST_INSTALL = True
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
     SOURCES += [
         'libstagefright_color_conversion.cpp',
     ]
 
-LIBRARY_NAME = 'stagefright_color_conversion'
+Library('stagefright_color_conversion')
 
 FORCE_SHARED_LIB = True
 
 LOCAL_INCLUDES += [
     '/media/omx-plugin/include/gb',
     '/media/omx-plugin/include/gb/media/stagefright/openmax',
 ]
 
--- a/media/omx-plugin/lib/gb/libutils/moz.build
+++ b/media/omx-plugin/lib/gb/libutils/moz.build
@@ -5,17 +5,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 NO_DIST_INSTALL = True
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
     SOURCES += [
         'libutils.cpp',
     ]
 
-LIBRARY_NAME = 'utils'
+Library('utils')
 
 FORCE_SHARED_LIB = True
 
 LOCAL_INCLUDES += [
     '/media/omx-plugin/include/gb',
     '/media/omx-plugin/include/gb/media/stagefright/openmax',
 ]
 
--- a/media/omx-plugin/lib/gb235/libstagefright/moz.build
+++ b/media/omx-plugin/lib/gb235/libstagefright/moz.build
@@ -5,17 +5,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 NO_DIST_INSTALL = True
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
     SOURCES += [
         'libstagefright.cpp',
     ]
 
-LIBRARY_NAME = 'stagefright'
+Library('stagefright')
 
 FORCE_SHARED_LIB = True
 
 LOCAL_INCLUDES += [
     '/media/omx-plugin/include/gb',
     '/media/omx-plugin/include/gb/media/stagefright/openmax',
 ]
 
--- a/media/omx-plugin/lib/hc/libstagefright/moz.build
+++ b/media/omx-plugin/lib/hc/libstagefright/moz.build
@@ -5,17 +5,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 NO_DIST_INSTALL = True
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
     SOURCES += [
         'libstagefright.cpp',
     ]
 
-LIBRARY_NAME = 'stagefright'
+Library('stagefright')
 
 FORCE_SHARED_LIB = True
 
 LOCAL_INCLUDES += [
     '/media/omx-plugin/include/gb',
     '/media/omx-plugin/include/gb/media/stagefright/openmax',
 ]
 
--- a/media/omx-plugin/lib/ics/libstagefright/moz.build
+++ b/media/omx-plugin/lib/ics/libstagefright/moz.build
@@ -5,17 +5,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 NO_DIST_INSTALL = True
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
     SOURCES += [
         'libstagefright.cpp',
     ]
 
-LIBRARY_NAME = 'stagefright'
+Library('stagefright')
 
 FORCE_SHARED_LIB = True
 
 LOCAL_INCLUDES += [
     '/media/omx-plugin/include/ics',
     '/media/omx-plugin/include/ics/media/stagefright/openmax',
 ]
 
--- a/media/omx-plugin/lib/ics/libutils/moz.build
+++ b/media/omx-plugin/lib/ics/libutils/moz.build
@@ -5,17 +5,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 NO_DIST_INSTALL = True
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
     SOURCES += [
         'libutils.cpp',
     ]
 
-LIBRARY_NAME = 'utils'
+Library('utils')
 
 FORCE_SHARED_LIB = True
 
 LOCAL_INCLUDES += [
     '/media/omx-plugin/include/ics',
     '/media/omx-plugin/include/ics/media/stagefright/openmax',
 ]
 
--- a/media/omx-plugin/lib/ics/libvideoeditorplayer/moz.build
+++ b/media/omx-plugin/lib/ics/libvideoeditorplayer/moz.build
@@ -5,15 +5,15 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 NO_DIST_INSTALL = True
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
     SOURCES += [
         'libvideoeditorplayer.cpp',
     ]
 
-LIBRARY_NAME = 'videoeditorplayer'
+Library('videoeditorplayer')
 
 FORCE_SHARED_LIB = True
 
 # Don't use STL wrappers; this isn't Gecko code
 DISABLE_STL_WRAPPING = True
 NO_VISIBILITY_FLAGS = True
--- a/media/omx-plugin/moz.build
+++ b/media/omx-plugin/moz.build
@@ -13,17 +13,17 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
 SOURCES += [
     'OmxPlugin.cpp',
 ]
 
-LIBRARY_NAME = 'omxplugin'
+Library('omxplugin')
 
 FORCE_SHARED_LIB = True
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
     pass
 else:
     LOCAL_INCLUDES += [
         'include/ics',
--- a/media/webrtc/signaling/test/moz.build
+++ b/media/webrtc/signaling/test/moz.build
@@ -1,21 +1,21 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
 if CONFIG['OS_TARGET'] != 'WINNT' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
-    CPP_UNIT_TESTS += [
+    CppUnitTests([
         'mediaconduit_unittests',
         'mediapipeline_unittest',
         'sdp_unittests',
         'signaling_unittests',
-    ]
+    ])
 
 SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 if CONFIG['OS_TARGET'] in ('Darwin', 'Android'):
     DEFINES['GTEST_USE_OWN_TR1_TUPLE'] = 1
 
--- a/memory/build/moz.build
+++ b/memory/build/moz.build
@@ -31,17 +31,17 @@ if CONFIG['MOZ_JEMALLOC3']:
     if CONFIG['_MSC_VER']:
         LOCAL_INCLUDES += ['/memory/jemalloc/src/include/msvc_compat']
 
 if CONFIG['MOZ_REPLACE_MALLOC']:
     SOURCES += [
         'replace_malloc.c',
     ]
 
-LIBRARY_NAME = 'memory'
+Library('memory')
 
 if CONFIG['MOZ_JEMALLOC3']:
     if not CONFIG['MOZ_NATIVE_JEMALLOC']:
         USE_LIBS += [
             'jemalloc',
         ]
 else:
     USE_LIBS += [
--- a/memory/jemalloc/moz.build
+++ b/memory/jemalloc/moz.build
@@ -31,17 +31,17 @@ SOURCES += [
 
 # Only OSX needs the zone allocation implementation,
 # but only if replace-malloc is not enabled.
 if CONFIG['OS_TARGET'] == 'Darwin' and not CONFIG['MOZ_REPLACE_MALLOC']:
     SOURCES += [
         'src/src/zone.c',
     ]
 
-LIBRARY_NAME = 'jemalloc'
+Library('jemalloc')
 
 FORCE_STATIC_LIB = True
 
 if CONFIG['MOZ_GLUE_PROGRAM_LDFLAGS']:
     SDK_LIBRARY = True
 
 if CONFIG['_MSC_VER']:
     DEFINES['DLLEXPORT'] = True
--- a/memory/mozalloc/moz.build
+++ b/memory/mozalloc/moz.build
@@ -52,17 +52,17 @@ elif CONFIG['OS_TARGET'] == 'WINNT':
     UNIFIED_SOURCES += [
         'VolatileBufferWindows.cpp',
     ]
 else:
     UNIFIED_SOURCES += [
         'VolatileBufferFallback.cpp',
     ]
 
-LIBRARY_NAME = 'mozalloc'
+Library('mozalloc')
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
     FORCE_STATIC_LIB = True
 else:
     FORCE_SHARED_LIB = True
     SDK_LIBRARY = True
 
 # The strndup declaration in string.h is in an ifdef __USE_GNU section
--- a/memory/mozalloc/tests/moz.build
+++ b/memory/mozalloc/tests/moz.build
@@ -1,17 +1,17 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-CPP_UNIT_TESTS += [
+CppUnitTests([
     'TestVolatileBuffer',
-]
+])
 
 SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
 
 USE_LIBS += [
     'mozalloc',
     'nspr',
     'xpcomglue_s',
     'xul',
--- a/memory/mozjemalloc/moz.build
+++ b/memory/mozjemalloc/moz.build
@@ -7,17 +7,17 @@
 EXPORTS += [
     'jemalloc_types.h',
 ]
 
 if not CONFIG['MOZ_JEMALLOC3']:
     SOURCES += [
         'jemalloc.c',
     ]
-    LIBRARY_NAME = 'mozjemalloc'
+    Library('mozjemalloc')
     STATIC_LIBRARY_NAME = 'jemalloc'
     FORCE_STATIC_LIB = True
 
 # For non release/esr builds, enable (some) fatal jemalloc assertions.  This
 # helps us catch memory errors.
 if CONFIG['MOZ_UPDATE_CHANNEL'] not in ('release', 'esr'):
     DEFINES['MOZ_JEMALLOC_HARD_ASSERTS'] = True
 
--- a/memory/replace/dmd/moz.build
+++ b/memory/replace/dmd/moz.build
@@ -13,17 +13,17 @@ SOURCES += [
     '../../../xpcom/base/nsStackWalk.cpp',
     'DMD.cpp',
 ]
 
 SOURCES += [
     '../../../nsprpub/lib/libc/src/strcpy.c',
 ]
 
-LIBRARY_NAME = 'dmd'
+Library('dmd')
 
 FORCE_SHARED_LIB = True
 
 DEFINES['MOZ_NO_MOZALLOC'] = True
 
 if CONFIG['MOZ_OPTIMIZE']:
     DEFINES['MOZ_OPTIMIZE'] = True
 
--- a/memory/replace/dummy/moz.build
+++ b/memory/replace/dummy/moz.build
@@ -4,13 +4,13 @@
 # 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/.
 NO_DIST_INSTALL = True
 
 SOURCES += [
     'dummy_replace_malloc.c',
 ]
 
-LIBRARY_NAME = 'replace_malloc'
+Library('replace_malloc')
 
 FORCE_SHARED_LIB = True
 
 DISABLE_STL_WRAPPING = True
--- a/memory/replace/jemalloc/moz.build
+++ b/memory/replace/jemalloc/moz.build
@@ -12,17 +12,17 @@ SOURCES += [
 # Android doesn't have pthread_atfork, so just implement a dummy function.
 # It shouldn't make much problem, as the use of fork is pretty limited on
 # Android.
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
     SOURCES += [
         'pthread_atfork.c',
     ]
 
-LIBRARY_NAME = 'replace_jemalloc'
+Library('replace_jemalloc')
 
 USE_LIBS += [
     'jemalloc',
 ]
 
 FORCE_SHARED_LIB = True
 
 DEFINES['MOZ_JEMALLOC3'] = True
--- a/mfbt/moz.build
+++ b/mfbt/moz.build
@@ -1,17 +1,17 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
 TEST_DIRS += ['tests']
 
-LIBRARY_NAME = 'mfbt'
+Library('mfbt')
 
 EXPORTS.mozilla = [
     'Alignment.h',
     'AllocPolicy.h',
     'Array.h',
     'ArrayUtils.h',
     'Assertions.h',
     'Atomics.h',
--- a/mfbt/tests/moz.build
+++ b/mfbt/tests/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-CPP_UNIT_TESTS += [
+CppUnitTests([
     'TestArrayUtils',
     'TestAtomics',
     'TestBinarySearch',
     'TestBloomFilter',
     'TestCasting',
     'TestCeilingFloor',
     'TestCheckedInt',
     'TestCountPopulation',
@@ -25,22 +25,22 @@ CPP_UNIT_TESTS += [
     'TestRefPtr',
     'TestRollingMean',
     'TestSHA1',
     'TestSplayTree',
     'TestTypedEnum',
     'TestTypeTraits',
     'TestUniquePtr',
     'TestWeakPtr',
-]
+])
 
 if not CONFIG['MOZ_ASAN']:
-    CPP_UNIT_TESTS += [
+    CppUnitTests([
         'TestPoisonArea',
-    ]
+    ])
 
 SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
 
 # Since we link directly with MFBT object files, define IMPL_MFBT
 DEFINES['IMPL_MFBT'] = True
 
 DISABLE_STL_WRAPPING = True
 
--- a/modules/libbz2/src/moz.build
+++ b/modules/libbz2/src/moz.build
@@ -15,19 +15,19 @@ csrcs = [
     'compress.c',
     'crctable.c',
     'decompress.c',
     'huffman.c',
     'randtable.c',
 ]
 
 HOST_SOURCES += csrcs
-HOST_LIBRARY_NAME = 'hostbz2'
+HostLibrary('hostbz2')
 
-LIBRARY_NAME = 'bz2'
+Library('bz2')
 
 UNIFIED_SOURCES += [
     'blocksort.c',
     'bzlib.c',
     'compress.c',
     'crctable.c',
     'decompress.c',
     'huffman.c',
--- a/modules/libmar/sign/moz.build
+++ b/modules/libmar/sign/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-LIBRARY_NAME = 'signmar'
+Library('signmar')
 
 UNIFIED_SOURCES += [
     'mar_sign.c',
     'nss_secutil.c',
 ]
 
 FORCE_STATIC_LIB = True
 
--- a/modules/libmar/src/moz.build
+++ b/modules/libmar/src/moz.build
@@ -9,19 +9,19 @@ EXPORTS += [
     'mar_cmdline.h',
 ]
 
 HOST_SOURCES += [
     'mar_create.c',
     'mar_extract.c',
     'mar_read.c',
 ]
-HOST_LIBRARY_NAME = 'hostmar'
+HostLibrary('hostmar')
 
-LIBRARY_NAME = 'mar'
+Library('mar')
 
 UNIFIED_SOURCES += [
     'mar_create.c',
     'mar_extract.c',
     'mar_read.c',
 ]
 
 FORCE_STATIC_LIB = True
--- a/modules/libmar/tool/moz.build
+++ b/modules/libmar/tool/moz.build
@@ -3,24 +3,24 @@
 # 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/.
 
 HOST_SOURCES += [
     'mar.c',
 ]
 
-HOST_PROGRAM = 'mar'
+HostProgram('mar')
 
 HOST_USE_LIBS += [
     'hostmar',
 ]
 
 if CONFIG['MOZ_ENABLE_SIGNMAR']:
-    PROGRAM = 'signmar'
+    Program('signmar')
 
     SOURCES += HOST_SOURCES
 
     USE_LIBS += [
         'mar',
         'signmar',
         'verifymar',
     ]
--- a/modules/libmar/verify/moz.build
+++ b/modules/libmar/verify/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-LIBRARY_NAME = 'verifymar'
+Library('verifymar')
 
 UNIFIED_SOURCES += [
     'cryptox.c',
     'mar_verify.c',
 ]
 
 FORCE_STATIC_LIB = True
 
--- a/mozglue/build/moz.build
+++ b/mozglue/build/moz.build
@@ -64,17 +64,17 @@ if CONFIG['CPU_ARCH'] == 'arm':
     ]
 
 if CONFIG['MOZ_ASAN']:
     SOURCES += [
         'AsanOptions.cpp',
     ]
 
 
-LIBRARY_NAME = 'mozglue'
+Library('mozglue')
 
 USE_LIBS += [
     'mfbt',
 ]
 
 if CONFIG['MOZ_LINKER']:
     USE_LIBS += [
         'zlib',
--- a/mozglue/linker/moz.build
+++ b/mozglue/linker/moz.build
@@ -7,24 +7,24 @@
 SOURCES += [
     'CustomElf.cpp',
     'ElfLoader.cpp',
     'Mappable.cpp',
     'SeekableZStream.cpp',
     'Zip.cpp',
 ]
 
-LIBRARY_NAME = 'linker'
+Library('linker')
 
 HOST_SOURCES += [
     'SeekableZStream.cpp',
     'szip.cpp',
 ]
 
-HOST_PROGRAM = 'szip'
+HostProgram('szip')
 
 FINAL_LIBRARY = 'mozglue'
 
 DEFINES['IMPL_MFBT'] = True
 
 DISABLE_STL_WRAPPING = True
 
 TEST_DIRS += ['tests']
--- a/mozglue/linker/tests/moz.build
+++ b/mozglue/linker/tests/moz.build
@@ -4,19 +4,19 @@
 # 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/.
 
 NO_DIST_INSTALL = True
 
 SOURCES += [
     'TestZip.cpp',
 ]
-SIMPLE_PROGRAMS += [
+SimplePrograms([
     'TestZip',
-]
+])
 LOCAL_INCLUDES += ['..']
 USE_LIBS += [
     'linker',
 ]
 DISABLE_STL_WRAPPING = True
 
 if CONFIG['MOZ_LINKER']:
     OS_LIBS += CONFIG['MOZ_ZLIB_LIBS']
--- a/mozglue/tests/moz.build
+++ b/mozglue/tests/moz.build
@@ -5,11 +5,11 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 DISABLE_STL_WRAPPING = True
 
 SOURCES += [
     'ShowSSEConfig.cpp',
 ]
 
-CPP_UNIT_TESTS += [
+CppUnitTests([
     'ShowSSEConfig',
-]
+])
--- a/netwerk/sctp/src/moz.build
+++ b/netwerk/sctp/src/moz.build
@@ -35,17 +35,17 @@ SOURCES += [
     'user_socket.c',
 ]
 
 if CONFIG['OS_TARGET'] == 'Android':
     SOURCES += [
         'ifaddrs_android.cpp',
     ]
 
-LIBRARY_NAME = 'nksctp_s'
+Library('nksctp_s')
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
     '../../base/src',
     '/content/base/src',
--- a/netwerk/srtp/src/moz.build
+++ b/netwerk/srtp/src/moz.build
@@ -26,17 +26,17 @@ UNIFIED_SOURCES += [
     'crypto/replay/ut_sim.c',
     'crypto/rng/ctr_prng.c',
     'crypto/rng/prng.c',
     'crypto/rng/rand_source.c',
     'srtp/ekt.c',
     'srtp/srtp.c',
 ]
 
-LIBRARY_NAME = 'nksrtp_s'
+Library('nksrtp_s')
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
     'crypto/include',
     'include',
--- a/netwerk/streamconv/test/moz.build
+++ b/netwerk/streamconv/test/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-PROGRAM = 'TestStreamConv'
+Program('TestStreamConv')
 
 UNIFIED_SOURCES += [
     'Converters.cpp',
     'TestStreamConv.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
--- a/netwerk/test/moz.build
+++ b/netwerk/test/moz.build
@@ -11,33 +11,33 @@ FAIL_ON_WARNINGS = True
 BROWSER_CHROME_MANIFESTS += ['browser/browser.ini']
 MOCHITEST_MANIFESTS += ['mochitests/mochitest.ini']
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
 
 # FIXME/bug 575918: out-of-process xpcshell is broken on OS X
 if CONFIG['OS_ARCH'] != 'Darwin':
     XPCSHELL_TESTS_MANIFESTS += ['unit_ipc/xpcshell.ini']
 
-SIMPLE_PROGRAMS = [
+SimplePrograms([
     'PropertiesTest',
     'ReadNTLM',
     'TestBlockingSocket',
     'TestCallbacks',
     'TestDNS',
     'TestIncrementalDownload',
     'TestOpen',
     'TestPageLoad',
     'TestProtocols',
     'TestServ',
     'TestStandardURL',
     'TestStreamLoader',
     'TestUpload',
     'TestURLParser',
     'urltest',
-]
+])
 
 # XXX Make this work in libxul builds.
 #SIMPLE_PROGRAMS += [
 #    TestIDN',
 #    TestIOThreads',
 #    TestPerf',
 #    TestSocketTransport',
 #    TestStreamChannel',
@@ -45,21 +45,21 @@ SIMPLE_PROGRAMS = [
 #    TestStreamTransport',
 #    TestUDPSocketProvider',
 #]
 
 SOURCES += [
     '%s.cpp' % s for s in SIMPLE_PROGRAMS
 ]
 
-CPP_UNIT_TESTS += [
+CppUnitTests([
     'TestCookie',
     'TestSTSParser',
     'TestUDPSocket',
-]
+])
 
 SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
 
 RESOURCE_FILES += [
     'urlparse.dat',
     'urlparse_unx.dat',
 ]
 
--- a/other-licenses/bsdiff/moz.build
+++ b/other-licenses/bsdiff/moz.build
@@ -3,17 +3,17 @@
 # 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/.
 
 HOST_SOURCES += [
     'bsdiff.c',
 ]
 
-HOST_PROGRAM = 'mbsdiff'
+HostProgram('mbsdiff')
 
 if CONFIG['MOZ_NATIVE_BZ2']:
     HOST_OS_LIBS += CONFIG['MOZ_BZ2_LIBS']
 else:
     HOST_USE_LIBS += [
         'hostbz2',
     ]
 
--- a/profile/dirserviceprovider/moz.build
+++ b/profile/dirserviceprovider/moz.build
@@ -10,15 +10,15 @@ EXPORTS += [
 
 UNIFIED_SOURCES += ['nsProfileDirServiceProvider.cpp']
 if CONFIG['MOZ_PROFILELOCKING']:
     UNIFIED_SOURCES += ['nsProfileLock.cpp']
     if CONFIG['OS_ARCH'] == 'WINNT':
         UNIFIED_SOURCES += ['ProfileUnlockerWin.cpp']
         EXPORTS.mozilla += ['ProfileUnlockerWin.h']
 
-LIBRARY_NAME = 'profdirserviceprovidersa_s'
+Library('profdirserviceprovidersa_s')
 
 FORCE_STATIC_LIB = True
 
 DEFINES['XPCOM_GLUE'] = 1
 
 DISABLE_STL_WRAPPING = True
--- a/python/mozbuild/mozbuild/frontend/context.py
+++ b/python/mozbuild/mozbuild/frontend/context.py
@@ -117,24 +117,24 @@ class Context(KeyedDefaultDict):
         # --but not a class that can be called), then it is actually a rule to
         # generate the default that should be used.
         default = defaults[0]
         if issubclass(default, ContextDerivedValue):
             return default(self)
         else:
             return default()
 
-    def _validate(self, key, value):
+    def _validate(self, key, value, is_template=False):
         """Validates whether the key is allowed and if the value's type
         matches.
         """
         stored_type, input_type, docs, tier = \
             self._allowed_variables.get(key, (None, None, None, None))
 
-        if stored_type is None:
+        if stored_type is None or not is_template and key in TEMPLATE_VARIABLES:
             raise KeyError('global_ns', 'set_unknown', key, value)
 
         # If the incoming value is not the type we store, we try to convert
         # it to that type. This relies on proper coercion rules existing. This
         # is the responsibility of whoever defined the symbols: a type should
         # not be in the allowed set if the constructor function for the stored
         # type does not accept an instance of that type.
         if not isinstance(value, (stored_type, input_type)):
@@ -177,16 +177,21 @@ class Context(KeyedDefaultDict):
     def get_affected_tiers(self):
         """Returns the list of tiers affected by the variables set in the
         context.
         """
         tiers = (VARIABLES[key][3] for key in self if key in VARIABLES)
         return set(tier for tier in tiers if tier)
 
 
+class TemplateContext(Context):
+    def _validate(self, key, value):
+        return Context._validate(self, key, value, True)
+
+
 class FinalTargetValue(ContextDerivedValue, unicode):
     def __new__(cls, context, value=""):
         if not value:
             value = 'dist/'
             if context['XPI_NAME']:
                 value += 'xpi-stage/' + context['XPI_NAME']
             else:
                 value += 'bin'
@@ -941,16 +946,37 @@ VARIABLES = {
 }
 
 # Sanity check: we don't want any variable above to have a list as storage type.
 for name, (storage_type, input_types, docs, tier) in VARIABLES.items():
     if storage_type == list:
         raise RuntimeError('%s has a "list" storage type. Use "List" instead.'
             % name)
 
+# Set of variables that are only allowed in templates:
+TEMPLATE_VARIABLES = {
+    'CPP_UNIT_TESTS',
+    'HOST_PROGRAM',
+    'HOST_LIBRARY_NAME',
+    'HOST_SIMPLE_PROGRAMS',
+    'LIBRARY_NAME',
+    'PROGRAM',
+    'SIMPLE_PROGRAMS',
+}
+
+# Add a note to template variable documentation.
+for name in TEMPLATE_VARIABLES:
+    if name not in VARIABLES:
+        raise RuntimeError('%s is in TEMPLATE_VARIABLES but not in VARIABLES.'
+            % name)
+    storage_type, input_types, docs, tier = VARIABLES[name]
+    docs += 'This variable is only available in templates.\n'
+    VARIABLES[name] = (storage_type, input_types, docs, tier)
+
+
 # The set of functions exposed to the sandbox.
 #
 # Each entry is a tuple of:
 #
 #  (function returning the corresponding function from a given sandbox,
 #   (argument types), docs)
 #
 # The first element is an attribute on Sandbox that should be a function type.
@@ -1206,12 +1232,89 @@ SPECIAL_VARIABLES = {
         will result in a run-time error.
 
         Access to an unknown variable will return None.
         """),
 }
 
 # Deprecation hints.
 DEPRECATION_HINTS = {
+    'CPP_UNIT_TESTS': '''
+        Please use'
+
+            CppUnitTests(['foo', 'bar'])
+
+        instead of
+
+            CPP_UNIT_TESTS += ['foo', 'bar']
+        ''',
+
+    'HOST_PROGRAM': '''
+        Please use
+
+            HostProgram('foo')
+
+        instead of
+
+            HOST_PROGRAM = 'foo'
+        ''',
+
+    'HOST_LIBRARY_NAME': '''
+        Please use
+
+            HostLibrary('foo')
+
+        instead of
+
+            HOST_LIBRARY_NAME = 'foo'
+        ''',
+
+    'HOST_SIMPLE_PROGRAMS': '''
+        Please use
+
+            HostSimplePrograms(['foo', 'bar'])
+
+        instead of
+
+            HOST_SIMPLE_PROGRAMS += ['foo', 'bar']"
+        ''',
+
+    'LIBRARY_NAME': '''
+        Please use
+
+            Library('foo')
+
+        instead of
+
+            LIBRARY_NAME = 'foo'
+        ''',
+
+    'PROGRAM': '''
+        Please use
+
+            Program('foo')
+
+        instead of
+
+            PROGRAM = 'foo'"
+        ''',
+
+    'SIMPLE_PROGRAMS': '''
+        Please use
+
+            SimplePrograms(['foo', 'bar'])
+
+        instead of
+
+            SIMPLE_PROGRAMS += ['foo', 'bar']"
+        ''',
+
     'TOOL_DIRS': 'Please use the DIRS variable instead.',
+
     'TEST_TOOL_DIRS': 'Please use the TEST_DIRS variable instead.',
+
     'PARALLEL_DIRS': 'Please use the DIRS variable instead.',
 }
+
+# Make sure that all template variables have a deprecation hint.
+for name in TEMPLATE_VARIABLES:
+    if name not in DEPRECATION_HINTS:
+        raise RuntimeError('Missing deprecation hint for %s' % name)
--- a/python/mozbuild/mozbuild/frontend/gyp_reader.py
+++ b/python/mozbuild/mozbuild/frontend/gyp_reader.py
@@ -6,17 +6,17 @@ from __future__ import unicode_literals
 import gyp
 import sys
 import time
 import os
 import mozpack.path as mozpath
 from mozpack.files import FileFinder
 from .sandbox import alphabetical_sorted
 from .context import (
-    Context,
+    TemplateContext,
     VARIABLES,
 )
 from mozbuild.util import (
     List,
     memoize,
 )
 from .reader import SandboxValidationError
 
@@ -47,26 +47,27 @@ for unused in ['RULE_INPUT_PATH', 'RULE_
                'RULE_INPUT_DIRNAME', 'RULE_INPUT_EXT',
                'EXECUTABLE_PREFIX', 'EXECUTABLE_SUFFIX',
                'STATIC_LIB_PREFIX', 'STATIC_LIB_SUFFIX',
                'SHARED_LIB_PREFIX', 'SHARED_LIB_SUFFIX',
                'LINKER_SUPPORTS_ICF']:
   generator_default_variables[unused] = b''
 
 
-class GypContext(Context):
+class GypContext(TemplateContext):
     """Specialized Context for use with data extracted from Gyp.
 
     config is the ConfigEnvironment for this context.
     relobjdir is the object directory that will be used for this context,
     relative to the topobjdir defined in the ConfigEnvironment.
     """
     def __init__(self, config, relobjdir):
         self._relobjdir = relobjdir
-        Context.__init__(self, allowed_variables=self.VARIABLES(), config=config)
+        TemplateContext.__init__(self, allowed_variables=self.VARIABLES(),
+            config=config)
 
     @classmethod
     @memoize
     def VARIABLES(cls):
         """Returns the allowed variables for a GypContext."""
         # Using a class method instead of a class variable to hide the content
         # from sphinx.
         return dict(VARIABLES,
--- a/python/mozbuild/mozbuild/frontend/reader.py
+++ b/python/mozbuild/mozbuild/frontend/reader.py
@@ -17,16 +17,17 @@ It does this by examining specific varia
 """
 
 from __future__ import print_function, unicode_literals
 
 import inspect
 import logging
 import os
 import sys
+import textwrap
 import time
 import tokenize
 import traceback
 import types
 
 from collections import OrderedDict
 from io import StringIO
 
@@ -54,16 +55,17 @@ from .sandbox import (
 )
 
 from .context import (
     Context,
     FUNCTIONS,
     VARIABLES,
     DEPRECATION_HINTS,
     SPECIAL_VARIABLES,
+    TemplateContext,
 )
 
 if sys.version_info.major == 2:
     text_type = unicode
     type_type = types.TypeType
 else:
     text_type = str
     type_type = type
@@ -374,35 +376,40 @@ class MozbuildSandbox(Sandbox):
         sandbox needs a function to execute. This is what this method returns.
         That function creates a new sandbox for execution of the template.
         After the template is executed, the data from its execution is merged
         with the context of the calling sandbox.
         """
         func, code, path = template
 
         def template_function(*args, **kwargs):
-            context = Context(VARIABLES, self._context.config)
+            context = TemplateContext(VARIABLES, self._context.config)
             context.add_source(self._execution_stack[-1])
             for p in self._context.all_paths:
                 context.add_source(p)
 
             sandbox = MozbuildSandbox(context, self.metadata)
             for k, v in inspect.getcallargs(func, *args, **kwargs).items():
                 sandbox[k] = v
 
             sandbox.exec_source(code, path)
 
+            # This is gross, but allows the merge to happen. Eventually, the
+            # merging will go away and template contexts emitted independently.
+            klass = self._context.__class__
+            self._context.__class__ = TemplateContext
             # The sandbox will do all the necessary checks for these merges.
             for key, value in context.items():
                 if isinstance(value, dict):
                     self[key].update(value)
                 elif isinstance(value, list):
                     self[key] += value
                 else:
                     self[key] = value
+            self._context.__class__ = klass
 
             for p in context.all_paths:
                 self._context.add_source(p)
 
         return template_function
 
 
 class SandboxValidationError(Exception):
@@ -663,17 +670,18 @@ class BuildReaderError(Exception):
             s.write('a reserved UPPERCASE variable that does not exist.\n')
             s.write('\n')
             s.write('The variable %s causing the error is:\n' % verb)
             s.write('\n')
             s.write('    %s\n' % inner.args[2])
             s.write('\n')
 
             if inner.args[2] in DEPRECATION_HINTS:
-                s.write('%s\n' % DEPRECATION_HINTS[inner.args[2]])
+                s.write('%s\n' %
+                    textwrap.dedent(DEPRECATION_HINTS[inner.args[2]]).strip())
                 return
 
             s.write('Please change the file to not use this variable.\n')
             s.write('\n')
             s.write('For reference, the set of valid variables is:\n')
             s.write('\n')
             s.write(', '.join(sorted(VARIABLES.keys())) + '\n')
             return
--- a/python/mozbuild/mozbuild/test/backend/data/visual-studio/moz.build
+++ b/python/mozbuild/mozbuild/test/backend/data/visual-studio/moz.build
@@ -1,7 +1,7 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # Any copyright is dedicated to the Public Domain.
 # http://creativecommons.org/publicdomain/zero/1.0/
 
 add_tier_dir('libs', ['dir1'])
 
-LIBRARY_NAME = 'test'
+Library('test')
--- a/python/mozbuild/mozbuild/test/frontend/data/program/moz.build
+++ b/python/mozbuild/mozbuild/test/frontend/data/program/moz.build
@@ -1,6 +1,15 @@
 # Any copyright is dedicated to the Public Domain.
 # http://creativecommons.org/publicdomain/zero/1.0/
 
-PROGRAM = 'test_program'
+@template
+def Program(name):
+    PROGRAM = name
+
 
-SIMPLE_PROGRAMS = [ 'test_program1', 'test_program2' ]
+@template
+def SimplePrograms(names):
+    SIMPLE_PROGRAMS += names
+
+Program('test_program')
+
+SimplePrograms([ 'test_program1', 'test_program2' ])
--- a/rdf/tests/rdfcat/moz.build
+++ b/rdf/tests/rdfcat/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-PROGRAM = 'rdfcat'
+Program('rdfcat')
 
 SOURCES += [
     'rdfcat.cpp',
 ]
 
 USE_LIBS += [
     'mozalloc',
     'nspr',
--- a/rdf/tests/rdfpoll/moz.build
+++ b/rdf/tests/rdfpoll/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-PROGRAM = 'rdfpoll'
+Program('rdfpoll')
 
 SOURCES += [
     'rdfpoll.cpp',
 ]
 
 USE_LIBS += [
     'mozalloc',
     'nspr',
--- a/rdf/tests/triplescat/moz.build
+++ b/rdf/tests/triplescat/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-PROGRAM = 'triplescat'
+Program('triplescat')
 
 SOURCES += [
     'triplescat.cpp',
 ]
 
 USE_LIBS += [
     'mozalloc',
     'nspr',
--- a/rdf/util/moz.build
+++ b/rdf/util/moz.build
@@ -9,12 +9,12 @@ DIRS += ['internal']
 EXPORTS += [
     'nsRDFResource.h',
 ]
 
 include('objs.mozbuild')
 
 SOURCES += rdf_util_src_cppsrcs
 
-LIBRARY_NAME = 'rdfutil_external_s'
+Library('rdfutil_external_s')
 
 # we don't want the shared lib, but we want to force the creation of a static lib.
 FORCE_STATIC_LIB = True
--- a/security/manager/ssl/tests/compiled/moz.build
+++ b/security/manager/ssl/tests/compiled/moz.build
@@ -1,17 +1,17 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-CPP_UNIT_TESTS += [
+CppUnitTests([
   'TestCertDB',
-]
+])
 
 SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
 
 USE_LIBS += [
     'mozalloc',
     'nspr',
     'xpcomglue_s',
     'xul',
--- a/security/manager/ssl/tests/unit/pkcs11testmodule/moz.build
+++ b/security/manager/ssl/tests/unit/pkcs11testmodule/moz.build
@@ -3,15 +3,15 @@
 # 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/.
 
 UNIFIED_SOURCES += [
     'pkcs11testmodule.cpp',
 ]
 
-LIBRARY_NAME = 'pkcs11testmodule'
+Library('pkcs11testmodule')
 
 FORCE_SHARED_LIB = True
 # C_GetFunctionList needs to be exported. As it turns out, it's much easier to
 # just export all the symbols.
 NO_VISIBILITY_FLAGS = True
 NO_DIST_INSTALL = True
--- a/security/manager/ssl/tests/unit/tlsserver/cmd/moz.build
+++ b/security/manager/ssl/tests/unit/tlsserver/cmd/moz.build
@@ -1,22 +1,22 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
 FAIL_ON_WARNINGS = True
 
-SIMPLE_PROGRAMS = [
+SimplePrograms([
     'BadCertServer',
     'ClientAuthServer',
     'GenerateOCSPResponse',
     'OCSPStaplingServer',
-]
+])
 
 SOURCES += [
     '%s.cpp' % s for s in SIMPLE_PROGRAMS
 ]
 
 LOCAL_INCLUDES += [
     '../lib',
 ]
--- a/security/manager/ssl/tests/unit/tlsserver/lib/moz.build
+++ b/security/manager/ssl/tests/unit/tlsserver/lib/moz.build
@@ -9,9 +9,9 @@ UNIFIED_SOURCES += [
     'TLSServer.cpp',
 ]
 
 LOCAL_INCLUDES += [
     '../../../../../../pkix/include',
     '../../../../../../pkix/test/lib',
 ]
 
-LIBRARY_NAME = 'tlsserver'
+Library('tlsserver')
--- a/security/pkix/moz.build
+++ b/security/pkix/moz.build
@@ -32,11 +32,11 @@ if CONFIG['_MSC_VER']:
     '-wd4668', # 'symbol' is not defined as a preprocessor macro...
     '-wd4710', # 'function': function not inlined
     '-wd4711', # function 'function' selected for inline expansion
     '-wd4820', # 'bytes' bytes padding added after construct 'member_name'
   ]
 
 FAIL_ON_WARNINGS = True
 
-LIBRARY_NAME = 'mozillapkix'
+Library('mozillapkix')
 
 FINAL_LIBRARY = 'xul'
--- a/security/pkix/test/lib/moz.build
+++ b/security/pkix/test/lib/moz.build
@@ -19,17 +19,17 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
 SOURCES += [
     'pkixtestutil.cpp',
 ]
 
-LIBRARY_NAME = 'pkixtestutil'
+Library('pkixtestutil')
 
 LOCAL_INCLUDES += [
     '../../include',
     '../../lib',
 ]
 
 FINAL_LIBRARY = 'xul-gtest'
 
--- a/security/sandbox/linux/moz.build
+++ b/security/sandbox/linux/moz.build
@@ -1,17 +1,17 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
 FAIL_ON_WARNINGS = True
 
-LIBRARY_NAME = 'mozsandbox'
+Library('mozsandbox')
 FORCE_SHARED_LIB = True
 
 EXPORTS.mozilla += [
     'Sandbox.h',
 ]
 
 SOURCES += [
     # Bug 1059038 workaround:
--- a/security/sandbox/moz.build
+++ b/security/sandbox/moz.build
@@ -4,17 +4,17 @@
 # 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/.
 
 if CONFIG['OS_ARCH'] == 'Linux':
     DIRS += ['linux']
 elif CONFIG['OS_ARCH'] == 'Darwin':
     DIRS += ['mac']
 elif CONFIG['OS_ARCH'] == 'WINNT':
-    LIBRARY_NAME = 'sandbox_s'
+    Library('sandbox_s')
     FORCE_STATIC_LIB = True
 
     DIRS += [
         'staticruntime',
         'win/src/sandboxbroker',
         'win/src/sandboxtarget',
     ]
 
--- a/security/sandbox/staticruntime/moz.build
+++ b/security/sandbox/staticruntime/moz.build
@@ -1,16 +1,16 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
 if CONFIG['OS_ARCH'] == 'WINNT':
-    LIBRARY_NAME = 'sandbox_staticruntime_s'
+    Library('sandbox_staticruntime_s')
     FORCE_STATIC_LIB = True
     USE_STATIC_LIBS = True
 
     include('../objs.mozbuild')
     SOURCES += security_sandbox_cppsrcs
 
     for var in ('UNICODE', '_UNICODE', 'NS_NO_XPCOM', 'SANDBOX_EXPORTS',
                 'NOMINMAX', '_CRT_RAND_S', 'CHROMIUM_SANDBOX_BUILD'):
--- a/security/sandbox/win/src/sandboxbroker/moz.build
+++ b/security/sandbox/win/src/sandboxbroker/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-LIBRARY_NAME = 'sandboxbroker'
+Library('sandboxbroker')
 
 USE_LIBS += [
     'nspr',
     'sandbox_s',
 ]
 
 SOURCES += [
     'sandboxBroker.cpp',
--- a/startupcache/test/moz.build
+++ b/startupcache/test/moz.build
@@ -1,17 +1,17 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-CPP_UNIT_TESTS += [
+CppUnitTests([
     'TestStartupCache',
-]
+])
 
 SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
 
 EXTRA_COMPONENTS += [
     'TestStartupCacheTelemetry.js',
     'TestStartupCacheTelemetry.manifest',
 ]
 
--- a/storage/test/moz.build
+++ b/storage/test/moz.build
@@ -1,37 +1,37 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
 
-CPP_UNIT_TESTS += [
+CppUnitTests([
     'test_AsXXX_helpers',
     'test_async_callbacks_with_spun_event_loops',
     'test_asyncStatementExecution_transaction',
     'test_binding_params',
     'test_file_perms',
     'test_mutex',
     'test_service_init_background_thread',
     'test_statement_scoper',
     'test_StatementCache',
     'test_transaction_helper',
     'test_true_async',
     'test_unlock_notify',
-]
+])
 
 if CONFIG['MOZ_DEBUG'] and CONFIG['OS_ARCH'] not in ('WINNT', 'Darwin'):
     # FIXME bug 523392: test_deadlock_detector doesn't like Windows
     # FIXME bug 523378: also fails on OS X
-    CPP_UNIT_TESTS += [
+    CppUnitTests([
         'test_deadlock_detector',
-    ]
+    ])
 
 SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
 
 LOCAL_INCLUDES += [
     '../src',
 ]
 
 FAIL_ON_WARNINGS = True
--- a/testing/gtest/moz.build
+++ b/testing/gtest/moz.build
@@ -57,17 +57,17 @@ if CONFIG['ENABLE_TESTS']:
     ]
 
     SOURCES += [
         'gmock/src/gmock-all.cc',
         'gtest/src/gtest-all.cc',
         'mozilla/GTestRunner.cpp',
     ]
 
-    LIBRARY_NAME = 'gtest'
+    Library('gtest')
 
     SOURCES += [
         'mozilla/SanityTest.cpp',
     ]
 
     LOCAL_INCLUDES += [
         'gmock',
         'gmock/include',
--- a/testing/mochitest/ssltunnel/moz.build
+++ b/testing/mochitest/ssltunnel/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-PROGRAM = 'ssltunnel'
+Program('ssltunnel')
 
 SOURCES += [
     'ssltunnel.cpp',
 ]
 
 USE_LIBS += [
     'mozalloc',
     'nspr',
--- a/testing/tools/screenshot/moz.build
+++ b/testing/tools/screenshot/moz.build
@@ -1,24 +1,24 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
 if CONFIG['MOZ_WIDGET_GTK'] and CONFIG['MOZ_X11']:
-    PROGRAM = 'screentopng'
+    Program('screentopng')
     SOURCES += [
         'gdk-screenshot.cpp',
     ]
     CXXFLAGS += CONFIG['TK_CFLAGS']
     OS_LIBS += CONFIG['TK_LIBS']
     OS_LIBS += CONFIG['XSS_LIBS']
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
-    PROGRAM = 'screenshot'
+    Program('screenshot')
     SOURCES += [
         'win32-screenshot.cpp',
     ]
     USE_STATIC_LIBS = True
     if CONFIG['GNU_CC']:
         WIN32_EXE_LDFLAGS += ['-municode']
     OS_LIBS += [
         'gdiplus',
--- a/toolkit/components/ctypes/tests/moz.build
+++ b/toolkit/components/ctypes/tests/moz.build
@@ -9,17 +9,17 @@ XPCSHELL_TESTS_MANIFESTS += ['unit/xpcsh
 MOCHITEST_CHROME_MANIFESTS += ['chrome/chrome.ini']
 
 UNIFIED_SOURCES += [
     'jsctypes-test-errno.cpp',
     'jsctypes-test-finalizer.cpp',
     'jsctypes-test.cpp',
 ]
 
-LIBRARY_NAME = 'jsctypes-test'
+Library('jsctypes-test')
 
 FORCE_SHARED_LIB = True
 
 LOCAL_INCLUDES += [
     '/js/src/ctypes',
 ]
 
 USE_LIBS += [
--- a/toolkit/components/maintenanceservice/moz.build
+++ b/toolkit/components/maintenanceservice/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-PROGRAM = 'maintenanceservice'
+Program('maintenanceservice')
 
 SOURCES += [
     'certificatecheck.cpp',
     'maintenanceservice.cpp',
     'registrycertificates.cpp',
     'servicebase.cpp',
     'serviceinstall.cpp',
     'workmonitor.cpp',
--- a/toolkit/components/places/tests/cpp/moz.build
+++ b/toolkit/components/places/tests/cpp/moz.build
@@ -1,17 +1,17 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-CPP_UNIT_TESTS += [
+CppUnitTests([
     'test_IHistory',
-]
+])
 
 SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
 
 FAIL_ON_WARNINGS = True
 
 USE_LIBS += [
     'mozalloc',
     'nspr',
--- a/toolkit/crashreporter/breakpad-windows-libxul/moz.build
+++ b/toolkit/crashreporter/breakpad-windows-libxul/moz.build
@@ -7,17 +7,17 @@
 DIRS += [
     'staticruntime'
 ]
 
 SOURCES += [
     '../google-breakpad/src/common/windows/http_upload.cc',
 ]
 
-LIBRARY_NAME = 'google_breakpad_libxul_s'
+Library('google_breakpad_libxul_s')
 
 FINAL_LIBRARY = 'xul'
 
 for var in ('UNICODE', 'UNICODE_', 'BREAKPAD_NO_TERMINATE_THREAD', 'NOMINMAX'):
     DEFINES[var] = True
 
 LOCAL_INCLUDES += [
     '/toolkit/crashreporter/google-breakpad/src',
--- a/toolkit/crashreporter/breakpad-windows-libxul/staticruntime/moz.build
+++ b/toolkit/crashreporter/breakpad-windows-libxul/staticruntime/moz.build
@@ -3,17 +3,17 @@
 # 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/.
 
 SOURCES += [
     '../../google-breakpad/src/common/windows/http_upload.cc',
 ]
 
-LIBRARY_NAME = 'google_breakpad_libxul_staticruntime_s'
+Library('google_breakpad_libxul_staticruntime_s')
 
 for var in ('UNICODE', 'UNICODE_', 'BREAKPAD_NO_TERMINATE_THREAD', 'NOMINMAX'):
     DEFINES[var] = True
 
 LOCAL_INCLUDES += [
     '/toolkit/crashreporter/google-breakpad/src',
 ]
 
--- a/toolkit/crashreporter/client/moz.build
+++ b/toolkit/crashreporter/client/moz.build
@@ -1,16 +1,16 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
 if CONFIG['OS_TARGET'] != 'Android':
-    PROGRAM = 'crashreporter'
+    Program('crashreporter')
 
     UNIFIED_SOURCES += [
         'crashreporter.cpp',
     ]
 
 LOCAL_INCLUDES += [
     '../google-breakpad/src',
 ]
--- a/toolkit/crashreporter/google-breakpad/src/common/dwarf/moz.build
+++ b/toolkit/crashreporter/google-breakpad/src/common/dwarf/moz.build
@@ -1,16 +1,16 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
 if CONFIG['MOZ_CRASHREPORTER']:
-    HOST_LIBRARY_NAME = 'host_breakpad_dwarf_s'
+    HostLibrary('host_breakpad_dwarf_s')
     HOST_SOURCES += [
         'bytereader.cc',
         'dwarf2diehandler.cc',
         'dwarf2reader.cc',
         'functioninfo.cc',
     ]
     LOCAL_INCLUDES += [
         '../..',
--- a/toolkit/crashreporter/google-breakpad/src/common/linux/moz.build
+++ b/toolkit/crashreporter/google-breakpad/src/common/linux/moz.build
@@ -18,28 +18,28 @@ SOURCES += [
 ]
 
 if CONFIG['OS_TARGET'] != 'Android':
     UNIFIED_SOURCES += [
         'http_upload.cc',
     ]
 
 if CONFIG['MOZ_CRASHREPORTER']:
-    HOST_LIBRARY_NAME = 'host_breakpad_linux_common_s'
+    HostLibrary('host_breakpad_linux_common_s')
     HOST_SOURCES += [
         'dump_symbols.cc',
         'elf_symbols_to_module.cc',
         'elfutils.cc',
         'file_id.cc',
         'guid_creator.cc',
         'linux_libc_support.cc',
         'memory_mapped_file.cc',
     ]
 
-LIBRARY_NAME = 'breakpad_linux_common_s'
+Library('breakpad_linux_common_s')
 
 FINAL_LIBRARY = 'xul'
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
     DEFINES['ELFSIZE'] = 32
 
 DEFINES['NO_STABS_SUPPORT'] = True
 
--- a/toolkit/crashreporter/google-breakpad/src/common/mac/moz.build
+++ b/toolkit/crashreporter/google-breakpad/src/common/mac/moz.build
@@ -18,24 +18,24 @@ UNIFIED_SOURCES += [
 # This is a little weird, but we're building a host and a target lib here.
 # The host lib is used for dump_syms, and the target lib for the
 # crash reporter client.  Therefore, we don't need all the srcs in both.
 if CONFIG['MOZ_CRASHREPORTER']:
     HOST_SOURCES += UNIFIED_SOURCES
     HOST_SOURCES += [
         'dump_syms.mm',
     ]
-    HOST_LIBRARY_NAME = 'host_breakpad_mac_common_s'
+    HostLibrary('host_breakpad_mac_common_s')
 
 SOURCES += [
     'HTTPMultipartUpload.m',
     'MachIPC.mm',
 ]
 
-LIBRARY_NAME = 'breakpad_mac_common_s'
+Library('breakpad_mac_common_s')
 
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
     '../..',
 ]
 
 CMFLAGS += ['-std=c99']
--- a/toolkit/crashreporter/google-breakpad/src/common/moz.build
+++ b/toolkit/crashreporter/google-breakpad/src/common/moz.build
@@ -42,17 +42,17 @@ else:
     if CONFIG['OS_TARGET'] != 'WINNT':
         UNIFIED_SOURCES += [
             'stabs_reader.cc',
             'stabs_to_module.cc',
         ]
 
 if CONFIG['OS_TARGET'] != 'WINNT' and CONFIG['MOZ_CRASHREPORTER']:
     HOST_SOURCES += [ 'convert_UTF.c' ]
-    HOST_LIBRARY_NAME = 'host_breakpad_common_s'
+    HostLibrary('host_breakpad_common_s')
     HOST_SOURCES += [
         'arm_ex_reader.cc',
         'arm_ex_to_module.cc',
         'dwarf_cfi_to_module.cc',
         'dwarf_cu_to_module.cc',
         'dwarf_line_to_module.cc',
         'language.cc',
         'logging.cc',
@@ -71,17 +71,17 @@ if CONFIG['OS_ARCH'] == 'Darwin':
     ]
 
 if CONFIG['OS_TARGET'] == 'Android':
     # We don't support unifying assembly files.
     SOURCES += [
         'android/breakpad_getcontext.S',
     ]
 
-LIBRARY_NAME = 'breakpad_common_s'
+Library('breakpad_common_s')
 
 MSVC_ENABLE_PGO = True
 
 FINAL_LIBRARY = 'xul'
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
     DEFINES['ELFSIZE'] = 32
 
--- a/toolkit/crashreporter/google-breakpad/src/common/solaris/moz.build
+++ b/toolkit/crashreporter/google-breakpad/src/common/solaris/moz.build
@@ -5,19 +5,19 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 UNIFIED_SOURCES += [
     'dump_symbols.cc',
     'file_id.cc',
     'guid_creator.cc',
 ]
 
-HOST_LIBRARY_NAME = 'host_breakpad_solaris_common_s'
+HostLibrary('host_breakpad_solaris_common_s')
 
-LIBRARY_NAME = 'breakpad_solaris_common_s'
+Library('breakpad_solaris_common_s')
 
 # not compiling http_upload.cc currently
 # since it depends on libcurl
 HOST_SOURCES += [
     'dump_symbols.cc',
     'file_id.cc',
     'guid_creator.cc',
 ]
--- a/toolkit/crashreporter/google-breakpad/src/tools/linux/dump_syms/moz.build
+++ b/toolkit/crashreporter/google-breakpad/src/tools/linux/dump_syms/moz.build
@@ -3,17 +3,17 @@
 # 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/.
 
 HOST_SOURCES += [
     'dump_syms.cc',
 ]
 
-HOST_PROGRAM = 'dump_syms'
+HostProgram('dump_syms')
 
 # host_breakpad_linux_common_s needs to come first
 HOST_USE_LIBS += [
     'host_breakpad_linux_common_s',
 ]
 HOST_USE_LIBS += [
     'host_breakpad_common_s',
     'host_breakpad_dwarf_s',
--- a/toolkit/crashreporter/google-breakpad/src/tools/mac/dump_syms/moz.build
+++ b/toolkit/crashreporter/google-breakpad/src/tools/mac/dump_syms/moz.build
@@ -3,17 +3,17 @@
 # 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/.
 
 HOST_SOURCES += [
     'dump_syms_tool.mm',
 ]
 
-HOST_PROGRAM = 'dump_syms'
+HostProgram('dump_syms')
 
 HOST_USE_LIBS += [
     'host_breakpad_common_s',
     'host_breakpad_dwarf_s',
     'host_breakpad_mac_common_s',
 ]
 
 LOCAL_INCLUDES += [
--- a/toolkit/crashreporter/google-breakpad/src/tools/solaris/dump_syms/moz.build
+++ b/toolkit/crashreporter/google-breakpad/src/tools/solaris/dump_syms/moz.build
@@ -3,17 +3,17 @@
 # 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/.
 
 HOST_SOURCES += [
     'dump_syms.cc',
 ]
   
-HOST_PROGRAM = 'dump_syms'
+HostProgram('dump_syms')
 
 HOST_USE_LIBS += [
     'host_breakpad_common_s',
     'host_breakpad_solaris_common_s',
 ]
 
 LOCAL_INCLUDES += [
     '../../..',
--- a/toolkit/crashreporter/injector/moz.build
+++ b/toolkit/crashreporter/injector/moz.build
@@ -3,17 +3,17 @@
 # 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/.
 
 SOURCES += [
     'injector.cpp',
 ]
 
-LIBRARY_NAME = 'breakpadinjector'
+Library('breakpadinjector')
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FORCE_SHARED_LIB = True
 
 LOCAL_INCLUDES += [
     '/toolkit/crashreporter/google-breakpad/src',
 ]
--- a/toolkit/crashreporter/test/moz.build
+++ b/toolkit/crashreporter/test/moz.build
@@ -12,17 +12,17 @@ UNIFIED_SOURCES += [
     '../google-breakpad/src/common/logging.cc',
     '../google-breakpad/src/common/pathname_stripper.cc',
     '../google-breakpad/src/processor/basic_code_modules.cc',
     '../google-breakpad/src/processor/minidump.cc',
     'dumputils.cpp',
     'nsTestCrasher.cpp',
 ]
 
-LIBRARY_NAME = 'testcrasher'
+Library('testcrasher')
 
 EXTRA_JS_MODULES += [
     'CrashTestUtils.jsm',
 ]
 
 FORCE_SHARED_LIB = True
 
 DEFINES['SHARED_LIBRARY'] = '%s%s%s' % (
--- a/toolkit/library/StaticXULComponentsEnd/moz.build
+++ b/toolkit/library/StaticXULComponentsEnd/moz.build
@@ -5,11 +5,11 @@
 SOURCES += [
     'StaticXULComponentsEnd.cpp',
 ]
 
 # Don't let LTO reorder StaticXULComponentsStart.o.
 if '-flto' in CONFIG['OS_CXXFLAGS']:
     SOURCES['StaticXULComponentsEnd.cpp'].flags += ['-fno-lto']
 
-LIBRARY_NAME = 'StaticXULComponentsEnd'
+Library('StaticXULComponentsEnd')
 
 DEFINES['MOZILLA_INTERNAL_API'] = True
--- a/toolkit/library/gtest/moz.build
+++ b/toolkit/library/gtest/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-LIBRARY_NAME = 'xul-gtest'
+Library('xul-gtest')
 
 FINAL_TARGET = 'dist/bin/gtest'
 
 USE_LIBS += [
     'static:xul',
 ]
 
 include('../libxul.mozbuild')
--- a/toolkit/library/moz.build
+++ b/toolkit/library/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-LIBRARY_NAME = 'xul'
+Library('xul')
 
 SDK_LIBRARY = True
 
 FORCE_STATIC_LIB = True
 
 STATIC_LIBRARY_NAME = 'xul_s'
 
 SOURCES += [
--- a/toolkit/mozapps/plugins/tests/moz.build
+++ b/toolkit/mozapps/plugins/tests/moz.build
@@ -1,17 +1,17 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-SIMPLE_PROGRAMS = [
+SimplePrograms([
     'BadPlugin',
     'GoodPlugin',
-]
+])
 
 SOURCES += [
     '%s.cpp' % s for s in SIMPLE_PROGRAMS
 ]
 
 BROWSER_CHROME_MANIFESTS += ['browser.ini']
 USE_STATIC_LIBS = True
--- a/toolkit/mozapps/update/common-standalone/moz.build
+++ b/toolkit/mozapps/update/common-standalone/moz.build
@@ -1,12 +1,12 @@
 # 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/.
 
-LIBRARY_NAME = 'updatecommon-standalone'
+Library('updatecommon-standalone')
 
 srcdir = '../common'
 
 include('../common/sources.mozbuild')
 
 if CONFIG['OS_ARCH'] == 'WINNT':
     USE_STATIC_LIBS = True
--- a/toolkit/mozapps/update/common/moz.build
+++ b/toolkit/mozapps/update/common/moz.build
@@ -13,15 +13,15 @@ EXPORTS += [
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
     EXPORTS += [
         'pathhash.h',
         'uachelper.h',
         'updatehelper.cpp',
         'updatehelper.h',
     ]
 
-LIBRARY_NAME = 'updatecommon'
+Library('updatecommon')
 
 srcdir = '.'
 
 include('sources.mozbuild')
 
 FINAL_LIBRARY = 'xul'
--- a/toolkit/mozapps/update/tests/moz.build
+++ b/toolkit/mozapps/update/tests/moz.build
@@ -8,20 +8,20 @@ XPCSHELL_TESTS_MANIFESTS += ['unit_aus_u
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android':
     MOCHITEST_CHROME_MANIFESTS += ['chrome/chrome.ini']
     XPCSHELL_TESTS_MANIFESTS += ['unit_base_updater/xpcshell.ini']
 
     if CONFIG['MOZ_MAINTENANCE_SERVICE'] and not CONFIG['HAVE_64BIT_BUILD']:
         XPCSHELL_TESTS_MANIFESTS += ['unit_service_updater/xpcshell.ini']
 
-    SIMPLE_PROGRAMS = [
+    SimplePrograms([
         'TestAUSHelper',
         'TestAUSReadStrings',
-    ]
+    ])
 
     SOURCES += [
         '%s.cpp' % s for s in SIMPLE_PROGRAMS
     ]
 
     LOCAL_INCLUDES += [
         '/toolkit/mozapps/update',
         '/toolkit/mozapps/update/common',
--- a/toolkit/mozapps/update/updater/moz.build
+++ b/toolkit/mozapps/update/updater/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-PROGRAM = 'updater'
+Program('updater')
 
 SOURCES += [
     'archivereader.cpp',
     'bspatch.cpp',
     'updater.cpp',
 ]
 
 have_progressui = 0
--- a/toolkit/webapps/tests/moz.build
+++ b/toolkit/webapps/tests/moz.build
@@ -1,9 +1,9 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
 MOCHITEST_CHROME_MANIFESTS += ['chrome.ini']
 SOURCES += ['TestWebappRT.cpp' ]
-SIMPLE_PROGRAMS += ['TestWebappRT']
+SimplePrograms(['TestWebappRT'])
--- a/toolkit/xre/test/win/moz.build
+++ b/toolkit/xre/test/win/moz.build
@@ -1,25 +1,25 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-SIMPLE_PROGRAMS = [
+SimplePrograms([
     'TestXREMakeCommandLineWin',
-]
+])
 
 SOURCES += [
     '%s.cpp' % s for s in SIMPLE_PROGRAMS
 ]
 
-CPP_UNIT_TESTS += [
+CppUnitTests([
     'TestDllInterceptor',
-]
+])
 
 SOURCES += [
     '%s.cpp' % s for s in CPP_UNIT_TESTS
 ]
 
 DEFINES['NS_NO_XPCOM'] = True
 
 LOCAL_INCLUDES += [
--- a/tools/jprof/moz.build
+++ b/tools/jprof/moz.build
@@ -1,17 +1,17 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
 DIRS += ['stub']
 
-PROGRAM = 'jprof'
+Program('jprof')
 
 SOURCES += [
     'bfd.cpp',
     'coff.cpp',
     'elf.cpp',
     'intcnt.cpp',
     'leaky.cpp',
     'strset.cpp',
--- a/tools/jprof/stub/moz.build
+++ b/tools/jprof/stub/moz.build
@@ -7,13 +7,13 @@
 EXPORTS += [
     'jprof.h',
 ]
 
 SOURCES += [
     'libmalloc.cpp',
 ]
 
-LIBRARY_NAME = 'jprof'
+Library('jprof')
 
 FORCE_SHARED_LIB = True
 
 DEFINES['_IMPL_JPROF_API'] = True
--- a/tools/trace-malloc/moz.build
+++ b/tools/trace-malloc/moz.build
@@ -1,16 +1,16 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
 if not CONFIG['MOZ_PROFILE_GENERATE']:
-    PROGRAM = 'spacetrace'
+    Program('spacetrace')
     SOURCES += [
         'formdata.c',
         'spacecategory.c',
         'spacetrace.c',
     ]
 
 bin_suffix = CONFIG['BIN_SUFFIX']
 
@@ -22,28 +22,28 @@ simple_c_sources = [
 
 SOURCES += [
     '%s.c' % s for s in simple_c_sources
 ]
 SOURCES += [
     'tmreader.c',
 ]
 
-SIMPLE_PROGRAMS += simple_c_sources
+SimplePrograms(simple_c_sources)
 
 simple_cpp_sources = [
     'bloatblame',
     'leaksoup',
 ]
 
 SOURCES += [
     '%s.cpp' % s for s in simple_cpp_sources
 ]
 
-SIMPLE_PROGRAMS += simple_cpp_sources
+SimplePrograms(simple_cpp_sources)
 
 RESOURCE_FILES += [
     'spacetrace.css'
 ]
 
 USE_LIBS += [
     'mozalloc',
     'nspr',
--- a/uriloader/exthandler/tests/moz.build
+++ b/uriloader/exthandler/tests/moz.build
@@ -11,19 +11,19 @@ XPCSHELL_TESTS_MANIFESTS += ['unit/xpcsh
 
 #FIXME/bug 575918: out-of-process xpcshell is broken on OS X
 if CONFIG['OS_ARCH'] != 'Darwin':
     # The encoding test is already implemented in the Downloads API by a set of
     # test cases with the string "content_encoding" in their names.
     if not CONFIG['MOZ_JSDOWNLOADS']:
         XPCSHELL_TESTS_MANIFESTS += ['unit_ipc/xpcshell.ini']
 
-SIMPLE_PROGRAMS = [
+SimplePrograms([
     'WriteArgument',
-]
+])
 
 SOURCES += [
     '%s.cpp' % s for s in SIMPLE_PROGRAMS
 ]
 
 USE_LIBS += [
     'nspr',
 ]
--- a/webapprt/gtk/moz.build
+++ b/webapprt/gtk/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-PROGRAM = 'webapprt-stub'
+Program('webapprt-stub')
 
 SOURCES += [
     'webapprt.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
 DEFINES['XPCOM_GLUE'] = True
--- a/webapprt/mac/moz.build
+++ b/webapprt/mac/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-PROGRAM = 'webapprt-stub'
+Program('webapprt-stub')
 
 SOURCES += [
     'webapprt.mm',
 ]
 
 DEFINES['XPCOM_GLUE'] = True
 
 GENERATED_INCLUDES += ['/build']
--- a/webapprt/win/moz.build
+++ b/webapprt/win/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-PROGRAM = 'webapprt-stub'
+Program('webapprt-stub')
 
 SOURCES += [
     'webapprt.cpp',
 ]
 
 DEFINES['XPCOM_GLUE'] = True
 if CONFIG['DEBUG']:
     DEFINES['DEBUG'] = True
--- a/widget/gonk/libdisplay/moz.build
+++ b/widget/gonk/libdisplay/moz.build
@@ -31,17 +31,17 @@ elif CONFIG['ANDROID_VERSION'] == '17':
     ]
 elif CONFIG['ANDROID_VERSION'] == '15':
     SOURCES += [
         'GonkDisplayICS.cpp'
     ]
 elif CONFIG['ANDROID_VERSION'] and CONFIG['COMPILE_ENVIRONMENT']:
     error('Unsupported platform version: %s' % (CONFIG['ANDROID_VERSION']))
 
-LIBRARY_NAME = 'display'
+Library('display')
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FORCE_STATIC_LIB = True
 
 DEFINES['XPCOM_GLUE'] = True
 
 DISABLE_STL_WRAPPING = True
--- a/widget/gtk/mozgtk/gtk2/moz.build
+++ b/widget/gtk/mozgtk/gtk2/moz.build
@@ -5,17 +5,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 SOURCES += [
     '../mozgtk.c',
 ]
 
 DEFINES['GTK3_SYMBOLS'] = True
 
-LIBRARY_NAME = 'mozgtk2'
+Library('mozgtk2')
 
 SONAME = 'mozgtk'
 
 FORCE_SHARED_LIB = True
 
 # If LDFLAGS contains -Wl,--as-needed, we need to add -Wl,--no-as-needed
 # before the gtk libraries, otherwise the linker will drop those dependencies
 # because no symbols are used from them. But those dependencies need to be
--- a/widget/gtk/mozgtk/gtk3/moz.build
+++ b/widget/gtk/mozgtk/gtk3/moz.build
@@ -5,17 +5,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 SOURCES += [
     '../mozgtk.c',
 ]
 
 DEFINES['GTK2_SYMBOLS'] = True
 
-LIBRARY_NAME = 'mozgtk'
+Library('mozgtk')
 
 SONAME = 'mozgtk'
 
 FORCE_SHARED_LIB = True
 
 # If LDFLAGS contains -Wl,--as-needed, we need to add -Wl,--no-as-needed
 # before the gtk libraries, otherwise the linker will drop those dependencies
 # because no symbols are used from them. But those dependencies need to be
--- a/widget/gtk/mozgtk/stub/moz.build
+++ b/widget/gtk/mozgtk/stub/moz.build
@@ -6,13 +6,13 @@
 
 SOURCES += [
     '../mozgtk.c',
 ]
 
 for var in ('COMMON_SYMBOLS', 'GTK2_SYMBOLS', 'GTK3_SYMBOLS'):
     DEFINES[var] = True
 
-LIBRARY_NAME = 'mozgtk_stub'
+Library('mozgtk_stub')
 
 SONAME = 'mozgtk'
 
 FORCE_SHARED_LIB = True
--- a/widget/tests/moz.build
+++ b/widget/tests/moz.build
@@ -3,19 +3,19 @@
 # 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/.
 
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
 MOCHITEST_MANIFESTS += ['mochitest.ini']
 MOCHITEST_CHROME_MANIFESTS += ['chrome.ini']
 
-CPP_UNIT_TESTS += [
+CppUnitTests([
     'TestAppShellSteadyState',
-]
+])
 
 FAIL_ON_WARNINGS = True
 
 # if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
 #     if CONFIG['NS_ENABLE_TSF']:
 #         Test disabled because it uses the internal string APIs incorrectly
 #         (see bug 582863)
 #         CPP_UNIT_TESTS += ['TestWinTSF']
--- a/widget/xremoteclient/moz.build
+++ b/widget/xremoteclient/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-PROGRAM = 'mozilla-xremote-client'
+Program('mozilla-xremote-client')
 
 FINAL_LIBRARY = 'xul'
 
 DEFINES['XPCOM_GLUE'] = True
 
 OS_LIBS += CONFIG['XLDFLAGS']
 OS_LIBS += CONFIG['XLIBS']
 
--- a/xpcom/glue/moz.build
+++ b/xpcom/glue/moz.build
@@ -90,17 +90,17 @@ include('objs.mozbuild')
 UNIFIED_SOURCES += xpcom_gluens_src_cppsrcs
 UNIFIED_SOURCES += xpcom_glue_src_cppsrcs
 
 UNIFIED_SOURCES += [
     'GenericModule.cpp',
     'nsStringAPI.cpp',
 ]
 
-LIBRARY_NAME = 'xpcomglue_s'
+Library('xpcomglue_s')
 
 SDK_LIBRARY = True
 
 FORCE_STATIC_LIB = True
 
 if CONFIG['_MSC_VER']:
     DEFINES['_USE_ANSI_CPP'] = True
     # Don't include directives about which CRT to use
--- a/xpcom/glue/nomozalloc/moz.build
+++ b/xpcom/glue/nomozalloc/moz.build
@@ -9,17 +9,17 @@ include('../objs.mozbuild')
 UNIFIED_SOURCES += xpcom_gluens_src_cppsrcs
 UNIFIED_SOURCES += xpcom_glue_src_cppsrcs
 
 UNIFIED_SOURCES += [
     '../GenericModule.cpp',
     '../nsStringAPI.cpp',
 ]
 
-LIBRARY_NAME = 'xpcomglue_s_nomozalloc'
+Library('xpcomglue_s_nomozalloc')
 
 SDK_LIBRARY = True
 
 # we don't want the shared lib, but we want to force the creation of a static lib.
 FORCE_STATIC_LIB = True
 
 if CONFIG['_MSC_VER']:
     DEFINES['_USE_ANSI_CPP'] = True
--- a/xpcom/glue/standalone/moz.build
+++ b/xpcom/glue/standalone/moz.build
@@ -13,17 +13,17 @@ include('../objs.mozbuild')
 
 SOURCES += xpcom_glue_src_cppsrcs
 
 SOURCES += [
     '../nsStringAPI.cpp',
     'nsXPCOMGlue.cpp',
 ]
 
-LIBRARY_NAME = 'xpcomglue'
+Library('xpcomglue')
 
 EXPORTS += [
     'nsXPCOMGlue.h',
 ]
 
 SDK_LIBRARY = True
 
 FORCE_STATIC_LIB = True
--- a/xpcom/glue/standalone/staticruntime/moz.build
+++ b/xpcom/glue/standalone/staticruntime/moz.build
@@ -8,17 +8,17 @@ include('../../objs.mozbuild')
 
 SOURCES += xpcom_glue_src_cppsrcs
 
 SOURCES += [
     '../../nsStringAPI.cpp',
     '../nsXPCOMGlue.cpp',
 ]
 
-LIBRARY_NAME = 'xpcomglue_staticruntime'
+Library('xpcomglue_staticruntime')
 
 SDK_LIBRARY = True
 
 # create a static lib
 FORCE_STATIC_LIB = True
 
 if CONFIG['_MSC_VER']:
     DEFINES['_USE_ANSI_CPP'] = True
--- a/xpcom/glue/staticruntime/moz.build
+++ b/xpcom/glue/staticruntime/moz.build
@@ -9,17 +9,17 @@ include('../objs.mozbuild')
 UNIFIED_SOURCES += xpcom_gluens_src_cppsrcs
 UNIFIED_SOURCES += xpcom_glue_src_cppsrcs
 
 UNIFIED_SOURCES += [
     '../GenericModule.cpp',
     '../nsStringAPI.cpp',
 ]
 
-LIBRARY_NAME = 'xpcomglue_staticruntime_s'
+Library('xpcomglue_staticruntime_s')
 
 SDK_LIBRARY = True
 
 FORCE_STATIC_LIB = True
 
 if CONFIG['_MSC_VER']:
     DEFINES['_USE_ANSI_CPP'] = True
     # Don't include directives about which CRT to use
--- a/xpcom/reflect/xptcall/md/test/moz.build
+++ b/xpcom/reflect/xptcall/md/test/moz.build
@@ -3,11 +3,11 @@
 # 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/.
 
 SOURCES += [
     'stub_test.cpp',
 ]
 
-SIMPLE_PROGRAMS += [
+SimplePrograms([
     'stub_test',
-]
+])
--- a/xpcom/reflect/xptcall/tests/moz.build
+++ b/xpcom/reflect/xptcall/tests/moz.build
@@ -1,17 +1,17 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-SIMPLE_PROGRAMS = [
+SimplePrograms([
     'TestXPTCInvoke',
-]
+])
 
 SOURCES += [
     '%s.cpp' % s for s in SIMPLE_PROGRAMS
 ]
 
 USE_LIBS += [
     'mozalloc',
     'nspr',
--- a/xpcom/reflect/xptinfo/tests/moz.build
+++ b/xpcom/reflect/xptinfo/tests/moz.build
@@ -3,18 +3,18 @@
 # 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/.
 
 SOURCES += [
     'TestInterfaceInfo.cpp',
 ]
 
-SIMPLE_PROGRAMS += [
+SimplePrograms([
     'TestInterfaceInfo'
-]
+])
 
 USE_LIBS += [
     'mozalloc',
     'nspr',
     'xpcomglue_s',
     'xul',
 ]
--- a/xpcom/sample/program/moz.build
+++ b/xpcom/sample/program/moz.build
@@ -6,19 +6,19 @@
 
 # We must specify CPP_SOURCES in order to link using the proper c++ linker
 # on certain platforms.
 SOURCES += [
     'nsTestSample.cpp',
 ]
 
 # SIMPLE_PROGRAMS compiles a single .cpp file into an executable
-SIMPLE_PROGRAMS += [
+SimplePrograms([
     'nsTestSample'
-]
+])
 
 # Whatever code is going to be linked with the *standalone* glue must be
 # built with the XPCOM_GLUE define set.
 DEFINES['XPCOM_GLUE'] = True
 
 # USE_LIBS specifies the in-tree  libraries to link when building an executable
 # program from this directory. We link against the "standalone glue" which does
 # not require# that the application be linked against the XPCOM dynamic library
--- a/xpcom/tests/external/moz.build
+++ b/xpcom/tests/external/moz.build
@@ -1,17 +1,17 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-SIMPLE_PROGRAMS = [
+SimplePrograms([
     'TestMinStringAPI',
-]
+])
 
 SOURCES += [
     '%s.cpp' % s for s in SIMPLE_PROGRAMS
 ]
 
 USE_LIBS += [
     'mozalloc',
     'nspr',
--- a/xpcom/tests/moz.build
+++ b/xpcom/tests/moz.build
@@ -18,48 +18,48 @@ if CONFIG['DEHYDRA_PATH']:
     TEST_DIRS += ['static-checker']
 
 FAIL_ON_WARNINGS = True
 
 EXPORTS.testing += [
     'TestHarness.h',
 ]
 
-SIMPLE_PROGRAMS = [
+SimplePrograms([
     'nsIFileEnumerator',
     'TestArguments',
     'TestBlockingProcess',
     'TestCallTemplates',
     'TestINIParser',
     'TestPRIntN',
     'TestQuickReturn',
     'TestRacingServiceManager',
     'TestRegistrationOrder',
     'TestThreadPoolListener',
     'TestTimers',
     'TestUnicodeArguments',
-]
+])
 
 if CONFIG['OS_TARGET'] == 'WINNT':
-    SIMPLE_PROGRAMS += [
+    SimplePrograms([
         'TestBase64',
-    ]
+    ])
 
 if CONFIG['WRAP_STL_INCLUDES'] and not CONFIG['CLANG_CL']:
-    SIMPLE_PROGRAMS += [
+    SimplePrograms([
         'TestSTLWrappers',
-    ]
+    ])
 
 SOURCES += [
     '%s.cpp' % s for s in sorted(SIMPLE_PROGRAMS)
 ]
 
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
 
-CPP_UNIT_TESTS += [
+CppUnitTests([
     'ShowAlignments',
     'TestAutoPtr',
     'TestAutoRef',
     'TestCOMArray',
     'TestCOMPtr',
     'TestCOMPtrEq',
     'TestDeque',
     'TestFile',
@@ -69,22 +69,22 @@ CPP_UNIT_TESTS += [
     'TestObserverArray',
     'TestObserverService',
     'TestPipe',
     'TestPLDHash',
     'TestStringAPI',
     'TestTArray',
     'TestTextFormatter',
     'TestThreadUtils'
-]
+])
 
 if CONFIG['MOZ_MEMORY']:
-    CPP_UNIT_TESTS += [
+    CppUnitTests([
         'TestJemalloc',
-    ]
+    ])
 
 # XXX Make these tests work in libxul builds.
 #CPP_UNIT_TESTS += [
 #    'TestArray',
 #    'TestCRT',
 #    'TestEncoding',
 #    'TestExpirationTracker',
 #    'TestPipes',
@@ -104,20 +104,20 @@ if CONFIG['MOZ_MEMORY']:
 # FIXME: bug 577500 TestStaticAtoms fails when run in dist/bin
 #CPP_UNIT_TESTS += [
 #    'TestStaticAtoms',
 #]
 
 if CONFIG['MOZ_DEBUG'] and CONFIG['OS_ARCH'] not in ('WINNT'):
     # FIXME bug 523392: TestDeadlockDetector doesn't like Windows
     # FIXME bug 523378: also fails on OS X
-    CPP_UNIT_TESTS += [
+    CppUnitTests([
         'TestDeadlockDetector',
         'TestDeadlockDetectorScalability',
-    ]
+    ])
 
 SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
 
 LOCAL_INCLUDES += [
     '../ds',
 ]
 
 RESOURCE_FILES += [
--- a/xpcom/tests/windows/moz.build
+++ b/xpcom/tests/windows/moz.build
@@ -1,18 +1,18 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-CPP_UNIT_TESTS += [
+CppUnitTests([
     'TestCOM',
     'TestNtPathToDosPath',
-]
+])
 
 SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS)
 
 USE_LIBS += [
     'mozalloc',
     'nspr',
     'xpcomglue_s',
     'xul',
--- a/xpcom/typelib/xpt/moz.build
+++ b/xpcom/typelib/xpt/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-LIBRARY_NAME = 'xpt'
+Library('xpt')
 
 DIRS += ['tools']
 
 UNIFIED_SOURCES += [
     'xpt_arena.cpp',
     'xpt_struct.cpp',
     'xpt_xdr.cpp',
 ]
--- a/xpcom/typelib/xpt/tests/moz.build
+++ b/xpcom/typelib/xpt/tests/moz.build
@@ -1,18 +1,18 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
-SIMPLE_PROGRAMS = [
+SimplePrograms([
     'PrimitiveTest',
     'SimpleTypeLib',
-]
+])
 
 SOURCES += [
     '%s.cpp' % s for s in SIMPLE_PROGRAMS
 ]
 
 FAIL_ON_WARNINGS = True
 
 USE_LIBS += [
--- a/xpcom/windbgdlg/moz.build
+++ b/xpcom/windbgdlg/moz.build
@@ -3,11 +3,11 @@
 # 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/.
 
 SOURCES += [
     'windbgdlg.cpp',
 ]
 
-SIMPLE_PROGRAMS += [
+SimplePrograms([
     'windbgdlg'
-]
+])
--- a/xulrunner/app/moz.build
+++ b/xulrunner/app/moz.build
@@ -1,17 +1,17 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
 DIRS += ['profile']
 
-PROGRAM = 'xulrunner'
+Program('xulrunner')
 
 SOURCES += [
     'nsXULRunnerApp.cpp',
 ]
 
 DEFINES['XULRUNNER_PROGNAME'] = '"xulrunner"'
 DEFINES['XPCOM_GLUE'] = True
 if CONFIG['DEBUG']:
--- a/xulrunner/stub/moz.build
+++ b/xulrunner/stub/moz.build
@@ -3,17 +3,17 @@
 # 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/.
 
 # The value of XULRUNNER_STUB_NAME is generated by configure to allow XULRunner
 # apps to override it using the --with-xulrunner-stub-name=<appname> argument.
 # If this configure argument is not present then the default name is
 # 'xulrunner-stub'.
-PROGRAM = CONFIG['XULRUNNER_STUB_NAME']
+Program(CONFIG['XULRUNNER_STUB_NAME'])
 
 SOURCES += [
     'nsXULStub.cpp',
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     FINAL_TARGET = 'dist/XUL.framework/Versions/%(MOZILLA_VERSION)s' % CONFIG
 
--- a/xulrunner/tools/redit/moz.build
+++ b/xulrunner/tools/redit/moz.build
@@ -1,16 +1,16 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=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/.
 
 if CONFIG['OS_ARCH'] == 'WINNT':
-    PROGRAM  = 'redit'
+    Program('redit')
     SOURCES += [
         'redit.cpp',
     ]
     for var in ('WIN32_LEAN_AND_MEAN', 'UNICODE', '_UNICODE', 'XPCOM_GLUE'):
         DEFINES[var] = True
     if CONFIG['GNU_CC']:
         WIN32_EXE_LDFLAGS += ['-municode']