Merge "perfetto: add CTS test skeleton"
diff --git a/include/perfetto/tracing/core/trace_config.h b/include/perfetto/tracing/core/trace_config.h
index 020ca5e..cb32628 100644
--- a/include/perfetto/tracing/core/trace_config.h
+++ b/include/perfetto/tracing/core/trace_config.h
@@ -34,7 +34,7 @@
#include <vector>
#include "perfetto/base/build_config.h"
-#include "include/perfetto/tracing/core/data_source_config.h"
+#include "perfetto/tracing/core/data_source_config.h"
// Forward declarations for protobuf types.
namespace perfetto {
diff --git a/tools/gen_tracing_cpp_headers_from_protos.py b/tools/gen_tracing_cpp_headers_from_protos.py
index 1ec4a95..c27a775 100755
--- a/tools/gen_tracing_cpp_headers_from_protos.py
+++ b/tools/gen_tracing_cpp_headers_from_protos.py
@@ -25,6 +25,7 @@
HEADER_PATH = 'include/perfetto/tracing/core'
CPP_PATH = 'src/tracing/core'
+INCLUDE_PATH = 'perfetto/tracing/core'
def run(cmd):
@@ -45,7 +46,7 @@
if not os.path.exists(tool):
print('Could not find %s, run ninja -C %s proto_to_cpp' % (tool, out_dir))
for proto in PROTOS:
- run([tool, proto] + [HEADER_PATH, CPP_PATH])
+ run([tool, proto] + [HEADER_PATH, CPP_PATH, INCLUDE_PATH])
fname = os.path.basename(proto).replace('.proto', '')
run(clang_format + [os.path.join(HEADER_PATH, fname + '.h')])
run(clang_format + [os.path.join(CPP_PATH, fname + '.cc')])
diff --git a/tools/proto_to_cpp/proto_to_cpp.cc b/tools/proto_to_cpp/proto_to_cpp.cc
index 6641bd9..549ffb7 100644
--- a/tools/proto_to_cpp/proto_to_cpp.cc
+++ b/tools/proto_to_cpp/proto_to_cpp.cc
@@ -114,28 +114,34 @@
class ProtoToCpp {
public:
- ProtoToCpp(const std::string& header_dir, const std::string& cpp_dir);
+ ProtoToCpp(const std::string& header_dir,
+ const std::string& cpp_dir,
+ const std::string& include_path);
static std::string GetCppType(const FieldDescriptor* field, bool constref);
void Convert(const std::string& src_proto);
std::string GetHeaderPath(const FileDescriptor*);
std::string GetCppPath(const FileDescriptor*);
+ std::string GetIncludePath(const FileDescriptor*);
void GenHeader(const Descriptor*, Printer*);
void GenCpp(const Descriptor*, Printer*, std::string prefix);
private:
std::string header_dir_;
std::string cpp_dir_;
+ std::string include_path_;
DiskSourceTree dst_;
ErrorPrinter error_printer_;
Importer importer_;
};
ProtoToCpp::ProtoToCpp(const std::string& header_dir,
- const std::string& cpp_dir)
+ const std::string& cpp_dir,
+ const std::string& include_path)
: header_dir_(header_dir),
cpp_dir_(cpp_dir),
+ include_path_(include_path),
importer_(&dst_, &error_printer_) {
dst_.MapPath("protos", "protos");
}
@@ -150,6 +156,11 @@
return cpp_dir_ + "/" + StringReplace(basename, ".proto", ".cc", false);
}
+std::string ProtoToCpp::GetIncludePath(const FileDescriptor* proto_file) {
+ std::string basename = Split(proto_file->name(), "/").back();
+ return include_path_ + "/" + StringReplace(basename, ".proto", ".h", false);
+}
+
std::string ProtoToCpp::GetCppType(const FieldDescriptor* field,
bool constref) {
switch (field->type()) {
@@ -225,7 +236,7 @@
// Generate includes for translated types of dependencies.
for (int i = 0; i < proto_file->dependency_count(); i++) {
const FileDescriptor* dep = proto_file->dependency(i);
- header_printer.Print("#include \"$f$\"\n", "f", GetHeaderPath(dep));
+ header_printer.Print("#include \"$f$\"\n", "f", GetIncludePath(dep));
}
header_printer.Print("\n");
@@ -459,11 +470,13 @@
}
int main(int argc, char** argv) {
- if (argc <= 3) {
- PERFETTO_ELOG("Usage: %s source.proto dir/for/header dir/for/cc", argv[0]);
+ if (argc <= 4) {
+ PERFETTO_ELOG(
+ "Usage: %s source.proto dir/for/header dir/for/cc include/path",
+ argv[0]);
return 1;
}
- ProtoToCpp proto_to_cpp(argv[2], argv[3]);
+ ProtoToCpp proto_to_cpp(argv[2], argv[3], argv[4]);
proto_to_cpp.Convert(argv[1]);
return 0;
}