VirtualBox

Changeset 3134 in kBuild for trunk/src


Ignore:
Timestamp:
Mar 1, 2018 6:42:56 PM (7 years ago)
Author:
bird
Message:

kmk_append: Extended it with an -i parameter that enables looking for --insert-variable=xxx and --inserv-command=xxx. This allows us to merge the kmk_builtin_append commands at the end of each compilation, which significantly (e.g. 1m4s -> 37s) speeds up builds on windows and its dead slow file system.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/kmkbuiltin/append.c

    r2771 r3134  
    5757            "      the first argument following the file name.\n"
    5858            "  -c  Output the command for specified target(s). [builtin only]\n"
     59            "  -i  look for --insert-command=trg and --insert-variable=var. [builtin only]\n"
    5960            "  -n  Insert a newline between the strings.\n"
    6061            "  -N  Suppress the trailing newline.\n"
     
    8283    int fVariables = 0;
    8384    int fCommands = 0;
     85    int fLookForInserts = 0;
    8486
    8587    g_progname = argv[0];
     
    9294       &&  argv[i][0] == '-'
    9395       &&  argv[i][1] != '\0' /* '-' is a file */
    94        &&  strchr("-cdnNtv", argv[i][1]) /* valid option char */
     96       &&  strchr("-cdinNtv", argv[i][1]) /* valid option char */
    9597       )
    9698    {
     
    123125                        fDefine = 1;
    124126                        break;
     127                    case 'i':
     128                        if (fVariables || fCommands)
     129                        {
     130                            errx(1, fVariables ? "Option '-i' clashes with '-v'." : "Option '-i' clashes with '-c'.");
     131                            return usage(stderr);
     132                        }
     133#ifndef kmk_builtin_append
     134                        fLookForInserts = 1;
     135                        break;
     136#else
     137                        errx(1, "Option '-C' isn't supported in external mode.");
     138                        return usage(stderr);
     139#endif
    125140                    case 'n':
    126141                        fNewline = 1;
     
    228243            }
    229244        }
     245        else if (fLookForInserts && strncmp(psz, "--insert-command=", 17) == 0)
     246        {
     247            char *pszOldBuf;
     248            unsigned cchOldBuf;
     249            char *pchEnd;
     250
     251            install_variable_buffer(&pszOldBuf, &cchOldBuf);
     252
     253            psz += 17;
     254            pchEnd = func_commands(variable_buffer, (char **)&psz, "commands");
     255            fwrite(variable_buffer, 1, pchEnd - variable_buffer, pFile);
     256
     257            restore_variable_buffer(pszOldBuf, cchOldBuf);
     258        }
     259        else if (fLookForInserts && strncmp(psz, "--insert-variable=", 18) == 0)
     260        {
     261            struct variable *pVar = lookup_variable(psz + 18, cch);
     262            if (!pVar)
     263                continue;
     264            if (   !pVar->recursive
     265                || IS_VARIABLE_RECURSIVE_WITHOUT_DOLLAR(pVar))
     266                fwrite(pVar->value, 1, pVar->value_length, pFile);
     267            else
     268            {
     269                char *pszExpanded = allocated_variable_expand(pVar->value);
     270                fwrite(pszExpanded, 1, strlen(pszExpanded), pFile);
     271                free(pszExpanded);
     272            }
     273        }
    230274        else
    231275#endif
Note: See TracChangeset for help on using the changeset viewer.

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