summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYifan Hong2017-08-25 19:55:33 -0500
committerYifan Hong2017-08-28 14:39:43 -0500
commit9f12df5a9890fe84d2c666a6e54b234aa90cc461 (patch)
tree9b0466a67af34e6d5391a8c0a472a6c4cbd4eef0
parent27b59fce39d5cdb1aa35955e52b0ca5d386983f2 (diff)
downloadplatform-system-libvintf-9f12df5a9890fe84d2c666a6e54b234aa90cc461.tar.gz
platform-system-libvintf-9f12df5a9890fe84d2c666a6e54b234aa90cc461.tar.xz
platform-system-libvintf-9f12df5a9890fe84d2c666a6e54b234aa90cc461.zip
assemble_vintf: accept arch specific kernel fragments
It is now allowed to provide the following arg: --kernel=3.18:.../android-base.cfg:.../android-base-arm64.cfg assemble_vintf detects the name of these files and sets conditions accordingly. For example, * android-base.cfg refer to common configs (no conditions) * android-base-foo-bar.cfg refer to configs that are conditioned on CONFIG_FOO_BAR being set. Also, android-base.cfg must exist for each version. Test: m system_compatibility_matrix.xml -j Bug: 64124223 Change-Id: Ib852b9f0c3ce6addce18473480f3da2f221f8d92
-rw-r--r--Android.bp3
-rw-r--r--assemble_vintf.cpp48
2 files changed, 43 insertions, 8 deletions
diff --git a/Android.bp b/Android.bp
index 70c7dc8..a6bfe7f 100644
--- a/Android.bp
+++ b/Android.bp
@@ -90,7 +90,8 @@ cc_binary_host {
90 name: "assemble_vintf", 90 name: "assemble_vintf",
91 cflags: libvintf_flags, 91 cflags: libvintf_flags,
92 shared_libs: [ 92 shared_libs: [
93 "libvintf" 93 "libvintf",
94 "libbase",
94 ], 95 ],
95 srcs: [ 96 srcs: [
96 "assemble_vintf.cpp" 97 "assemble_vintf.cpp"
diff --git a/assemble_vintf.cpp b/assemble_vintf.cpp
index 60cea7d..251d4bc 100644
--- a/assemble_vintf.cpp
+++ b/assemble_vintf.cpp
@@ -24,6 +24,8 @@
24#include <sstream> 24#include <sstream>
25#include <string> 25#include <string>
26 26
27#include <android-base/file.h>
28
27#include <vintf/KernelConfigParser.h> 29#include <vintf/KernelConfigParser.h>
28#include <vintf/parse_string.h> 30#include <vintf/parse_string.h>
29#include <vintf/parse_xml.h> 31#include <vintf/parse_xml.h>
@@ -33,11 +35,18 @@
33namespace android { 35namespace android {
34namespace vintf { 36namespace vintf {
35 37
38static const std::string gConfigPrefix = "android-base-";
39static const std::string gConfigSuffix = ".cfg";
40static const std::string gBaseConfig = "android-base.cfg";
41
36/** 42/**
37 * Slurps the device manifest file and add build time flag to it. 43 * Slurps the device manifest file and add build time flag to it.
38 */ 44 */
39class AssembleVintf { 45class AssembleVintf {
40public: 46 using Condition = std::unique_ptr<KernelConfig>;
47 using ConditionedConfig = std::pair<Condition, std::vector<KernelConfig> /* configs */>;
48
49 public:
41 template<typename T> 50 template<typename T>
42 static bool getFlag(const std::string& key, T* value) { 51 static bool getFlag(const std::string& key, T* value) {
43 const char *envValue = getenv(key.c_str()); 52 const char *envValue = getenv(key.c_str());
@@ -60,6 +69,10 @@ public:
60 return ss.str(); 69 return ss.str();
61 } 70 }
62 71
72 static bool isCommonConfig(const std::string& path) {
73 return ::android::base::Basename(path) == gBaseConfig;
74 }
75
63 static bool parseFileForKernelConfigs(const std::string& path, std::vector<KernelConfig>* out) { 76 static bool parseFileForKernelConfigs(const std::string& path, std::vector<KernelConfig>* out) {
64 std::ifstream ifs{path}; 77 std::ifstream ifs{path};
65 if (!ifs.is_open()) { 78 if (!ifs.is_open()) {
@@ -92,17 +105,36 @@ public:
92 return true; 105 return true;
93 } 106 }
94 107
95 static bool parseFilesForKernelConfigs(const std::string& path, std::vector<KernelConfig>* out) { 108 static bool parseFilesForKernelConfigs(const std::string& path,
109 std::vector<ConditionedConfig>* out) {
110 out->clear();
111 ConditionedConfig commonConfig;
112 bool foundCommonConfig = false;
96 bool ret = true; 113 bool ret = true;
97 char *pathIter; 114 char *pathIter;
98 char *modPath = new char[path.length() + 1]; 115 char *modPath = new char[path.length() + 1];
99 strcpy(modPath, path.c_str()); 116 strcpy(modPath, path.c_str());
100 pathIter = strtok(modPath, ":"); 117 pathIter = strtok(modPath, ":");
101 while (ret && pathIter != NULL) { 118 while (ret && pathIter != NULL) {
102 ret &= parseFileForKernelConfigs(pathIter, out); 119 if (isCommonConfig(pathIter)) {
120 ret &= parseFileForKernelConfigs(pathIter, &commonConfig.second);
121 foundCommonConfig = true;
122 } else {
123 std::vector<KernelConfig> kernelConfigs;
124 if ((ret &= parseFileForKernelConfigs(pathIter, &kernelConfigs)))
125 out->emplace_back(nullptr, std::move(kernelConfigs));
126 }
103 pathIter = strtok(NULL, ":"); 127 pathIter = strtok(NULL, ":");
104 } 128 }
105 delete[] modPath; 129 delete[] modPath;
130
131 if (!foundCommonConfig) {
132 std::cerr << "No android-base.cfg is found in these paths: '" << path << "'"
133 << std::endl;
134 }
135 ret &= foundCommonConfig;
136 // first element is always common configs (no conditions).
137 out->insert(out->begin(), std::move(commonConfig));
106 return ret; 138 return ret;
107 } 139 }
108 140
@@ -166,12 +198,14 @@ public:
166 matrix->framework.mKernels.clear(); 198 matrix->framework.mKernels.clear();
167 } 199 }
168 for (const auto& pair : mKernels) { 200 for (const auto& pair : mKernels) {
169 std::vector<KernelConfig> configs; 201 std::vector<ConditionedConfig> conditionedConfigs;
170 if (!parseFilesForKernelConfigs(pair.second, &configs)) { 202 if (!parseFilesForKernelConfigs(pair.second, &conditionedConfigs)) {
171 return false; 203 return false;
172 } 204 }
173 matrix->framework.mKernels.push_back( 205 for (ConditionedConfig& conditionedConfig : conditionedConfigs) {
174 MatrixKernel{KernelVersion{pair.first}, std::move(configs)}); 206 matrix->framework.mKernels.push_back(
207 MatrixKernel{KernelVersion{pair.first}, std::move(conditionedConfig.second)});
208 }
175 } 209 }
176 return true; 210 return true;
177 } 211 }