summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot2017-10-03 03:14:54 -0500
committerandroid-build-team Robot2017-10-03 03:14:54 -0500
commit8ce3211b609c588c08e8bf72c930f68d06b6f390 (patch)
treea55b09ad7f2e94b1704f2877f40a03fae3343eb8
parent8f640d31fa0b1b8c5591cd6f10901506d18481cf (diff)
parent8977ba3867816ede43c843fd481f37126014db6a (diff)
downloadplatform-system-libvintf-8ce3211b609c588c08e8bf72c930f68d06b6f390.tar.gz
platform-system-libvintf-8ce3211b609c588c08e8bf72c930f68d06b6f390.tar.xz
platform-system-libvintf-8ce3211b609c588c08e8bf72c930f68d06b6f390.zip
Snap for 4373608 from 8977ba3867816ede43c843fd481f37126014db6a to pi-release
Change-Id: I1a2ba0f2fc157e73935461eeefee8de38bd1321a
-rw-r--r--Android.bp13
-rw-r--r--check_vintf.cpp68
-rw-r--r--utils.h5
3 files changed, 83 insertions, 3 deletions
diff --git a/Android.bp b/Android.bp
index 2b39ad8..c2419e4 100644
--- a/Android.bp
+++ b/Android.bp
@@ -90,6 +90,19 @@ cc_binary {
90} 90}
91 91
92cc_binary_host { 92cc_binary_host {
93 name: "checkvintf",
94 defaults: ["libvintf-defaults"],
95 shared_libs: [
96 "libvintf",
97 "libbase"
98 ],
99 srcs: [
100 "check_vintf.cpp",
101 "utils.cpp"
102 ],
103}
104
105cc_binary_host {
93 name: "assemble_vintf", 106 name: "assemble_vintf",
94 defaults: ["libvintf-defaults"], 107 defaults: ["libvintf-defaults"],
95 shared_libs: [ 108 shared_libs: [
diff --git a/check_vintf.cpp b/check_vintf.cpp
new file mode 100644
index 0000000..211702e
--- /dev/null
+++ b/check_vintf.cpp
@@ -0,0 +1,68 @@
1/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <iostream>
18
19#include <vintf/parse_xml.h>
20#include "utils.h"
21
22namespace android {
23namespace vintf {
24
25template <typename T>
26std::unique_ptr<T> readObject(const std::string& path, const XmlConverter<T>& converter) {
27 std::string xml;
28 status_t err = details::gFetcher->fetch(path, xml);
29 if (err != OK) {
30 std::cerr << "Error: Cannot read '" << path << "': " << strerror(-err) << std::endl;
31 return nullptr;
32 }
33 auto ret = std::make_unique<T>();
34 if (!converter(ret.get(), xml)) {
35 std::cerr << "Error: Cannot parse '" << path << "': " << converter.lastError() << std::endl;
36 return nullptr;
37 }
38 return ret;
39}
40
41} // namespace vintf
42} // namespace android
43
44int main(int argc, char** argv) {
45 using namespace android::vintf;
46 if (argc < 3) {
47 std::cerr << "usage: " << argv[0] << " <manifest.xml> <matrix.xml>" << std::endl
48 << " Checks compatibility between a manifest and a compatibility matrix."
49 << std::endl;
50 return -1;
51 }
52
53 auto manifest = readObject(argv[1], gHalManifestConverter);
54 auto matrix = readObject(argv[2], gCompatibilityMatrixConverter);
55 if (manifest == nullptr || matrix == nullptr) {
56 return -1;
57 }
58
59 std::string error;
60 if (!manifest->checkCompatibility(*matrix, &error)) {
61 std::cerr << "Error: Incompatible: " << error << std::endl;
62 std::cout << "false" << std::endl;
63 return 1;
64 }
65
66 std::cout << "true" << std::endl;
67 return 0;
68}
diff --git a/utils.h b/utils.h
index 973c524..c08a22e 100644
--- a/utils.h
+++ b/utils.h
@@ -23,9 +23,8 @@
23 23
24#include <android-base/logging.h> 24#include <android-base/logging.h>
25#include <utils/Errors.h> 25#include <utils/Errors.h>
26 26#include <vintf/RuntimeInfo.h>
27#include "RuntimeInfo.h" 27#include <vintf/parse_xml.h>
28#include "parse_xml.h"
29 28
30namespace android { 29namespace android {
31namespace vintf { 30namespace vintf {