forked from qt-creator/qt-creator
C++: Clean up dev tools.
* Add -h and -help options describing the tools and their usage.
* Make the tools compile and run on Windows (MinGW, MSVC).
* Rename project dirs, executables and main source files to more
meaningful names:
- Use same base name for project dir, *.pro file, main source file
and (if applicable) script file.
- Use the prefix "cplusplus-".
- The names are now:
- gen-cpp-ast/generate-ast --> cplusplus-update-frontend
- mkvisitor --> cplusplus-mkvisitor
- cplusplus-dump/cplusplus0 --> cplusplus-ast2png
* Get rid of 'c++' shell scripts.
* Get rid of duplicates of 'conf.c++'. Rename to 'pp-configuration.inc'.
* Introduce src/tools/cplusplus-tools-utils containing common stuff
that is used at least in two tools. 'pp-configuration.inc' can also be
found here.
* cplusplus-update-frontend:
- Print file paths of written files to stdout.
- Convenience: Use default values referencing the appropriate dirs and
files.
* cplusplus-mkvisitor:
- Take only one argument, namely the path to AST.h.
- Convenience: Use default path to AST.h.
* cplusplus-ast2png:
- Make it run without LD_LIBRARY_PATH.
- As the name suggests, generate image files in png format (needs
'dot' from graphviz).
- Convenience: Read from stdin, which useful for small snippets.
Change-Id: I79c4061fce4a1571c0588dfedd50d4a70715d9df
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh
|
||||
me=$(dirname $0)
|
||||
${CPP-gcc} -U__BLOCKS__ -xc++ -E -include $me/conf.c++ $* > $me/file.i
|
||||
$me/cplusplus0 $me/file.i
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
#define __extension__
|
||||
#define __context__
|
||||
#define __range__
|
||||
#define __asm(a...)
|
||||
#define __asm__(a...)
|
||||
#define restrict
|
||||
#define __restrict
|
||||
#define __restrict__
|
||||
// #define __weak
|
||||
#define __builtin_va_arg(a,b) ((b)0)
|
||||
#define __stdcall
|
||||
#define __fastcall
|
||||
#define __imag__
|
||||
#define __real__
|
||||
#define __complex__
|
||||
@@ -40,6 +40,8 @@
|
||||
#include <CoreTypes.h>
|
||||
#include <CppDocument.h>
|
||||
|
||||
#include "cplusplus-tools-utils.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QList>
|
||||
#include <QCoreApplication>
|
||||
@@ -54,18 +56,47 @@
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
void printUsage()
|
||||
{
|
||||
std::cout << "Usage: " << qPrintable(QFileInfo(qApp->arguments().at(0)).fileName())
|
||||
<< " [-v] <file1> <file2> ...\n\n"
|
||||
<< "Run the parser with the given files.\n";
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
QStringList args = app.arguments();
|
||||
args.removeFirst();
|
||||
|
||||
QStringList files = app.arguments();
|
||||
files.removeFirst();
|
||||
bool optionVerbose = false;
|
||||
|
||||
// Process options & arguments
|
||||
if (args.contains("-v")) {
|
||||
optionVerbose = true;
|
||||
args.removeOne("-v");
|
||||
}
|
||||
const bool helpRequested = args.contains("-h") || args.contains("-help");
|
||||
if (args.isEmpty() || helpRequested) {
|
||||
printUsage();
|
||||
return helpRequested ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Process files
|
||||
const QStringList files = args;
|
||||
foreach (const QString &fileName, files) {
|
||||
QFile file(fileName);
|
||||
if (! file.open(QFile::ReadOnly))
|
||||
continue;
|
||||
// Run preprocessor
|
||||
const QString fileNamePreprocessed = fileName + QLatin1String(".preprocessed");
|
||||
CplusplusToolsUtils::SystemPreprocessor preprocessor(optionVerbose);
|
||||
preprocessor.preprocessFile(fileName, fileNamePreprocessed);
|
||||
|
||||
// Run parser
|
||||
QFile file(fileNamePreprocessed);
|
||||
if (! file.open(QFile::ReadOnly)) {
|
||||
std::cerr << "Error: Could not open file \"" << qPrintable(file.fileName()) << "\"."
|
||||
<< std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
const QByteArray source = file.readAll();
|
||||
file.close();
|
||||
|
||||
@@ -1,21 +1,13 @@
|
||||
QT = core gui
|
||||
macx:CONFIG -= app_bundle
|
||||
TARGET = cplusplus0
|
||||
win32:CONFIG += console
|
||||
TEMPLATE = app
|
||||
TARGET = cplusplus-frontend
|
||||
DESTDIR = ./
|
||||
|
||||
include(../../../qtcreator.pri)
|
||||
include($$IDE_SOURCE_TREE/src/libs/cplusplus/cplusplus.pri)
|
||||
include($$IDE_SOURCE_TREE/src/libs/languageutils/languageutils.pri)
|
||||
include($$IDE_SOURCE_TREE/src/libs/utils/utils.pri)
|
||||
include($$IDE_SOURCE_TREE/src/libs/cplusplus/cplusplus-lib.pri)
|
||||
include($$IDE_SOURCE_TREE/tests/auto/qttestrpath.pri)
|
||||
include(../../../src/tools/cplusplus-tools-utils/cplusplus-tools-utils.pri)
|
||||
|
||||
# Input
|
||||
SOURCES += main.cpp
|
||||
|
||||
unix {
|
||||
debug:OBJECTS_DIR = $${OUT_PWD}/.obj/debug-shared
|
||||
release:OBJECTS_DIR = $${OUT_PWD}/.obj/release-shared
|
||||
|
||||
debug:MOC_DIR = $${OUT_PWD}/.moc/debug-shared
|
||||
release:MOC_DIR = $${OUT_PWD}/.moc/release-shared
|
||||
|
||||
RCC_DIR = $${OUT_PWD}/.rcc/
|
||||
UI_DIR = $${OUT_PWD}/.uic/
|
||||
}
|
||||
SOURCES += cplusplus-frontend.cpp
|
||||
|
||||
Reference in New Issue
Block a user