]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
configure.ac, config: Redesign how all-settings.c is built
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 19 Apr 2023 23:47:10 +0000 (02:47 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 20 Nov 2023 12:21:56 +0000 (14:21 +0200)
Later commits will start adding settings to all kinds of files, not just
*-settings.[ch] files. Use grep instead to find the files that contain
settings that are needed for all-settings.c.

configure.ac
src/config/Makefile.am
src/config/settings-get.pl

index c5d65fab4aa6156948baafb65d1668a7b1d88c30..6030fd93c102cb864e7a6aec86d7d021e06911a2 100644 (file)
@@ -682,11 +682,41 @@ dnl **
 dnl ** Settings
 dnl **
 
-dnl get a list of setting .[ch] files, but list .h files first
-FILES1=`find $srcdir/src -name '*settings.[[ch]]'|grep "$srcdir/src/lib-" | sed 's/^\(.*\)\(.\)$/\2 \1\2/' | grep -E -v 'lib-(master|smtp|settings).*c$' | sort -r | sed s/^..//`
-FILES2=`find $srcdir/src -name '*settings.[[ch]]'|grep -v "$srcdir/src/lib-" | sed 's/^\(.*\)\(.\)$/\2 \1\2/' | grep -v all-settings | sort -r | sed s/^..//`
-SETTING_FILES=`echo $FILES1 $FILES2 | sed -e s,$srcdir/src,./src,g -e 's,./src,$(top_srcdir)/src,g'`
+libdovecot_dirs=`echo "$LIBDOVECOT_LA_LIBS" | sed -e "s:\\$(top_builddir):$srcdir:g" -e 's:/[[^/]]*\\.la::g'`
+
+libdovecot_headers=
+libdovecot_c_files=
+non_libdovecot_headers=
+non_libdovecot_c_files=
+all_files=`find $srcdir/src -name '*.[[ch]]' | grep -v '/src/config/all-settings.c' | grep -v '/src/lib-settings/' | grep -v '/test-' | xargs grep '\\(struct setting_parser_info [[a-z]]\\)\\|\\(struct service_settings [[a-z]]\\)\\|\\(<settings checks>\\)' | sed 's/:.*//' | sort | uniq`
+for file in $all_files; do
+  dir=`echo "$file" | sed 's:/[[^/]]*$::'`
+  if echo "$libdovecot_dirs" | grep "$dir" >/dev/null; then
+    dnl lib-dovecot
+    if echo "$file" | grep '\.h$' >/dev/null; then
+      libdovecot_headers="$libdovecot_headers $file"
+    else
+      libdovecot_c_files="$libdovecot_c_files $file"
+    fi
+  else
+    dnl not lib-dovecot
+    if echo "$file" | grep '\.h$' >/dev/null; then
+      non_libdovecot_headers="$non_libdovecot_headers $file"
+    else
+      non_libdovecot_c_files="$non_libdovecot_c_files $file"
+    fi
+  fi
+done
+
+dnl libdovecot is linked to doveconf/config binaries, so don't duplicate the .c
+dnl file contents. However, we still need to scan the .c files for any
+dnl setting_parser_infos that aren't elsewhere.
+
+# list headers first, C files last
+SETTING_FILES=`echo $libdovecot_headers $non_libdovecot_headers $non_libdovecot_c_files | sed -e s,$srcdir/src,./src,g -e 's,./src,$(top_srcdir)/src,g'`
+SETTING_LINKED_FILES=`echo $libdovecot_c_files | sed -e s,$srcdir/src,./src,g -e 's,./src,$(top_srcdir)/src,g'`
 AC_SUBST(SETTING_FILES)
+AC_SUBST(SETTING_LINKED_FILES)
 
 dnl **
 dnl ** capabilities
index 2a391cccba2e68df67ee9189b6a74e59dd3cd30c..cf2b60c1302dc59d99cd86a4dea4ab79be98d013 100644 (file)
@@ -79,8 +79,8 @@ pkginclude_HEADERS = \
        config-parser-private.h \
        config-request.h
 
-all-settings.c: $(SETTING_FILES) $(top_srcdir)/src/config/settings-get.pl
-       $(AM_V_GEN)$(top_srcdir)/src/config/settings-get.pl $(SETTING_FILES) > all-settings.c || rm -f all-settings.c
+all-settings.c: $(SETTING_FILES) $(SETTING_LINKED_FILES) $(top_srcdir)/src/config/settings-get.pl
+       $(AM_V_GEN)$(top_srcdir)/src/config/settings-get.pl $(SETTING_FILES) -- $(SETTING_LINKED_FILES) > all-settings.c || rm -f all-settings.c
 
 EXTRA_DIST = \
        config-settings.c \
index f61e47c58dd4a104e32fcc64be87f08ebf02f9dd..354e1cb3013b688732435ffeabff24ebbe1c3927 100755 (executable)
@@ -33,7 +33,12 @@ my @services = ();
 my @service_ifdefs = ();
 my %parsers = {};
 
+my $linked_file = 0;
 foreach my $file (@ARGV) {
+  if ($file eq "--") {
+    $linked_file = 1;
+    next;
+  }
   my $f;
   open($f, $file) || die "Can't open $file: $@";
   
@@ -65,8 +70,15 @@ foreach my $file (@ARGV) {
        push @service_ifdefs, $ifdef;
       } elsif (/^(static )?const struct setting_parser_info (.*) = \{/) {
        $cur_name = $2;
+       if (/^const/ && $cur_name !~ /^\*/) {
+         $parsers{$cur_name} = 1;
+         if ($linked_file) {
+           $externs .= "extern const struct setting_parser_info $cur_name;\n";
+         }
+       }
        $state++ if ($cur_name !~ /^\*default_/);
       } elsif (/^extern const struct setting_parser_info (.*);/) {
+       $parsers{$1} = 1;
        $externs .= "extern const struct setting_parser_info $1;\n";
       } elsif (/\/\* <settings checks> \*\//) {
        $state = 4;
@@ -93,9 +105,6 @@ foreach my $file (@ARGV) {
     
     if ($state == 1 || $state == 3) {
       if ($state == 1 && $cur_name ne "") {
-       if (/\.name = "(.*)"/) {
-         $parsers{$cur_name} = $1;
-       }
        if (/\.parent = /) {
          delete($parsers{$cur_name});
        }
@@ -132,8 +141,10 @@ foreach my $file (@ARGV) {
   
   print "/* $file */\n";
   print $externs;
-  print $code;
-  print $file_contents;
+  if (!$linked_file) {
+    print $code;
+    print $file_contents;
+  }
 
   close $f;
 }
@@ -152,10 +163,6 @@ print "\t{ { config_all_services, sizeof(config_all_services) } }\n";
 print "};\n";
 
 print "const struct setting_parser_info *all_default_roots[] = {\n";
-print "\t&master_service_setting_parser_info,\n";
-print "\t&master_service_ssl_setting_parser_info,\n";
-print "\t&master_service_ssl_server_setting_parser_info,\n";
-print "\t&smtp_submit_setting_parser_info,\n";
 foreach my $name (sort(keys %parsers)) {
   my $module = $parsers{$name};
   next if (!$module);