1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
|
/***************************************************************************
* This file is part of KDevelop *
* Copyright 2007 Andreas Pakulat <apaku@gmx.de> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library General Public License as *
* published by the Free Software Foundation; either version 2 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#include "cmakedebugvisitor.h"
#include "astfactory.h"
#include <kdebug.h>
#define WRITEOUT kDebug(9042) << ast->line()
enum RecursivityType { No, Yes, End };
extern RecursivityType recursivity(const QString& functionName);
int CMakeAstDebugVisitor::visit( const CMakeAst * ast )
{
WRITEOUT << "CMAKEAST: (" << "NOT IMPLEMENTED";
return 1;
}
int CMakeAstDebugVisitor::visit( const GetCMakePropertyAst * ast )
{
WRITEOUT << "GETCMAKEPROPERTY: (" << "NOT IMPLEMENTED";
return 1;
}
int CMakeAstDebugVisitor::visit( const SubdirsAst * ast )
{
WRITEOUT << "SUBDIRS: " << "(excludeFromAll, directories, preorder, isDeprecated ) = (" << ast->exluceFromAll() << "," << ast->directories() << "," << ast->preorder() << "," << ast->isDeprecated() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const StringAst * ast )
{
WRITEOUT << "STRING: " << "(cmdType,only,outputVariable,escapeQuotes,regex,type,begin,replace,input,length) = (" << ast->cmdType() << "," << ast->only() << "," << ast->outputVariable() << "," << ast->escapeQuotes() << "," << ast->regex() << "," << ast->type() << "," << ast->begin() << "," << ast->replace() << "," << ast->input() << "," << ast->length() << "," << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const ForeachAst * ast )
{
WRITEOUT << "FOREACH: " << "(loopVar,arguments,range,ranges-start,ranges-stop,ranges-step) = (" << ast->loopVar() << "," << ast->arguments() << "," << ast->type() << "," << ast->ranges().start << "," << ast->ranges().stop << "," << ast->ranges().step << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const ListAst * ast )
{
WRITEOUT << "LIST: " << "(index,list,elements,output,type) = (" << ast->index() << "," << ast->list() << "," << ast->elements() << "," << ast->output() << "," << ast->type() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const OptionAst * ast )
{
WRITEOUT << "OPTION: " << "(description,variableName,defaultValue) = (" << ast->description() << "," << ast->variableName() << "," << ast->defaultValue() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const GetFilenameComponentAst * ast )
{
WRITEOUT << "GETFILENAMECOMPONENT: " << "(fileName,programArts,type,variableName) = (" << ast->fileName() << "," << ast->programArgs() << "," << ast->type() << "," << ast->variableName() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const MacroAst * ast )
{
WRITEOUT << "MACRO: " << "(macroName,knownArgs) = (" << ast->macroName() << "," << ast->knownArgs() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const MathAst * ast )
{
WRITEOUT << "MATH: " << "(outputVariable,expression) = (" << ast->outputVariable() << "," << ast->expression() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const MessageAst * ast )
{
WRITEOUT << "MESSAGE: " << "(message,type) = (" << ast->message() << "," << ast->type() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const FileAst * ast )
{
WRITEOUT << "FILE: " << "(type,variable,directory,path,globbingExpressions,message,directories,followSymlinks) = (" << ast->type() << "," << ast->variable() << "," << ast->directory() << "," << ast->path() << "," << ast->globbingExpressions() << "," << ast->message() << "," << ast->directories() << "," << ast->isFollowingSymlinks() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const IfAst * ast )
{
WRITEOUT << "IF: " << "(kind,condition) = (" << ast->kind() << "," << ast->condition() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const ExecProgramAst * ast )
{
WRITEOUT << "EXECPROGRAM: " << "(executableName,returnValue,outputVariable,arguments,workingDirectory) = (" << ast->executableName() << "," << ast->returnValue() << "," << ast->outputVariable() << "," << ast->arguments() << "," << ast->workingDirectory() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const FindFileAst * ast )
{
WRITEOUT << "FINDFILE: " << "(filenames,noDefaultPath,noSystemEnvironmentPath,noCmakeEnvironmentPath,path,variableName,documentation,pathSuffixes,noCmakePath,noCMakeSystemPath) = (" << ast->filenames() << "," << ast->noDefaultPath() << "," << ast->noSystemEnvironmentPath() << "," << ast->noCmakeEnvironmentPath() << "," << ast->path() << "," << ast->variableName() << "," << ast->documentation() << "," << ast->pathSuffixes() << "," << ast->noCmakePath() << "," << ast->noCmakeSystemPath() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const FindLibraryAst * ast )
{
WRITEOUT << "FINDLIBRARY: " << "(filenames,noDefaultPath,noSystemEnvironmentPath,noCmakeEnvironmentPath,path,variableName,documentation,pathSuffixes,noCmakePath,noCMakeSystemPath) = (" << ast->filenames() << "," << ast->noDefaultPath() << "," << ast->noSystemEnvironmentPath() << "," << ast->noCmakeEnvironmentPath() << "," << ast->path() << "," << ast->variableName() << "," << ast->documentation() << "," << ast->pathSuffixes() << "," << ast->noCmakePath() << "," << ast->noCmakeSystemPath() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const FindPathAst * ast )
{
WRITEOUT << "FINDPATH: " << "(filenames,noDefaultPath,noSystemEnvironmentPath,noCmakeEnvironmentPath,path,variableName,documentation,pathSuffixes,noCmakePath,noCMakeSystemPath) = (" << ast->filenames() << "," << ast->noDefaultPath() << "," << ast->noSystemEnvironmentPath() << "," << ast->noCmakeEnvironmentPath() << "," << ast->path() << "," << ast->variableName() << "," << ast->documentation() << "," << ast->pathSuffixes() << "," << ast->noCmakePath() << "," << ast->noCmakeSystemPath() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const FindProgramAst * ast )
{
WRITEOUT << "FINDPROGRAM: " << "(filenames,noDefaultPath,noSystemEnvironmentPath,noCMakeEnvironmentPath,path,variableName,documentation,pathSuffixes,noCmakePath,noCmakeSystemPath) = (" << ast->filenames() << "," << ast->noDefaultPath() << "," << ast->noSystemEnvironmentPath() << "," << ast->noCmakeEnvironmentPath() << "," << ast->path() << "," << ast->variableName() << "," << ast->documentation() << "," << ast->pathSuffixes() << "," << ast->noCmakePath() << "," << ast->noCmakeSystemPath() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const FindPackageAst * ast )
{
WRITEOUT << "FINDPACKAGE: " << "(noModule,isRequired,version,isQuiet,name) = (" << ast->noModule() << "," << ast->isRequired() << "," << ast->version() << "," << ast->isQuiet() << "," << ast->name() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const MarkAsAdvancedAst * ast )
{
WRITEOUT << "MARKASADVANCED: " << "(isClear,isForce,advancedVars) = (" << ast->isClear() << "," << ast->isForce() << "," << ast->advancedVars() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const MacroCallAst * ast )
{
WRITEOUT << "MACROCALL: " << "(name,arguments) = (" << ast->name() << "," << ast->arguments() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const IncludeDirectoriesAst * ast )
{
WRITEOUT << "INCLUDEDIRECTORIES: " << "(includeDirectories,isSystem,includeType) = (" << ast->includedDirectories() << "," << ast->isSystem() << "," << ast->includeType() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const ExecuteProcessAst * ast )
{
WRITEOUT << "EXECUTEPROCESS: " << "(errorFile,isOutputQuiet,isOutputStrip,errorVariable,outputFile,outputVariable,inputFile,resultVariable,isErrorQuiet,timeout,workingDirectory,commands) = (" << ast->errorFile() << "," << ast->isOutputQuiet() << "," << ast->isOutputStrip() << "," << ast->errorVariable() << "," << ast->outputFile() << "," << ast->outputVariable() << "," << ast->inputFile() << "," << ast->resultVariable() << "," << ast->isErrorQuiet() << "," << ast->timeout() << "," << ast->workingDirectory() << "," << ast->commands() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const ProjectAst * ast )
{
WRITEOUT << "PROJECT: " << "(projectname,isCpp,isC,isJava) = (" << ast->projectName() << "," << ast->useCpp() << "," << "," << ast->useC() << "," << "," << ast->useJava() << "," << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const SetAst * ast )
{
WRITEOUT << "SET: " << "(entryType,forceStoring,storeInCache,documentation,values,variableName) = (" << ast->entryType() << "," << ast->forceStoring() << "," << ast->storeInCache() << "," << ast->documentation() << "," << ast->values() << "," << ast->variableName() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const IncludeAst * ast )
{
WRITEOUT << "INCLUDE: " << "(optional,resultVariable,includeFile) = (" << ast->optional() << "," << ast->resultVariable() << "," << ast->includeFile() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const ConfigureFileAst * ast )
{
WRITEOUT << "CONFIGUREFILE: " << "(outputFile,escapeQuotes,copyOnly,immediate,atsOnly,inputFile) = (" << ast->outputFile() << "," << ast->escapeQuotes() << "," << ast->copyOnly() << "," << ast->immediate() << "," << ast->atsOnly() << "," << ast->inputFile() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const CMakeMinimumRequiredAst * ast )
{
WRITEOUT << "CMAKEMINIMUMREQUIRED: " << "(wrongVersionIsFatal,version) = (" << ast->wrongVersionIsFatal() << "," << ast->version() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const BuildNameAst * ast )
{
WRITEOUT << "BUILDNAME: " << "(buildName) = (" << ast->buildName() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const BuildCommandAst * ast )
{
WRITEOUT << "BUILDCOMMAND: " << "(makeCommand,variableName) = (" << ast->makeCommand() << "," << ast->variableName() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const AuxSourceDirectoryAst * ast )
{
WRITEOUT << "AUXSOURCEDIRECTORY: " << "(dirName,variableName) = (" << ast->dirName() << "," << ast->variableName() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const AddTestAst * ast )
{
WRITEOUT << "ADDTEST: " << "(testArgs,exeName,testName) = (" << ast->testArgs() << "," << ast->exeName() << "," << ast->testName() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const AddSubdirectoryAst * ast )
{
WRITEOUT << "ADDSUBDIRECTORY: " << "(excludeFromAll,sourcedir,binaryDir) = (" << ast->excludeFromAll() << "," << ast->sourceDir() << "," << ast->binaryDir() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const AddLibraryAst * ast )
{
WRITEOUT << "ADDLIBRARY: " << "(type,excludeFromAll,libraryName,sourceLists) = (" << ast->type() << "," << ast->excludeFromAll() << "," << ast->libraryName() << "," << ast->sourceLists() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const AddExecutableAst * ast )
{
WRITEOUT << "ADDEXECUTABLE: " << "(executable,isOSXBundle,excludeFromAll,isWin32,sourceLists) = (" << ast->executable() << "," << ast->isOsXBundle() << "," << ast->excludeFromAll() << "," << ast->isWin32() << "," << ast->sourceLists() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const AddDependenciesAst * ast )
{
WRITEOUT << "ADDDEPENDECIES: " << "(dependecies,target) = (" << ast->dependencies() << "," << ast->target() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const AddDefinitionsAst * ast )
{
WRITEOUT << "ADDEFINITIONS: " << "(definitions) = (" << ast->definitions() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const CustomTargetAst * ast )
{
WRITEOUT << "CUSTOMTARGET: " << "(target,workingDir,commandArgs,comment,dependecies,buildAlways,isVerbatim) = (" << ast->target() << "," << "," << ast->workingDir() << "," << "," << ast->commandArgs() << "," << "," << ast->comment() << "," << ast->dependencies() << "," << ast->buildAlways() << "," << ast->isVerbatim() << ")";
return 1;
}
int CMakeAstDebugVisitor::visit( const CustomCommandAst * ast )
{
WRITEOUT << "CUSTOMCOMMAND: " << "(otherDependecies,outputs,targetName,workingDirectory,commands,comment,isForTarget,buildStage,mainDependecy) = (" << ast->otherDependencies() << "," << "," << ast->outputs() << "," << "," << ast->targetName() << "," << "," << ast->workingDirectory() << "," << "," << ast->commands() << "," << "," << ast->comment() << "," << "," << ast->isForTarget() << "," << "," << ast->buildStage() << "," << "," << ast->mainDependency() << ")";
return 1;
}
CMakeAstDebugVisitor::~CMakeAstDebugVisitor( )
{
}
CMakeAstDebugVisitor::CMakeAstDebugVisitor( )
{
}
int CMakeAstDebugVisitor::walk(const QString& filename, const CMakeFileContent & fc, int line)
{
kDebug(9042) << "-----------------------------------------------------------";
kDebug(9042) << "Walking file:" << filename;
CMakeFileContent::const_iterator it=fc.constBegin()+line, itEnd=fc.constEnd();
for(; it!=itEnd; )
{
Q_ASSERT( line<fc.count() );
Q_ASSERT( line>=0 );
// kDebug(9042) << "@" << line;
// kDebug(9042) << it->writeBack() << "==" << fc[line].writeBack();
Q_ASSERT( *it == fc[line] );
// kDebug(9042) << "At line" << line << "/" << fc.count();
CMakeAst* element = AstFactory::self()->createAst(it->name);
if(!element)
{
element = new MacroCallAst;
}
CMakeFunctionDesc func = *it;
QString funcName=func.name;
bool correct = element->parseFunctionInfo(func);
if(!correct)
{
kDebug(9042) << "error! found an error while processing" << func.writeBack() << "was" << it->writeBack() << endl <<
" at" << func.filePath << ":" << func.line << endl;
//FIXME: Should avoid to run
}
RecursivityType r = recursivity(funcName);
if(r==End)
{
// kDebug(9042) << "Found an end." << func.writeBack();
delete element;
return line;
}
if(element->isDeprecated())
kDebug(9042) << "Warning: Using the function: " << funcName << " which is deprecated by cmake.";
element->setContent(fc, line);
int lines=element->accept(this);
line+=lines;
it+=lines;
delete element;
}
kDebug(9042) << "Walk stopped @" << line;
kDebug(9042) << "-----------------------------------------------------------";
return line;
}
|