mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 14:45:14 +00:00
Improved QtCreator projects for codegen, include dirs used in codegen.
This commit is contained in:
@@ -52,6 +52,8 @@ Token invalidToken() {
|
||||
return { Type::Invalid, QString(), ConstUtf8String(nullptr, 0), false };
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
BasicTokenizedFile::BasicTokenizedFile(const QString &filepath) : reader_(filepath) {
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user