summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ryan Mitchell <rtmitchell@google.com> 2019-02-26 21:48:08 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-02-26 21:48:08 +0000
commit1b05ef9cc16424af6f3657cf4538c4fb3e40f89a (patch)
treead99caa1a6cfa75fb311008af9349620bc606298
parent4d7b766376cc5cab42bf312afbf2ed2136392936 (diff)
parentf22ed8dc0ec107cb0e80eb25c7de4094c7f5301e (diff)
Merge "Sort inputs to compile and link"
-rw-r--r--tools/aapt2/cmd/Compile.cpp5
-rw-r--r--tools/aapt2/io/FileSystem.cpp8
2 files changed, 11 insertions, 2 deletions
diff --git a/tools/aapt2/cmd/Compile.cpp b/tools/aapt2/cmd/Compile.cpp
index 0512bdc5bf72..bec6c6973613 100644
--- a/tools/aapt2/cmd/Compile.cpp
+++ b/tools/aapt2/cmd/Compile.cpp
@@ -769,7 +769,10 @@ int CompileCommand::Action(const std::vector<std::string>& args) {
auto collection = util::make_unique<io::FileCollection>();
// Collect data from the path for each input file.
- for (const std::string& arg : args) {
+ std::vector<std::string> sorted_args = args;
+ std::sort(sorted_args.begin(), sorted_args.end());
+
+ for (const std::string& arg : sorted_args) {
collection->InsertFile(arg);
}
diff --git a/tools/aapt2/io/FileSystem.cpp b/tools/aapt2/io/FileSystem.cpp
index 51cc9032fb3e..e15f935cad27 100644
--- a/tools/aapt2/io/FileSystem.cpp
+++ b/tools/aapt2/io/FileSystem.cpp
@@ -79,6 +79,7 @@ std::unique_ptr<FileCollection> FileCollection::Create(const android::StringPiec
return nullptr;
}
+ std::vector<std::string> sorted_files;
while (struct dirent *entry = readdir(d.get())) {
std::string prefix_path = root.to_string();
file::AppendPath(&prefix_path, entry->d_name);
@@ -105,10 +106,15 @@ std::unique_ptr<FileCollection> FileCollection::Create(const android::StringPiec
continue;
}
- collection->InsertFile(full_path);
+ sorted_files.push_back(full_path);
}
}
+ std::sort(sorted_files.begin(), sorted_files.end());
+ for (const std::string& full_path : sorted_files) {
+ collection->InsertFile(full_path);
+ }
+
return collection;
}