diff options
Diffstat (limited to 'tools/aapt2/cmd/Link.cpp')
-rw-r--r-- | tools/aapt2/cmd/Link.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/aapt2/cmd/Link.cpp b/tools/aapt2/cmd/Link.cpp index a7b8d2535e79..f354bb610224 100644 --- a/tools/aapt2/cmd/Link.cpp +++ b/tools/aapt2/cmd/Link.cpp @@ -67,6 +67,7 @@ #include "process/IResourceTableConsumer.h" #include "process/SymbolTable.h" #include "split/TableSplitter.h" +#include "trace/TraceBuffer.h" #include "util/Files.h" #include "xml/XmlDom.h" @@ -213,6 +214,7 @@ class FeatureSplitSymbolTableDelegate : public DefaultSymbolTableDelegate { static bool FlattenXml(IAaptContext* context, const xml::XmlResource& xml_res, const StringPiece& path, bool keep_raw_values, bool utf16, OutputFormat format, IArchiveWriter* writer) { + TRACE_CALL(); if (context->IsVerbose()) { context->GetDiagnostics()->Note(DiagMessage(path) << "writing to archive (keep_raw_values=" << (keep_raw_values ? "true" : "false") @@ -250,6 +252,7 @@ static bool FlattenXml(IAaptContext* context, const xml::XmlResource& xml_res, // Inflates an XML file from the source path. static std::unique_ptr<xml::XmlResource> LoadXml(const std::string& path, IDiagnostics* diag) { + TRACE_CALL(); FileInputStream fin(path); if (fin.HadError()) { diag->Error(DiagMessage(path) << "failed to load XML file: " << fin.GetError()); @@ -421,6 +424,7 @@ std::vector<T> make_singleton_vec(T&& val) { std::vector<std::unique_ptr<xml::XmlResource>> ResourceFileFlattener::LinkAndVersionXmlFile( ResourceTable* table, FileOperation* file_op) { + TRACE_CALL(); xml::XmlResource* doc = file_op->xml_to_flatten.get(); const Source& src = doc->file.source; @@ -489,6 +493,7 @@ static auto kDrawableVersions = std::map<std::string, ApiVersion>{ }; bool ResourceFileFlattener::Flatten(ResourceTable* table, IArchiveWriter* archive_writer) { + TRACE_CALL(); bool error = false; std::map<std::pair<ConfigDescription, StringPiece>, FileOperation> config_sorted_files; @@ -806,6 +811,7 @@ class Linker { // Creates a SymbolTable that loads symbols from the various APKs. // Pre-condition: context_->GetCompilationPackage() needs to be set. bool LoadSymbolsFromIncludePaths() { + TRACE_NAME("LoadSymbolsFromIncludePaths: #" + std::to_string(options_.include_paths.size())); auto asset_source = util::make_unique<AssetManagerSymbolSource>(); for (const std::string& path : options_.include_paths) { if (context_->IsVerbose()) { @@ -891,6 +897,7 @@ class Linker { } Maybe<AppInfo> ExtractAppInfoFromManifest(xml::XmlResource* xml_res, IDiagnostics* diag) { + TRACE_CALL(); // Make sure the first element is <manifest> with package attribute. xml::Element* manifest_el = xml::FindRootElement(xml_res->root.get()); if (manifest_el == nullptr) { @@ -1041,6 +1048,7 @@ class Linker { } bool FlattenTable(ResourceTable* table, OutputFormat format, IArchiveWriter* writer) { + TRACE_CALL(); switch (format) { case OutputFormat::kApk: { BigBuffer buffer(1024); @@ -1114,6 +1122,7 @@ class Linker { } bool GenerateJavaClasses() { + TRACE_CALL(); // The set of packages whose R class to call in the main classes onResourcesLoaded callback. std::vector<std::string> packages_to_callback; @@ -1197,6 +1206,7 @@ class Linker { } bool WriteManifestJavaFile(xml::XmlResource* manifest_xml) { + TRACE_CALL(); if (!options_.generate_java_class_path) { return true; } @@ -1254,6 +1264,7 @@ class Linker { } bool WriteProguardFile(const Maybe<std::string>& out, const proguard::KeepSet& keep_set) { + TRACE_CALL(); if (!out) { return true; } @@ -1278,6 +1289,7 @@ class Linker { } bool MergeStaticLibrary(const std::string& input, bool override) { + TRACE_CALL(); if (context_->IsVerbose()) { context_->GetDiagnostics()->Note(DiagMessage() << "merging static library " << input); } @@ -1328,6 +1340,7 @@ class Linker { bool MergeExportedSymbols(const Source& source, const std::vector<SourcedResourceName>& exported_symbols) { + TRACE_CALL(); // Add the exports of this file to the table. for (const SourcedResourceName& exported_symbol : exported_symbols) { ResourceName res_name = exported_symbol.name; @@ -1353,6 +1366,7 @@ class Linker { } bool MergeCompiledFile(const ResourceFile& compiled_file, io::IFile* file, bool override) { + TRACE_CALL(); if (context_->IsVerbose()) { context_->GetDiagnostics()->Note(DiagMessage() << "merging '" << compiled_file.name @@ -1371,6 +1385,7 @@ class Linker { // An io::IFileCollection is created from the ZIP file and added to the set of // io::IFileCollections that are open. bool MergeArchive(const std::string& input, bool override) { + TRACE_CALL(); if (context_->IsVerbose()) { context_->GetDiagnostics()->Note(DiagMessage() << "merging archive " << input); } @@ -1418,6 +1433,7 @@ class Linker { // All other file types are ignored. This is because these files could be coming from a zip, // where we could have other files like classes.dex. bool MergeFile(io::IFile* file, bool override) { + TRACE_CALL(); const Source& src = file->GetSource(); if (util::EndsWith(src.path, ".xml") || util::EndsWith(src.path, ".png")) { @@ -1458,6 +1474,7 @@ class Linker { while ((entry = reader.Next()) != nullptr) { if (entry->Type() == ContainerEntryType::kResTable) { + TRACE_NAME(std::string("Process ResTable:") + file->GetSource().path); pb::ResourceTable pb_table; if (!entry->GetResTable(&pb_table)) { context_->GetDiagnostics()->Error(DiagMessage(src) << "failed to read resource table: " @@ -1478,6 +1495,7 @@ class Linker { return false; } } else if (entry->Type() == ContainerEntryType::kResFile) { + TRACE_NAME(std::string("Process ResFile") + file->GetSource().path); pb::internal::CompiledFile pb_compiled_file; off64_t offset; size_t len; @@ -1551,6 +1569,7 @@ class Linker { // to the IArchiveWriter. bool WriteApk(IArchiveWriter* writer, proguard::KeepSet* keep_set, xml::XmlResource* manifest, ResourceTable* table) { + TRACE_CALL(); const bool keep_raw_values = (context_->GetPackageType() == PackageType::kStaticLib) || options_.keep_raw_values; bool result = FlattenXml(context_, *manifest, kAndroidManifestPath, keep_raw_values, @@ -1632,6 +1651,7 @@ class Linker { } int Run(const std::vector<std::string>& input_files) { + TRACE_CALL(); // Load the AndroidManifest.xml std::unique_ptr<xml::XmlResource> manifest_xml = LoadXml(options_.manifest_path, context_->GetDiagnostics()); @@ -1839,6 +1859,7 @@ class Linker { std::vector<ConfigDescription> excluded_configs; for (auto& config_string : options_.exclude_configs_) { + TRACE_NAME("ConfigDescription::Parse"); ConfigDescription config_description; if (!ConfigDescription::Parse(config_string, &config_description)) { @@ -2038,6 +2059,7 @@ class Linker { }; int LinkCommand::Action(const std::vector<std::string>& args) { + TRACE_FLUSH(trace_folder_ ? trace_folder_.value() : "", "LinkCommand::Action"); LinkContext context(diag_); // Expand all argument-files passed into the command line. These start with '@'. |