VirtualBox

Changeset 3278 in kBuild for trunk/src/kmk/kbuild.c


Ignore:
Timestamp:
Jan 4, 2019 5:08:23 PM (6 years ago)
Author:
bird
Message:

kmk,footer-pass2-compiling-targets.kmk: Optimize def_target_source_rule and the associated kb-src-one function. This ditches the .obj aliases, so use .o instead.

File:
1 edited

Legend:

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

    r3251 r3278  
    20072007#endif
    20082008    struct variable *pObj       = kbuild_set_object_name_and_dep_and_dirdep_and_PATH_target_source(pTarget, pSource, pOutBase, pObjSuff, "obj", &pDep, &pDirDep);
    2009     int fInstallOldVars = 0;
     2009    int fInstallOldObjsVar = 0;
    20102010    char *pszDstVar, *pszDst, *pszSrcVar, *pszSrc, *pszVal, *psz;
    20112011    char *pszSavedVarBuf;
     
    21232123    /** @todo Make all these local variables, if someone needs the info later it
    21242124     *        can be recalculated. (Ticket #80.) */
    2125     cch = sizeof("TOOL_") + pTool->value_length + sizeof("_COMPILE_") + pType->value_length + sizeof("_OUTPUT_MAYBE");
     2125    cch = sizeof("TOOL_") + pTool->value_length + sizeof("_COMPILE_") + pType->value_length + sizeof("_USES_KOBJCACHE");
    21262126    if (cch < pTarget->value_length + sizeof("$(_2_OBJS)"))
    21272127        cch = pTarget->value_length + sizeof("$(_2_OBJS)");
     
    21432143    memcpy(pszDst, "_CMDS_", sizeof("_CMDS_"));
    21442144    pVar = kbuild_get_recursive_variable(pszSrcVar);
    2145     do_variable_definition_2(NILF, pszDstVar, pVar->value, pVar->value_length,
    2146                              !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */);
     2145    if (iVer <= 2)
     2146        do_variable_definition_2(NILF, pszDstVar, pVar->value, pVar->value_length,
     2147                                 !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */);
    21472148    do_variable_definition_2(NILF, "kbsrc_cmds", pVar->value, pVar->value_length,
    21482149                             !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */);
     
    21512152    memcpy(pszDst, "_OUTPUT_", sizeof("_OUTPUT_"));
    21522153    pVar = kbuild_get_recursive_variable(pszSrcVar);
    2153     pOutput = do_variable_definition_2(NILF, pszDstVar, pVar->value, pVar->value_length,
    2154                                        !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */);
     2154    if (iVer <= 2)
     2155        pOutput = do_variable_definition_2(NILF, pszDstVar, pVar->value, pVar->value_length,
     2156                                           !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */);
    21552157    pOutput = do_variable_definition_2(NILF, "kbsrc_output", pVar->value, pVar->value_length,
    21562158                                       !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */);
     
    21612163    if (pVar)
    21622164    {
    2163         pOutputMaybe = do_variable_definition_2(NILF, pszDstVar, pVar->value, pVar->value_length,
    2164                                                 !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */);
     2165        if (iVer <= 2)
     2166            pOutputMaybe = do_variable_definition_2(NILF, pszDstVar, pVar->value, pVar->value_length,
     2167                                                    !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */);
    21652168        pOutputMaybe = do_variable_definition_2(NILF, "kbsrc_output_maybe", pVar->value, pVar->value_length,
    21662169                                                !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */);
     
    21682171    else
    21692172    {
    2170         pOutputMaybe = do_variable_definition_2(NILF, pszDstVar, "", 0, 1, 0, o_local, f_simple, 0 /* !target_var */);
     2173        if (iVer <= 2)
     2174            pOutputMaybe = do_variable_definition_2(NILF, pszDstVar, "", 0, 1, 0, o_local, f_simple, 0 /* !target_var */);
    21712175        pOutputMaybe = do_variable_definition_2(NILF, "kbsrc_output_maybe", "", 0, 1, 0, o_local, f_simple, 0 /* !target_var */);
    21722176    }
     
    21812185    *psz++ = ' ';
    21822186    memcpy(psz, pSource->value, pSource->value_length + 1);
    2183     do_variable_definition_2(NILF, pszDstVar, pszVal, pVar->value_length + 1 + pDeps->value_length + 1 + pSource->value_length,
    2184                              !pVar->recursive && !pDeps->recursive && !pSource->recursive,
    2185                              NULL, o_local, f_simple, 0 /* !target_var */);
     2187    if (iVer <= 2)
     2188        do_variable_definition_2(NILF, pszDstVar, pszVal, pVar->value_length + 1 + pDeps->value_length + 1 + pSource->value_length,
     2189                                 !pVar->recursive && !pDeps->recursive && !pSource->recursive,
     2190                                 NULL, o_local, f_simple, 0 /* !target_var */);
    21862191    do_variable_definition_2(NILF, "kbsrc_depend", pszVal, pVar->value_length + 1 + pDeps->value_length + 1 + pSource->value_length,
    21872192                             !pVar->recursive && !pDeps->recursive && !pSource->recursive,
     
    21972202    *psz++ = ' ';
    21982203    memcpy(psz, pOrderDeps->value, pOrderDeps->value_length + 1);
    2199     do_variable_definition_2(NILF, pszDstVar, pszVal,
    2200                              pVar->value_length + 1 + pDirDep->value_length + 1 + pOrderDeps->value_length,
    2201                              !pVar->recursive && !pDirDep->recursive && !pOrderDeps->recursive,
    2202                              NULL, o_local, f_simple, 0 /* !target_var */);
     2204    if (iVer <= 2)
     2205        do_variable_definition_2(NILF, pszDstVar, pszVal,
     2206                                 pVar->value_length + 1 + pDirDep->value_length + 1 + pOrderDeps->value_length,
     2207                                 !pVar->recursive && !pDirDep->recursive && !pOrderDeps->recursive,
     2208                                 NULL, o_local, f_simple, 0 /* !target_var */);
    22032209    do_variable_definition_2(NILF, "kbsrc_depord", pszVal,
    22042210                             pVar->value_length + 1 + pDirDep->value_length + 1 + pOrderDeps->value_length,
     
    22192225    memcpy(pszDstVar + pTarget->value_length, "_2_OBJS", sizeof("_2_OBJS"));
    22202226    pVar = kbuild_query_recursive_variable_n(pszDstVar, pTarget->value_length + sizeof("_2_OBJS") - 1);
    2221     fInstallOldVars |= iVer <= 2 && (!pVar || !pVar->value_length);
     2227    fInstallOldObjsVar |= iVer <= 2 && (!pVar || !pVar->value_length);
    22222228    if (pVar)
    22232229    {
     
    22352241
    22362242    /*
    2237      * Install legacy variables.
    2238      */
    2239     if (fInstallOldVars)
     2243     * Install legacy variable.
     2244     */
     2245    if (fInstallOldObjsVar)
    22402246    {
    22412247        /* $(target)_OBJS_ = $($(target)_2_OBJS)*/
     
    22592265    $(eval $(def_target_source_rule))
    22602266    */
    2261     pVar = kbuild_get_recursive_variable("def_target_source_rule");
    2262     pszVal = variable_expand_string_2 (o, pVar->value, pVar->value_length, &psz);
     2267    if (iVer > 2)
     2268    {
     2269        /*ifneq ($(TOOL_$(tool)_COMPILE_$(type)_USES_KOBJCACHE),)*/
     2270        int fUsesObjCache = 0;
     2271        memcpy(pszSrc, "_USES_KOBJCACHE", sizeof("_USES_KOBJCACHE"));
     2272        pVar = lookup_variable(pszSrcVar, pszSrc + sizeof("_USES_KOBJCACHE") - 1 - pszSrcVar);
     2273        if (pVar)
     2274        {
     2275            if (   !pVar->recursive
     2276                || IS_VARIABLE_RECURSIVE_WITHOUT_DOLLAR(pVar))
     2277                fUsesObjCache = pVar->value_length > 0;
     2278            else
     2279            {
     2280                unsigned int cchTmp = 0;
     2281                char *pszTmp = allocated_variable_expand_2(pVar->value, pVar->value_length, &cchTmp);
     2282                free(pszTmp);
     2283                fUsesObjCache = cchTmp > 0;
     2284            }
     2285        }
     2286        if (!fUsesObjCache)
     2287            pVar = kbuild_get_recursive_variable("def_target_source_rule_v3plus");
     2288        else
     2289            pVar = kbuild_get_recursive_variable("def_target_source_rule_v3plus_objcache");
     2290    }
     2291    else
     2292        pVar = kbuild_get_recursive_variable("def_target_source_rule");
     2293    pszVal = variable_expand_string_2(o, pVar->value, pVar->value_length, &psz);
    22632294    assert(!((size_t)pszVal & 3));
    22642295
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette