[Libreoffice] patch for make to help in gbuild debugging
Norbert Thiebaud
nthiebaud at gmail.com
Mon Jun 27 12:02:38 PDT 2011
On Mon, Jun 27, 2011 at 12:37 PM, Norbert Thiebaud <nthiebaud at gmail.com> wrote:
> On Mon, Jun 27, 2011 at 12:26 PM, Norbert Thiebaud <nthiebaud at gmail.com> wrote:
>> On Mon, Jun 27, 2011 at 12:03 PM, Tor Lillqvist <tlillqvist at novell.com> wrote:
>>>> If we do that, we definitely should then also add built-in mkdir and cp
>>>> commands in it,
>>>
>>> Hmm, or actually, I don't think that will be such a great win after all, as the gbuild recipies where tons of mkdir commands are being run typically are in a shell expression with && anyway, so they couldn't be run as "built-in" simple make commands anyway. Forget it.
>>
>> Yeah, but maybe there is something to be investigated to avoid fork
>> when running recipies... I've read somewhere that spawn was much more
>> performant than fork under cywin (note: I don;t know if make already
>> do that or not, nor what are the implication...)
>>
>> Another thing: I think most of these mkdir could be avoided at the
>> cost of another layer of dependencies: create rules for every target
>> so that the parent directory is a pre-req target and have rules for
>> directories to build them... that should put most of the the workload
>> on make itself an limit drastically the number of mkdir...
>
> Another solution is a quick and dirty path to make to have ot try to
> create the base directory of a target before running a recipe for it.
something like
diff -r -u make-3.82/commands.c make-3.82-lo_trace/commands.c
--- make-3.82/commands.c 2010-07-12 20:20:37.000000000 -0500
+++ make-3.82-lo_trace/commands.c 2011-06-27 13:48:40.000000000 -0500
@@ -437,6 +437,45 @@
}
}
^L
+static int _create_dirname(const char* name)
+{
+ char buffer[PATH_MAX + 1];
+ char* cursor;
+
+ if(name == NULL)
+ {
+ return 0;
+ }
+ strncpy(buffer, name, PATH_MAX);
+ buffer[PATH_MAX] = 0;
+ cursor = buffer + strlen(buffer);
+ while(cursor > buffer)
+ {
+ if(*cursor == '/' || *cursor == '\\')
+ {
+ struct stat s;
+ *cursor = 0;
+ if(stat(buffer, &s))
+ {
+ if(errno == ENOENT)
+ {
+ if(_create_dirname(buffer))
+ {
+ return -1;
+ }
+ return mkdir(buffer, 0777);
+ }
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ cursor -= 1;
+ }
+ return -1;
+}
+
/* Execute the commands to remake FILE. If they are currently executing,
return or have already finished executing, just return. Otherwise,
fork off a child process to run the first command line in the sequence. */
@@ -446,6 +485,7 @@
{
const char *p;
+ _create_dirname(file->name);
/* Don't go through all the preparations if
the commands are nothing but whitespace. */
Note: this need hardening on windows to deal with C:\ and //xxx stuf
and possibly with /./ or /../ in the path (I'm not sure they are
possible at that stage of make)
Norbert
More information about the LibreOffice
mailing list