blob: cbf1614163cb81b840a4e0f7cbaec5626b5fb7e1 [file] [log] [blame]
David Brazdil0f672f62019-12-10 10:32:29 +00001// SPDX-License-Identifier: GPL-2.0-only
2//
3/// Adds missing MODULE_IMPORT_NS statements to source files
4///
5/// This script is usually called from scripts/nsdeps with -D ns=<namespace> to
6/// add a missing namespace tag to a module source file.
7///
8
Olivier Deprez0e641232021-09-23 10:07:05 +02009virtual nsdeps
David Brazdil0f672f62019-12-10 10:32:29 +000010virtual report
11
12@has_ns_import@
13declarer name MODULE_IMPORT_NS;
14identifier virtual.ns;
15@@
16MODULE_IMPORT_NS(ns);
17
18// Add missing imports, but only adjacent to a MODULE_LICENSE statement.
19// That ensures we are adding it only to the main module source file.
Olivier Deprez0e641232021-09-23 10:07:05 +020020@do_import depends on !has_ns_import && nsdeps@
David Brazdil0f672f62019-12-10 10:32:29 +000021declarer name MODULE_LICENSE;
22expression license;
23identifier virtual.ns;
24@@
25MODULE_LICENSE(license);
26+ MODULE_IMPORT_NS(ns);
Olivier Deprez0e641232021-09-23 10:07:05 +020027
28// Dummy rule for report mode that would otherwise be empty and make spatch
29// fail ("No rules apply.")
30@script:python depends on report@
31@@