Changeset 1128 for trunk/src/kmk


Ignore:
Timestamp:
Sep 27, 2007, 12:32:26 AM (18 years ago)
Author:
bird
Message:

OUTPUT_MAYBE support for compilers and assemblers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/kbuild.c

    r1071 r1128  
    417417}
    418418
     419
    419420/**
    420421 * Gets a variable that must exist and can be recursive.
     
    447448}
    448449
     450
     451/**
     452 * Gets a variable that doesn't have to exit, but if it does can be recursive.
     453 *
     454 * @returns Pointer to the variable.
     455 *          NULL if not found.
     456 * @param   pszName     The variable name.
     457 */
     458static struct variable *
     459kbuild_query_recursive_variable(const char *pszName)
     460{
     461#ifndef NDEBUG
     462    unsigned i;
     463#endif
     464    struct variable *pVar = lookup_variable(pszName, strlen(pszName));
     465    if (pVar)
     466    {
     467#ifndef NDEBUG
     468        i = strlen(pVar->value);
     469        if (i != pVar->value_length)
     470        {
     471            printf("%d != %d %s\n", pVar->value_length, i, pVar->name);
     472# ifdef _MSC_VER
     473            __debugbreak();
     474# endif
     475            assert(0);
     476        }
     477#endif
     478    }
     479    return pVar;
     480}
     481
     482
    449483/**
    450484 * Converts the specified variable into a 'simple' one.
     
    466500    return pVar;
    467501}
     502
    468503
    469504/**
     
    498533}
    499534
     535
    500536/**
    501537 * Looks up a variable and applies default a path to all relative paths.
     
    515551}
    516552
     553
    517554/** Same as kbuild_lookup_variable except that a '%s' in the name string
    518  * will be substituted with the values of the variables in the va list.  */
     555 * will be substituted with the values of the variables in the va list. */
    519556static struct variable *
    520557kbuild_lookup_variable_fmt_va(struct variable *pDefPath, const char *pszNameFmt, va_list va)
     
    569606}
    570607
     608
    571609/** Same as kbuild_lookup_variable except that a '%s' in the name string
    572610 * will be substituted with the values of the variables in the ellipsis.  */
     
    581619    return pVar;
    582620}
     621
    583622
    584623/**
     
    654693    return NULL;
    655694}
     695
    656696
    657697/*
     
    693733}
    694734
     735
    695736/* Implements _SOURCE_TOOL. */
    696737char *
     
    708749
    709750}
     751
    710752
    711753/* This has been extended a bit, it's now identical to _SOURCE_TOOL.
     
    737779}
    738780
     781
    739782/*  */
    740783char *
     
    872915}
    873916
     917
    874918/* Implements _OBJECT_BASE. */
    875919char *
     
    900944    unsigned cTargetSource;
    901945};
     946
    902947
    903948/* Fills in the SDK struct (remember to free it). */
     
    10101055}
    10111056
     1057
    10121058/* releases resources allocated in the kbuild_get_sdks. */
    10131059static void
     
    10191065    free(pSdks->pa);
    10201066}
     1067
    10211068
    10221069/* this kind of stuff:
     
    13951442}
    13961443
     1444
    13971445/* get a source property. Doesn't respect the default path. */
    13981446char *
     
    14341482}
    14351483
     1484
    14361485/*
    14371486dep     := $(obj)$(SUFF_DEP)
     
    16211670    $(target)_$(source)_CMDS_   := $(TOOL_$(tool)_COMPILE_$(type)_CMDS)
    16221671    $(target)_$(source)_OUTPUT_ := $(TOOL_$(tool)_COMPILE_$(type)_OUTPUT)
     1672    $(target)_$(source)_OUTPUT_MAYBE_ := $(TOOL_$(tool)_COMPILE_$(type)_OUTPUT_MAYBE)
    16231673    $(target)_$(source)_DEPEND_ := $(TOOL_$(tool)_COMPILE_$(type)_DEPEND) $(deps) $(source)
    16241674    $(target)_$(source)_DEPORD_ := $(TOOL_$(tool)_COMPILE_$(type)_DEPORD) $(dirdep)
    16251675    */
    1626     cch = sizeof("TOOL_") + pTool->value_length + sizeof("_COMPILE_") + pType->value_length + sizeof("_OUTPUT");
     1676    cch = sizeof("TOOL_") + pTool->value_length + sizeof("_COMPILE_") + pType->value_length + sizeof("_OUTPUT_MAYBE");
    16271677    psz = pszSrcVar = alloca(cch);
    16281678    memcpy(psz, "TOOL_", sizeof("TOOL_") - 1);          psz += sizeof("TOOL_") - 1;
     
    16321682    pszSrc = psz;
    16331683
    1634     cch = pTarget->value_length + 1 + pSource->value_length + sizeof("_OUTPUT_");
     1684    cch = pTarget->value_length + 1 + pSource->value_length + sizeof("_OUTPUT_MAYBE_");
    16351685    psz = pszDstVar = alloca(cch);
    16361686    memcpy(psz, pTarget->value, pTarget->value_length); psz += pTarget->value_length;
     
    16481698    pVar = kbuild_get_recursive_variable(pszSrcVar);
    16491699    pOutput = do_variable_definition(NILF, pszDstVar, pVar->value, o_file, f_simple, 0 /* !target_var */);
     1700
     1701    memcpy(pszSrc, "_OUTPUT_MAYBE", sizeof("_OUTPUT_MAYBE"));
     1702    memcpy(pszDst, "_OUTPUT_MAYBE_", sizeof("_OUTPUT_MAYBE_"));
     1703    pVar = kbuild_query_recursive_variable(pszSrcVar);
     1704    pOutput = do_variable_definition(NILF, pszDstVar, pVar ? pVar->value : "", o_file, f_simple, 0 /* !target_var */);
    16501705
    16511706    memcpy(pszSrc, "_DEPEND", sizeof("_DEPEND"));
Note: See TracChangeset for help on using the changeset viewer.