[PATCH 1/2] build: Make generate-plugin-docs.pl independent of autotools



`generate-plugin-docs.pl` script which is used to parse
`nm-setting-c*.c` files depends on autotools. This is because it
parses the `Makefile.am` in order to figure out the setting files
it needs to parse.

This patch makes the script independent of autotools by passing
the necessary setting files by command line instead of parsing the
`Makefile.am` file. It also changes the autotools' and meson's
accordingly.
---
 Makefile.am                   | 46 ++++++++++++++++++++++---------------------
 libnm-core/meson.build        | 25 ++++++++++++-----------
 libnm/generate-plugin-docs.pl | 20 ++++---------------
 libnm/meson.build             | 12 +++++------
 4 files changed, 48 insertions(+), 55 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 4d2657a79..cbcbb4a41 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -453,23 +453,7 @@ libnm_core_lib_h_priv = \
        libnm-core/nm-property-compare.h \
        libnm-core/nm-setting-private.h \
        libnm-core/nm-utils-private.h
-libnm_core_lib_c_real = \
-       shared/nm-utils/c-list-util.c \
-       shared/nm-utils/nm-dedup-multi.c \
-       shared/nm-utils/nm-enum-utils.c \
-       shared/nm-utils/nm-hash-utils.c \
-       shared/nm-utils/nm-shared-utils.c \
-       shared/nm-utils/nm-random-utils.c \
-       shared/nm-utils/nm-udev-utils.c \
-       shared/nm-meta-setting.c \
-       libnm-core/crypto.c \
-       libnm-core/nm-connection.c \
-       libnm-core/nm-dbus-utils.c \
-       libnm-core/nm-errors.c \
-       libnm-core/nm-keyfile-reader.c \
-       libnm-core/nm-keyfile-utils.c \
-       libnm-core/nm-keyfile-writer.c \
-       libnm-core/nm-property-compare.c \
+libnm_core_lib_c_settings_real = \
        libnm-core/nm-setting-8021x.c \
        libnm-core/nm-setting-adsl.c \
        libnm-core/nm-setting-bluetooth.c \
@@ -509,7 +493,25 @@ libnm_core_lib_c_real = \
        libnm-core/nm-setting-wimax.c \
        libnm-core/nm-setting-wired.c \
        libnm-core/nm-setting-wireless-security.c \
-       libnm-core/nm-setting-wireless.c \
+       libnm-core/nm-setting-wireless.c
+libnm_core_lib_c_real = \
+       $(libnm_core_lib_c_settings_real) \
+       shared/nm-utils/c-list-util.c \
+       shared/nm-utils/nm-dedup-multi.c \
+       shared/nm-utils/nm-enum-utils.c \
+       shared/nm-utils/nm-hash-utils.c \
+       shared/nm-utils/nm-shared-utils.c \
+       shared/nm-utils/nm-random-utils.c \
+       shared/nm-utils/nm-udev-utils.c \
+       shared/nm-meta-setting.c \
+       libnm-core/crypto.c \
+       libnm-core/nm-connection.c \
+       libnm-core/nm-dbus-utils.c \
+       libnm-core/nm-errors.c \
+       libnm-core/nm-keyfile-reader.c \
+       libnm-core/nm-keyfile-utils.c \
+       libnm-core/nm-keyfile-writer.c \
+       libnm-core/nm-property-compare.c \
        libnm-core/nm-setting.c \
        libnm-core/nm-simple-connection.c \
        libnm-core/nm-utils.c \
@@ -991,10 +993,10 @@ libnm_noinst_data = \
 
 noinst_DATA += $(libnm_noinst_data)
 
-libnm_docs_sources = $(libnm_core_lib_c_real)
+libnm_docs_sources = $(libnm_core_lib_c_settings_real)
 
 libnm/nm-settings-docs-overrides.xml: libnm/generate-plugin-docs.pl $(libnm_docs_sources)
-       $(AM_V_GEN) $(srcdir)/libnm/generate-plugin-docs.pl dbus "$(srcdir)" $@
+       $(AM_V_GEN) $(srcdir)/libnm/generate-plugin-docs.pl dbus $@ $(libnm_docs_sources)
 
 # When the python scripts loads libnm and the address sanitizers is
 # enabled, we must LD_PRELOAD libasan otherwise it will complain that
@@ -1021,9 +1023,9 @@ libnm/nm-settings-docs.xml: libnm/generate-setting-docs.py libnm/nm-settings-doc
                --output $@
 
 libnm/nm-settings-keyfile-docs.xml: libnm/generate-plugin-docs.pl $(libnm_docs_sources)
-       $(AM_V_GEN) $(srcdir)/libnm/generate-plugin-docs.pl keyfile "$(srcdir)" $@
+       $(AM_V_GEN) $(srcdir)/libnm/generate-plugin-docs.pl keyfile $@ $(libnm_docs_sources)
 libnm/nm-settings-ifcfg-rh-docs.xml: libnm/generate-plugin-docs.pl $(libnm_docs_sources)
-       $(AM_V_GEN) $(srcdir)/libnm/generate-plugin-docs.pl ifcfg-rh "$(srcdir)" $@
+       $(AM_V_GEN) $(srcdir)/libnm/generate-plugin-docs.pl ifcfg-rh $@ $(libnm_docs_sources)
 
 EXTRA_DIST += $(libnm_noinst_data)
 
