Ensure Consistent Order of build_files in WriteAutoRegenerationRule
Fixes #3061
This PR addresses an issue with the WriteAutoRegenerationRule function in node-gyp, where the build_files set was passed without sorting, leading to an inconsistent order of dependencies in the generated Makefile.
Changes:
Wrapped the build_files set in the sorted() function before it is processed in WriteAutoRegenerationRule. This ensures that the order of files is consistent across all runs, preventing issues in CI environments that rely on file hash comparisons. Impact: This change stabilizes the output of the Makefile generation process, resolving the issue of inconsistent file order and reducing false positives in CI checks.
Checklist
- [x]
npm install && npm run lint && npm testpasses - [ ] ~~tests are included~~ NO, There are no tests for this code area
- [ ] ~~documentation is changed or added~~ There is not documantation for this code area
- [x] commit message follows commit guidelines
Description of change
I added the first line to the comment message to link the pull request to the issue as discussed in
- https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue
There is a small performance decrease because of the "function all overhead" but I think it negligible if others agree.
@cclauss Can you approve and merge?
It would be great if this PR can be merged and released.
Thanks for your work.
@cclauss How can we proceed and merge those changes
@lukekarrys
Thanks for your attention.
I think it would be better to add this change into node-gyp first.
I found node-gyp is still in use in the latest LTS v22.14.0.
$ wget https://nodejs.org/dist/v22.14.0/node-v22.14.0-linux-x64.tar.xz
$ tar -xJf node-v22.14.0-linux-x64.tar.xz
$ cd node-v22.14.0-linux-x64/
$ grep 'gyp.RegenerateFlags' lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py
[gyp_binary, "-fmake"] + gyp.RegenerateFlags(options) + build_files_args
@zhan9san This repo has automated updates to gyp-next (eg https://github.com/nodejs/node-gyp/pull/3149), so if this PR was merged then a later update to gyp-next would overwrite this change.
So to get this change in node-gyp the best way would be to open this as a PR on https://github.com/nodejs/gyp-next. When that lands and is released, it will automatically get pulled in to node-gyp.
@lukekarrys Thanks for your reminder.
@ben-zalekta-lmnd Since you submitted this PR first, I’d recommend that you create another PR in https://github.com/nodejs/gyp-next/blob/1a214a8b796eba56d7aa5b61e02fed16f00924e4/pylib/gyp/generator/make.py#L2386
However, if you don’t mind, I’d be happy to help with it.