templates.mozbuild (1904B)
1 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- 2 # vim: set filetype=python: 3 # This Source Code Form is subject to the terms of the Mozilla Public 4 # License, v. 2.0. If a copy of the MPL was not distributed with this 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 7 8 @template 9 def DevToolsModules(*modules): 10 """Installs JS modules at a resource:// path that corresponds directly to 11 their source tree location. 12 13 For this to work as intended, a moz.build file should be placed in each 14 source directory which uses this template to install only the JS files in 15 its own directory. Subdirectories should use their own moz.build. 16 17 By following this pattern, there's less magic to require() and resource:// 18 paths, since they now match the source tree.""" 19 20 for m in modules: 21 if "/" in m: 22 error( 23 "DevToolsModules must be used from the same directory as " 24 + "the files to be installed." 25 ) 26 27 # jar.mn manifest files are typically used to install files to chrome 28 # locations. Instead of doing this, use this DevToolsModules syntax via 29 # moz.build files to do the installation so that we can enforce correct 30 # paths based on source tree location. 31 base = FINAL_TARGET_FILES.chrome.devtools.modules 32 for dir in RELATIVEDIR.split("/"): 33 base = base[dir] 34 base += [m for m in modules] 35 36 37 @template 38 def RenamedDevToolsModules(source, target): 39 """Helper function to ship a file (source) with a distinct name (target). 40 This will ship the file the same way DevToolsModule does it, to resource://devtools/ 41 """ 42 43 base = FINAL_TARGET_FILES.chrome.devtools.modules 44 for dir in RELATIVEDIR.split("/"): 45 base = base[dir] 46 base += ["!%s" % target] 47 48 GeneratedFile( 49 target, 50 script="/devtools/rename.py", 51 inputs=[source], 52 )