templates.mozbuild 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
  2. # This Source Code Form is subject to the terms of the Mozilla Public
  3. # License, v. 2.0. If a copy of the MPL was not distributed with this
  4. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  5. @template
  6. def DevToolsModules(*modules):
  7. '''Installs JS modules at a resource:// path that corresponds directly to
  8. their source tree location.
  9. For this to work as intended, a moz.build file should be placed in each
  10. source directory which uses this template to install only the JS files in
  11. its own directory. Subdirectories should use their own moz.build.
  12. By following this pattern, there's less magic to require() and resource://
  13. paths, since they now match the source tree.
  14. Currently `DevToolsModules` can only be called once per moz.build, so we
  15. build a list manually above. Bug 1198013 tracks fixing this to make it more
  16. like other moz.build constructs.'''
  17. for m in modules:
  18. if '/' in m:
  19. error('DevToolsModules must be used from the same directory as ' +
  20. 'the files to be installed.')
  21. # jar.mn manifest files are typically used to install files to chrome
  22. # locations. Instead of doing this, use this DevToolsModules syntax via
  23. # moz.build files to do the installation so that we can enforce correct
  24. # paths based on source tree location.
  25. base = FINAL_TARGET_FILES.chrome.devtools.modules
  26. for dir in RELATIVEDIR.split('/'):
  27. base = base[dir]
  28. base += [m for m in modules]