From b0e481a653b01e4329bccb1d101d56e3e878e960 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 3 Jun 2016 16:43:46 +0300 Subject: Port to MinGW --- build2/cxx/compile.cxx | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) (limited to 'build2/cxx/compile.cxx') diff --git a/build2/cxx/compile.cxx b/build2/cxx/compile.cxx index b11a919..e0fabb4 100644 --- a/build2/cxx/compile.cxx +++ b/build2/cxx/compile.cxx @@ -424,8 +424,28 @@ namespace build2 { char c (l[p]); - if (c == '\\') - c = l[++p]; + if (p + 1 != n) + { + if (c == '$') + { + // Got to be another (escaped) '$'. + // + if (l[p + 1] == '$') + ++p; + } + else if (c == '\\') + { + // This may or may not be an escape sequence depending on whether + // what follows is "escapable". + // + switch (c = l[++p]) + { + case '\\': break; + case ' ': break; + default: c = '\\'; --p; // Restore. + } + } + } r += c; } @@ -627,8 +647,14 @@ namespace build2 { args.push_back ("-M"); // Note: -MM -MG skips missing <>-included. args.push_back ("-MG"); // Treat missing headers as generated. + + // Previously we used '*' as a target name but it gets expanded to + // the current directory file names by GCC (4.9) that comes with + // MSYS2 (2.4). Yes, this is the (bizarre) behavior of GCC being + // executed in the shell with -MQ '*' option and not just -MQ *. + // args.push_back ("-MQ"); // Quoted target name. - args.push_back ("*"); // Old versions can't do empty target name. + args.push_back ("^"); // Old versions can't do empty target name. } // We are using absolute source file path in order to get absolute @@ -1051,19 +1077,19 @@ namespace build2 break; } - assert (l[0] == '*' && l[1] == ':' && l[2] == ' '); + assert (l[0] == '^' && l[1] == ':' && l[2] == ' '); first = false; second = true; // While normally we would have the source file on the first // line, if too long, it will be moved to the next line and - // all we will have on this line is "*: \". + // all we will have on this line is "^: \". // if (l.size () == 4 && l[3] == '\\') continue; else - pos = 3; // Skip "*: ". + pos = 3; // Skip "^: ". // Fall through to the 'second' block. } -- cgit v1.1