diff --git a/tools/versioner/platforms b/tools/versioner/platforms deleted file mode 120000 index bcb7da88d..000000000 --- a/tools/versioner/platforms +++ /dev/null @@ -1 +0,0 @@ -../../../development/ndk/platforms \ No newline at end of file diff --git a/tools/versioner/src/SymbolDatabase.cpp b/tools/versioner/src/SymbolDatabase.cpp index 8521f4ddf..5b8ed5ab4 100644 --- a/tools/versioner/src/SymbolDatabase.cpp +++ b/tools/versioner/src/SymbolDatabase.cpp @@ -61,91 +61,3 @@ std::unordered_set getSymbols(const std::string& filename) { return result; } - -// The NDK platforms are built by copying the platform directories on top of -// each other to build each successive API version. Thus, we need to walk -// backwards to find each desired file. -static std::string readPlatformFile(const CompilationType& type, llvm::StringRef platform_dir, - const std::string& filename, bool required) { - int api_level = type.api_level; - std::ifstream stream; - while (api_level >= arch_min_api[type.arch]) { - std::string path = std::string(platform_dir) + "/android-" + std::to_string(api_level) + - "/arch-" + to_string(type.arch) + "/symbols/" + filename; - - stream = std::ifstream(path); - if (stream) { - return std::string(std::istreambuf_iterator(stream), std::istreambuf_iterator()); - } - - --api_level; - } - - if (required) { - errx(1, "failed to find platform file '%s' for %s", filename.c_str(), to_string(type).c_str()); - } - - return std::string(); -} - -static std::map parsePlatform(const CompilationType& type, - const std::string& platform_dir) { - std::map result; - std::map wanted_files = { - { "libc.so.functions.txt", true }, - { "libc.so.variables.txt", false }, - { "libdl.so.functions.txt", false }, - { "libm.so.functions.txt", false }, - { "libm.so.variables.txt", false }, - }; - - for (const auto& pair : wanted_files) { - llvm::StringRef file = pair.first; - bool required = pair.second; - NdkSymbolType symbol_type; - if (file.endswith(".functions.txt")) { - symbol_type = NdkSymbolType::function; - } else if (file.endswith(".variables.txt")) { - symbol_type = NdkSymbolType::variable; - } else { - errx(1, "internal error: unexpected platform filename '%s'\n", file.str().c_str()); - } - - std::string platform_file = readPlatformFile(type, platform_dir, file, required); - if (platform_file.empty()) { - continue; - } - - llvm::SmallVector symbols; - llvm::StringRef(platform_file).split(symbols, "\n"); - - for (llvm::StringRef symbol_name : symbols) { - if (symbol_name.empty()) { - continue; - } - - if (result.count(symbol_name) != 0) { - if (strict) { - printf("duplicated symbol '%s' in '%s'\n", symbol_name.str().c_str(), file.str().c_str()); - } - } - - result[symbol_name] = symbol_type; - } - } - - return result; -} - -NdkSymbolDatabase parsePlatforms(const std::set& types, - const std::string& platform_dir) { - std::map> result; - for (const CompilationType& type : types) { - std::map symbols = parsePlatform(type, platform_dir); - for (const auto& it : symbols) { - result[it.first][type] = it.second; - } - } - - return result; -} diff --git a/tools/versioner/src/SymbolDatabase.h b/tools/versioner/src/SymbolDatabase.h index 09948f55f..c5b89d7ae 100644 --- a/tools/versioner/src/SymbolDatabase.h +++ b/tools/versioner/src/SymbolDatabase.h @@ -32,5 +32,3 @@ enum class NdkSymbolType { }; using NdkSymbolDatabase = std::map>; -NdkSymbolDatabase parsePlatforms(const std::set& types, - const std::string& platform_dir); diff --git a/tools/versioner/src/versioner.cpp b/tools/versioner/src/versioner.cpp index a082f07c9..efb39bd83 100644 --- a/tools/versioner/src/versioner.cpp +++ b/tools/versioner/src/versioner.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -614,9 +615,6 @@ int main(int argc, char** argv) { std::string versioner_dir = to_string(top) + "/bionic/tools/versioner"; location.header_path = versioner_dir + "/current"; location.dependency_dir = versioner_dir + "/dependencies"; - if (platform_dir.empty()) { - platform_dir = versioner_dir + "/platforms"; - } } else { if (!android::base::Realpath(argv[optind], &location.header_path)) { err(1, "failed to get realpath for path '%s'", argv[optind]); @@ -653,16 +651,10 @@ int main(int argc, char** argv) { } std::set compilation_types; - NdkSymbolDatabase symbol_database; + std::optional symbol_database; compilation_types = generateCompilationTypes(selected_architectures, selected_levels); - // Do this before compiling so that we can early exit if the platforms don't match what we - // expect. - if (!platform_dir.empty()) { - symbol_database = parsePlatforms(compilation_types, platform_dir); - } - auto start = std::chrono::high_resolution_clock::now(); std::unique_ptr declaration_database = compileHeaders(compilation_types, location); @@ -682,8 +674,8 @@ int main(int argc, char** argv) { failed = true; } - if (!platform_dir.empty()) { - if (!checkVersions(compilation_types, declaration_database.get(), symbol_database)) { + if (symbol_database) { + if (!checkVersions(compilation_types, declaration_database.get(), *symbol_database)) { printf("versioner: version check failed\n"); failed = true; }