Build Node.js shared library for multiple platforms
Prepare build environment
macOS:
brew install coreutils
Ubuntu:
apt-get install python g++ gcc make gcc-multilib g++-multilib lib32z1 -y
Download the Node.js source code
git clone https://github.com/nodejs/node.git
cd node
git checkout v16.7.0
Apply patches for knode
./scripts/patch.sh apply
Start building, get some ☕️:
./build.sh
After build successfully, all the artifacts are under artifacts
directory
cd node
git stash
git fetch origin
git checkout vxx.xx.x
git stash pop
Build scripts in this repository use patch files(under the patches
directory) to apply changes for Node.js, so the Node.js upgrade work can be easier and it is intuitive to know what changes we've made.
If you need to do some changes in node's codebase, you should generate patches files and commit *.patch
files instead of commiting changes directly.
Before doing your change, make sure your local changes is up-to-date:
git pull origin main
# your local changes under `node` directory will be dropped
./scripts/patch.sh apply -f
Now you can edit any files in Node.js under the node
directory, to commit your changes, you need to update the patch files:
./scripts/patch.sh generate