build: do not hard code module and napi versions #49277
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Node encourages embedders to define their own
node_module_version, but currently the only way to modify the number is to edit thesrc/node_version.hfile, which means anyone who wants to embed Node has also to fork Node, sometime merely to edit thesrc/node_version.hfile.What this PR does
This PR makes
node_module_versionandnapi_build_versionnumbers configurable so embedders do not have to fork Node to set the numbers. It does follow things:configure.pyto overridenode_module_versionandnapi_build_version, there is also anode_api_versions.jsonfile added which records current versions.src/node_version.htosrc/node_version.h.in, and replace the values ofNODE_MODULE_VERSIONmacros with placeholders.src/node_version.h.in, replace the placeholders with actual numbers, and then write anode_version.hto output directory.node_version.hfile.Changes to Node's release workflows
This unfortunately affects Node's release workflows, namely 2 things:
node_module_versionandnapi_build_versionnumbers, developers will edit thenode_api_versions.jsonfile instead ofsrc/node_version.h.src/node_version.h.infile.Benefits
configure.pyscript no longer needs to parsesrc/node_version.hto get thenode_module_versionandnapi_build_versionnumbers, and thetools/getmoduleversion.pyandtools/getnapibuildversion.pyscripts can be removed.