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.h
file, which means anyone who wants to embed Node has also to fork Node, sometime merely to edit thesrc/node_version.h
file.What this PR does
This PR makes
node_module_version
andnapi_build_version
numbers configurable so embedders do not have to fork Node to set the numbers. It does follow things:configure.py
to overridenode_module_version
andnapi_build_version
, there is also anode_api_versions.json
file added which records current versions.src/node_version.h
tosrc/node_version.h.in
, and replace the values ofNODE_MODULE_VERSION
macros with placeholders.src/node_version.h.in
, replace the placeholders with actual numbers, and then write anode_version.h
to output directory.node_version.h
file.Changes to Node's release workflows
This unfortunately affects Node's release workflows, namely 2 things:
node_module_version
andnapi_build_version
numbers, developers will edit thenode_api_versions.json
file instead ofsrc/node_version.h
.src/node_version.h.in
file.Benefits
configure.py
script no longer needs to parsesrc/node_version.h
to get thenode_module_version
andnapi_build_version
numbers, and thetools/getmoduleversion.py
andtools/getnapibuildversion.py
scripts can be removed.