1# vim: set filetype=python:
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
6@template
7def CompiledModules(*modules):
8  compiled_directory_whitelist = (
9    "devtools/client/debugger/src",
10  )
11
12  if not RELATIVEDIR.startswith(compiled_directory_whitelist):
13    error("File in directory provided to CompiledModules not allowed: " + RELATIVEDIR)
14
15  # HACK. Template export() propagation is janky so we have to re-implement the
16  # logic for computing FINAL_TARGET from scratch. Here we emulate the
17  # DIST_SUBDIR export in devtools/moz.build.
18  if CONFIG['MOZ_BUILD_APP'] == 'browser':
19    final_target = 'dist/bin/browser'
20  else:
21    final_target = 'dist/bin'
22
23  final = '/'.join([TOPOBJDIR, final_target, 'chrome/devtools/modules',
24                    RELATIVEDIR])
25  # For the same reason as https://searchfox.org/mozilla-central/source/mobile/android/base/moz.build#180-184
26  # we have to insert a first entry as recursivemake overrides the first entry and we end up with empty files
27  # for the first file only.
28  GeneratedFile(
29      "node.stub", *[final + '/' + module for module in modules],
30      script='/python/mozbuild/mozbuild/action/node.py',
31      entry_point='generate',
32      inputs=['/devtools/client/shared/build/build.js'] +
33             [module for module in modules],
34      flags=[final])
35