Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f22ed8dc authored by Ryan Mitchell's avatar Ryan Mitchell
Browse files

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
parent 32981ff4
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -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);
    }

+7 −1
Original line number Diff line number Diff line
@@ -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,8 +106,13 @@ 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;