Changeset 530 in kBuild
- Timestamp:
- Sep 17, 2006 8:38:57 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r529 r530 3 3 2006-09-17: 4 4 - kBuild/gmake: 5 o Added kBuild specific functions for speeding up source processing. 5 6 o Fixed assertion in w32_fixcase when shell doesn't have a full path 6 7 and some other case. -
trunk/kBuild/footer.kmk
r524 r530 27 27 ifndef __footer_kmk__ 28 28 # start-of-file-content 29 30 # 31 # Make sure that the core variables we defined in recursive expansion mode 32 # up in header.kmk get expanded before we really start using them. The kBuild 33 # functions added to kmk to speed stuff up assumes that the variables are 34 # expanded here. 35 # 36 PATH_OBJ := $(PATH_OBJ) 37 PATH_TARGET := $(PATH_TARGET) 38 PATH_INS := $(PATH_INS) 39 PATH_BIN := $(PATH_BIN) 40 PATH_DLL := $(PATH_DLL) 41 PATH_SYS := $(PATH_SYS) 42 PATH_LIB := $(PATH_LIB) 43 PATH_DOC := $(PATH_DOC) 29 44 30 45 # … … 109 124 $($(target)_$(source)_TOOL.$(bld_trg)) \ 110 125 $($(target)_$(source)_TOOL) \ 126 $($(source)_$(type)TOOL.$(bld_trg).$(bld_trg_arch)) \ 127 $($(source)_$(type)TOOL.$(bld_trg)) \ 128 $($(source)_$(type)TOOL) \ 129 $($(source)_TOOL.$(bld_trg).$(bld_trg_arch)) \ 130 $($(source)_TOOL.$(bld_trg)) \ 131 $($(source)_TOOL) \ 111 132 $($(target)_$(type)TOOL.$(bld_trg).$(bld_trg_arch)) \ 112 133 $($(target)_$(type)TOOL.$(bld_trg)) \ … … 115 136 $($(target)_TOOL.$(bld_trg)) \ 116 137 $($(target)_TOOL) \ 117 $($(source)_$(type)TOOL.$(bld_trg).$(bld_trg_arch)) \118 $($(source)_$(type)TOOL.$(bld_trg)) \119 $($(source)_$(type)TOOL) \120 $($(source)_TOOL.$(bld_trg).$(bld_trg_arch)) \121 $($(source)_TOOL.$(bld_trg)) \122 $($(source)_TOOL) \123 138 $($(type)TOOL.$(bld_trg).$(bld_trg_arch)) \ 124 139 $($(type)TOOL.$(bld_trg)) \ … … 480 495 ## wrapper the compile command dependency check. 481 496 ifndef NO_COMPILE_CMDS_DEPS 497 ifdef NEW_KMK 498 _DEP_COMPILE_CMDS = $(comp-vars $(target)_$(source)_CMDS_PREV_,$(target)_$(source)_CMDS_,FORCE) 499 else 482 500 _DEP_COMPILE_CMDS = $(if $(subst $(strip $($(target)_$(source)_CMDS_PREV_)),,$(strip $($(target)_$(source)_CMDS_))),FORCE,) 501 endif 483 502 else 484 503 _DEP_COMPILE_CMDS = … … 577 596 # @param bld_trg_cpu Build target cpu. 578 597 # 579 # @remark I've no clue why I've to $(eval ..) everything in this define. MAKE bug? 580 # @remark I now have a clue. Have to use $$ if not. 581 define def_target_source_c_cpp_asm 598 define def_target_source_c_cpp_asm_old 582 599 #$ (warning dbg: def_target_source_c_cpp_asm: source='$(source)' target='$(target)' type='$(type)') 583 600 … … 937 954 endef 938 955 956 ## Generic macro for processing C, C++ and Assembly sources. 957 # @param $(target) Normalized target name. 958 # @param $(source) Source file name. 959 # @param $(type) Source type. {C,CXX,AS} 960 # @param bld_type Build type. 961 # @param bld_trg Build target. 962 # @param bld_trg_arch Build target arch. 963 # @param bld_trg_cpu Build target cpu. 964 # 965 #$ (warning dbg: def_target_source_c_cpp_asm: source='$(source)' target='$(target)' type='$(type)') 966 def_target_source_c_cpp_asm_new = $(kb-src-one x) 967 968 ifdef NEW_KMK 969 def_target_source_c_cpp_asm_var = def_target_source_c_cpp_asm_new 970 else 971 def_target_source_c_cpp_asm_var = def_target_source_c_cpp_asm_old 972 endif 973 939 974 ## Generic macro for processing all target sources. 940 975 # @param $(target) Normalized target name. … … 944 979 type := C 945 980 $(foreach source, $(filter %.c , $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\ 946 ,$(eval $(value def_target_source_c_cpp_asm)) )981 ,$(eval $(value $(def_target_source_c_cpp_asm_var))) ) 947 982 948 983 # C++ sources 949 984 type := CXX 950 985 $(foreach source, $(filter %.cpp %.cxx %.xx, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\ 951 ,$(eval $(value def_target_source_c_cpp_asm)) )986 ,$(eval $(value $(def_target_source_c_cpp_asm_var))) ) 952 987 953 988 # ASM sources 954 989 type := AS 955 990 $(foreach source, $(filter %.asm %.s %.S , $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\ 956 ,$(eval $(value def_target_source_c_cpp_asm)) )991 ,$(eval $(value $(def_target_source_c_cpp_asm_var))) ) 957 992 958 993 endef -
trunk/src/gmake/Makefile.kmk
r527 r530 21 21 CONFIG_NO_DEFAULT_VARIABLES \ 22 22 CONFIG_WITH_EXTENDED_NOTPARALLEL \ 23 CONFIG_WITH_INCLUDEDEP \ 23 24 CONFIG_WITH_TOUPPER_TOLOWER \ 24 CONFIG_WITH_INCLUDEDEP \ 25 CONFIG_WITH_VALUE_LENGTH \ 26 CONFIG_WITH_COMPARE \ 25 27 KMK \ 26 28 CONFIG_WITH_OPTIMIZATION_HACKS \ 27 VARIABLE_HASH 29 VARIABLE_HASH 28 30 29 31 kmk_SOURCES = \ … … 49 51 version.c \ 50 52 vpath.c \ 51 remote-stub.c 53 remote-stub.c \ 54 kbuild.c 52 55 53 56 kmk_SOURCES.win32 = \ -
trunk/src/gmake/dep.h
r503 r530 82 82 extern struct dep *read_all_makefiles PARAMS ((char **makefiles)); 83 83 extern int eval_buffer PARAMS ((char *buffer)); 84 #ifdef CONFIG_WITH_INCLUDEDEP 85 extern void eval_include_dep PARAMS ((char *name, struct floc *f)); 86 #endif 84 87 extern int update_goal_chain PARAMS ((struct dep *goals)); 85 88 extern void uniquize_deps PARAMS ((struct dep *)); 89 -
trunk/src/gmake/expand.c
r527 r530 522 522 /* Either expand it or copy it, depending. */ 523 523 if (! v->recursive) 524 #ifdef CONFIG_WITH_VALUE_LENGTH 525 return variable_buffer_output (buf, v->value, 526 v->value_length >= 0 ? v->value_length : strlen (v->value)); 527 #else 524 528 return variable_buffer_output (buf, v->value, strlen (v->value)); 525 529 #endif 530 531 #ifdef CONFIG_WITH_VALUE_LENGTH 532 buf = variable_expand_string (buf, v->value, v->value_length >= 0 ? v->value_length : strlen (v->value)); 533 #else 526 534 buf = variable_expand_string (buf, v->value, strlen (v->value)); 535 #endif 527 536 return (buf + strlen (buf)); 528 537 } -
trunk/src/gmake/function.c
r527 r530 17 17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ 18 18 19 #ifdef CONFIG_WITH_OPTIMIZATION_HACKS 20 # include <assert.h> 21 #endif 19 22 #include "make.h" 20 23 #include "filedef.h" … … 32 35 # include "pathstuff.h" 33 36 #endif 34 #include <assert.h> /* bird */ 37 38 #ifdef KMK 39 # include "kbuild.h" 40 #endif 35 41 36 42 … … 265 271 it can't be function and we can skip the hash lookup drop out. */ 266 272 267 #define MAX_FUNCTION_LENGTH 10 /* bird */ 273 #ifdef KMK 274 # define MAX_FUNCTION_LENGTH 12 275 #else 276 # define MAX_FUNCTION_LENGTH 10 277 #endif 268 278 269 279 /* Look up a function by name. */ … … 1411 1421 /* Copy its value into the output buffer without expanding it. */ 1412 1422 if (v) 1423 #ifdef CONFIG_WITH_VALUE_LENGTH 1424 o = variable_buffer_output (o, v->value, 1425 v->value_length >= 0 ? v->value_length : strlen(v->value)); 1426 #else 1413 1427 o = variable_buffer_output (o, v->value, strlen(v->value)); 1428 #endif 1414 1429 1415 1430 return o; … … 2117 2132 } 2118 2133 #endif /* CONFIG_WITH_TOUPPER_TOLOWER */ 2134 2135 #if defined(CONFIG_WITH_VALUE_LENGTH) && defined(CONFIG_WITH_COMPARE) 2136 /* Returns empty string if equal, returns the third arg if not equal. */ 2137 static char * 2138 func_comp_vars (char *o, char **argv, const char *funcname) 2139 { 2140 const char *s1, *e1, *x1, *s2, *e2, *x2; 2141 char *a1 = NULL, *a2 = NULL; 2142 size_t l, l1, l2; 2143 struct variable *var1 = lookup_variable (argv[0], strlen (argv[0])); 2144 struct variable *var2 = lookup_variable (argv[1], strlen (argv[1])); 2145 2146 /* the simple cases */ 2147 if (var1 == var2) 2148 return variable_buffer_output (o, "", 1); /* eq */ 2149 if (!var1 || !var2) 2150 return variable_buffer_output (o, argv[2], strlen(argv[2])); 2151 if (var1->value == var2->value) 2152 return variable_buffer_output (o, "", 1); /* eq */ 2153 if (!var1->recursive && !var2->recursive) 2154 { 2155 if ( var1->value_length == var2->value_length 2156 && !memcmp (var1->value, var2->value, var1->value_length)) 2157 return variable_buffer_output (o, "", 1); /* eq */ 2158 2159 /* ignore trailing and leading blanks */ 2160 s1 = var1->value; 2161 while (isblank ((unsigned char) *s1)) 2162 s1++; 2163 e1 = s1 + var1->value_length; 2164 while (e1 > s1 && isblank ((unsigned char) e1[-1])) 2165 e1--; 2166 2167 s2 = var2->value; 2168 while (isblank ((unsigned char) *s2)) 2169 s2++; 2170 e2 = s2 + var2->value_length; 2171 while (e2 > s2 && isblank ((unsigned char) e2[-1])) 2172 e2--; 2173 2174 if (e1 - s1 != e2 - s2) 2175 return variable_buffer_output (o, "", 1); /* eq */ 2176 l_simple_compare: 2177 if (!memcmp (s1, s2, e1 - s1)) 2178 return variable_buffer_output (o, "", 1); /* eq */ 2179 return variable_buffer_output (o, argv[2], strlen(argv[2])); 2180 } 2181 2182 /* ignore trailing and leading blanks */ 2183 s1 = var1->value; 2184 e1 = s1 + var1->value_length; 2185 while (isblank ((unsigned char) *s1)) 2186 s1++; 2187 while (e1 > s1 && isblank ((unsigned char) e1[-1])) 2188 e1--; 2189 2190 s2 = var2->value; 2191 e2 = s2 + var2->value_length; 2192 while (isblank((unsigned char)*s2)) 2193 s2++; 2194 while (e2 > s2 && isblank ((unsigned char) e2[-1])) 2195 e2--; 2196 2197 /* both empty after stripping? */ 2198 if (s1 == e1 && s2 == e2) 2199 return variable_buffer_output (o, "", 1); /* eq */ 2200 2201 /* optimist. */ 2202 if ( e1 - s1 == e2 - s2 2203 && !memcmp(s1, s2, e1 - s1)) 2204 return variable_buffer_output (o, "", 1); /* eq */ 2205 2206 /* compare up to the first '$' or the end. */ 2207 x1 = var1->recursive ? memchr (s1, '$', e1 - s1) : NULL; 2208 x2 = var2->recursive ? memchr (s2, '$', e2 - s2) : NULL; 2209 if (!x1 && !x2) 2210 return variable_buffer_output (o, argv[2], strlen (argv[2])); 2211 2212 l1 = x1 ? x1 - s1 : e1 - s1; 2213 l2 = x2 ? x2 - s2 : e2 - s2; 2214 l = l1 <= l2 ? l1 : l2; 2215 if (l && memcmp (s1, s2, l)) 2216 return variable_buffer_output (o, argv[2], strlen (argv[2])); 2217 2218 /* one or both buffers now require expanding. */ 2219 if (!x1) 2220 s1 += l; 2221 else 2222 { 2223 s1 = a1 = allocated_variable_expand ((char *)s1 + l); 2224 if (!l) 2225 while (isblank ((unsigned char) *s1)) 2226 s1++; 2227 e1 = strchr (s1, '\0'); /*hmm*/ 2228 while (e1 > s1 && isblank ((unsigned char) e1[-1])) 2229 e1--; 2230 } 2231 2232 if (!x2) 2233 s2 += l; 2234 else 2235 { 2236 s2 = a2 = allocated_variable_expand ((char *)s2 + l); 2237 if (!l) 2238 while (isblank ((unsigned char) *s2)) 2239 s2++; 2240 e2 = strchr (s2, '\0'); /*hmm*/ 2241 while (e2 > s2 && isblank ((unsigned char) e2[-1])) 2242 e2--; 2243 } 2244 2245 /* the final compare */ 2246 l = ( e1 - s1 != e2 - s2 2247 || memcmp (s1, s2, e1 - s1)); 2248 if (a1) 2249 free (a1); 2250 if (a2) 2251 free (a2); 2252 if (l) 2253 return variable_buffer_output (o, "", 1); 2254 return variable_buffer_output (o, argv[2], strlen (argv[2])); 2255 } 2256 #endif 2119 2257 2120 2258 /* Lookup table for builtin functions. … … 2179 2317 { STRING_SIZE_TUPLE("tolower"), 0, 1, 1, func_toupper_tolower}, 2180 2318 #endif 2319 #if defined(CONFIG_WITH_VALUE_LENGTH) && defined(CONFIG_WITH_COMPARE) 2320 { STRING_SIZE_TUPLE("comp-vars"), 3, 3, 1, func_comp_vars}, 2321 #endif 2322 #ifdef KMK 2323 { STRING_SIZE_TUPLE("kb-src-tool"), 1, 1, 0, func_kbuild_source_tool}, 2324 { STRING_SIZE_TUPLE("kb-obj-base"), 1, 1, 0, func_kbuild_object_base}, 2325 { STRING_SIZE_TUPLE("kb-obj-suff"), 1, 1, 0, func_kbuild_object_suffix}, 2326 { STRING_SIZE_TUPLE("kb-src-prop"), 3, 3, 0, func_kbuild_source_prop}, 2327 { STRING_SIZE_TUPLE("kb-src-one"), 1, 1, 0, func_kbuild_source_one}, 2328 #endif 2181 2329 }; 2182 2330 -
trunk/src/gmake/main.c
r522 r530 282 282 283 283 struct variable shell_var; 284 285 #ifdef KMK 286 /* Process priority. 287 0 = no change; 288 1 = idle / max nice; 289 2 = below normal / nice 10; 290 3 = normal / nice 0; 291 4 = high / nice -10; 292 4 = realtime / nice -19; */ 293 int process_priority = 0; 294 #endif 284 295 285 296 … … 402 413 { 'p', flag, (char *) &print_data_base_flag, 1, 1, 0, 0, 0, 403 414 "print-data-base" }, 415 #ifdef KMK 416 { CHAR_MAX+5, positive_int, (char *) &process_priority, 1, 1, 0, 0, 0, 417 "priority" }, 418 #endif 404 419 { 'q', flag, (char *) &question_flag, 1, 1, 1, 0, 0, "question" }, 405 420 { 'r', flag, (char *) &no_builtin_rules_flag, 1, 1, 0, 0, 0, … … 667 682 } 668 683 } 684 685 686 #ifdef KMK 687 static void 688 set_make_priority (void) 689 { 690 #ifdef WINDOWS32 691 DWORD dwPriority; 692 switch (process_priority) 693 { 694 case 0: return; 695 case 1: dwPriority = IDLE_PRIORITY_CLASS; break; 696 case 2: dwPriority = BELOW_NORMAL_PRIORITY_CLASS; break; 697 case 3: dwPriority = NORMAL_PRIORITY_CLASS; break; 698 case 4: dwPriority = HIGH_PRIORITY_CLASS; break; 699 case 5: dwPriority = REALTIME_PRIORITY_CLASS; break; 700 default: fatal(NILF, _("invalid priority %d\n"), process_priority); 701 } 702 SetPriorityClass(GetCurrentProcess(), dwPriority); 703 #else /*#elif HAVE_NICE */ 704 int nice = 0; 705 switch (process_priority) 706 { 707 case 0: return; 708 case 1: nice = 19; break; 709 case 2: nice = 10; break; 710 case 3: nice = 0; break; 711 case 4: nice = -10; break; 712 case 5: nice = -19; break; 713 default: fatal(NILF, _("invalid priority %d\n"), process_priority); 714 } 715 nice(nice); 716 #endif 717 } 718 #endif 719 669 720 670 721 #ifdef WINDOWS32 … … 1277 1328 1278 1329 decode_debug_flags (); 1330 1331 #ifdef KMK 1332 set_make_priority (); 1333 #endif 1279 1334 1280 1335 /* Set always_make_flag if -B was given and we've not restarted already. */ -
trunk/src/gmake/read.c
r528 r530 461 461 } 462 462 463 #ifdef CONFIG_WITH_INCLUDEDEP 464 /* no nonsense dependency file including. */ 465 void 466 eval_include_dep(char *name, struct floc *f) 467 { 468 FILE *fp; 469 long max_size; 470 long size; 471 char *buf; 472 unsigned int saved_var_len; 473 char *saved_var_buf; 474 475 /* ignore non-existing dependency files. */ 476 if (!file_exists_p (name)) 477 return; 478 479 /* open it and determin the size. */ 480 errno = 0; 481 fp = fopen (name, "r"); 482 if (!fp) 483 { 484 error (f, "%s: %s", name, strerror (errno)); 485 return; 486 } 487 488 if (fseek (fp, 0, SEEK_END)) 489 fatal (f, "%s: fseek failed - %s", name, strerror (errno)); 490 max_size = ftell (fp); 491 if (max_size < 0) 492 fatal (f, "%s: ftell failed - %s", name, strerror (errno)); 493 if (fseek (fp, 0, SEEK_SET)) 494 fatal (f, "%s: fseek failed - %s", name, strerror (errno)); 495 496 /* ignore empty files. */ 497 if (max_size == 0) 498 { 499 fclose (fp); 500 return; 501 } 502 503 /* allocate a buffer and read the file. \r\n -> \n conversion 504 make this intersting ... */ 505 buf = xmalloc (max_size + 1); 506 size = fread (buf, 1, max_size, fp); /* FIXME: EINTR? incomplete reads? */ 507 if ( size == -1 508 || (ferror (fp) && !feof (fp))) 509 fatal (f, "%s: fread failed - %s", name, strerror (errno)); 510 if (size < max_size / 2) 511 fatal (f, "%s: fread failed - %s", name, strerror (errno)); 512 buf[size] = '\0'; 513 514 /* evaluate the buffer and cleanup. */ 515 install_variable_buffer (&saved_var_buf, &saved_var_len); 516 eval_buffer (buf); 517 restore_variable_buffer (saved_var_buf, saved_var_len); 518 519 free (buf); 520 fclose (fp); 521 } 522 #endif /* CONFIG_WITH_INCLUDEDEP */ 523 463 524 464 525 … … 809 870 does not globbing and doesn't support multiple names. It's 810 871 trying to save time by being dead simple. */ 811 struct conditionals *save;812 struct conditionals new_conditionals;813 872 char *name = p2; 814 873 char *end = strchr(name, '\0'); 815 874 char saved; 816 int r;817 875 818 876 while (end > name && isspace ((unsigned char)end[-1])) 819 877 --end; 878 820 879 saved = *end; /* not sure if this is required... */ 821 880 *end = '\0'; 822 823 if (file_exists_p (name)) 824 { 825 /* Save the state of conditionals and start 826 the included makefile with a clean slate. */ 827 save = install_conditionals (&new_conditionals); 828 829 /* Record the rules that are waiting so they will determine 830 the default goal before those in the included makefile. */ 831 record_waiting_files (); 832 833 /* Read the makefile. */ 834 r = eval_makefile (name, RM_INCLUDED | RM_NO_TILDE | RM_DONTCARE); 835 if (!r) 836 error (fstart, "%s: %s", name, strerror (errno)); 837 838 /* Restore conditional state. */ 839 restore_conditionals (save); 840 } 881 eval_include_dep (name, fstart); 841 882 *end = saved; 883 842 884 goto rule_complete; 843 885 } -
trunk/src/gmake/variable.c
r527 r530 351 351 if ((int) origin >= (int) v->origin) 352 352 { 353 if (v->value != 0) 354 free (v->value); 353 #ifdef CONFIG_WITH_VALUE_LENGTH 354 v->value_length = strlen (value); 355 v->value = xrealloc (v->value, v->value_length + 1); 356 bcopy (value, v->value, v->value_length + 1); 357 #else 358 if (v->value != 0) 359 free (v->value); 355 360 v->value = xstrdup (value); 361 #endif 356 362 if (flocp != 0) 357 363 v->fileinfo = *flocp; … … 374 380 #endif 375 381 hash_insert_at (&set->table, v, var_slot); 382 #ifdef CONFIG_WITH_VALUE_LENGTH 383 v->value_length = strlen (value); 384 v->value = xmalloc (v->value_length + 1); 385 bcopy (value, v->value, v->value_length + 1); 386 #else 376 387 v->value = xstrdup (value); 388 #endif 377 389 if (flocp != 0) 378 390 v->fileinfo = *flocp; … … 1031 1043 v->origin = o_file; 1032 1044 v->value = xstrdup (default_shell); 1045 #ifdef CONFIG_WITH_VALUE_LENGTH 1046 v->value_length = -1; 1047 #endif 1033 1048 } 1034 1049 #endif … … 1305 1320 val = alloc_value = allocated_variable_expand (val); 1306 1321 1307 oldlen = strlen (v->value); 1322 #ifdef CONFIG_WITH_VALUE_LENGTH 1323 oldlen = v->value_length; 1324 assert(oldlen == strlen (v->value)); 1325 #endif 1308 1326 vallen = strlen (val); 1309 1327 p = (char *) alloca (oldlen + 1 + vallen + 1); … … 1538 1556 p = next_token (p); 1539 1557 v->value = p; 1558 #ifdef CONFIG_WITH_VALUE_LENGTH 1559 v->value_length = -1; 1560 #endif 1540 1561 1541 1562 /* Expand the name, so "$(foo)bar = baz" works. */ -
trunk/src/gmake/variable.h
r526 r530 57 57 int hash2; /* the secondary hash */ 58 58 #endif 59 #ifdef CONFIG_WITH_VALUE_LENGTH 60 int value_length; /* The length of the value, usually unused. */ 61 #endif 59 62 char *value; /* Variable value. */ 60 63 struct floc fileinfo; /* Where the variable was defined. */
Note:
See TracChangeset
for help on using the changeset viewer.