node-gyp icon indicating copy to clipboard operation
node-gyp copied to clipboard

Ensure Consistent Order of build_files in WriteAutoRegenerationRule

Open ben-zalekta-lmnd opened this issue 1 year ago • 7 comments

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 test passes
  • [ ] ~~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

ben-zalekta-lmnd avatar Aug 19 '24 14:08 ben-zalekta-lmnd

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 avatar Aug 19 '24 15:08 cclauss

@cclauss Can you approve and merge?

ben-zalekta-lmnd avatar Aug 21 '24 08:08 ben-zalekta-lmnd

It would be great if this PR can be merged and released.

Thanks for your work.

zhan9san avatar Sep 10 '24 13:09 zhan9san

@cclauss How can we proceed and merge those changes

ben-zalekta-lmnd avatar Oct 14 '24 12:10 ben-zalekta-lmnd

@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 avatar Feb 26 '25 08:02 zhan9san

@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 avatar Apr 01 '25 11:04 lukekarrys

@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.

zhan9san avatar Apr 01 '25 12:04 zhan9san