Bug 912121 - Define DevToolsModules template for installing JS modules. r=glandium draft
authorJ. Ryan Stinnett <jryans@gmail.com>
Thu, 03 Sep 2015 23:43:44 -0500
changeset 290603 c85acf32715e4bc9e24276193638d37fff185798
parent 290602 6693418a3db66018a4ea6a43f3842421449f3c64
child 290604 bc6902cf586380c4566e83aac743d3f3fd4611bc
push id5164
push userjryans@gmail.com
push dateMon, 07 Sep 2015 01:24:15 +0000
reviewersglandium
bugs912121
milestone43.0a1
Bug 912121 - Define DevToolsModules template for installing JS modules. r=glandium
devtools/client/moz.build
devtools/server/moz.build
devtools/shared/moz.build
devtools/templates.mozbuild
--- a/devtools/client/moz.build
+++ b/devtools/client/moz.build
@@ -1,14 +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/.
 
+include('../templates.mozbuild')
+
 DIRS += [
     'animationinspector',
     'app-manager',
     'canvasdebugger',
     'commandline',
     'debugger',
     'eyedropper',
     'fontinspector',
--- a/devtools/server/moz.build
+++ b/devtools/server/moz.build
@@ -1,14 +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/.
 
+include('../templates.mozbuild')
+
 BROWSER_CHROME_MANIFESTS += ['tests/browser/browser.ini']
 MOCHITEST_CHROME_MANIFESTS += ['tests/mochitest/chrome.ini']
 XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini']
 
 XPIDL_SOURCES += [
     'nsIJSInspector.idl',
 ]
 
--- a/devtools/shared/moz.build
+++ b/devtools/shared/moz.build
@@ -1,14 +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/.
 
+include('../templates.mozbuild')
+
 DIRS += [
     'acorn',
     'apps',
     'client',
     'discovery',
     'gcli',
     'heapsnapshot',
     'jsbeautify',
new file mode 100644
--- /dev/null
+++ b/devtools/templates.mozbuild
@@ -0,0 +1,27 @@
+# -*- 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 DevToolsModules(*modules):
+    '''Installs JS modules at a resource:// path that corresponds directly to
+    their source tree location.
+
+    For this to work as intended, a moz.build file should be placed in each
+    source directory which uses this template to install only the JS files in
+    its own directory.  Subdirectories should use their own moz.build.
+
+    By following this pattern, there's less magic to require() and resource://
+    paths, since they now match the source tree.'''
+
+    for m in modules:
+        if '/' in m:
+            error('DevToolsModules must be used from the same directory as ' +
+                  'the files to be installed.')
+
+    base = EXTRA_JS_MODULES
+    for dir in RELATIVEDIR.split('/'):
+        base = base[dir]
+    base += [m for m in modules]