From dea8eee7ff38af850e7803d284fb65da851ad1d4 Mon Sep 17 00:00:00 2001 From: Water-Melon Date: Wed, 24 Jan 2024 02:00:38 +0000 Subject: [PATCH] fix(configure): fix the module dependency algorithm --- configure | 56 ++++++++++++++++++++++++++++----------------- include/mln_types.h | 1 - src/mln_conf.c | 1 + src/mln_file.c | 1 + src/mln_lang.c | 1 + src/mln_lang_ast.c | 1 + src/mln_lex.c | 1 + src/mln_tools.c | 1 + 8 files changed, 41 insertions(+), 22 deletions(-) diff --git a/configure b/configure index 8e5ee412..ea85df38 100755 --- a/configure +++ b/configure @@ -384,33 +384,47 @@ get_source_files() { files+=$f" " done else - old_ifs=$IFS - IFS=',' - for f in $select_files + while true do - IFS=$old_ifs - fname='mln_'$f'.c' - fname=`find src -name $fname` - if [ -z $fname ]; then - echo "[$f] not found" - exit 1 - fi - files+=$fname" " - for header in `cpp -MM -MG $fname 2> /dev/null` + old_ifs=$IFS + IFS=',' + current_files=$select_files + for f in $select_files do - suffix=`echo $header | cut -d '.' -f 2` - if [ $suffix == 'h' ]; then - source_file=`echo $header | cut -d '.' -f 1`'.c' - source_file=`find src -name $source_file` - if [ ! -z $source_file ]; then - if [[ ! "${files[@]}" =~ $source_file ]]; then - files+=$source_file" " + IFS=$old_ifs + fname='mln_'$f'.c' + fname=`find src -name $fname` + if [ -z $fname ]; then + echo "[$f] not found" + exit 1 + fi + if [[ ! "${files[@]}" =~ $fname ]]; then + files+=$fname" " + fi + for header in `cpp -MM -MG -I include $fname 2> /dev/null` + do + suffix=`echo $header | cut -d '.' -f 2` + if [ $suffix == 'h' ]; then + source_file=`echo $header | cut -d '/' -f 2` + module_name=`echo $source_file | cut -d '.' -f 1` + source_file='src/'$module_name'.c' + module_name=$(echo "$module_name" | sed 's/mln_//') + source_file=`find src -wholename "$source_file"` + if [ ! -z $source_file ]; then + if [[ ! "${files[@]}" =~ $source_file ]]; then + files+=$source_file" " + current_files+=","$module_name + fi fi fi - fi + done done + if [ $select_files = $current_files ]; then + break + fi + select_files=$current_files + IFS=$old_ifs done - IFS=$old_ifs fi select_files=$files } diff --git a/include/mln_types.h b/include/mln_types.h index a980d7df..1d68339d 100644 --- a/include/mln_types.h +++ b/include/mln_types.h @@ -8,7 +8,6 @@ #include #include "mln_utils.h" -#include "mln_path.h" #if defined(__GNUC__) && (__GNUC__ >= 4 && __GNUC_MINOR__ > 1) typedef long mln_spin_t; #elif defined(i386) || defined(__x86_64) diff --git a/src/mln_conf.c b/src/mln_conf.c index 68cec4b2..afb78e2d 100644 --- a/src/mln_conf.c +++ b/src/mln_conf.c @@ -7,6 +7,7 @@ #include "mln_conf.h" #include "mln_log.h" #include "mln_ipc.h" +#include "mln_path.h" #include #define CONF_ERR(lex,TK,MSG); \ diff --git a/src/mln_file.c b/src/mln_file.c index 0023e433..814c9e6b 100644 --- a/src/mln_file.c +++ b/src/mln_file.c @@ -4,6 +4,7 @@ */ #include "mln_file.h" +#include "mln_path.h" #include #include #include diff --git a/src/mln_lang.c b/src/mln_lang.c index 55d0f7e2..368e7520 100644 --- a/src/mln_lang.c +++ b/src/mln_lang.c @@ -22,6 +22,7 @@ #include "mln_lang_real.h" #include "mln_lang_str.h" #include "mln_lang_array.h" +#include "mln_path.h" #if defined(WIN32) #include #else diff --git a/src/mln_lang_ast.c b/src/mln_lang_ast.c index a01379ea..28e53017 100644 --- a/src/mln_lang_ast.c +++ b/src/mln_lang_ast.c @@ -5,6 +5,7 @@ #include #include "mln_lang_ast.h" #include "mln_parser_generator.h" +#include "mln_path.h" MLN_DECLARE_PARSER_GENERATOR(static, \ mln_lang, \ diff --git a/src/mln_lex.c b/src/mln_lex.c index 541f9464..5b85d66e 100644 --- a/src/mln_lex.c +++ b/src/mln_lex.c @@ -15,6 +15,7 @@ #include #include "mln_string.h" #include "mln_lex.h" +#include "mln_path.h" /* * error information diff --git a/src/mln_tools.c b/src/mln_tools.c index 46963b43..52a3b17c 100644 --- a/src/mln_tools.c +++ b/src/mln_tools.c @@ -18,6 +18,7 @@ #include "mln_global.h" #include "mln_conf.h" #include "mln_log.h" +#include "mln_path.h" static int mln_boot_help(const char *boot_str, const char *alias);