buildtool.cpp revision c8018fbabc7f87b95c861e702fb44aea6d7f650d
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * Simple build automation tool.
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * Bob Jamison
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * Jasper van de Gronde
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * Johan Engelen
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * Copyright (C) 2006-2008 Bob Jamison
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * This library is free software; you can redistribute it and/or
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * modify it under the terms of the GNU Lesser General Public
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * License as published by the Free Software Foundation; either
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * version 2.1 of the License, or (at your option) any later version.
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * This library is distributed in the hope that it will be useful,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * but WITHOUT ANY WARRANTY; without even the implied warranty of
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * Lesser General Public License for more details.
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * You should have received a copy of the GNU Lesser General Public
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * License along with this library; if not, write to the Free Software
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * To use this file, compile with:
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * g++ -O3 buildtool.cpp -o btool.exe -fopenmp
742a1b08138aef8fc3c19730ae48e5477ee43fc5Johan B. C. Engelen * (or whatever your compiler might be)
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * btool {target}
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * Note: if you are using MinGW, and a not very recent version of it,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * gettimeofday() might be missing. If so, just build this file with
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * this command:
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * g++ -O3 -DNEED_GETTIMEOFDAY buildtool.cpp -o btool.exe -fopenmp
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen#define BUILDTOOL_VERSION "BuildTool v0.9.9multi"
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen//########################################################################
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen//# Definition of gettimeofday() for those who don't have it
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen//########################################################################
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen int tz_minuteswest; /* minutes west of Greenwich */
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelenstatic int gettimeofday (struct timeval *tv, struct timezone *tz)
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen//########################################################################
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen//########################################################################
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen//## R E G E X P
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen//########################################################################
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen//########################################################################
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * This is the T-Rex regular expression library, which we
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * gratefully acknowledge. It's clean code and small size allow
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen * us to embed it in BuildTool without adding a dependency
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen/***************************************************************
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen T-Rex a tiny regular expression library
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen Copyright (C) 2003-2006 Alberto Demichelis
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen This software is provided 'as-is', without any express
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen or implied warranty. In no event will the authors be held
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen liable for any damages arising from the use of this software.
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen Permission is granted to anyone to use this software for
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen any purpose, including commercial applications, and to alter
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen it and redistribute it freely, subject to the following restrictions:
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen 1. The origin of this software must not be misrepresented;
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen you must not claim that you wrote the original software.
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen If you use this software in a product, an acknowledgment
b49365c42b99e3cc135dcde0077aad31d930f6c1Johan B. C. Engelen in the product documentation would be appreciated but
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen is not required.
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen 2. Altered source versions must be plainly marked as such,
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen and must not be misrepresented as being the original software.
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen 3. This notice may not be removed or altered from any
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen source distribution.
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen****************************************************************/
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen#define TRexChar unsigned short
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen#define _TREXC(c) L##c
4fd537e3c7f3fb1b0013f94688e95b0c3ef6649cJohan Engelen#define _TREXC(c) (c)
742a1b08138aef8fc3c19730ae48e5477ee43fc5Johan B. C. Engelentypedef unsigned int TRexBool;
742a1b08138aef8fc3c19730ae48e5477ee43fc5Johan B. C. Engelentypedef struct {
742a1b08138aef8fc3c19730ae48e5477ee43fc5Johan B. C. EngelenTREX_API TRex *trex_compile(const TRexChar *pattern,const TRexChar **error);
742a1b08138aef8fc3c19730ae48e5477ee43fc5Johan B. C. EngelenTREX_API TRexBool trex_match(TRex* exp,const TRexChar* text);
742a1b08138aef8fc3c19730ae48e5477ee43fc5Johan B. C. EngelenTREX_API TRexBool trex_search(TRex* exp,const TRexChar* text, const TRexChar** out_begin, const TRexChar** out_end);
742a1b08138aef8fc3c19730ae48e5477ee43fc5Johan B. C. EngelenTREX_API TRexBool trex_searchrange(TRex* exp,const TRexChar* text_begin,const TRexChar* text_end,const TRexChar** out_begin, const TRexChar** out_end);
742a1b08138aef8fc3c19730ae48e5477ee43fc5Johan B. C. EngelenTREX_API int trex_getsubexpcount(TRex* exp);
742a1b08138aef8fc3c19730ae48e5477ee43fc5Johan B. C. EngelenTREX_API TRexBool trex_getsubexp(TRex* exp, int n, TRexMatch *subexp);
26467da82c920aae52b2c00844c12f9ea236b480Johan B. C. Engelen/* see copyright notice in trex.h */
742a1b08138aef8fc3c19730ae48e5477ee43fc5Johan B. C. Engelen#define _SC(x) L(x)
742a1b08138aef8fc3c19730ae48e5477ee43fc5Johan B. C. Engelen _SC("NONE"),_SC("OP_GREEDY"), _SC("OP_OR"),
742a1b08138aef8fc3c19730ae48e5477ee43fc5Johan B. C. Engelen _SC("OP_EXPR"),_SC("OP_NOCAPEXPR"),_SC("OP_DOT"), _SC("OP_CLASS"),
742a1b08138aef8fc3c19730ae48e5477ee43fc5Johan B. C. Engelen _SC("OP_CCLASS"),_SC("OP_NCLASS"),_SC("OP_RANGE"),_SC("OP_CHAR"),
742a1b08138aef8fc3c19730ae48e5477ee43fc5Johan B. C. Engelen _SC("OP_EOL"),_SC("OP_BOL"),_SC("OP_WB")
742a1b08138aef8fc3c19730ae48e5477ee43fc5Johan B. C. Engelen#define OP_GREEDY (MAX_CHAR+1) // * + ? {n}
742a1b08138aef8fc3c19730ae48e5477ee43fc5Johan B. C. Engelen#define OP_EXPR (MAX_CHAR+3) //parentesis ()
742a1b08138aef8fc3c19730ae48e5477ee43fc5Johan B. C. Engelen#define OP_NOCAPEXPR (MAX_CHAR+4) //parentesis (?:)
742a1b08138aef8fc3c19730ae48e5477ee43fc5Johan B. C. Engelen#define OP_NCLASS (MAX_CHAR+8) //negates class the [^
742a1b08138aef8fc3c19730ae48e5477ee43fc5Johan B. C. Engelen#define TREX_SYMBOL_GREEDY_ONE_OR_MORE ('+')
TRexNode n;
int newid;
return (int)newid;
TRexChar t;
if(!isclass) {
return node;
if(exp->_nodes[first].type == OP_CCLASS) trex_error(exp,_SC("cannot use character classes in ranges"));
chain = r;
int c = first;
chain = c;
int c = first;
chain = c;
return ret;
return ret;
int op;
if(isgreedy) {
if((*exp->_p != TREX_SYMBOL_BRANCH) && (*exp->_p != ')') && (*exp->_p != TREX_SYMBOL_GREEDY_ZERO_OR_MORE) && (*exp->_p != TREX_SYMBOL_GREEDY_ONE_OR_MORE) && (*exp->_p != '\0')) {
return ret;
else ret = e;
return ret;
switch(cclass) {
case OP_RANGE:
case OP_CCLASS:
return TRex_False;
switch(type) {
case OP_GREEDY: {
nmaches++;
good=s;
if(greedystop) {
if(stop) {
return NULL;
case OP_OR: {
return asd;
return asd;
return NULL;
case OP_EXPR:
case OP_NOCAPEXPR:{
return NULL;
return cur;
case OP_WB:
case OP_BOL:
return NULL;
case OP_EOL:
return NULL;
case OP_DOT:{
*str++;
return str;
case OP_NCLASS:
case OP_CLASS:
if(trex_matchclass(exp,&exp->_nodes[node->left],*str)?(type == OP_CLASS?TRex_True:TRex_False):(type == OP_NCLASS?TRex_True:TRex_False)) {
*str++;
return str;
return NULL;
case OP_CCLASS:
*str++;
return str;
return NULL;
*str++;
return str;
return NULL;
#ifdef _DEBUG
int nsize,i;
TRexNode *t;
for(i = 0;i < nsize; i++) {
scprintf(_SC("left %02d right %02d next %02d\n"),exp->_nodes[i].left,exp->_nodes[i].right,exp->_nodes[i].next);
return NULL;
return exp;
if(exp) {
return TRex_False;
return TRex_True;
TRexBool trex_searchrange(TRex* exp,const TRexChar* text_begin,const TRexChar* text_end,const TRexChar** out_begin, const TRexChar** out_end)
if(!cur)
*text_begin++;
return TRex_False;
--text_begin;
return TRex_True;
TRexBool trex_search(TRex* exp,const TRexChar* text, const TRexChar** out_begin, const TRexChar** out_end)
return TRex_True;
typedef unsigned int XMLCh;
class Namespace
virtual ~Namespace()
{ return prefix; }
{ return namespaceURI; }
class Attribute
virtual ~Attribute()
{ return name; }
{ return value; }
class Element
friend class Parser;
Element()
init();
init();
init();
virtual ~Element()
delete children[i];
{ return name; }
{ return value; }
{ return parent; }
{ return children; }
{ return attributes; }
void print();
int getLine()
{ return line; }
void init()
line = 0;
int line;
class Parser
Parser()
{ init(); }
virtual ~Parser()
void init()
keepGoing = true;
parselen = 0;
currentPosition = 0;
int skipwhite(int p);
bool keepGoing;
int parselen;
int currentPosition;
return elem;
return res;
return res;
return res;
if (!child)
for (i=0;i<indent;i++)
for (int i=0;i<indent;i++)
for (int i=0; i<indent; i++)
writeIndentedRecursive(f, 0);
const char *escaped;
char value;
} EntityEntry;
return res;
int count = 0;
count++;
return count;
for (long i=0 ; i<pos ; i++)
col = 0;
line ++;
col++;
int lineNr;
int colNr;
return ch;
return ret;
int p = p0;
while (*text)
return p0;
p++; text++;
while (p<parselen)
if (p2 > p)
p = p2;
while (p<parselen)
if (p2 > p)
p = p2;
if (!isspace(b))
int p = p0;
while (p<parselen)
int p = p0;
return p0;
while ( p<parselen )
bool found = false;
if (p2>p)
p = p2;
found = true;
if (!found)
int p = p0;
return p0;
return p0;
while (p<parselen)
return p0;
//printf("Got version:%s\n",buf.c_str());
int p = p0;
p = skipwhite(p);
return p0;
return p0;
while (p<parselen)
//printf("Got doctype:%s\n",buf.c_str());
int p = p0;
int p2 = p;
p = skipwhite(p);
return p0;
p = skipwhite(p);
//printf("####tag :%s\n", openTagName.c_str());
p = skipwhite(p);
while (p<parselen)
p = skipwhite(p);
p = skipwhite(p);
if (p2==p)
p=p2;
p = skipwhite(p);
p = skipwhite(p);
//printf("name:'%s' value:'%s'\n",attrName.c_str(),attrVal.c_str());
bool cdata = false;
while (p<parselen)
p = p2;
while (p<parselen)
if (p2 > p)
p = p2;
if (p2 > p)
cdata = true;
p = p2;
if (p2 == p)
openTagName.c_str(), p2, p);
return p0;
p = p2;
bool found = false;
if (p2>p)
p = p2;
found = true;
if (!found)
//printf("%d : data:%s\n",p,data.c_str());
p = skipwhite(p);
return p0;
return p0;
p = skipwhite(p);
return p0;
p = skipwhite(p);
return p0;
// printf("close element:%s\n",closeTagName.c_str());
p = skipwhite(p);
return rootNode;
for ( ; i < len ; i++)
delete[] charbuf;
for ( ; i < len ; i++)
delete[] charbuf;
return NULL;
fclose(f);
return NULL;
fclose(f);
delete[] charbuf;
class URI
SCHEME_NONE =0,
} SchemeTypes;
URI()
init();
init();
init();
init();
init();
virtual ~URI()
virtual int getScheme() const;
virtual int getPort() const;
virtual bool isAbsolute() const;
virtual bool isOpaque() const;
virtual void normalize();
void init()
parselen = 0;
port = 0;
absolute = false;
opaque = false;
int scheme;
bool portSpecified;
int port;
bool absolute;
bool opaque;
int peek(int p);
int parseScheme(int p);
int parse(int p);
char *parsebuf;
int parselen;
int ival;
const char *sval;
int port;
} LookupEntry;
{ 0, NULL, 0 }
return str;
return scheme;
return schemeStr;
return ret;
return authority;
return port;
return path;
#ifdef __WIN32__
firstChar++;
return npath;
return absolute;
return opaque;
return query;
return fragment;
return other;
return fragUri;
//## 3 http://www.ietf.org/rfc/rfc2396.txt, section 5.2
return newUri;
bool abs = false;
abs = true;
pos++;
//printf("last segment:%s\n", seg.c_str());
//printf("segment:%s\n", seg.c_str());
pos++;
bool edited = false;
edited = true;
edited = true;
iter++;
if (edited)
if (abs)
if (p<0 || p>=parselen)
return parsebuf[p];
int p = p0;
while (p < parselen)
p++; key++;
return p0;
//# http://www.gbiv.com/protocols/uri/rfc/rfc3986.html#components
int p = p0;
if (p2 > p)
p = p2;
int p = p0;
int ch;
if (p2 > p)
p = p2;
portSpecified = false;
while (p < parselen)
portSpecified = true;
else if (portSpecified)
char *endStr;
absolute = true;
absolute = true;
opaque = true;
while (p < parselen)
int p = p0;
return p0;
while (p < parselen)
int p = p0;
return p0;
while (p < parselen)
int p = p0;
if (p2 < 0)
p = p2;
if (p2 < 0)
p = p2;
if (p2 < 0)
p = p2;
if (p2 < 0)
p = p2;
init();
int p = parse(0);
normalize();
//printf("path:%s\n", path.c_str());
struct StatResult {
int result;
//printf("Stat path: %s\n", f.c_str());
std::pair<statCacheType::iterator, bool> result = statCache.insert(statCacheType::value_type(f, StatResult()));
//printf("Removing from cache: %s\n", f.c_str());
std::pair<dirCacheType::iterator,bool> result = dirCache.insert(dirCacheType::value_type(dirNative, DirListing()));
if (result.second) {
DIR *dir = opendir(dirNative.c_str());
dirNative.c_str(), strerror(errno));
if (s.size() == 0 || s[0] == '.')
if (dirName.size()>0)
//trace("directory: %s", childName.c_str());
error("unknown file:%s", childName.c_str());
class FileSet
FileSet()
virtual ~FileSet()
{ return directory; }
{ return files; }
{ return includes; }
{ return excludes; }
void clear()
class FileList
FileList()
virtual ~FileList()
{ return directory; }
{ return files; }
void clear()
class MakeBase
MakeBase()
{ line = 0; }
virtual ~MakeBase()
{ return uri; }
int getLine()
{ return line; }
return String();
return sval;
static int numThreads;
* ${env.JAVA_HOME}
{ return properties; }
int query,
int line;
init();
virtual ~PkgConfig()
{ return name; }
{ return path; }
{ return prefix; }
{ return description; }
{ return cflags; }
{ return libs; }
return ret;
{ return version; }
virtual int getMajorVersion()
{ return majorVersion; }
virtual int getMinorVersion()
{ return minorVersion; }
virtual int getMicroVersion()
{ return microVersion; }
{ return attrs; }
{ return requireList; }
void init()
majorVersion = 0;
minorVersion = 0;
microVersion = 0;
bool parseRequires();
void parseVersion();
void dumpAttrs();
int majorVersion;
int minorVersion;
int microVersion;
char *parsebuf;
int parselen;
if (!ret)
* elements/attributes. Safe from changes in format.
if (!ret)
if (!elem)
const char *fieldNames[] =
fclose(f);
return ret;
if (!expr)
if (!terror)
bool ret = true;
ret = true;
ret = false;
return ret;
pos++;
//trace("suffix:%s", res.c_str());
return res;
for (p=del ; *p ; p++)
if (*p == ch)
return res;
for (int i = 0 ; i<len ; i++)
char ch = s[i];
for ( ; i<len ; i++)
ch = s[i];
return stripped;
for (int i = 0 ; i<len ; )
char ch;
while (i<len)
ch = s[i];
while (i<len)
ch = s[i];
return out;
return res;
if (s.size()==0)
return ret;
#ifdef __WIN32__
firstChar++;
return npath;
return path;
#ifdef __WIN32__
#include <tchar.h>
NULL,
dw,
0, NULL );
if(p != NULL)
return ret;
#ifdef __WIN32__
// command.c_str());
read buffer in command.com and cmd.exe are just too small
bool ret = true;
if (!paramBuf)
delete[] paramBuf;
delete[] paramBuf;
delete[] paramBuf;
ret = false;
delete[] paramBuf;
bool lastLoop = false;
if (avail > 0)
bytesRead = 0;
if (bytesRead > 0)
for (unsigned int i=0 ; i<bytesRead ; i++)
if (avail > 0)
bytesRead = 0;
if (bytesRead > 0)
for (unsigned int i=0 ; i<bytesRead ; i++)
if (lastLoop)
lastLoop = true;
//trace("outbuf:%s", outbuf.c_str());
if (exitCode != 0)
ret = false;
return ret;
if (pid < 0)
bool outOpen = true;
bool errOpen = true;
char ch;
if (outOpen)
if (errOpen)
if (ret < 0)
{ outOpen = false; }
else if (ch <= 0)
{ errOpen = false; }
else if (ch <= 0)
int childReturnValue;
if (childReturnValue != 0)
if (!de)
//trace("directory: %s", childName.c_str());
if (!dir)
if (!de)
//trace("directory: %s", childName.c_str());
//trace("INCLUDED:%s", s.c_str());
bool skipme = false;
//trace("EXCLUDED:%s", s.c_str());
skipme = true;
if (!skipme)
int query,
if (query == 0)
if (!envstr)
for (int i=0 ; i<len ; i++)
char ch = s[i];
for ( ; j<len ; j++)
ch = s[j];
s.c_str());
if (s.size()==0)
return defaultVal;
return ret;
return defaultVal;
if (s.size()==0)
return defaultVal;
return defaultVal;
if (s.size()==0) {
return defaultVal;
return val;
if (ret)
return ret;
if (ret)
return ret;
//trace("EXCLUDE: %s", fname.c_str());
//trace("INCLUDE: %s", fname.c_str());
if (dir.size() > 0)
for (std::size_t i=0 ; i<result.size() ; i++)
//trace("## createDirectory: %s", dirname.c_str());
#ifdef __WIN32__
cnative);
#ifdef __WIN32__
if (!dir)
if (!de)
//trace("DEL dir: %s", childName.c_str());
//trace("DEL file: %s", childName.c_str());
#ifndef __WIN32__
if (!srcf)
if (!destf)
if (ch<0)
#ifdef WIN32
if (ch < 0)
pos++;
return pos;
if (ch < 0)
pos++;
return pos;
int pos = 0;
//trace("val %s", val.c_str());
if (ends == s)
return val;
pos++;
pos++;
int pos = 0;
pos++;
pos++;
if (ch < 0)
pos++;
//trace("prefix override:%s", prefix.c_str());
//trace("subVal:%s", subVal.c_str());
pos++;
// attrName.c_str(), attrVal.c_str());
init();
int lineNr = 0;
lineNr++;
parseVersion();
//trace("### PkgConfig attributes for %s", fileName.c_str());
if (ch < 0)
fclose(f);
//trace("####### File:\n%s", buf.c_str());
class FileRec
} FileType;
FileRec()
~FileRec()
int type;
void init()
class DepRec
DepRec()
{init();}
~DepRec()
void init()
DepTool()
{ init(); }
~DepTool()
virtual void init();
{ return sourceDir; }
virtual bool createFileList();
virtual bool generateDependencies();
bool forceRefresh);
int depFileSize;
char *depFileBuf;
pos++;
//trace("parsename:%s %s %s", path.c_str(),
// basename.c_str(), suffix.c_str());
//trace("## FileName:%s", fileName.c_str());
if (ch < 0)
pos++;
return pos;
if (ch < 0)
pos++;
return pos;
while (*key)
//# in allFiles, like "myinc.h"
//trace("local: '%s'", iname.c_str());
//trace("Normalized %s to %s", dfname.c_str(), fullPath.c_str());
//trace("other: '%s'", iname.c_str());
while (!feof(f))
fclose(f);
int pos = 0;
pos++;
pos++;
pos++;
pos++;
//trace("file '%s' already seen", fname.c_str());
//trace("ofile:%s", fname.c_str());
if (!createFileList())
if (!generateDependencies())
fclose(f);
if (!root)
//error("Could not open %s for reading", depFile.c_str());
return result;
delete root;
return result;
return result;
//trace("object:%s", objName.c_str());
return result;
//trace(" dep:%s", depName.c_str());
bool inserted = false;
inserted = true;
if (!inserted)
delete root;
return result;
bool forceRefresh)
if (forceRefresh)
return result;
class Target;
class Make;
} TaskType;
{ init(); }
virtual ~Task()
{ return parent; }
virtual int getType()
{ return type; }
{ return name; }
virtual bool execute()
void init()
return str;
int type;
virtual ~TaskCC()
virtual bool execute()
refreshCache = true;
// First create all directories, fails if done in OpenMP parallel loop below... goes superfast anyway, so don't optimize
fclose(f);
bool errorOccurred = false;
#ifdef _OPENMP
bool compileMe = false;
// destFullName.c_str(), srcFullName.c_str());
compileMe = true;
// destFullName.c_str(), depFullName.c_str());
if (depRequires)
compileMe = true;
if (!compileMe)
int col = 0;
col = 0;
col++;
col = 0;
fflush(f);
if (!ret) {
errorOccurred = true;
fclose(f);
return !errorOccurred;
String s;
} CopyType;
haveFileSet = false;
virtual ~TaskCopy()
virtual bool execute()
switch (cptype)
case CP_TOFILE:
if (verbose)
case CP_TODIR:
if (haveFileSet)
int nrFiles = 0;
//trace("fileName:%s", fileName.c_str());
if (verbose)
if (verbose)
nrFiles++;
if (verbose)
haveFileSet = false;
haveFileSet = true;
int cptype;
bool haveFileSet;
virtual ~TaskCxxTestPart()
virtual bool execute()
unsigned int newFiles = 0;
if (newFiles>0) {
virtual ~TaskCxxTestRoot()
virtual bool execute()
unsigned int newFiles = 0;
if (newFiles>0) {
virtual ~TaskCxxTestRun()
virtual bool execute()
unsigned int newFiles = 0;
// Note that the log file names are based on the exact name used to call cxxtests (it uses argv[0] + ".log"/".xml")
unsigned int workingDirDepth = 0;
bool wasSlash = true;
if (newFiles>0) {
} DeleteType;
virtual ~TaskDelete()
virtual bool execute()
switch (delType)
case DEL_FILE:
//error("Could not delete file '%s'", fullName.c_str());
case DEL_DIR:
//error("Could not delete directory '%s'", fullDir.c_str());
int delType;
virtual ~TaskEcho()
virtual bool execute()
virtual ~TaskJar()
virtual bool execute()
if (!ret)
virtual ~TaskJavac()
virtual bool execute()
int count = 0;
//trace("fullsrc:%s fulldest:%s", fullSrc.c_str(), fullDest.c_str());
count++;
fclose(f);
if (!count)
if (!ret)
virtual ~TaskLink()
virtual bool execute()
//trace("%d files in %s", fileSet.size(), fileSetDir.c_str());
bool doit = false;
//trace("link: tgt:%s obj:%s", fullTarget.c_str(),
// fullObj.c_str());
doit = true;
if (!doit)
//trace("LINK cmd:%s", cmd.c_str());
if (doStrip)
virtual ~TaskMakeFile()
virtual bool execute()
//trace("fullName:%s", fullName.c_str());
fclose(f);
//trace("dirname:%s", dirName.c_str());
virtual ~TaskMkDir()
virtual bool execute()
//trace("fullDir:%s", fullDir.c_str());
virtual ~TaskMsgFmt()
virtual bool execute()
//trace("msgfmt: %d", fileSet.size());
if (owndir)
//trace("skip %s", fullSource.c_str());
if (pos>0)
} QueryTypes;
virtual ~TaskPkgConfig()
virtual bool execute()
virtual ~TaskRanlib()
virtual bool execute()
//trace("fullDir:%s", fullDir.c_str());
virtual ~TaskRC()
virtual bool execute()
virtual ~TaskSharedLib()
virtual bool execute()
//trace("###########HERE %d", fileSet.size());
bool doit = false;
//trace("ar fullout: %s", fullOut.c_str());
//trace("ar : %s/%s", fullOut.c_str(), fullName.c_str());
doit = true;
if (!doit)
virtual ~TaskStaticLib()
virtual bool execute()
bool doit = false;
//trace("ar fullout: %s", fullOut.c_str());
//trace("###########HERE %s", fileSetDir.c_str());
//trace("ar : %s/%s", fullOut.c_str(), fullName.c_str());
doit = true;
if (!doit)
virtual ~TaskStrip()
virtual bool execute()
//trace("fullDir:%s", fullDir.c_str());
virtual ~TaskTouch()
virtual bool execute()
if (ret != 0)
if (ret != 0)
virtual ~TaskTstamp()
virtual bool execute()
//trace("task:%s", tagName.c_str());
return NULL;
delete task;
return NULL;
return task;
{ init(); }
virtual ~Target()
{ cleanup() ; }
{ return parent; }
{ return name; }
{ return description; }
{ return deps; }
{ return ifVar; }
{ return unlessVar; }
{ return tasks; }
void init()
void cleanup()
Make()
{ init(); }
virtual ~Make()
{ cleanup(); }
{ return targets; }
{ return BUILDTOOL_VERSION; }
virtual bool run();
void init();
void cleanup();
bool execute();
bool parseFile();
delete allTasks[i];
delete allTasks[i];
return res;
int p = pos;
while (p < len)
int linenr = 0;
while (!feof(f))
linenr++;
s = trim(s);
if (len == 0)
if (p2 <= p)
fclose(f);
if (!isspace(s[p]))
for ( ; p<len ; p++)
if (!isspace(s[p]))
fileName.c_str(), linenr);
if (p>=len)
fclose(f);
setLine(0);
if (!root)
delete root;
if (s.size() > 0)
projectName = s;
if (s.size() > 0)
defaultTarget = s;
if (s.size() > 0)
baseDir = s;
if (!task)
delete root;
if (!parseFile())
if (!execute())
* Get a formatted MM:SS.sss time elapsed string
static String
return ret;
if (!run())
for (i=0 ; i<len ; i++)
char ch = s[i];
for ( ; i<len ; i++)
char ch = s[i];
if (res.size() == 0)
bool ret = make.executeCommand("gcc xx.cpp", "", out, err);