Changeset 534 for trunk/src/gmake/kbuild.c
- Timestamp:
- Sep 19, 2006, 1:16:21 AM (19 years ago)
- File:
-
- 1 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 */
Note:
See TracChangeset
for help on using the changeset viewer.