-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compiles ok with QMetaObject installation
- Loading branch information
Showing
33 changed files
with
8,957 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
cmake_minimum_required(VERSION 3.0.0) | ||
project(mcc VERSION 0.1.0 LANGUAGES C CXX) | ||
|
||
set(CMAKE_CXX_STANDARD 20) | ||
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MP>) | ||
|
||
add_executable(mcc main.cpp | ||
collectjson.cpp | ||
generator.cpp | ||
moc.cpp | ||
parser.cpp | ||
preprocessor.cpp) | ||
|
||
target_compile_definitions(${PROJECT_NAME} PUBLIC | ||
QT_USE_QSTRINGBUILDER #for QStringBuilder operator% | ||
UNICODE | ||
) | ||
|
||
find_package(QMetaClass REQUIRED) | ||
target_link_libraries(${PROJECT_NAME} QMetaClass::QMetaClass) | ||
get_target_property(QMetaClass_LIBRARY_DLL QMetaClass::QMetaClass LOCATION) | ||
message(STATUS "Path to the library's DLL file: ${QMetaClass_LIBRARY_DLL}") | ||
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E copy_if_different | ||
${QMetaClass_LIBRARY_DLL} | ||
$<TARGET_FILE_DIR:mcc> | ||
) | ||
|
||
target_include_directories(${PROJECT_NAME} #private header files | ||
PRIVATE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/>" | ||
) | ||
|
||
include(CTest) | ||
enable_testing() | ||
|
||
set(CPACK_PROJECT_NAME ${PROJECT_NAME}) | ||
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) | ||
include(CPack) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# CMake generated Testfile for | ||
# Source directory: D:/github/qtbase-everywhere-src-6.5.1/src/tools/moc | ||
# Build directory: D:/github/qtbase-everywhere-src-6.5.1/src/tools/moc | ||
# | ||
# This file includes the relevant testing commands required for | ||
# testing this directory and lists subdirectories to be tested as well. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
# mcc | ||
Meta Class Compiler, a modified version of Qt's Meta-Object Compiler (moc) | ||
|
||
|
||
|
||
cmake .. -DCMAKE_PREFIX_PATH=D:\testcode\installtest | ||
|
||
cmake --build . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright (C) 2018 Intel Corporation. | ||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 | ||
|
||
#ifndef CBORDEVICE_H | ||
#define CBORDEVICE_H | ||
|
||
#include <memory> | ||
#include <stdio.h> | ||
|
||
#define CBOR_API inline | ||
#define CBOR_PRIVATE_API inline | ||
#define CBOR_NO_PARSER_API 1 | ||
#include <3rdparty/tinycbor/src/cbor.h> | ||
|
||
|
||
class CborDevice | ||
{ | ||
public: | ||
CborDevice(FILE *out) : out(out) {} | ||
|
||
void nextItem(const char *comment = nullptr) | ||
{ | ||
i = 0; | ||
if (comment) | ||
fprintf(out, "\n // %s", comment); | ||
} | ||
|
||
static CborError callback(void *self, const void *ptr, size_t len, CborEncoderAppendType t) | ||
{ | ||
auto that = static_cast<CborDevice *>(self); | ||
auto data = static_cast<const char *>(ptr); | ||
if (t == CborEncoderAppendCborData) { | ||
while (len--) | ||
that->putByte(*data++); | ||
} else { | ||
while (len--) | ||
that->putChar(*data++); | ||
} | ||
return CborNoError; | ||
} | ||
|
||
private: | ||
FILE *out; | ||
int i = 0; | ||
|
||
void putNewline() | ||
{ | ||
if ((i++ % 8) == 0) | ||
fputs("\n ", out); | ||
} | ||
|
||
void putByte(uint8_t c) | ||
{ | ||
putNewline(); | ||
fprintf(out, " 0x%02x, ", c); | ||
} | ||
|
||
void putChar(char c) | ||
{ | ||
putNewline(); | ||
if (uchar(c) < 0x20) | ||
fprintf(out, " '\\x%x',", uint8_t(c)); | ||
else if (uchar(c) >= 0x7f) | ||
fprintf(out, " uchar('\\x%x'),", uint8_t(c)); | ||
else if (c == '\'' || c == '\\') | ||
fprintf(out, " '\\%c',", c); | ||
else | ||
fprintf(out, " '%c', ", c); | ||
} | ||
}; | ||
|
||
#endif // CBORDEVICE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Install script for directory: D:/github/qtbase-everywhere-src-6.5.1/src/tools/moc | ||
|
||
# Set the install prefix | ||
if(NOT DEFINED CMAKE_INSTALL_PREFIX) | ||
set(CMAKE_INSTALL_PREFIX "D:/qtbuild") | ||
endif() | ||
string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") | ||
|
||
# Set the install configuration name. | ||
if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) | ||
if(BUILD_TYPE) | ||
string(REGEX REPLACE "^[^A-Za-z0-9_]+" "" | ||
CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") | ||
else() | ||
set(CMAKE_INSTALL_CONFIG_NAME "Debug") | ||
endif() | ||
message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") | ||
endif() | ||
|
||
# Set the component getting installed. | ||
if(NOT CMAKE_INSTALL_COMPONENT) | ||
if(COMPONENT) | ||
message(STATUS "Install component: \"${COMPONENT}\"") | ||
set(CMAKE_INSTALL_COMPONENT "${COMPONENT}") | ||
else() | ||
set(CMAKE_INSTALL_COMPONENT) | ||
endif() | ||
endif() | ||
|
||
# Is this installation the result of a crosscompile? | ||
if(NOT DEFINED CMAKE_CROSSCOMPILING) | ||
set(CMAKE_CROSSCOMPILING "FALSE") | ||
endif() | ||
|
||
# Set default install directory permissions. | ||
if(NOT DEFINED CMAKE_OBJDUMP) | ||
set(CMAKE_OBJDUMP "CMAKE_OBJDUMP-NOTFOUND") | ||
endif() | ||
|
||
if(CMAKE_INSTALL_COMPONENT STREQUAL "Unspecified" OR NOT CMAKE_INSTALL_COMPONENT) | ||
if(CMAKE_INSTALL_CONFIG_NAME MATCHES "^([Dd][Ee][Bb][Uu][Gg])$") | ||
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" TYPE EXECUTABLE FILES "D:/github/qtbase-everywhere-src-6.5.1/bin/moc.exe") | ||
endif(CMAKE_INSTALL_CONFIG_NAME MATCHES "^([Dd][Ee][Bb][Uu][Gg])$") | ||
endif() | ||
|
||
if(CMAKE_INSTALL_COMPONENT STREQUAL "Unspecified" OR NOT CMAKE_INSTALL_COMPONENT) | ||
if(CMAKE_INSTALL_CONFIG_NAME MATCHES "^([Dd][Ee][Bb][Uu][Gg])$") | ||
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" TYPE FILE OPTIONAL FILES "D:/github/qtbase-everywhere-src-6.5.1/bin/moc.pdb") | ||
endif(CMAKE_INSTALL_CONFIG_NAME MATCHES "^([Dd][Ee][Bb][Uu][Gg])$") | ||
endif() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Copyright (C) 2018 The Qt Company Ltd. | ||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 | ||
|
||
#include <io/qfile.h> | ||
#include <serialization/qjsonarray.h> | ||
#include <serialization/qjsondocument.h> | ||
#include <serialization/qjsonobject.h> | ||
#include <tools/qhashfunctions.h> | ||
#include <text/qstringlist.h> | ||
#include <cstdlib> | ||
|
||
static bool readFromDevice(QIODevice *device, QJsonArray *allMetaObjects) | ||
{ | ||
const QByteArray contents = device->readAll(); | ||
if (contents.isEmpty()) | ||
return true; | ||
|
||
QJsonParseError error {}; | ||
QJsonDocument metaObjects = QJsonDocument::fromJson(contents, &error); | ||
if (error.error != QJsonParseError::NoError) { | ||
fprintf(stderr, "%s at %d\n", error.errorString().toUtf8().constData(), error.offset); | ||
return false; | ||
} | ||
|
||
allMetaObjects->append(metaObjects.object()); | ||
return true; | ||
} | ||
|
||
int collectJson(const QStringList &jsonFiles, const QString &outputFile, bool skipStdIn) | ||
{ | ||
QHashSeed::setDeterministicGlobalSeed(); | ||
|
||
QFile output; | ||
if (outputFile.isEmpty()) { | ||
if (!output.open(stdout, QIODevice::WriteOnly)) { | ||
fprintf(stderr, "Error opening stdout for writing\n"); | ||
return EXIT_FAILURE; | ||
} | ||
} else { | ||
output.setFileName(outputFile); | ||
if (!output.open(QIODevice::WriteOnly)) { | ||
fprintf(stderr, "Error opening %s for writing\n", qPrintable(outputFile)); | ||
return EXIT_FAILURE; | ||
} | ||
} | ||
|
||
QJsonArray allMetaObjects; | ||
if (jsonFiles.isEmpty() && !skipStdIn) { | ||
QFile f; | ||
if (!f.open(stdin, QIODevice::ReadOnly)) { | ||
fprintf(stderr, "Error opening stdin for reading\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!readFromDevice(&f, &allMetaObjects)) { | ||
fprintf(stderr, "Error parsing data from stdin\n"); | ||
return EXIT_FAILURE; | ||
} | ||
} | ||
|
||
QStringList jsonFilesSorted = jsonFiles; | ||
jsonFilesSorted.sort(); | ||
for (const QString &jsonFile : std::as_const(jsonFilesSorted)) { | ||
QFile f(jsonFile); | ||
if (!f.open(QIODevice::ReadOnly)) { | ||
fprintf(stderr, "Error opening %s for reading\n", qPrintable(jsonFile)); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!readFromDevice(&f, &allMetaObjects)) { | ||
fprintf(stderr, "Error parsing %s\n", qPrintable(jsonFile)); | ||
return EXIT_FAILURE; | ||
} | ||
} | ||
|
||
QJsonDocument doc(allMetaObjects); | ||
output.write(doc.toJson()); | ||
|
||
return EXIT_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (C) 2019 The Qt Company Ltd. | ||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 | ||
|
||
#ifndef COLLECTJSON_H | ||
#define COLLECTJSON_H | ||
|
||
#include <global/qglobal.h> | ||
#include <text/qstring.h> | ||
#include <text/qstringlist.h> | ||
|
||
QT_BEGIN_NAMESPACE | ||
|
||
int collectJson(const QStringList &jsonFiles, const QString &outputFile, bool skipStdIn); | ||
|
||
QT_END_NAMESPACE | ||
|
||
#endif // COLLECTOJSON_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (C) 2021 The Qt Company Ltd. | ||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 | ||
|
||
#ifndef QTBASE_DEPFILE_SHARED_H | ||
#define QTBASE_DEPFILE_SHARED_H | ||
|
||
#include <qobject.hpp> //from QMetaClass | ||
#include <io/qfile.h> | ||
|
||
// Escape characters in given path. Dependency paths are Make-style, not NMake/Jom style. | ||
// The paths can also be consumed by Ninja. | ||
// "$" replaced by "$$" | ||
// "#" replaced by "\#" | ||
// " " replaced by "\ " | ||
// "\#" replaced by "\\#" | ||
// "\ " replaced by "\\\ " | ||
// | ||
// The escape rules are according to what clang / llvm escapes when generating a Make-style | ||
// dependency file. | ||
// Is a template function, because input param can be either a QString or a QByteArray. | ||
template <typename T> struct CharType; | ||
template <> struct CharType<QString> { using type = QLatin1Char; }; | ||
template <> struct CharType<QByteArray> { using type = char; }; | ||
template <typename StringType> | ||
StringType escapeDependencyPath(const StringType &path) | ||
{ | ||
using CT = typename CharType<StringType>::type; | ||
StringType escapedPath; | ||
int size = path.size(); | ||
escapedPath.reserve(size); | ||
for (int i = 0; i < size; ++i) { | ||
if (path[i] == CT('$')) { | ||
escapedPath.append(CT('$')); | ||
} else if (path[i] == CT('#')) { | ||
escapedPath.append(CT('\\')); | ||
} else if (path[i] == CT(' ')) { | ||
escapedPath.append(CT('\\')); | ||
int backwards_it = i - 1; | ||
while (backwards_it > 0 && path[backwards_it] == CT('\\')) { | ||
escapedPath.append(CT('\\')); | ||
--backwards_it; | ||
} | ||
} | ||
escapedPath.append(path[i]); | ||
} | ||
return escapedPath; | ||
} | ||
|
||
static inline QByteArray escapeAndEncodeDependencyPath(const QString &path) | ||
{ | ||
return QFile::encodeName(escapeDependencyPath(path)); | ||
} | ||
|
||
#endif // QTBASE_DEPFILE_SHARED_H |
Oops, something went wrong.