From: Timo Sirainen Date: Wed, 19 Apr 2023 23:47:10 +0000 (+0300) Subject: configure.ac, config: Redesign how all-settings.c is built X-Git-Tag: 2.4.0~2089 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4af18e0f382801ebd7dce9b1df07e7faba889e96;p=thirdparty%2Fdovecot%2Fcore.git configure.ac, config: Redesign how all-settings.c is built 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. --- diff --git a/configure.ac b/configure.ac index c5d65fab4a..6030fd93c1 100644 --- a/configure.ac +++ b/configure.ac @@ -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]]\\)\\|\\(\\)' | 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 diff --git a/src/config/Makefile.am b/src/config/Makefile.am index 2a391cccba..cf2b60c130 100644 --- a/src/config/Makefile.am +++ b/src/config/Makefile.am @@ -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 \ diff --git a/src/config/settings-get.pl b/src/config/settings-get.pl index f61e47c58d..354e1cb301 100755 --- a/src/config/settings-get.pl +++ b/src/config/settings-get.pl @@ -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 (/\/\* \*\//) { $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);