1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
|
/****************************************************************************
**
** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qbs.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\qmltype protobuf.cpp
\inqmlmodule QbsModules
\since Qbs 1.13
\brief Provides support for protocol buffers for the C++ language.
The \c protobuf.cpp module provides support for generating C++ headers
and sources from proto definition files using the \l protoc tool.
A simple qbs file that uses protobuf can be written as follows:
\code
CppApplication {
Depends { name: "protobuf.cpp" }
files: ["foo.proto", "main.cpp"]
}
\endcode
A generated header now can be included in the C++ sources:
\code
#include <foo.pb.h>
int main(int argc, char* argv[]) {
Foo bar;
bar.set_answer(42);
google::protobuf::ShutdownProtobufLibrary();
return 0;
}
\endcode
\section2 Relevant File Tags
\table
\header
\li Tag
\li Auto-tagged File Names
\li Since
\li Description
\row
\li \c{"protobuf.input"}
\li \c{*.proto}
\li 1.13.0
\li Source files with this tag are considered inputs to the \c protoc compiler.
\row
\li \c{"protobuf.grpc"}
\li
\li 1.14.0
\li Source files with this tag are considered as gRPC files.
\row
\li \c{"protobuf.hpp"}
\li
\li 1.18.0
\li This tag is attached to the header files generated by \c protoc compiler.
\endtable
\section2 Dependencies
The \l protobuf.cpp module requires runtime libraries to be operational. It depends on the
\c "protobuflib" module which can be created by the \l qbspkgconfig or fallback module
providers (the corresponding packages are \c protobuf or \c protobuf-lite). If \l useGrpc is
set to true, the \l protobuf.cpp module also depends on the \c "grpc++" module.
*/
/*!
\qmlproperty string protobuf.cpp::compilerName
The name of the protoc binary.
\since Qbs 1.17
\defaultvalue \c "protoc"
*/
/*!
\qmlproperty string protobuf.cpp::compilerPath
The path to the protoc binary.
Use this property to override the auto-detected location.
\since Qbs 1.17
\defaultvalue \c auto-detected
*/
/*!
\qmlproperty pathList protobuf.cpp::importPaths
The list of imports that are passed to the \c protoc tool via the \c --proto_path option.
These imports should contain the proto files. They are used to determine
the relative structure of the generated files.
\note The paths are passed to \c protoc in the same order as specified in this property and
\c protoc output may differ depending on that order.
\defaultvalue \c []
*/
/*!
\qmlproperty string protobuf.cpp::outputDir
\readonly
The directory where the \c protoc compiler generated files are placed.
The value of this property is automatically set by \QBS and cannot be
changed by the user.
*/
/*!
\qmlproperty bool protobuf.cpp::useGrpc
Whether to use gRPC framework.
Use this property to enable support for the modern open source high performance RPC
framework by Google, gRPC (\l{https://www.grpc.io}).
A simple qbs file that uses grpc can be written as follows:
\code
CppApplication {
Depends { name: "protobuf.cpp" }
protobuf.cpp.useGrpc: true
files: ["main.cpp"]
Group {
files: "grpc.proto"
fileTags: "protobuf.grpc"
}
}
\endcode
\note that \c protobuf.grpc tag should be assigned manually because gRPC uses same \c *.proto
files and \QBS can't detect whether to generate gRPC or \c protobuf.
The following \c grpc.proto file...
\code
syntax = "proto3";
package Qbs;
message Request {
string name = 1;
}
message Response {
string name = 1;
}
service Grpc {
rpc doWork(Request) returns (Response) {}
}
\endcode
...can be used in the C++ sources as follows:
\code
#include <grpc.grpc.pb.h>
class Service final : public Qbs::Grpc::Service
{
grpc::Status doWork(
grpc::ServerContext* context,
const Qbs::Request* request,
Qbs::Response* reply) override
{
(void)context;
reply->set_name(request->name());
return grpc::Status::OK;
}
};
\endcode
\defaultvalue \c false
*/
|