Improved QtCreator projects for codegen, include dirs used in codegen.

This commit is contained in:
John Preston 2016-04-20 15:59:25 +03:00
parent 18d8666312
commit ed3281d0f5
7 changed files with 37 additions and 72 deletions

View File

@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
*/
// Legacy styles
using "Resources/basic_types.style";
using "Resources/basic.style";
using "./basic_types.style";
using "./basic.style";
//using "overview/overview.style";

View File

@ -18,7 +18,7 @@ to link the code of portions of this program with the OpenSSL library.
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
*/
using "Resources/basic_types.style";
using "./basic_types.style";
semibold: "Open Sans Semibold";

View File

@ -52,6 +52,8 @@ Token invalidToken() {
return { Type::Invalid, QString(), ConstUtf8String(nullptr, 0), false };
}
} // namespace
BasicTokenizedFile::BasicTokenizedFile(const QString &filepath) : reader_(filepath) {

View File

@ -44,6 +44,16 @@ constexpr int kErrorIdentifierNotFound = 804;
constexpr int kErrorAlreadyDefined = 805;
constexpr int kErrorBadString = 806;
QString findInputFile(const Options &options) {
for (const auto &dir : options.includePaths) {
QString tryPath = QDir(dir).absolutePath() + '/' + options.inputPath;
if (QFileInfo(tryPath).exists()) {
return tryPath;
}
}
return options.inputPath;
}
QString tokenValue(const BasicToken &token) {
if (token.type == BasicType::String) {
return token.value;
@ -144,7 +154,8 @@ bool validateAlignString(const QString &value) {
} // namespace
ParsedFile::ParsedFile(const Options &options)
: file_(options.inputPath)
: filePath_(findInputFile(options))
, file_(filePath_)
, options_(options) {
}
@ -153,8 +164,8 @@ bool ParsedFile::read() {
return false;
}
auto filepath = QFileInfo(options_.inputPath).absoluteFilePath();
module_ = std::make_unique<structure::Module>(filepath);
auto absolutePath = QFileInfo(filePath_).absoluteFilePath();
module_ = std::make_unique<structure::Module>(absolutePath);
do {
if (auto startToken = file_.getToken(BasicType::Name)) {
if (tokenValue(startToken) == "using") {
@ -739,6 +750,7 @@ BasicToken ParsedFile::assertNextToken(BasicToken::Type type) {
Options ParsedFile::includedOptions(const QString &filepath) {
auto result = options_;
result.inputPath = filepath;
result.includePaths[0] = QFileInfo(filePath_).dir().absolutePath();
return result;
}

View File

@ -107,6 +107,7 @@ private:
// Compose context-dependent full name.
structure::FullName composeFullName(const QString &name);
QString filePath_;
common::BasicTokenizedFile file_;
Options options_;
bool failed_ = false;

View File

@ -304,41 +304,6 @@ namespace {
}
};
bool fileExists(const QString &name, int options = UserPath | SafePath) {
if (options & UserPath) {
if (!_userWorking()) return false;
} else {
if (!_working()) return false;
}
// detect order of read attempts
QString toTry[2];
toTry[0] = ((options & UserPath) ? _userBasePath : _basePath) + name + '0';
if (options & SafePath) {
QFileInfo toTry0(toTry[0]);
if (toTry0.exists()) {
toTry[1] = ((options & UserPath) ? _userBasePath : _basePath) + name + '1';
QFileInfo toTry1(toTry[1]);
if (toTry1.exists()) {
QDateTime mod0 = toTry0.lastModified(), mod1 = toTry1.lastModified();
if (mod0 < mod1) {
qSwap(toTry[0], toTry[1]);
}
} else {
toTry[1] = QString();
}
} else {
toTry[0][toTry[0].size() - 1] = '1';
}
}
for (int32 i = 0; i < 2; ++i) {
QString fname(toTry[i]);
if (fname.isEmpty()) break;
if (QFileInfo(fname).exists()) return true;
}
return false;
}
bool readFile(FileReadDescriptor &result, const QString &name, int options = UserPath | SafePath) {
if (options & UserPath) {
if (!_userWorking()) return false;

View File

@ -5,15 +5,15 @@ CONFIG += plugin static c++11
CONFIG(debug, debug|release) {
DEFINES += _DEBUG
OBJECTS_DIR = ./../DebugIntermediate
MOC_DIR = ./GenFiles/Debug
RCC_DIR = ./GenFiles
MOC_DIR = ./GeneratedFiles/Debug
RCC_DIR = ./GeneratedFiles
DESTDIR = ./../Debug
}
CONFIG(release, debug|release) {
DEFINES += CUSTOM_API_ID
OBJECTS_DIR = ./../ReleaseIntermediate
MOC_DIR = ./GenFiles/Release
RCC_DIR = ./GenFiles
MOC_DIR = ./GeneratedFiles/Release
RCC_DIR = ./GeneratedFiles
DESTDIR = ./../Release
}
@ -29,44 +29,29 @@ linux {
HEADERS += ./SourceFiles/pspecific_linux.h
}
codegen_style.target = ./GeneratedFiles/styles/style_basic_types.h
codegen_style.target = style_target
codegen_style.depends = FORCE
codegen_style.commands = ./../codegen/Debug/codegen_style "-I./../../Telegram/SourceFiles" "-o./GeneratedFiles/styles" "./../../Telegram/Resources/all_files.style" --rebuild
codegen_numbers.target = ./GeneratedFiles/numbers.cpp
codegen_numbers.target = numbers_target
codegen_numbers.depends = ./../../Telegram/Resources/numbers.txt
CONFIG(debug, debug|release) {
codegen_style.commands = cd ../../Telegram && ./../Linux/codegen/Debug/codegen_style "-I./SourceFiles" "-o./GeneratedFiles/styles" "./Resources/all_files.style" --rebuild && cd ../Linux/DebugIntermediate
codegen_numbers.commands = cd ../../Telegram && ./../Linux/codegen/Debug/codegen_numbers "-o./GeneratedFiles" "./Resources/numbers.txt" && cd ../Linux/DebugIntermediate
#codegen_style.commands = cd ../../Telegram && ./../Linux/codegen/Debug/codegen_style "-I./SourceFiles" "-o./../Linux/DebugIntermediate/GeneratedFiles/styles" "./Resources/all_files.style" --rebuild && cd ../Linux/DebugIntermediate
codegen_numbers.commands = cd ../../Telegram && ./../Linux/codegen/Debug/codegen_numbers "-o./../Linux/DebugIntermediate/GeneratedFiles" "./Resources/numbers.txt" && cd ../Linux/DebugIntermediate
}
CONFIG(release, debug|release) {
codegen_style.commands = cd ../../Telegram && ./../Linux/codegen/Debug/codegen_style "-I./SourceFiles" "-o./GeneratedFiles/styles" "./Resources/all_files.style" --rebuild && cd ../Linux/ReleaseIntermediate
codegen_numbers.commands = cd ../../Telegram && ./../Linux/codegen/Debug/codegen_numbers "-o./GeneratedFiles" "./Resources/numbers.txt" && cd ../Linux/ReleaseIntermediate
#codegen_style.commands = cd ../../Telegram && ./../Linux/codegen/Debug/codegen_style "-I./SourceFiles" "-o./../Linux/ReleaseIntermediate/GeneratedFiles/styles" "./Resources/all_files.style" --rebuild && cd ../Linux/ReleaseIntermediate
codegen_numbers.commands = cd ../../Telegram && ./../Linux/codegen/Debug/codegen_numbers "-o./../Linux/ReleaseIntermediate/GeneratedFiles" "./Resources/numbers.txt" && cd ../Linux/ReleaseIntermediate
}
lang_auto_cpp.target = ./GeneratedFiles/lang_auto.cpp
lang_auto_cpp.depends = FORCE
lang_auto_cpp.commands = mkdir -p ./../../Telegram/GeneratedFiles && ./../DebugLang/MetaLang -lang_in ./../../Telegram/Resources/lang.strings -lang_out ./../../Telegram/GeneratedFiles/lang_auto
lang_auto_cpp.depends = ./../../Telegram/Resources/lang.strings
codegen_lang.target = lang_target
codegen_lang.depends = ./../../Telegram/Resources/lang.strings
codegen_lang.commands = mkdir -p ./GeneratedFiles && ./../DebugLang/MetaLang -lang_in ./../../Telegram/Resources/lang.strings -lang_out ./GeneratedFiles/lang_auto
lang_auto_h.target = ./GeneratedFiles/lang_auto.h
lang_auto_h.depends = FORCE
lang_auto_h.commands = mkdir -p ./../../Telegram/GeneratedFiles && ./../DebugLang/MetaLang -lang_in ./../../Telegram/Resources/lang.strings -lang_out ./../../Telegram/GeneratedFiles/lang_auto
lang_auto_h.depends = ./../../Telegram/Resources/lang.strings
QMAKE_EXTRA_TARGETS += codegen_style codegen_numbers codegen_lang
#hook.depends = style_auto_cpp style_auto_h style_classes_h numbers_cpp lang_auto_cpp lang_auto_h
hook.depends = codegen_style codegen_numbers lang_auto_cpp lang_auto_h
CONFIG(debug,debug|release):hook.target = Makefile.Debug
CONFIG(release,debug|release):hook.target = Makefile.Release
#QMAKE_EXTRA_TARGETS += style_auto_cpp style_auto_h style_classes_h numbers_cpp lang_auto_cpp lang_auto_h hook
QMAKE_EXTRA_TARGETS += codegen_style codegen_numbers lang_auto_cpp lang_auto_h hook
#PRE_TARGETDEPS += ./GeneratedFiles/style_auto.cpp ./GeneratedFiles/style_auto.h ./GeneratedFiles/style_classes.h ./GeneratedFiles/numbers.cpp ./GeneratedFiles/lang_auto.h ./GeneratedFiles/lang_auto.cpp
PRE_TARGETDEPS += \
./GeneratedFiles/styles/style_basic_types.h \
./GeneratedFiles/lang_auto.h \
./GeneratedFiles/lang_auto.cpp
PRE_TARGETDEPS += style_target numbers_target lang_target
unix {
linux-g++:QMAKE_TARGET.arch = $$QMAKE_HOST.arch