Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow skip including headers of annootations #394

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmake/DtkTools/DtkDBusMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ function(dtk_add_dbus_interface _sources _interface _relativename)
set(_params -m)
endif()

get_source_file_property(_skipincludeannotations ${_interface} SKIP_INCLUDE_ANNOTATIONS)
if(_skipincludeannotations)
set(_params ${_params} -S)
endif()

get_source_file_property(_classname ${_interface} CLASSNAME)
if(_classname)
set(_params ${_params} -c ${_classname})
Expand Down
13 changes: 10 additions & 3 deletions tools/qdbusxml2cpp/qdbusxml2cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ static QString inputFile;
static bool skipNamespaces;
static bool verbose;
static bool includeMocs;
static bool skipIncludeAnnotations;
static QString commandLine;
static QStringList includes;
static QStringList wantedInterfaces;
Expand All @@ -56,6 +57,7 @@ static const char help[] =
" -N Don't use namespaces\n"
" -p <filename> Write the proxy code to <filename>\n"
" -v Be verbose.\n"
" -S Skip include annotation headers from \"types/\".\n"
" -V Show the program version and quit.\n"
"\n"
"If the file name given to the options -a and -p does not end in .cpp or .h, the\n"
Expand Down Expand Up @@ -158,6 +160,9 @@ static void parseCmdLine(QStringList args)
case 'N':
skipNamespaces = true;
break;
case 'S':
skipIncludeAnnotations = true;
break;

case '?':
case 'h':
Expand Down Expand Up @@ -625,9 +630,11 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf
}
}

for (const QString &annotation : annotations) {
if (annotation.indexOf('<') == -1) {
hs << "#include \"types/" << annotation.toLower() << ".h\"" << endl;
if (!skipIncludeAnnotations) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看下面还有对annotations进行处理的逻辑,是不是需要一起跳过,
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

下面是处理类型,这里需要跳过的是处理include,下面是原本没有fix的工具的逻辑

Copy link
Contributor

@18202781743 18202781743 Dec 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include都跳过了,类型处理不跳过么?会不会出现类型不识别的问题,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qt的工具是要求所有类型都放在-I的头文件的,我们为了方便把类型分开成各个头文件了

for (const QString &annotation : annotations) {
if (annotation.indexOf('<') == -1) {
hs << "#include \"types/" << annotation.toLower() << ".h\"" << endl;
}
}
}
hs << endl;
Expand Down