Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 1 | /* |
Elliott Hughes | dfb74c5 | 2016-10-24 12:53:17 -0700 | [diff] [blame] | 2 | * Copyright (C) 2016 The Android Open Source Project |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 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 | * |
Elliott Hughes | dfb74c5 | 2016-10-24 12:53:17 -0700 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 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 <dirent.h> |
| 18 | #include <err.h> |
| 19 | #include <limits.h> |
| 20 | #include <stdio.h> |
| 21 | #include <sys/stat.h> |
| 22 | #include <sys/types.h> |
| 23 | #include <unistd.h> |
| 24 | |
Josh Gao | 338cf12 | 2016-11-09 18:01:41 -0800 | [diff] [blame] | 25 | #if defined(__linux__) |
| 26 | #include <sched.h> |
| 27 | #endif |
| 28 | |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 29 | #include <atomic> |
Josh Gao | 338cf12 | 2016-11-09 18:01:41 -0800 | [diff] [blame] | 30 | #include <chrono> |
Josh Gao | 16016df | 2016-11-07 18:27:16 -0800 | [diff] [blame] | 31 | #include <functional> |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 32 | #include <iostream> |
| 33 | #include <map> |
| 34 | #include <memory> |
| 35 | #include <set> |
| 36 | #include <sstream> |
| 37 | #include <string> |
| 38 | #include <thread> |
| 39 | #include <unordered_map> |
| 40 | #include <vector> |
| 41 | |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 42 | #include <llvm/ADT/StringRef.h> |
| 43 | |
Josh Gao | b50b8c8 | 2017-04-27 17:22:52 -0700 | [diff] [blame] | 44 | #include <android-base/file.h> |
Josh Gao | 338cf12 | 2016-11-09 18:01:41 -0800 | [diff] [blame] | 45 | #include <android-base/macros.h> |
Josh Gao | 16016df | 2016-11-07 18:27:16 -0800 | [diff] [blame] | 46 | #include <android-base/parseint.h> |
George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame^] | 47 | #include <android-base/strings.h> |
Josh Gao | 16016df | 2016-11-07 18:27:16 -0800 | [diff] [blame] | 48 | |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 49 | #include "Arch.h" |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 50 | #include "DeclarationDatabase.h" |
Josh Gao | b5c4963 | 2016-11-08 22:21:31 -0800 | [diff] [blame] | 51 | #include "Driver.h" |
Josh Gao | f8592a3 | 2016-07-26 18:58:27 -0700 | [diff] [blame] | 52 | #include "Preprocessor.h" |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 53 | #include "SymbolDatabase.h" |
| 54 | #include "Utils.h" |
Josh Gao | 78b8a14 | 2016-11-09 01:00:41 -0800 | [diff] [blame] | 55 | #include "VFS.h" |
| 56 | |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 57 | #include "versioner.h" |
| 58 | |
Josh Gao | 338cf12 | 2016-11-09 18:01:41 -0800 | [diff] [blame] | 59 | using namespace std::chrono_literals; |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 60 | using namespace std::string_literals; |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 61 | |
Josh Gao | acc3d80 | 2016-11-09 18:22:44 -0800 | [diff] [blame] | 62 | bool strict; |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 63 | bool verbose; |
Josh Gao | acc3d80 | 2016-11-09 18:22:44 -0800 | [diff] [blame] | 64 | bool add_include; |
Josh Gao | 338cf12 | 2016-11-09 18:01:41 -0800 | [diff] [blame] | 65 | |
| 66 | static int getCpuCount(); |
| 67 | static int max_thread_count = getCpuCount(); |
| 68 | |
| 69 | static int getCpuCount() { |
| 70 | #if defined(__linux__) |
| 71 | cpu_set_t cpu_set; |
| 72 | int rc = sched_getaffinity(getpid(), sizeof(cpu_set), &cpu_set); |
| 73 | if (rc != 0) { |
| 74 | err(1, "sched_getaffinity failed"); |
| 75 | } |
| 76 | return CPU_COUNT(&cpu_set); |
| 77 | #else |
| 78 | return 1; |
| 79 | #endif |
| 80 | } |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 81 | |
George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame^] | 82 | namespace { |
| 83 | struct HeaderLocationInformation { |
| 84 | std::string header_dir; |
| 85 | std::string dependency_dir; |
| 86 | // Absolute paths to ignore all children -- including subdirectories -- of. |
| 87 | std::unordered_set<std::string> ignored_directories; |
| 88 | }; |
| 89 | } |
| 90 | |
| 91 | static CompilationRequirements collectRequirements(const Arch& arch, |
| 92 | const HeaderLocationInformation& location) { |
| 93 | std::vector<std::string> headers = |
| 94 | collectHeaders(location.header_dir, location.ignored_directories); |
| 95 | std::vector<std::string> dependencies = { location.header_dir }; |
| 96 | if (!location.dependency_dir.empty()) { |
Yi Kong | ff6c8de | 2017-04-20 09:08:11 -0700 | [diff] [blame] | 97 | auto collect_children = [&dependencies](const std::string& dir_path) { |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 98 | DIR* dir = opendir(dir_path.c_str()); |
| 99 | if (!dir) { |
| 100 | err(1, "failed to open dependency directory '%s'", dir_path.c_str()); |
| 101 | } |
| 102 | |
| 103 | struct dirent* dent; |
| 104 | while ((dent = readdir(dir))) { |
| 105 | if (dent->d_name[0] == '.') { |
| 106 | continue; |
| 107 | } |
| 108 | |
| 109 | // TODO: Resolve symlinks. |
| 110 | std::string dependency = dir_path + "/" + dent->d_name; |
| 111 | |
| 112 | struct stat st; |
| 113 | if (stat(dependency.c_str(), &st) != 0) { |
| 114 | err(1, "failed to stat dependency '%s'", dependency.c_str()); |
| 115 | } |
| 116 | |
| 117 | if (!S_ISDIR(st.st_mode)) { |
| 118 | errx(1, "'%s' is not a directory", dependency.c_str()); |
| 119 | } |
| 120 | |
| 121 | dependencies.push_back(dependency); |
| 122 | } |
| 123 | |
| 124 | closedir(dir); |
| 125 | }; |
| 126 | |
George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame^] | 127 | collect_children(location.dependency_dir + "/common"); |
| 128 | collect_children(location.dependency_dir + "/" + to_string(arch)); |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | auto new_end = std::remove_if(headers.begin(), headers.end(), [&arch](llvm::StringRef header) { |
| 132 | for (const auto& it : header_blacklist) { |
| 133 | if (it.second.find(arch) == it.second.end()) { |
| 134 | continue; |
| 135 | } |
| 136 | |
| 137 | if (header.endswith("/" + it.first)) { |
| 138 | return true; |
| 139 | } |
| 140 | } |
| 141 | return false; |
| 142 | }); |
| 143 | |
| 144 | headers.erase(new_end, headers.end()); |
| 145 | |
| 146 | CompilationRequirements result = { .headers = headers, .dependencies = dependencies }; |
| 147 | return result; |
| 148 | } |
| 149 | |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 150 | static std::set<CompilationType> generateCompilationTypes(const std::set<Arch> selected_architectures, |
| 151 | const std::set<int>& selected_levels) { |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 152 | std::set<CompilationType> result; |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 153 | for (const auto& arch : selected_architectures) { |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 154 | int min_api = arch_min_api[arch]; |
| 155 | for (int api_level : selected_levels) { |
| 156 | if (api_level < min_api) { |
| 157 | continue; |
| 158 | } |
Josh Gao | a77b3a9 | 2016-08-15 16:39:27 -0700 | [diff] [blame] | 159 | |
| 160 | for (int file_offset_bits : { 32, 64 }) { |
| 161 | CompilationType type = { |
| 162 | .arch = arch, .api_level = api_level, .file_offset_bits = file_offset_bits |
| 163 | }; |
| 164 | result.insert(type); |
| 165 | } |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 166 | } |
| 167 | } |
| 168 | return result; |
| 169 | } |
| 170 | |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 171 | static std::unique_ptr<HeaderDatabase> compileHeaders(const std::set<CompilationType>& types, |
George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame^] | 172 | const HeaderLocationInformation& location) { |
Josh Gao | 16016df | 2016-11-07 18:27:16 -0800 | [diff] [blame] | 173 | if (types.empty()) { |
| 174 | errx(1, "compileHeaders received no CompilationTypes"); |
| 175 | } |
| 176 | |
George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame^] | 177 | auto vfs = createCommonVFS(location.header_dir, location.dependency_dir, add_include); |
Josh Gao | 78b8a14 | 2016-11-09 01:00:41 -0800 | [diff] [blame] | 178 | |
Josh Gao | 16016df | 2016-11-07 18:27:16 -0800 | [diff] [blame] | 179 | size_t thread_count = max_thread_count; |
| 180 | std::vector<std::thread> threads; |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 181 | |
| 182 | std::map<CompilationType, HeaderDatabase> header_databases; |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 183 | std::unordered_map<Arch, CompilationRequirements> requirements; |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 184 | |
Josh Gao | 16016df | 2016-11-07 18:27:16 -0800 | [diff] [blame] | 185 | auto result = std::make_unique<HeaderDatabase>(); |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 186 | for (const auto& type : types) { |
| 187 | if (requirements.count(type.arch) == 0) { |
George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame^] | 188 | requirements[type.arch] = collectRequirements(type.arch, location); |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 189 | } |
| 190 | } |
| 191 | |
Josh Gao | 78b8a14 | 2016-11-09 01:00:41 -0800 | [diff] [blame] | 192 | initializeTargetCC1FlagCache(vfs, types, requirements); |
Josh Gao | b5c4963 | 2016-11-08 22:21:31 -0800 | [diff] [blame] | 193 | |
| 194 | std::vector<std::pair<CompilationType, const std::string&>> jobs; |
Josh Gao | 338cf12 | 2016-11-09 18:01:41 -0800 | [diff] [blame] | 195 | std::atomic<size_t> job_index(0); |
Josh Gao | 16016df | 2016-11-07 18:27:16 -0800 | [diff] [blame] | 196 | for (CompilationType type : types) { |
| 197 | CompilationRequirements& req = requirements[type.arch]; |
| 198 | for (const std::string& header : req.headers) { |
Josh Gao | b5c4963 | 2016-11-08 22:21:31 -0800 | [diff] [blame] | 199 | jobs.emplace_back(type, header); |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 200 | } |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 201 | } |
| 202 | |
Josh Gao | b5c4963 | 2016-11-08 22:21:31 -0800 | [diff] [blame] | 203 | thread_count = std::min(thread_count, jobs.size()); |
| 204 | |
| 205 | if (thread_count == 1) { |
| 206 | for (const auto& job : jobs) { |
Josh Gao | 78b8a14 | 2016-11-09 01:00:41 -0800 | [diff] [blame] | 207 | compileHeader(vfs, result.get(), job.first, job.second); |
Josh Gao | b5c4963 | 2016-11-08 22:21:31 -0800 | [diff] [blame] | 208 | } |
| 209 | } else { |
| 210 | // Spawn threads. |
| 211 | for (size_t i = 0; i < thread_count; ++i) { |
Yi Kong | ff6c8de | 2017-04-20 09:08:11 -0700 | [diff] [blame] | 212 | threads.emplace_back([&jobs, &job_index, &result, vfs]() { |
Josh Gao | 338cf12 | 2016-11-09 18:01:41 -0800 | [diff] [blame] | 213 | while (true) { |
| 214 | size_t idx = job_index++; |
| 215 | if (idx >= jobs.size()) { |
| 216 | return; |
| 217 | } |
| 218 | |
| 219 | const auto& job = jobs[idx]; |
Josh Gao | 78b8a14 | 2016-11-09 01:00:41 -0800 | [diff] [blame] | 220 | compileHeader(vfs, result.get(), job.first, job.second); |
Josh Gao | b5c4963 | 2016-11-08 22:21:31 -0800 | [diff] [blame] | 221 | } |
| 222 | }); |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 223 | } |
| 224 | |
Josh Gao | b5c4963 | 2016-11-08 22:21:31 -0800 | [diff] [blame] | 225 | // Reap them. |
| 226 | for (auto& thread : threads) { |
| 227 | thread.join(); |
| 228 | } |
| 229 | threads.clear(); |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 230 | } |
| 231 | |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 232 | return result; |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 233 | } |
| 234 | |
Josh Gao | 1a176de | 2016-11-04 13:15:11 -0700 | [diff] [blame] | 235 | static std::set<CompilationType> getCompilationTypes(const Declaration* decl) { |
| 236 | std::set<CompilationType> result; |
| 237 | for (const auto& it : decl->availability) { |
| 238 | result.insert(it.first); |
| 239 | } |
| 240 | return result; |
| 241 | } |
| 242 | |
| 243 | template<typename T> |
| 244 | static std::vector<T> Intersection(const std::set<T>& a, const std::set<T>& b) { |
| 245 | std::vector<T> intersection; |
| 246 | std::set_intersection(a.begin(), a.end(), b.begin(), b.end(), std::back_inserter(intersection)); |
| 247 | return intersection; |
| 248 | } |
| 249 | |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 250 | // Perform a sanity check on a symbol's declarations, enforcing the following invariants: |
| 251 | // 1. At most one inline definition of the function exists. |
| 252 | // 2. All of the availability declarations for a symbol are compatible. |
| 253 | // If a function is declared as an inline before a certain version, the inline definition |
| 254 | // should have no version tag. |
| 255 | // 3. Each availability type must only be present globally or on a per-arch basis. |
| 256 | // (e.g. __INTRODUCED_IN_ARM(9) __INTRODUCED_IN_X86(10) __DEPRECATED_IN(11) is fine, |
| 257 | // but not __INTRODUCED_IN(9) __INTRODUCED_IN_X86(10)) |
| 258 | static bool checkSymbol(const Symbol& symbol) { |
| 259 | std::string cwd = getWorkingDir() + "/"; |
| 260 | |
Josh Gao | 1a176de | 2016-11-04 13:15:11 -0700 | [diff] [blame] | 261 | std::unordered_map<const Declaration*, std::set<CompilationType>> inline_definitions; |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 262 | for (const auto& decl_it : symbol.declarations) { |
| 263 | const Declaration* decl = &decl_it.second; |
| 264 | if (decl->is_definition) { |
Josh Gao | 1a176de | 2016-11-04 13:15:11 -0700 | [diff] [blame] | 265 | std::set<CompilationType> compilation_types = getCompilationTypes(decl); |
| 266 | for (const auto& inline_def_it : inline_definitions) { |
| 267 | auto intersection = Intersection(compilation_types, inline_def_it.second); |
| 268 | if (!intersection.empty()) { |
| 269 | fprintf(stderr, "versioner: conflicting inline definitions:\n"); |
| 270 | fprintf(stderr, " declarations visible in: %s\n", Join(intersection, ", ").c_str()); |
| 271 | decl->dump(cwd, stderr, 4); |
| 272 | inline_def_it.first->dump(cwd, stderr, 4); |
| 273 | return false; |
| 274 | } |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 275 | } |
| 276 | |
Josh Gao | 1a176de | 2016-11-04 13:15:11 -0700 | [diff] [blame] | 277 | inline_definitions[decl] = std::move(compilation_types); |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | DeclarationAvailability availability; |
| 281 | if (!decl->calculateAvailability(&availability)) { |
| 282 | fprintf(stderr, "versioner: failed to calculate availability for declaration:\n"); |
Josh Gao | 566735d | 2016-08-02 15:07:32 -0700 | [diff] [blame] | 283 | decl->dump(cwd, stderr, 2); |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 284 | return false; |
| 285 | } |
| 286 | |
| 287 | if (decl->is_definition && !availability.empty()) { |
| 288 | fprintf(stderr, "versioner: inline definition has non-empty versioning information:\n"); |
Josh Gao | 566735d | 2016-08-02 15:07:32 -0700 | [diff] [blame] | 289 | decl->dump(cwd, stderr, 2); |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 290 | return false; |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | DeclarationAvailability availability; |
| 295 | if (!symbol.calculateAvailability(&availability)) { |
| 296 | fprintf(stderr, "versioner: inconsistent availability for symbol '%s'\n", symbol.name.c_str()); |
| 297 | symbol.dump(cwd); |
| 298 | return false; |
| 299 | } |
| 300 | |
| 301 | // TODO: Check invariant #3. |
| 302 | return true; |
| 303 | } |
| 304 | |
| 305 | static bool sanityCheck(const HeaderDatabase* database) { |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 306 | bool error = false; |
Josh Gao | 958f3b3 | 2016-06-03 13:44:00 -0700 | [diff] [blame] | 307 | std::string cwd = getWorkingDir() + "/"; |
| 308 | |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 309 | for (const auto& symbol_it : database->symbols) { |
| 310 | if (!checkSymbol(symbol_it.second)) { |
| 311 | error = true; |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 312 | } |
| 313 | } |
| 314 | return !error; |
| 315 | } |
| 316 | |
| 317 | // Check that our symbol availability declarations match the actual NDK |
| 318 | // platform symbol availability. |
| 319 | static bool checkVersions(const std::set<CompilationType>& types, |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 320 | const HeaderDatabase* header_database, |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 321 | const NdkSymbolDatabase& symbol_database) { |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 322 | std::string cwd = getWorkingDir() + "/"; |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 323 | bool failed = false; |
| 324 | |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 325 | std::map<Arch, std::set<CompilationType>> arch_types; |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 326 | for (const CompilationType& type : types) { |
| 327 | arch_types[type.arch].insert(type); |
| 328 | } |
| 329 | |
Josh Gao | d67dbf0 | 2016-06-02 15:21:14 -0700 | [diff] [blame] | 330 | std::set<std::string> completely_unavailable; |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 331 | std::map<std::string, std::set<CompilationType>> missing_availability; |
| 332 | std::map<std::string, std::set<CompilationType>> extra_availability; |
Josh Gao | d67dbf0 | 2016-06-02 15:21:14 -0700 | [diff] [blame] | 333 | |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 334 | for (const auto& symbol_it : header_database->symbols) { |
| 335 | const auto& symbol_name = symbol_it.first; |
| 336 | DeclarationAvailability symbol_availability; |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 337 | |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 338 | if (!symbol_it.second.calculateAvailability(&symbol_availability)) { |
| 339 | errx(1, "failed to calculate symbol availability"); |
| 340 | } |
| 341 | |
| 342 | const auto platform_availability_it = symbol_database.find(symbol_name); |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 343 | if (platform_availability_it == symbol_database.end()) { |
Josh Gao | d67dbf0 | 2016-06-02 15:21:14 -0700 | [diff] [blame] | 344 | completely_unavailable.insert(symbol_name); |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 345 | continue; |
| 346 | } |
| 347 | |
| 348 | const auto& platform_availability = platform_availability_it->second; |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 349 | |
| 350 | for (const CompilationType& type : types) { |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 351 | bool should_be_available = true; |
| 352 | const auto& global_availability = symbol_availability.global_availability; |
| 353 | const auto& arch_availability = symbol_availability.arch_availability[type.arch]; |
| 354 | if (global_availability.introduced != 0 && global_availability.introduced > type.api_level) { |
| 355 | should_be_available = false; |
| 356 | } |
| 357 | |
| 358 | if (arch_availability.introduced != 0 && arch_availability.introduced > type.api_level) { |
| 359 | should_be_available = false; |
| 360 | } |
| 361 | |
| 362 | if (global_availability.obsoleted != 0 && global_availability.obsoleted <= type.api_level) { |
| 363 | should_be_available = false; |
| 364 | } |
| 365 | |
| 366 | if (arch_availability.obsoleted != 0 && arch_availability.obsoleted <= type.api_level) { |
| 367 | should_be_available = false; |
| 368 | } |
| 369 | |
| 370 | if (arch_availability.future) { |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 371 | continue; |
| 372 | } |
| 373 | |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 374 | // The function declaration might be (validly) missing for the given CompilationType. |
| 375 | if (!symbol_it.second.hasDeclaration(type)) { |
| 376 | should_be_available = false; |
| 377 | } |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 378 | |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 379 | bool is_available = platform_availability.count(type); |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 380 | |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 381 | if (should_be_available != is_available) { |
| 382 | if (is_available) { |
| 383 | extra_availability[symbol_name].insert(type); |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 384 | } else { |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 385 | missing_availability[symbol_name].insert(type); |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 386 | } |
| 387 | } |
| 388 | } |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 389 | } |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 390 | |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 391 | for (const auto& it : symbol_database) { |
| 392 | const std::string& symbol_name = it.first; |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 393 | |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 394 | bool symbol_error = false; |
Josh Gao | 0a284f5 | 2016-12-15 13:56:00 -0800 | [diff] [blame] | 395 | if (auto missing_it = missing_availability.find(symbol_name); |
| 396 | missing_it != missing_availability.end()) { |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 397 | printf("%s: declaration marked available but symbol missing in [%s]\n", symbol_name.c_str(), |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 398 | Join(missing_it->second, ", ").c_str()); |
| 399 | symbol_error = true; |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 400 | failed = true; |
| 401 | } |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 402 | |
Josh Gao | acc3d80 | 2016-11-09 18:22:44 -0800 | [diff] [blame] | 403 | if (strict) { |
Josh Gao | 0a284f5 | 2016-12-15 13:56:00 -0800 | [diff] [blame] | 404 | if (auto extra_it = extra_availability.find(symbol_name); |
| 405 | extra_it != extra_availability.end()) { |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 406 | printf("%s: declaration marked unavailable but symbol available in [%s]\n", |
| 407 | symbol_name.c_str(), Join(extra_it->second, ", ").c_str()); |
| 408 | symbol_error = true; |
| 409 | failed = true; |
Josh Gao | 958f3b3 | 2016-06-03 13:44:00 -0700 | [diff] [blame] | 410 | } |
| 411 | } |
| 412 | |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 413 | if (symbol_error) { |
Josh Gao | 0a284f5 | 2016-12-15 13:56:00 -0800 | [diff] [blame] | 414 | if (auto symbol_it = header_database->symbols.find(symbol_name); |
| 415 | symbol_it != header_database->symbols.end()) { |
| 416 | symbol_it->second.dump(cwd); |
| 417 | } else { |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 418 | errx(1, "failed to find symbol in header database"); |
| 419 | } |
Josh Gao | d67dbf0 | 2016-06-02 15:21:14 -0700 | [diff] [blame] | 420 | } |
Josh Gao | d67dbf0 | 2016-06-02 15:21:14 -0700 | [diff] [blame] | 421 | } |
| 422 | |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 423 | // TODO: Verify that function/variable declarations are actually function/variable symbols. |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 424 | return !failed; |
| 425 | } |
| 426 | |
Josh Gao | 62aaf8f | 2016-06-02 14:27:21 -0700 | [diff] [blame] | 427 | static void usage(bool help = false) { |
| 428 | fprintf(stderr, "Usage: versioner [OPTION]... [HEADER_PATH] [DEPS_PATH]\n"); |
| 429 | if (!help) { |
| 430 | printf("Try 'versioner -h' for more information.\n"); |
| 431 | exit(1); |
| 432 | } else { |
| 433 | fprintf(stderr, "Version headers at HEADER_PATH, with DEPS_PATH/ARCH/* on the include path\n"); |
Josh Gao | 9b5af7a | 2016-06-02 14:29:13 -0700 | [diff] [blame] | 434 | fprintf(stderr, "Autodetects paths if HEADER_PATH and DEPS_PATH are not specified\n"); |
Josh Gao | 62aaf8f | 2016-06-02 14:27:21 -0700 | [diff] [blame] | 435 | fprintf(stderr, "\n"); |
| 436 | fprintf(stderr, "Target specification (defaults to all):\n"); |
| 437 | fprintf(stderr, " -a API_LEVEL\tbuild with specified API level (can be repeated)\n"); |
| 438 | fprintf(stderr, " \t\tvalid levels are %s\n", Join(supported_levels).c_str()); |
| 439 | fprintf(stderr, " -r ARCH\tbuild with specified architecture (can be repeated)\n"); |
| 440 | fprintf(stderr, " \t\tvalid architectures are %s\n", Join(supported_archs).c_str()); |
| 441 | fprintf(stderr, "\n"); |
| 442 | fprintf(stderr, "Validation:\n"); |
| 443 | fprintf(stderr, " -p PATH\tcompare against NDK platform at PATH\n"); |
Josh Gao | acc3d80 | 2016-11-09 18:22:44 -0800 | [diff] [blame] | 444 | fprintf(stderr, " -s\t\tenable strict warnings\n"); |
Josh Gao | 62aaf8f | 2016-06-02 14:27:21 -0700 | [diff] [blame] | 445 | fprintf(stderr, "\n"); |
Josh Gao | f8592a3 | 2016-07-26 18:58:27 -0700 | [diff] [blame] | 446 | fprintf(stderr, "Preprocessing:\n"); |
| 447 | fprintf(stderr, " -o PATH\tpreprocess header files and emit them at PATH\n"); |
Josh Gao | d744a9b | 2017-04-03 11:24:48 -0700 | [diff] [blame] | 448 | fprintf(stderr, " -f\t\tpreprocess header files even if validation fails\n"); |
Josh Gao | f8592a3 | 2016-07-26 18:58:27 -0700 | [diff] [blame] | 449 | fprintf(stderr, "\n"); |
Josh Gao | 62aaf8f | 2016-06-02 14:27:21 -0700 | [diff] [blame] | 450 | fprintf(stderr, "Miscellaneous:\n"); |
George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame^] | 451 | fprintf(stderr, " -F\t\tdo not ignore FORTIFY headers by default\n"); |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 452 | fprintf(stderr, " -d\t\tdump function availability\n"); |
Josh Gao | 16016df | 2016-11-07 18:27:16 -0800 | [diff] [blame] | 453 | fprintf(stderr, " -j THREADS\tmaximum number of threads to use\n"); |
Josh Gao | acc3d80 | 2016-11-09 18:22:44 -0800 | [diff] [blame] | 454 | fprintf(stderr, " -v\t\tenable verbose logging\n"); |
Josh Gao | 62aaf8f | 2016-06-02 14:27:21 -0700 | [diff] [blame] | 455 | fprintf(stderr, " -h\t\tdisplay this message\n"); |
| 456 | exit(0); |
| 457 | } |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 458 | } |
| 459 | |
Andreas Gampe | d10d3ee | 2017-04-28 19:32:13 -0700 | [diff] [blame] | 460 | // versioner uses a prebuilt version of clang, which is not up-to-date wrt/ |
| 461 | // container annotations. So disable container overflow checking. b/37775238 |
| 462 | extern "C" const char* __asan_default_options() { |
| 463 | return "detect_container_overflow=0"; |
| 464 | } |
| 465 | |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 466 | int main(int argc, char** argv) { |
| 467 | std::string cwd = getWorkingDir() + "/"; |
| 468 | bool default_args = true; |
| 469 | std::string platform_dir; |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 470 | std::set<Arch> selected_architectures; |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 471 | std::set<int> selected_levels; |
Josh Gao | f8592a3 | 2016-07-26 18:58:27 -0700 | [diff] [blame] | 472 | std::string preprocessor_output_path; |
| 473 | bool force = false; |
Josh Gao | 16016df | 2016-11-07 18:27:16 -0800 | [diff] [blame] | 474 | bool dump = false; |
George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame^] | 475 | bool ignore_fortify_headers = true; |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 476 | |
| 477 | int c; |
George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame^] | 478 | while ((c = getopt(argc, argv, "a:r:p:so:fdj:vhFi")) != -1) { |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 479 | default_args = false; |
| 480 | switch (c) { |
| 481 | case 'a': { |
| 482 | char* end; |
| 483 | int api_level = strtol(optarg, &end, 10); |
| 484 | if (end == optarg || strlen(end) > 0) { |
| 485 | usage(); |
| 486 | } |
| 487 | |
| 488 | if (supported_levels.count(api_level) == 0) { |
| 489 | errx(1, "unsupported API level %d", api_level); |
| 490 | } |
| 491 | |
| 492 | selected_levels.insert(api_level); |
| 493 | break; |
| 494 | } |
| 495 | |
| 496 | case 'r': { |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 497 | Arch arch = arch_from_string(optarg); |
| 498 | selected_architectures.insert(arch); |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 499 | break; |
| 500 | } |
| 501 | |
| 502 | case 'p': { |
| 503 | if (!platform_dir.empty()) { |
| 504 | usage(); |
| 505 | } |
| 506 | |
| 507 | platform_dir = optarg; |
| 508 | |
Josh Gao | f8592a3 | 2016-07-26 18:58:27 -0700 | [diff] [blame] | 509 | if (platform_dir.empty()) { |
| 510 | usage(); |
| 511 | } |
| 512 | |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 513 | struct stat st; |
| 514 | if (stat(platform_dir.c_str(), &st) != 0) { |
| 515 | err(1, "failed to stat platform directory '%s'", platform_dir.c_str()); |
| 516 | } |
| 517 | if (!S_ISDIR(st.st_mode)) { |
| 518 | errx(1, "'%s' is not a directory", optarg); |
| 519 | } |
| 520 | break; |
| 521 | } |
| 522 | |
Josh Gao | acc3d80 | 2016-11-09 18:22:44 -0800 | [diff] [blame] | 523 | case 's': |
| 524 | strict = true; |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 525 | break; |
| 526 | |
Josh Gao | f8592a3 | 2016-07-26 18:58:27 -0700 | [diff] [blame] | 527 | case 'o': |
| 528 | if (!preprocessor_output_path.empty()) { |
| 529 | usage(); |
| 530 | } |
| 531 | preprocessor_output_path = optarg; |
| 532 | if (preprocessor_output_path.empty()) { |
| 533 | usage(); |
| 534 | } |
| 535 | break; |
| 536 | |
| 537 | case 'f': |
| 538 | force = true; |
| 539 | break; |
| 540 | |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 541 | case 'd': |
| 542 | dump = true; |
| 543 | break; |
| 544 | |
Josh Gao | 16016df | 2016-11-07 18:27:16 -0800 | [diff] [blame] | 545 | case 'j': |
| 546 | if (!android::base::ParseInt<int>(optarg, &max_thread_count, 1)) { |
| 547 | usage(); |
| 548 | } |
| 549 | break; |
| 550 | |
Josh Gao | acc3d80 | 2016-11-09 18:22:44 -0800 | [diff] [blame] | 551 | case 'v': |
| 552 | verbose = true; |
| 553 | break; |
| 554 | |
Josh Gao | 62aaf8f | 2016-06-02 14:27:21 -0700 | [diff] [blame] | 555 | case 'h': |
| 556 | usage(true); |
| 557 | break; |
| 558 | |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 559 | case 'i': |
| 560 | // Secret option for tests to -include <android/versioning.h>. |
| 561 | add_include = true; |
| 562 | break; |
| 563 | |
George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame^] | 564 | case 'F': |
| 565 | ignore_fortify_headers = false; |
| 566 | break; |
| 567 | |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 568 | default: |
| 569 | usage(); |
| 570 | break; |
| 571 | } |
| 572 | } |
| 573 | |
Josh Gao | 9b5af7a | 2016-06-02 14:29:13 -0700 | [diff] [blame] | 574 | if (argc - optind > 2 || optind > argc) { |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 575 | usage(); |
| 576 | } |
| 577 | |
George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame^] | 578 | HeaderLocationInformation location; |
Josh Gao | 9b5af7a | 2016-06-02 14:29:13 -0700 | [diff] [blame] | 579 | |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 580 | const char* top = getenv("ANDROID_BUILD_TOP"); |
| 581 | if (!top && (optind == argc || add_include)) { |
| 582 | fprintf(stderr, "versioner: failed to autodetect bionic paths. Is ANDROID_BUILD_TOP set?\n"); |
| 583 | usage(); |
| 584 | } |
| 585 | |
Josh Gao | 9b5af7a | 2016-06-02 14:29:13 -0700 | [diff] [blame] | 586 | if (optind == argc) { |
| 587 | // Neither HEADER_PATH nor DEPS_PATH were specified, so try to figure them out. |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 588 | std::string versioner_dir = to_string(top) + "/bionic/tools/versioner"; |
George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame^] | 589 | location.header_dir = versioner_dir + "/current"; |
| 590 | location.dependency_dir = versioner_dir + "/dependencies"; |
Josh Gao | 9b5af7a | 2016-06-02 14:29:13 -0700 | [diff] [blame] | 591 | if (platform_dir.empty()) { |
| 592 | platform_dir = versioner_dir + "/platforms"; |
| 593 | } |
| 594 | } else { |
George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame^] | 595 | if (!android::base::Realpath(argv[optind], &location.header_dir)) { |
Josh Gao | b50b8c8 | 2017-04-27 17:22:52 -0700 | [diff] [blame] | 596 | err(1, "failed to get realpath for path '%s'", argv[optind]); |
| 597 | } |
Josh Gao | 9b5af7a | 2016-06-02 14:29:13 -0700 | [diff] [blame] | 598 | |
| 599 | if (argc - optind == 2) { |
George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame^] | 600 | location.dependency_dir = argv[optind + 1]; |
Josh Gao | 9b5af7a | 2016-06-02 14:29:13 -0700 | [diff] [blame] | 601 | } |
| 602 | } |
| 603 | |
George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame^] | 604 | // Every file that lives in bits/fortify is logically a part of a header outside of bits/fortify. |
| 605 | // This makes the files there impossible to build on their own. |
| 606 | if (ignore_fortify_headers) { |
| 607 | std::string fortify_path = location.header_dir; |
| 608 | if (!android::base::EndsWith(location.header_dir, "/")) { |
| 609 | fortify_path += '/'; |
| 610 | } |
| 611 | fortify_path += "bits/fortify"; |
| 612 | location.ignored_directories.insert(std::move(fortify_path)); |
| 613 | } |
| 614 | |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 615 | if (selected_levels.empty()) { |
| 616 | selected_levels = supported_levels; |
| 617 | } |
| 618 | |
| 619 | if (selected_architectures.empty()) { |
| 620 | selected_architectures = supported_archs; |
| 621 | } |
| 622 | |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 623 | |
| 624 | struct stat st; |
George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame^] | 625 | if (const char *dir = location.header_dir.c_str(); stat(dir, &st) != 0) { |
| 626 | err(1, "failed to stat '%s'", dir); |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 627 | } else if (!S_ISDIR(st.st_mode)) { |
George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame^] | 628 | errx(1, "'%s' is not a directory", dir); |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 629 | } |
| 630 | |
| 631 | std::set<CompilationType> compilation_types; |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 632 | NdkSymbolDatabase symbol_database; |
| 633 | |
| 634 | compilation_types = generateCompilationTypes(selected_architectures, selected_levels); |
| 635 | |
| 636 | // Do this before compiling so that we can early exit if the platforms don't match what we |
| 637 | // expect. |
| 638 | if (!platform_dir.empty()) { |
| 639 | symbol_database = parsePlatforms(compilation_types, platform_dir); |
| 640 | } |
| 641 | |
Josh Gao | 338cf12 | 2016-11-09 18:01:41 -0800 | [diff] [blame] | 642 | auto start = std::chrono::high_resolution_clock::now(); |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 643 | std::unique_ptr<HeaderDatabase> declaration_database = |
George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame^] | 644 | compileHeaders(compilation_types, location); |
Josh Gao | 338cf12 | 2016-11-09 18:01:41 -0800 | [diff] [blame] | 645 | auto end = std::chrono::high_resolution_clock::now(); |
| 646 | |
| 647 | if (verbose) { |
| 648 | auto diff = (end - start) / 1.0ms; |
| 649 | printf("Compiled headers for %zu targets in %0.2LFms\n", compilation_types.size(), diff); |
| 650 | } |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 651 | |
Josh Gao | 16016df | 2016-11-07 18:27:16 -0800 | [diff] [blame] | 652 | bool failed = false; |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 653 | if (dump) { |
George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame^] | 654 | declaration_database->dump(location.header_dir + "/"); |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 655 | } else { |
| 656 | if (!sanityCheck(declaration_database.get())) { |
| 657 | printf("versioner: sanity check failed\n"); |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 658 | failed = true; |
| 659 | } |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 660 | |
Josh Gao | bfb6bae | 2016-07-15 17:25:21 -0700 | [diff] [blame] | 661 | if (!platform_dir.empty()) { |
| 662 | if (!checkVersions(compilation_types, declaration_database.get(), symbol_database)) { |
| 663 | printf("versioner: version check failed\n"); |
| 664 | failed = true; |
| 665 | } |
| 666 | } |
| 667 | } |
Josh Gao | f8592a3 | 2016-07-26 18:58:27 -0700 | [diff] [blame] | 668 | |
| 669 | if (!preprocessor_output_path.empty() && (force || !failed)) { |
George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame^] | 670 | failed = !preprocessHeaders(preprocessor_output_path, location.header_dir, declaration_database.get()); |
Josh Gao | f8592a3 | 2016-07-26 18:58:27 -0700 | [diff] [blame] | 671 | } |
Josh Gao | bf8a285 | 2016-05-27 11:59:09 -0700 | [diff] [blame] | 672 | return failed; |
| 673 | } |