From e6aa6d14212eee2261bec5b226bf673fd8985845 Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Wed, 20 Dec 2017 14:01:14 -0800 Subject: [PATCH] AAPT2: Keep file enumeration consistent across platforms Filesystem directory enumeration is platform dependent, so sort the files lexicographically according to source path before consuming them in the compile command. Bug: 70680618 Test: manual Change-Id: I6706dea2eb40cbaff8a586994dd1013976e4ced4 --- tools/aapt2/cmd/Compile.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/aapt2/cmd/Compile.cpp b/tools/aapt2/cmd/Compile.cpp index 7c1e96e88fee2..3bec082fc57ab 100644 --- a/tools/aapt2/cmd/Compile.cpp +++ b/tools/aapt2/cmd/Compile.cpp @@ -186,6 +186,12 @@ static bool LoadInputFilesFromDir(IAaptContext* context, const CompileOptions& o out_path_data->push_back(std::move(path_data.value())); } } + + // File-system directory enumeration order is platform-dependent. Sort the result to remove any + // inconsistencies between platforms. + std::sort( + out_path_data->begin(), out_path_data->end(), + [](const ResourcePathData& a, const ResourcePathData& b) { return a.source < b.source; }); return true; }