bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GNU enhancement -- $(xargs cmd, list)


From: Reid Madsen
Subject: Re: GNU enhancement -- $(xargs cmd, list)
Date: Mon, 6 Nov 2000 16:05:01 -0600 (CST)

Thanks for your comments...

We've now gone live with the following changes:

    static int xargs_file_count = 0;

    static char *
    func_xargs(o, argv, funcname)
            char *o;
            char **argv;
            const char* funcname;
    {
        char filename[256];
        FILE* fd;
        char* rm_str;
        char* xargs_str;

        sprintf (filename, "/tmp/gnumake.%d.%d.xargs", getpid(), 
xargs_file_count++);
        fd = fopen(filename, "w");
        fprintf(fd, "%s\n", argv[1]);
        fclose(fd);

        xargs_str = o;
        o = reference_variable(o, "XARGS", 5);
        if (o == xargs_str)
          o = variable_buffer_output(o, "xargs", 5);

        o = variable_buffer_output(o, " ", 1);
        o = variable_buffer_output(o, argv[0], strlen(argv[0]));
        o = variable_buffer_output(o, " < ", 3);
        o = variable_buffer_output(o, filename, strlen(filename));
        o = variable_buffer_output(o, "; ", 2);

        rm_str = o;
        o = reference_variable(o, "RM", 2);
        if (o == rm_str)
          o = variable_buffer_output(o, "rm -f", 5);

        o = variable_buffer_output(o, " ", 1);
        o = variable_buffer_output(o, filename, strlen(filename));

        return o;
    }

Note that I changed this to use $(XARGS) and $(RM), and "<" instead of 'cat'.

Initially I tried stuffing in $(XARGS) and $(RM), but found that the function
string is not recursively expanded.  So, I had to expose the
'reference_variable' function in variable.c to get the expansions.

Perhaps you can suggest cleanups to this code.  If so I'll integrate them.

So, you guys up to adding this in the next release?  Or will I always have to
go back and hack it in myself?

Reid


-- 
Reid Madsen                             address@hidden                      
Senior Member, Tech. Staff              (972) 536-3261 (Desk)
I2 Technologies                         (214) 850-9613 (Cellular)
--
Making incrementally (without 'clean') since May 18, 2000.
Long live incremental make!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]