header-checker: Do not expose format-specific details
Test: ./tests/test.py
Test: ${ANDROID_HOST_OUT}/nativetest64/\
header-checker-unittests/header-checker-unittests
Change-Id: Ib55dc8bdd195d4072d875d0cbd495c7c9c550fec
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
#include "repr/ir_diff_dumper.h"
|
||||
|
||||
#include "repr/ir_representation.h"
|
||||
#include "repr/protobuf/ir_diff_dumper.h"
|
||||
#include "repr/protobuf/api.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -31,7 +31,7 @@ std::unique_ptr<IRDiffDumper> IRDiffDumper::CreateIRDiffDumper(
|
||||
TextFormatIR text_format, const std::string &dump_path) {
|
||||
switch (text_format) {
|
||||
case TextFormatIR::ProtobufTextFormat:
|
||||
return std::make_unique<ProtobufIRDiffDumper>(dump_path);
|
||||
return CreateProtobufIRDiffDumper(dump_path);
|
||||
default:
|
||||
// Nothing else is supported yet.
|
||||
llvm::errs() << "Text format not supported yet\n";
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
|
||||
#include "repr/ir_dumper.h"
|
||||
|
||||
#include "repr/json/ir_dumper.h"
|
||||
#include "repr/protobuf/ir_dumper.h"
|
||||
#include "repr/json/api.h"
|
||||
#include "repr/protobuf/api.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -31,9 +31,9 @@ std::unique_ptr<IRDumper> IRDumper::CreateIRDumper(
|
||||
TextFormatIR text_format, const std::string &dump_path) {
|
||||
switch (text_format) {
|
||||
case TextFormatIR::ProtobufTextFormat:
|
||||
return std::make_unique<ProtobufIRDumper>(dump_path);
|
||||
return CreateProtobufIRDumper(dump_path);
|
||||
case TextFormatIR::Json:
|
||||
return std::make_unique<JsonIRDumper>(dump_path);
|
||||
return CreateJsonIRDumper(dump_path);
|
||||
default:
|
||||
llvm::errs() << "Text format not supported yet\n";
|
||||
return nullptr;
|
||||
|
||||
@@ -17,9 +17,8 @@
|
||||
#include "repr/abi_diff_helpers.h"
|
||||
#include "repr/ir_representation.h"
|
||||
#include "repr/ir_representation_internal.h"
|
||||
#include "repr/ir_diff_representation.h"
|
||||
#include "repr/json/ir_reader.h"
|
||||
#include "repr/protobuf/ir_reader.h"
|
||||
#include "repr/json/api.h"
|
||||
#include "repr/protobuf/api.h"
|
||||
|
||||
#include <list>
|
||||
#include <memory>
|
||||
@@ -41,9 +40,9 @@ IRReader::CreateIRReader(
|
||||
TextFormatIR text_format, const std::set<std::string> *exported_headers) {
|
||||
switch (text_format) {
|
||||
case TextFormatIR::ProtobufTextFormat:
|
||||
return std::make_unique<ProtobufIRReader>(exported_headers);
|
||||
return CreateProtobufIRReader(exported_headers);
|
||||
case TextFormatIR::Json:
|
||||
return std::make_unique<JsonIRReader>(exported_headers);
|
||||
return CreateJsonIRReader(exported_headers);
|
||||
default:
|
||||
llvm::errs() << "Text format not supported yet\n";
|
||||
return nullptr;
|
||||
|
||||
41
vndk/tools/header-checker/src/repr/json/api.h
Normal file
41
vndk/tools/header-checker/src/repr/json/api.h
Normal file
@@ -0,0 +1,41 @@
|
||||
// Copyright (C) 2019 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef HEADER_CHECKER_REPR_JSON_API_H_
|
||||
#define HEADER_CHECKER_REPR_JSON_API_H_
|
||||
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace header_checker {
|
||||
namespace repr {
|
||||
|
||||
|
||||
class IRDumper;
|
||||
class IRReader;
|
||||
|
||||
|
||||
std::unique_ptr<IRDumper> CreateJsonIRDumper(const std::string &dump_path);
|
||||
|
||||
std::unique_ptr<IRReader> CreateJsonIRReader(
|
||||
const std::set<std::string> *exported_headers);
|
||||
|
||||
|
||||
} // namespace repr
|
||||
} // namespace header_checker
|
||||
|
||||
|
||||
#endif // HEADER_CHECKER_REPR_JSON_API_H_
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "repr/ir_dumper.h"
|
||||
#include "repr/ir_reader.h"
|
||||
#include "repr/ir_representation_internal.h"
|
||||
#include "repr/json/api.h"
|
||||
#include "repr/json/converter.h"
|
||||
|
||||
#include <json/reader.h>
|
||||
@@ -426,6 +427,10 @@ JsonIRDumper::JsonIRDumper(const std::string &dump_path)
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<IRDumper> CreateJsonIRDumper(const std::string &dump_path) {
|
||||
return std::make_unique<JsonIRDumper>(dump_path);
|
||||
}
|
||||
|
||||
|
||||
} // namespace repr
|
||||
} // header_checker
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "repr/ir_dumper.h"
|
||||
#include "repr/ir_reader.h"
|
||||
#include "repr/ir_representation_internal.h"
|
||||
#include "repr/json/api.h"
|
||||
#include "repr/json/converter.h"
|
||||
|
||||
#include <json/reader.h>
|
||||
@@ -478,6 +479,11 @@ void JsonIRReader::ReadElfObjects(const JsonObjectRef &tu) {
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<IRReader> CreateJsonIRReader(
|
||||
const std::set<std::string> *exported_headers) {
|
||||
return std::make_unique<JsonIRReader>(exported_headers);
|
||||
}
|
||||
|
||||
|
||||
} // namespace repr
|
||||
} // header_checker
|
||||
|
||||
45
vndk/tools/header-checker/src/repr/protobuf/api.h
Normal file
45
vndk/tools/header-checker/src/repr/protobuf/api.h
Normal file
@@ -0,0 +1,45 @@
|
||||
// Copyright (C) 2019 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef HEADER_CHECKER_REPR_PROTOBUF_API_H_
|
||||
#define HEADER_CHECKER_REPR_PROTOBUF_API_H_
|
||||
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace header_checker {
|
||||
namespace repr {
|
||||
|
||||
|
||||
class IRDiffDumper;
|
||||
class IRDumper;
|
||||
class IRReader;
|
||||
|
||||
|
||||
std::unique_ptr<IRDumper> CreateProtobufIRDumper(const std::string &dump_path);
|
||||
|
||||
std::unique_ptr<IRReader> CreateProtobufIRReader(
|
||||
const std::set<std::string> *exported_headers);
|
||||
|
||||
std::unique_ptr<IRDiffDumper> CreateProtobufIRDiffDumper(
|
||||
const std::string &dump_path);
|
||||
|
||||
|
||||
} // namespace repr
|
||||
} // namespace header_checker
|
||||
|
||||
|
||||
#endif // HEADER_CHECKER_REPR_PROTOBUF_API_H_
|
||||
@@ -15,10 +15,12 @@
|
||||
#include "repr/protobuf/ir_diff_dumper.h"
|
||||
|
||||
#include "repr/ir_diff_representation.h"
|
||||
#include "repr/protobuf/api.h"
|
||||
#include "repr/protobuf/converter.h"
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <llvm/Support/raw_ostream.h>
|
||||
|
||||
@@ -366,6 +368,11 @@ bool ProtobufIRDiffDumper::Dump() {
|
||||
return google::protobuf::TextFormat::Print(*diff_tu_.get(), &text_os);
|
||||
}
|
||||
|
||||
std::unique_ptr<IRDiffDumper> CreateProtobufIRDiffDumper(
|
||||
const std::string &dump_path) {
|
||||
return std::make_unique<ProtobufIRDiffDumper>(dump_path);
|
||||
}
|
||||
|
||||
|
||||
} // namespace repr
|
||||
} // namespace header_checker
|
||||
|
||||
@@ -15,8 +15,10 @@
|
||||
#include "repr/protobuf/ir_dumper.h"
|
||||
|
||||
#include "repr/protobuf/abi_dump.h"
|
||||
#include "repr/protobuf/api.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
|
||||
#include <llvm/Support/raw_ostream.h>
|
||||
|
||||
@@ -489,6 +491,10 @@ bool ProtobufIRDumper::Dump() {
|
||||
return google::protobuf::TextFormat::Print(*tu_ptr_.get(), &text_os);
|
||||
}
|
||||
|
||||
std::unique_ptr<IRDumper> CreateProtobufIRDumper(const std::string &dump_path) {
|
||||
return std::make_unique<ProtobufIRDumper>(dump_path);
|
||||
}
|
||||
|
||||
|
||||
} // namespace repr
|
||||
} // namespace header_checker
|
||||
|
||||
@@ -15,9 +15,11 @@
|
||||
#include "repr/protobuf/ir_reader.h"
|
||||
|
||||
#include "repr/ir_representation_internal.h"
|
||||
#include "repr/protobuf/api.h"
|
||||
#include "repr/protobuf/converter.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
|
||||
#include <google/protobuf/text_format.h>
|
||||
|
||||
@@ -369,6 +371,11 @@ void ProtobufIRReader::ReadElfObjects(const abi_dump::TranslationUnit &tu) {
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<IRReader> CreateProtobufIRReader(
|
||||
const std::set<std::string> *exported_headers) {
|
||||
return std::make_unique<ProtobufIRReader>(exported_headers);
|
||||
}
|
||||
|
||||
|
||||
} // namespace repr
|
||||
} // namespace header_checker
|
||||
|
||||
Reference in New Issue
Block a user