Changeset 534 in kBuild
- Timestamp:
- Sep 18, 2006 11:16:21 PM (19 years ago)
- Location:
- trunk/src/gmake
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gmake/kbuild.c
r532 r534 30 30 31 31 #include "make.h" 32 #include "filedef.h" 32 33 #include "variable.h" 33 34 #include "dep.h" … … 40 41 #ifndef va_copy 41 42 # define va_copy(dst, src) do {(dst) = (src);} while (0) 42 #endif 43 #endif 43 44 44 45 45 46 /** 46 47 * Gets a variable that must exist. 47 * Will cause a fatal failure if the variable doesn't exist. 48 * 48 * Will cause a fatal failure if the variable doesn't exist. 49 * 49 50 * @returns Pointer to the variable. 50 51 * @param pszName The variable name. … … 55 56 #ifndef NDEBUG 56 57 unsigned i; 57 #endif 58 #endif 58 59 struct variable *pVar = lookup_variable(pszName, strlen(pszName)); 59 60 if (!pVar) … … 66 67 { 67 68 printf("%d != %d %s\n", pVar->value_length, i, pVar->name); 69 # ifdef _MSC_VER 68 70 __asm int 3; 71 # endif 72 assert(0); 69 73 } 70 74 #endif … … 74 78 /** 75 79 * Gets a variable that must exist and can be recursive. 76 * Will cause a fatal failure if the variable doesn't exist. 77 * 80 * Will cause a fatal failure if the variable doesn't exist. 81 * 78 82 * @returns Pointer to the variable. 79 83 * @param pszName The variable name. … … 84 88 #ifndef NDEBUG 85 89 unsigned i; 86 #endif 90 #endif 87 91 struct variable *pVar = lookup_variable(pszName, strlen(pszName)); 88 92 if (!pVar) … … 93 97 { 94 98 printf("%d != %d %s\n", pVar->value_length, i, pVar->name); 99 # ifdef _MSC_VER 95 100 __asm int 3; 101 # endif 102 assert(0); 96 103 } 97 104 #endif … … 103 110 * Looks up a variable. 104 111 * The value_length field is valid upon successful return. 105 * 112 * 106 113 * @returns Pointer to the variable. NULL if not found. 107 114 * @param pszName The variable name. … … 118 125 { 119 126 printf("%d != %d %s\n", pVar->value_length, i, pVar->name); 127 # ifdef _MSC_VER 120 128 __asm int 3; 129 # endif 130 assert(0); 121 131 } 122 132 #endif … … 219 229 */ 220 230 static struct variable * 221 kbuild_get_source_tool(struct variable *pTarget, struct variable *pSource, struct variable *pType, 231 kbuild_get_source_tool(struct variable *pTarget, struct variable *pSource, struct variable *pType, 222 232 struct variable *pBldTrg, struct variable *pBldTrgArch, const char *pszVarName) 223 233 { … … 261 271 *pszEnd = '\0'; 262 272 if (!strchr(pszEnd, '$')) 263 pVar = define_variable_vl(pszVarName, strlen(pszVarName), psz, pszEnd - psz, 273 pVar = define_variable_vl(pszVarName, strlen(pszVarName), psz, pszEnd - psz, 264 274 1 /* duplicate */, o_file, 0 /* !recursive */); 265 275 else … … 276 286 { 277 287 *pszExpEnd = '\0'; 278 pVar = define_variable_vl(pszVarName, strlen(pszVarName), pszExp, 288 pVar = define_variable_vl(pszVarName, strlen(pszVarName), pszExp, 279 289 pszExpEnd - pszExp, 1 /* duplicate */, 280 290 o_file, 0 /* !recursive */); … … 302 312 kbuild_get_variable("type"), 303 313 kbuild_get_variable("bld_trg"), 304 kbuild_get_variable("bld_trg_arch"), 314 kbuild_get_variable("bld_trg_arch"), 305 315 argv[0]); 306 316 if (pVar) 307 317 o = variable_buffer_output(o, pVar->value, pVar->value_length); 308 318 return o; 309 319 310 320 } 311 321 … … 347 357 { 348 358 pszSrc = pSource->value + pPathRoot->value_length; 349 if ( *pszSrc == '/' 359 if ( *pszSrc == '/' 350 360 && !strncmp(pszSrc, pPathSubCur->value, pPathSubCur->value_length)) 351 361 pszSrc += 1 + pPathSubCur->value_length; 352 362 } 353 else 363 else 354 364 pszSrc = pSource->value; 355 365 … … 358 368 if (isalpha(pszSrc[0]) && pszSrc[1] == ':') 359 369 pszSrc += 2; 360 #endif 370 #endif 361 371 while (*pszSrc == '/' 362 372 #ifdef HAVE_DOS_PATHS 363 373 || *pszSrc == '\\' 364 #endif 374 #endif 365 375 ) 366 376 pszSrc++; … … 374 384 || *pszSrcEnd == '/' 375 385 #ifdef HAVE_DOS_PATHS 376 || *pszSrcEnd == '\\' 386 || *pszSrcEnd == '\\' 377 387 || *pszSrcEnd == ':' 378 388 #endif … … 405 415 *psz = '\0'; 406 416 407 /* 417 /* 408 418 * Define the variable in the current set and return it. 409 419 */ 410 return define_variable_vl(pszVarName, strlen(pszVarName), pszResult, cch - 1, 420 return define_variable_vl(pszVarName, strlen(pszVarName), pszResult, cch - 1, 411 421 0 /* use pszResult */, o_file, 0 /* !recursive */); 412 422 } … … 417 427 { 418 428 struct variable *pVar = kbuild_get_object_base(kbuild_lookup_variable("target"), 419 kbuild_lookup_variable("source"), 429 kbuild_lookup_variable("source"), 420 430 argv[0]); 421 431 if (pVar) 422 432 o = variable_buffer_output(o, pVar->value, pVar->value_length); 423 433 return o; 424 434 425 435 } 426 436 … … 444 454 static struct variable * 445 455 kbuild_get_object_suffix(struct variable *pTarget, struct variable *pSource, 446 struct variable *pBldTrg, struct variable *pBldTrgArch, 456 struct variable *pBldTrg, struct variable *pBldTrgArch, 447 457 const char *pszVarName) 448 458 { … … 475 485 *pszEnd = '\0'; 476 486 if (!strchr(pszEnd, '$')) 477 pVar = define_variable_vl(pszVarName, strlen(pszVarName), psz, pszEnd - psz, 487 pVar = define_variable_vl(pszVarName, strlen(pszVarName), psz, pszEnd - psz, 478 488 1 /* duplicate */, o_file, 0 /* !recursive */); 479 489 else … … 490 500 { 491 501 *pszExpEnd = '\0'; 492 pVar = define_variable_vl(pszVarName, strlen(pszVarName), pszExp, 493 pszExpEnd - pszExp, 1 /* duplicate */, 502 pVar = define_variable_vl(pszVarName, strlen(pszVarName), pszExp, 503 pszExpEnd - pszExp, 1 /* duplicate */, 494 504 o_file, 0 /* !recursive */); 495 505 } … … 515 525 kbuild_get_variable("source"), 516 526 kbuild_get_variable("bld_trg"), 517 kbuild_get_variable("bld_trg_arch"), 527 kbuild_get_variable("bld_trg_arch"), 518 528 argv[0]); 519 529 if (pVar) 520 530 o = variable_buffer_output(o, pVar->value, pVar->value_length); 521 531 return o; 522 532 523 533 } 524 534 … … 543 553 /* Fills in the SDK struct (remember to free it). */ 544 554 static void 545 kbuild_get_sdks(struct kbuild_sdks *pSdks, struct variable *pTarget, struct variable *pSource, 555 kbuild_get_sdks(struct kbuild_sdks *pSdks, struct variable *pTarget, struct variable *pSource, 546 556 struct variable *pBldType, struct variable *pBldTrg, struct variable *pBldTrgArch) 547 557 { … … 580 590 pSdks->cTarget = 0; 581 591 sprintf(pszTmp, "$(%s_SDKS) $(%s_SDKS.%s) $(%s_SDKS.%s) $(%s_SDKS.%s.%s)", 582 pTarget->value, pBldType->value, 583 pTarget->value, pBldTrg->value, 584 pTarget->value, pBldTrg->value, 592 pTarget->value, pBldType->value, 593 pTarget->value, pBldTrg->value, 594 pTarget->value, pBldTrg->value, 585 595 pTarget->value, pBldTrgArch->value); 586 596 pszIterator = pSdks->apsz[1] = allocated_variable_expand(pszTmp); … … 593 603 pSdks->cSource = 0; 594 604 sprintf(pszTmp, "$(%s_SDKS) $(%s_SDKS.%s) $(%s_SDKS.%s) $(%s_SDKS.%s.%s)", 595 pSource->value, pBldType->value, 596 pSource->value, pBldTrg->value, 597 pSource->value, pBldTrg->value, 605 pSource->value, pBldType->value, 606 pSource->value, pBldTrg->value, 607 pSource->value, pBldTrg->value, 598 608 pSource->value, pBldTrgArch->value); 599 609 pszIterator = pSdks->apsz[2] = allocated_variable_expand(pszTmp); … … 606 616 pSdks->cTargetSource = 0; 607 617 sprintf(pszTmp, "$(%s_%s_SDKS) $(%s_%s_SDKS.%s) $(%s_%s_SDKS.%s) $(%s_%s_SDKS.%s.%s)", 608 pTarget->value, pSource->value, pBldType->value, 609 pTarget->value, pSource->value, pBldTrg->value, 610 pTarget->value, pSource->value, pBldTrg->value, 618 pTarget->value, pSource->value, pBldType->value, 619 pTarget->value, pSource->value, pBldTrg->value, 620 pTarget->value, pSource->value, pBldTrg->value, 611 621 pTarget->value, pSource->value, pBldTrgArch->value); 612 622 pszIterator = pSdks->apsz[3] = allocated_variable_expand(pszTmp); … … 619 629 return; 620 630 621 /* 622 * Allocate the variable array and create the variables. 631 /* 632 * Allocate the variable array and create the variables. 623 633 */ 624 634 pSdks->pa = (struct variable *)xmalloc(sizeof(pSdks->pa[0]) * i); … … 770 780 */ 771 781 static struct variable * 772 kbuild_collect_source_prop(struct variable *pTarget, struct variable *pSource, 782 kbuild_collect_source_prop(struct variable *pTarget, struct variable *pSource, 773 783 struct variable *pTool, struct kbuild_sdks *pSdks, 774 784 struct variable *pType, struct variable *pBldType, … … 792 802 Prop.value_length = strlen(pszProp); 793 803 794 /* 804 /* 795 805 * Get the variables. 796 806 */ … … 943 953 paVars[iVar++].pVar = kbuild_lookup_variable_fmt("%_%_%.%.%", pTarget, pSource, &Prop, pBldTrg, pBldTrgArch); 944 954 paVars[iVar++].pVar = kbuild_lookup_variable_fmt("%_%_%.%", pTarget, pSource, &Prop, pBldTrgCpu); 945 955 946 956 paVars[iVar++].pVar = kbuild_lookup_variable_fmt("%_%_%%", pTarget, pSource, pType, &Prop); 947 957 paVars[iVar++].pVar = kbuild_lookup_variable_fmt("%_%_%%.%", pTarget, pSource, pType, &Prop, pBldType); … … 960 970 for (iVar = iDirection > 0 ? 0 : cVars - 1; iVar != iVarEnd; iVar += iDirection) 961 971 { 962 paVars[iVar].cchExp = 0; 972 paVars[iVar].cchExp = 0; 963 973 if (!paVars[iVar].pVar) 964 974 continue; … … 1034 1044 kbuild_put_sdks(&Sdks); 1035 1045 return o; 1036 1046 1037 1047 } 1038 1048 … … 1044 1054 */ 1045 1055 static struct variable * 1046 kbuild_set_object_name_and_dep_and_dirdep_and_PATH_target_source(struct variable *pTarget, struct variable *pSource, 1047 struct variable *pOutBase, struct variable *pObjSuff, 1056 kbuild_set_object_name_and_dep_and_dirdep_and_PATH_target_source(struct variable *pTarget, struct variable *pSource, 1057 struct variable *pOutBase, struct variable *pObjSuff, 1048 1058 const char *pszVarName, struct variable **ppDep, 1049 1059 struct variable **ppDirDep) … … 1064 1074 *ppDep = define_variable_vl("dep", 3, pszResult, cch - 1, 1 /*dup*/, o_file, 0 /* !recursive */); 1065 1075 1066 /* 1067 * obj 1076 /* 1077 * obj 1068 1078 */ 1069 1079 *psz = '\0'; 1070 pObj = define_variable_vl(pszVarName, strlen(pszVarName), pszResult, psz - pszResult, 1080 pObj = define_variable_vl(pszVarName, strlen(pszVarName), pszResult, psz - pszResult, 1071 1081 1/* dup */, o_file, 0 /* !recursive */); 1072 1082 1073 /* 1074 * PATH_$(target)_$(source) - this is global! 1083 /* 1084 * PATH_$(target)_$(source) - this is global! 1075 1085 */ 1076 1086 /* calc variable name. */ … … 1099 1109 #ifdef HAVE_DOS_PATHS 1100 1110 || *psz == '\\' 1101 #endif 1111 #endif 1102 1112 ) 1103 1113 { … … 1106 1116 #ifdef HAVE_DOS_PATHS 1107 1117 || psz[-1] == '\\' 1108 #endif 1118 #endif 1109 1119 ) 1110 1120 psz--; … … 1264 1274 memcpy(psz, pVar->value, pVar->value_length); psz += pVar->value_length; 1265 1275 *psz++ = ' '; 1266 memcpy(psz, pOutput->value, pOutput->value_length + 1); 1276 memcpy(psz, pOutput->value, pOutput->value_length + 1); 1267 1277 do_variable_definition(NILF, "_OUT_FILES", pszVal, o_file, f_simple, 0 /* !target_var */); 1268 1278 free(pszVal); 1269 1279 1270 /* 1280 /* 1271 1281 $(target)_OBJS_ += $(obj) 1272 1282 */ -
trunk/src/gmake/main.c
r532 r534 284 284 285 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; 286 /* Process priority. 287 0 = no change; 288 1 = idle / max nice; 289 2 = below normal / nice 10; 290 3 = normal / nice 0; 291 291 4 = high / nice -10; 292 292 4 = realtime / nice -19; */ 293 293 int process_priority = 0; 294 #endif 294 #endif 295 295 296 296 … … 414 414 "print-data-base" }, 415 415 #ifdef KMK 416 { CHAR_MAX+5, positive_int, (char *) &process_priority, 1, 1, 0, 416 { CHAR_MAX+5, positive_int, (char *) &process_priority, 1, 1, 0, 417 417 (char *) &process_priority, (char *) &process_priority, "priority" }, 418 418 #endif … … 515 515 #else /* CONFIG_WITH_EXTENDED_NOTPARALLEL */ 516 516 517 /* Negative if we have seen the `.NOTPARALLEL' target with an 518 empty dependency list. 519 520 Zero if no `.NOTPARALLEL' or no file in the dependency list 521 is being executed. 522 523 Positive when a file in the `.NOTPARALLEL' dependency list 517 /* Negative if we have seen the `.NOTPARALLEL' target with an 518 empty dependency list. 519 520 Zero if no `.NOTPARALLEL' or no file in the dependency list 521 is being executed. 522 523 Positive when a file in the `.NOTPARALLEL' dependency list 524 524 is in progress, the value is the number of notparallel files 525 525 in progress (running or queued for running). … … 689 689 { 690 690 #ifdef WINDOWS32 691 692 693 694 695 696 697 698 699 700 701 702 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 703 #else /*#elif HAVE_NICE */ 704 int nice= 0;705 706 707 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 714 715 nice(nice);716 #endif 704 int nice_level = 0; 705 switch (process_priority) 706 { 707 case 0: return; 708 case 1: nice_level = 19; break; 709 case 2: nice_level = 10; break; 710 case 3: nice_level = 0; break; 711 case 4: nice_level = -10; break; 712 case 5: nice_level = -19; break; 713 default: fatal(NILF, _("invalid priority %d\n"), process_priority); 714 } 715 nice (nice_level); 716 #endif 717 717 } 718 #endif 718 #endif 719 719 720 720 … … 895 895 #ifdef KMK 896 896 /* WORKAROUND: 897 With GNU Make 3.81, this kludge was necessary to get double quotes 898 working correctly again (worked fine with the 3.81beta1 code). 899 beta1 was forcing batch_mode_shell I think, so let's enforce that 897 With GNU Make 3.81, this kludge was necessary to get double quotes 898 working correctly again (worked fine with the 3.81beta1 code). 899 beta1 was forcing batch_mode_shell I think, so let's enforce that 900 900 for the kBuild shell. */ 901 901 if (sh_found && strstr(default_shell, "kmk_ash")) { … … 903 903 batch_mode_shell = 1; 904 904 } else 905 #endif 905 #endif 906 906 /* naive test */ 907 907 if (!unixy_shell && sh_found && … … 1331 1331 #ifdef KMK 1332 1332 set_make_priority (); 1333 #endif 1333 #endif 1334 1334 1335 1335 /* Set always_make_flag if -B was given and we've not restarted already. */ -
trunk/src/gmake/variable.c
r533 r534 109 109 typedef signed int int32_t; 110 110 typedef signed short int int16_t; 111 # endif 111 # endif 112 112 static inline unsigned long variable_hash_2i(register const unsigned char *var, register int length) 113 113 { … … 318 318 define_variable_in_set (const char *name, unsigned int length, 319 319 char *value, unsigned int value_length, int duplicate_value, 320 enum variable_origin origin, int recursive, 320 enum variable_origin origin, int recursive, 321 321 struct variable_set *set, const struct floc *flocp) 322 322 #else 323 323 struct variable * 324 324 define_variable_in_set (const char *name, unsigned int length, 325 char *value, enum variable_origin origin, 326 int recursive, struct variable_set *set, 325 char *value, enum variable_origin origin, 326 int recursive, struct variable_set *set, 327 327 const struct floc *flocp) 328 #endif 328 #endif 329 329 { 330 330 struct variable *v; … … 386 386 free (v->value); 387 387 v->value = xstrdup (value); 388 #endif 388 #endif 389 389 if (flocp != 0) 390 390 v->fileinfo = *flocp; … … 426 426 #else 427 427 v->value = xstrdup (value); 428 #endif 428 #endif 429 429 if (flocp != 0) 430 430 v->fileinfo = *flocp; … … 1086 1086 v->value_length = strlen (v->value); 1087 1087 v->value_alloc_len = v->value_length + 1; 1088 #endif 1088 #endif 1089 1089 } 1090 1090 #endif … … 1274 1274 #ifdef CONFIG_WITH_VALUE_LENGTH 1275 1275 static struct variable * 1276 do_variable_definition_append (const struct floc *flocp, struct variable *v, char *value, 1277 enum Variable_origin origin)1276 do_variable_definition_append (const struct floc *flocp, struct variable *v, char *value, 1277 enum variable_origin origin) 1278 1278 { 1279 1279 if (env_overrides && origin == o_env) … … 1296 1296 v->fileinfo = *flocp; 1297 1297 1298 /* The juicy bits, append the specified value to the variable 1298 /* The juicy bits, append the specified value to the variable 1299 1299 This is a heavily exercied code path in kBuild. */ 1300 1300 if (v->recursive) … … 1322 1322 v->value_length = new_value_len; 1323 1323 } 1324 else 1324 else 1325 1325 { 1326 1326 /* The previous definition of the variable was simple. … … 1351 1351 # ifdef CONFIG_WITH_VALUE_LENGTH 1352 1352 unsigned int value_len = ~0U; 1353 # endif 1353 # endif 1354 1354 1355 1355 /* Calculate the variable's new value in VALUE. */ … … 1543 1543 # ifdef CONFIG_WITH_VALUE_LENGTH 1544 1544 ~0U, 1 /* duplicate_value */, 1545 # endif 1545 # endif 1546 1546 origin, flavor == f_recursive, 1547 1547 (target_var … … 1556 1556 if (alloc_value) 1557 1557 free (alloc_value); 1558 # endif 1558 # endif 1559 1559 } 1560 1560 else … … 1581 1581 if (alloc_value) 1582 1582 free (alloc_value); 1583 #endif 1583 #endif 1584 1584 1585 1585 return v; … … 1681 1681 #ifdef CONFIG_WITH_VALUE_LENGTH 1682 1682 v->value_length = v->value_alloc_len = -1; 1683 #endif 1683 #endif 1684 1684 1685 1685 /* Expand the name, so "$(foo)bar = baz" works. */
Note:
See TracChangeset
for help on using the changeset viewer.