diff --git a/libnm-core/meson.build b/libnm-core/meson.build
index 13155138f..6f8ba1769 100644
--- a/libnm-core/meson.build
+++ b/libnm-core/meson.build
@@ -54,16 +54,7 @@ libnm_core_headers = files(
   'nm-vpn-plugin-info.h'
 )
 
-libnm_core_sources = files(
-  'crypto.c',
-  'crypto_' + crypto + '.c',
-  'nm-connection.c',
-  'nm-dbus-utils.c',
-  'nm-errors.c',
-  'nm-keyfile-reader.c',
-  'nm-keyfile-utils.c',
-  'nm-keyfile-writer.c',
-  'nm-property-compare.c',
+libnm_core_settings_sources = files(
   'nm-setting-8021x.c',
   'nm-setting-adsl.c',
   'nm-setting-bluetooth.c',
@@ -103,7 +94,19 @@ libnm_core_sources = files(
   'nm-setting-wimax.c',
   'nm-setting-wired.c',
   'nm-setting-wireless-security.c',
-  'nm-setting-wireless.c',
+  'nm-setting-wireless.c'
+)
+
+libnm_core_sources = libnm_core_settings_sources + files(
+  'crypto.c',
+  'crypto_' + crypto + '.c',
+  'nm-connection.c',
+  'nm-dbus-utils.c',
+  'nm-errors.c',
+  'nm-keyfile-reader.c',
+  'nm-keyfile-utils.c',
+  'nm-keyfile-writer.c',
+  'nm-property-compare.c',
   'nm-setting.c',
   'nm-simple-connection.c',
   'nm-utils.c',
diff --git a/libnm/generate-plugin-docs.pl b/libnm/generate-plugin-docs.pl
index 24912a037..e4963b7c5 100755
--- a/libnm/generate-plugin-docs.pl
+++ b/libnm/generate-plugin-docs.pl
@@ -46,25 +46,14 @@ use v5.10;
 
 # global variables
 my @keywords = ("property", "variable", "format", "values", "default", "example", "description");
-my @source_files;
 my @data;
 my $fo;
 
-(scalar @ARGV == 3) or die "Usage: $0 <plugin> <srcdir> <output-xml-file>\n";
-my ($plugin, $srcdir, $output) = @ARGV;
+(scalar @ARGV >= 3) or die "Usage: $0 <plugin> <output-xml-file> <srcfiles>\n";
+my ($plugin, $output, (@source_files)) = @ARGV;
 my $start_tag = "---$plugin---\\s*\$";
 my $end_tag   = '---end---';
 
-# get source files to scan for documentation comments (nm-setting-<something>.c)
-my $file = "$srcdir/Makefile.am";
-open my $fh, '<', $file or die "Can't open $file: $!";
-while (my $line = <$fh>) {
-  if ($line =~ /^\t*(libnm-core\/nm-setting-[^.]*\.c)( \\)?$/g) {
-    push @source_files, $1;
-  }
-}
-close $fh;
-
 # open output file
 open $fo, '>', $output or die "Can't open $output: $!";
 
@@ -73,11 +62,10 @@ write_header();
 
 # write generated documenation for each setting
 foreach my $c_file (@source_files) {
-  my $path = "$srcdir/$c_file";
-  my $setting_name = get_setting_name($path);
+  my $setting_name = get_setting_name($c_file);
   if ($setting_name) {
     write_item("<setting name=\"$setting_name\">");
-    scan_doc_comments($path, $start_tag, $end_tag);
+    scan_doc_comments($c_file, $start_tag, $end_tag);
     write_item("</setting>");
   }
 }
diff --git a/libnm/meson.build b/libnm/meson.build
index 3541832a5..d06c379dd 100644
--- a/libnm/meson.build
+++ b/libnm/meson.build
@@ -236,26 +236,26 @@ if enable_introspection
   name = 'nm-settings-keyfile-docs.xml'
   nm_settings_keyfile_docs = custom_target(
     name,
-    input: meson.source_root(),
+    input: libnm_core_settings_sources,
     output: name,
-    command: [perl, generate_plugin_docs, 'keyfile', '@INPUT@', '@OUTPUT@']
+    command: [perl, generate_plugin_docs, 'keyfile', '@OUTPUT@', '@INPUT@']
   )
 
   name = 'nm-settings-docs-overrides.xml'
   nm_settings_docs_overrides = custom_target(
     name,
-    input: meson.source_root(),
+    input: libnm_core_settings_sources,
     output: name,
-    command: [perl, generate_plugin_docs, 'dbus', '@INPUT@', '@OUTPUT@']
+    command: [perl, generate_plugin_docs, 'dbus', '@OUTPUT@', '@INPUT@']
   )
 
   if enable_ifcfg_rh
     name = 'nm-settings-ifcfg-rh-docs.xml'
     nm_settings_ifcfg_rh_docs = custom_target(
       name,
-      input: meson.source_root(),
+      input: libnm_core_settings_sources,
       output: name,
-      command: [perl, generate_plugin_docs, 'ifcfg-rh', '@INPUT@', '@OUTPUT@']
+      command: [perl, generate_plugin_docs, 'ifcfg-rh', '@OUTPUT@', '@INPUT@']
     )
   endif
 
-- 
2.15.1



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]