Commit e7f709eb authored by Bernhard M. Wiedemann's avatar Bernhard M. Wiedemann
Browse files

Sort file lists

to enable more reproducible builds
without patching individual build definitions
parent c095e90f
Pipeline #61032 passed with stage
sorted glob
-----------
* calls like `file(GLOB SOMEVARIABLE "*.c")`
will now return sorted results on POSIX-compliant platforms
to avoid builds that order functions in output files depending on
random filesystem order
......@@ -201,17 +201,21 @@ bool Directory::Load(const std::string& name)
{
this->Clear();
DIR* dir = opendir(name.c_str());
kwsys_dirent** namelist;
int n;
n = scandir(name.c_str(), &namelist, NULL, alphasort);
if (!dir) {
if (n == -1) {
return 0;
}
for (kwsys_dirent* d = readdir(dir); d; d = readdir(dir)) {
while ( n-- ) {
kwsys_dirent* d = namelist[n];
this->Internal->Files.push_back(d->d_name);
free(d);
}
this->Internal->Path = name;
closedir(dir);
free(namelist);
return 1;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment