diff options
author | "Vladimir N. Oleynik" <dzo@simtreas.ru> | 2005-10-07 15:36:26 +0000 |
---|---|---|
committer | "Vladimir N. Oleynik" <dzo@simtreas.ru> | 2005-10-07 15:36:26 +0000 |
commit | 6c0642d772c6661186e2191174fa83182fdc443e (patch) | |
tree | 1c691c0e617451715d834a88f48d033d50cb8585 | |
parent | 0b42a6a8cf94dd05434cf5554449a6b19d47fb1e (diff) | |
download | busybox-w32-6c0642d772c6661186e2191174fa83182fdc443e.tar.gz busybox-w32-6c0642d772c6661186e2191174fa83182fdc443e.tar.bz2 busybox-w32-6c0642d772c6661186e2191174fa83182fdc443e.zip |
fast replace if src outside
-rw-r--r-- | scripts/bb_mkdep.c | 50 |
1 files changed, 21 insertions, 29 deletions
diff --git a/scripts/bb_mkdep.c b/scripts/bb_mkdep.c index 0a2054c03..76db960fd 100644 --- a/scripts/bb_mkdep.c +++ b/scripts/bb_mkdep.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Another fast dependencies generator for Makefiles, Version 2.4 | 2 | * Another fast dependencies generator for Makefiles, Version 2.5 |
3 | * | 3 | * |
4 | * Copyright (C) 2005 by Vladimir Oleynik <dzo@simtreas.ru> | 4 | * Copyright (C) 2005 by Vladimir Oleynik <dzo@simtreas.ru> |
5 | * mmaping file may be originally by Linus Torvalds. | 5 | * mmaping file may be originally by Linus Torvalds. |
@@ -97,7 +97,11 @@ static void parse_conf_opt(const char *opt, const char *val, | |||
97 | static char first_chars[257]; /* + L_EOF */ | 97 | static char first_chars[257]; /* + L_EOF */ |
98 | static char isalnums[257]; /* + L_EOF */ | 98 | static char isalnums[257]; /* + L_EOF */ |
99 | /* trick for fast find "define", "include", "undef" */ | 99 | /* trick for fast find "define", "include", "undef" */ |
100 | static char first_chars_diu[256]; | 100 | static char first_chars_diu[256] = { |
101 | [(int)'d'] = (char)5, /* strlen("define") - 1; */ | ||
102 | [(int)'i'] = (char)6, /* strlen("include") - 1; */ | ||
103 | [(int)'u'] = (char)4, /* strlen("undef") - 1; */ | ||
104 | }; | ||
101 | 105 | ||
102 | static int pagesizem1; | 106 | static int pagesizem1; |
103 | static size_t mema_id = 128; /* first allocated for id */ | 107 | static size_t mema_id = 128; /* first allocated for id */ |
@@ -136,7 +140,6 @@ static char *id_s; | |||
136 | id[id_len++] = c; } while(0) | 140 | id[id_len++] = c; } while(0) |
137 | 141 | ||
138 | 142 | ||
139 | |||
140 | /* stupid C lexical analyser */ | 143 | /* stupid C lexical analyser */ |
141 | static void c_lex(const char *fname, long fsize) | 144 | static void c_lex(const char *fname, long fsize) |
142 | { | 145 | { |
@@ -605,14 +608,19 @@ static void parse_conf_opt(const char *opt, const char *val, | |||
605 | } | 608 | } |
606 | } | 609 | } |
607 | 610 | ||
608 | static int show_dep(int first, bb_key_t *k, const char *name) | 611 | static char *pwd; |
612 | |||
613 | static int show_dep(int first, bb_key_t *k, const char *name, const char *f) | ||
609 | { | 614 | { |
610 | bb_key_t *cur; | 615 | bb_key_t *cur; |
611 | 616 | ||
612 | for(cur = k; cur; cur = cur->next) { | 617 | for(cur = k; cur; cur = cur->next) { |
613 | if(cur->checked) { | 618 | if(cur->checked) { |
614 | if(first) { | 619 | if(first) { |
615 | printf("\n%s:", name); | 620 | if(f == NULL) |
621 | printf("\n%s:", name); | ||
622 | else | ||
623 | printf("\n%s/%s:", pwd, name); | ||
616 | first = 0; | 624 | first = 0; |
617 | } else { | 625 | } else { |
618 | printf(" \\\n "); | 626 | printf(" \\\n "); |
@@ -624,8 +632,7 @@ static int show_dep(int first, bb_key_t *k, const char *name) | |||
624 | return first; | 632 | return first; |
625 | } | 633 | } |
626 | 634 | ||
627 | static char *pwd; | 635 | static size_t replace; |
628 | static char *replace; | ||
629 | 636 | ||
630 | static struct stat st_kp; | 637 | static struct stat st_kp; |
631 | static int dontgenerate_dep; | 638 | static int dontgenerate_dep; |
@@ -673,23 +680,17 @@ parse_chd(const char *fe, const char *p, size_t dirlen) | |||
673 | if(*e == 'c') { | 680 | if(*e == 'c') { |
674 | /* *.c -> *.o */ | 681 | /* *.c -> *.o */ |
675 | *e = 'o'; | 682 | *e = 'o'; |
676 | if(replace) { | 683 | /* /src_dir/path/file.o to path/file.o */ |
677 | /* /src_dir/path/file.o to path/file.o */ | 684 | fp += replace; |
678 | e = fp + strlen(replace); | 685 | if(*fp == '/') |
679 | while(*e == '/') | 686 | fp++; |
680 | e++; | ||
681 | /* path/file.o to pwd/path/file.o */ | ||
682 | e = fp = bb_asprint("%s/%s", pwd, e); | ||
683 | } | ||
684 | } else { | 687 | } else { |
685 | e = NULL; | 688 | e = NULL; |
686 | } | 689 | } |
687 | first = show_dep(1, Ifound, fp); | 690 | first = show_dep(1, Ifound, fp, e); |
688 | first = show_dep(first, key_top, fp); | 691 | first = show_dep(first, key_top, fp, e); |
689 | if(first == 0) | 692 | if(first == 0) |
690 | putchar('\n'); | 693 | putchar('\n'); |
691 | if(replace && e) | ||
692 | free(e); | ||
693 | } | 694 | } |
694 | return NULL; | 695 | return NULL; |
695 | } else if(S_ISDIR(st.st_mode)) { | 696 | } else if(S_ISDIR(st.st_mode)) { |
@@ -726,10 +727,7 @@ static void scan_dir_find_ch_files(const char *p) | |||
726 | size_t dirlen; | 727 | size_t dirlen; |
727 | 728 | ||
728 | dirs = llist_add_to(NULL, bb_simplify_path(p)); | 729 | dirs = llist_add_to(NULL, bb_simplify_path(p)); |
729 | if(strcmp(dirs->data, pwd)) | 730 | replace = strlen(dirs->data); |
730 | replace = bb_xstrdup(dirs->data); | ||
731 | else | ||
732 | replace = NULL; | ||
733 | /* emulate recursive */ | 731 | /* emulate recursive */ |
734 | while(dirs) { | 732 | while(dirs) { |
735 | d_add = NULL; | 733 | d_add = NULL; |
@@ -755,8 +753,6 @@ static void scan_dir_find_ch_files(const char *p) | |||
755 | } | 753 | } |
756 | dirs = d_add; | 754 | dirs = d_add; |
757 | } | 755 | } |
758 | free(replace); | ||
759 | replace = NULL; | ||
760 | } | 756 | } |
761 | 757 | ||
762 | 758 | ||
@@ -832,10 +828,6 @@ int main(int argc, char **argv) | |||
832 | first_chars[i] = ANY; | 828 | first_chars[i] = ANY; |
833 | } | 829 | } |
834 | first_chars[i] = '-'; /* L_EOF */ | 830 | first_chars[i] = '-'; /* L_EOF */ |
835 | /* trick for fast find "define", "include", "undef" */ | ||
836 | first_chars_diu[(int)'d'] = (char)5; /* strlen("define") - 1; */ | ||
837 | first_chars_diu[(int)'i'] = (char)6; /* strlen("include") - 1; */ | ||
838 | first_chars_diu[(int)'u'] = (char)4; /* strlen("undef") - 1; */ | ||
839 | 831 | ||
840 | /* parse configs */ | 832 | /* parse configs */ |
841 | for(fl = configs; fl; fl = fl->link) { | 833 | for(fl = configs; fl; fl = fl->link) { |