diff options
| author | Jani Nikula <jani.nikula@intel.com> | 2016-06-07 04:00:52 -0400 |
|---|---|---|
| committer | Jani Nikula <jani.nikula@intel.com> | 2016-06-10 04:29:19 -0400 |
| commit | 88c2b57da4ce3c8b5f849dc5356bdea9e2ed1134 (patch) | |
| tree | 11abd7211827f7a473ce07549ccf859933f75419 /scripts/kernel-doc | |
| parent | 1ad560e43c911e19751df65dd2af21341d02eac5 (diff) | |
kernel-doc: add support for specifying extra files for EXPORT_SYMBOLs
If the kernel-doc comments for functions are not in the same file as the
EXPORT_SYMBOL statements, the -export and -internal output selections do
not work as expected. This is typically the case when the kernel-doc
comments are in header files next to the function declarations and the
EXPORT_SYMBOL statements are next to the function definitions in the
source files.
Let the user specify additional source files in which to look for the
EXPORT_SYMBOLs using the new -export-file FILE option, which may be
given multiple times.
The pathological example for this is include/net/mac80211.h, which has
all the kernel-doc documentation for the exported functions defined in a
plethora of source files net/mac80211/*.c.
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Diffstat (limited to 'scripts/kernel-doc')
| -rwxr-xr-x | scripts/kernel-doc | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/scripts/kernel-doc b/scripts/kernel-doc index 516d95fcefb7..9708a87c7069 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc | |||
| @@ -61,10 +61,10 @@ Output format selection (mutually exclusive): | |||
| 61 | Output selection (mutually exclusive): | 61 | Output selection (mutually exclusive): |
| 62 | -export Only output documentation for symbols that have been | 62 | -export Only output documentation for symbols that have been |
| 63 | exported using EXPORT_SYMBOL() or EXPORT_SYMBOL_GPL() | 63 | exported using EXPORT_SYMBOL() or EXPORT_SYMBOL_GPL() |
| 64 | in the same FILE. | 64 | in the same FILE or any -export-file FILE. |
| 65 | -internal Only output documentation for symbols that have NOT been | 65 | -internal Only output documentation for symbols that have NOT been |
| 66 | exported using EXPORT_SYMBOL() or EXPORT_SYMBOL_GPL() | 66 | exported using EXPORT_SYMBOL() or EXPORT_SYMBOL_GPL() |
| 67 | in the same FILE. | 67 | in the same FILE or any -export-file FILE. |
| 68 | -function NAME Only output documentation for the given function(s) | 68 | -function NAME Only output documentation for the given function(s) |
| 69 | or DOC: section title(s). All other functions and DOC: | 69 | or DOC: section title(s). All other functions and DOC: |
| 70 | sections are ignored. May be specified multiple times. | 70 | sections are ignored. May be specified multiple times. |
| @@ -76,6 +76,9 @@ Output selection modifiers: | |||
| 76 | -no-doc-sections Do not output DOC: sections. | 76 | -no-doc-sections Do not output DOC: sections. |
| 77 | -enable-lineno Enable output of #define LINENO lines. Only works with | 77 | -enable-lineno Enable output of #define LINENO lines. Only works with |
| 78 | reStructuredText format. | 78 | reStructuredText format. |
| 79 | -export-file FILE Specify an additional FILE in which to look for | ||
| 80 | EXPORT_SYMBOL() and EXPORT_SYMBOL_GPL(). To be used with | ||
| 81 | -export or -internal. May be specified multiple times. | ||
| 79 | 82 | ||
| 80 | Other parameters: | 83 | Other parameters: |
| 81 | -v Verbose output, more warnings and other information. | 84 | -v Verbose output, more warnings and other information. |
| @@ -336,6 +339,8 @@ use constant { | |||
| 336 | my $output_selection = OUTPUT_ALL; | 339 | my $output_selection = OUTPUT_ALL; |
| 337 | my $show_not_found = 0; | 340 | my $show_not_found = 0; |
| 338 | 341 | ||
| 342 | my @export_file_list; | ||
| 343 | |||
| 339 | my @build_time; | 344 | my @build_time; |
| 340 | if (defined($ENV{'KBUILD_BUILD_TIMESTAMP'}) && | 345 | if (defined($ENV{'KBUILD_BUILD_TIMESTAMP'}) && |
| 341 | (my $seconds = `date -d"${ENV{'KBUILD_BUILD_TIMESTAMP'}}" +%s`) ne '') { | 346 | (my $seconds = `date -d"${ENV{'KBUILD_BUILD_TIMESTAMP'}}" +%s`) ne '') { |
| @@ -488,6 +493,9 @@ while ($ARGV[0] =~ m/^-(.*)/) { | |||
| 488 | } elsif ($cmd eq "-internal") { # only non-exported symbols | 493 | } elsif ($cmd eq "-internal") { # only non-exported symbols |
| 489 | $output_selection = OUTPUT_INTERNAL; | 494 | $output_selection = OUTPUT_INTERNAL; |
| 490 | %function_table = (); | 495 | %function_table = (); |
| 496 | } elsif ($cmd eq "-export-file") { | ||
| 497 | my $file = shift @ARGV; | ||
| 498 | push(@export_file_list, $file); | ||
| 491 | } elsif ($cmd eq "-v") { | 499 | } elsif ($cmd eq "-v") { |
| 492 | $verbose = 1; | 500 | $verbose = 1; |
| 493 | } elsif (($cmd eq "-h") || ($cmd eq "--help")) { | 501 | } elsif (($cmd eq "-h") || ($cmd eq "--help")) { |
| @@ -2747,6 +2755,25 @@ sub map_filename($) { | |||
| 2747 | return $file; | 2755 | return $file; |
| 2748 | } | 2756 | } |
| 2749 | 2757 | ||
| 2758 | sub process_export_file($) { | ||
| 2759 | my ($orig_file) = @_; | ||
| 2760 | my $file = map_filename($orig_file); | ||
| 2761 | |||
| 2762 | if (!open(IN,"<$file")) { | ||
| 2763 | print STDERR "Error: Cannot open file $file\n"; | ||
| 2764 | ++$errors; | ||
| 2765 | return; | ||
| 2766 | } | ||
| 2767 | |||
| 2768 | while (<IN>) { | ||
| 2769 | if (/$export_symbol/) { | ||
| 2770 | $function_table{$2} = 1; | ||
| 2771 | } | ||
| 2772 | } | ||
| 2773 | |||
| 2774 | close(IN); | ||
| 2775 | } | ||
| 2776 | |||
| 2750 | sub process_file($) { | 2777 | sub process_file($) { |
| 2751 | my $file; | 2778 | my $file; |
| 2752 | my $identifier; | 2779 | my $identifier; |
| @@ -3081,6 +3108,14 @@ if (open(SOURCE_MAP, "<.tmp_filelist.txt")) { | |||
| 3081 | close(SOURCE_MAP); | 3108 | close(SOURCE_MAP); |
| 3082 | } | 3109 | } |
| 3083 | 3110 | ||
| 3111 | if ($output_selection == OUTPUT_EXPORTED || | ||
| 3112 | $output_selection == OUTPUT_INTERNAL) { | ||
| 3113 | foreach (@export_file_list) { | ||
| 3114 | chomp; | ||
| 3115 | process_export_file($_); | ||
| 3116 | } | ||
| 3117 | } | ||
| 3118 | |||
| 3084 | foreach (@ARGV) { | 3119 | foreach (@ARGV) { |
| 3085 | chomp; | 3120 | chomp; |
| 3086 | process_file($_); | 3121 | process_file($_); |
