diff options
author | Ryan Mitchell <rtmitchell@google.com> | 2019-02-20 08:05:31 -0800 |
---|---|---|
committer | Ryan Mitchell <rtmitchell@google.com> | 2019-02-26 17:40:30 +0000 |
commit | f22ed8dc0ec107cb0e80eb25c7de4094c7f5301e (patch) | |
tree | cfbd2d0f979450690cedae268be10116e160107c /tools/aapt2/io/FileSystem.cpp | |
parent | 32981ff4d406cd44c5e57814088028fecb9bf72f (diff) |
Sort inputs to compile and link
This change sorts the input files of compile and link and also traverses
directories in sorted order in FileCollection::Create. This change
attempts to fix non-determinism issues with aapt2.
Bug: 122518436
Test: builds
Change-Id: I615b8d7f1117e3850366760f16672f0cf5b02070
Diffstat (limited to 'tools/aapt2/io/FileSystem.cpp')
-rw-r--r-- | tools/aapt2/io/FileSystem.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
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; } |