Skip to content

Commit 0cddb0a

Browse files
ShogunPandaaduh95tniessenlpinca
authored andcommitted
tools: add update-llhttp.sh
PR-URL: #44652 Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com> Co-authored-by: Tobias Nießen <tniessen@tnie.de> Co-authored-by: Luigi Pinca <luigipinca@gmail.com>
1 parent 35fbd2c commit 0cddb0a

File tree

2 files changed

+87
-24
lines changed

2 files changed

+87
-24
lines changed

doc/contributing/maintaining-http.md

+24-24
Original file line numberDiff line numberDiff line change
@@ -78,32 +78,32 @@ are maintained in the [llhttp](https://github.com/nodejs/llhttp)
7878
repository. Updates are pulled into Node.js under
7979
[deps/llhttp](https://github.com/nodejs/node/tree/HEAD/deps/llhttp).
8080

81-
In order to update Node.js with a new version of llhttp:
82-
83-
* check out the tagged release that you want to update to (a release
84-
should be created in the llhttp repo before updating Node.js).
85-
* run `npm install` in the directory that you checked out llhttp.
86-
* run `make release` in the directory that you checked out llhttp.
87-
* copy the contents of the `release` directory from the directory you
88-
checked llhttp out to
89-
[deps/llhttp](https://github.com/nodejs/node/tree/HEAD/deps/llhttp)
90-
91-
It should look like the following:
92-
93-
```console
94-
├── CMakeLists.txt
95-
├── common.gypi
96-
├── include
97-
│ └── llhttp.h
98-
├── LICENSE-MIT
99-
├── llhttp.gyp
100-
├── README.md
101-
└── src
102-
├── api.c
103-
├── http.c
104-
└── llhttp.c
81+
In order to update Node.js with a new version of llhttp you can use the
82+
`tools/update-llhttp.sh` script.
83+
84+
The contents of the `deps/llhttp` folder should look like the following:
85+
86+
```bash
87+
$ find deps/llhttp
88+
89+
deps/llhttp/
90+
deps/llhttp/CMakeLists.txt
91+
deps/llhttp/include
92+
deps/llhttp/include/llhttp.h
93+
deps/llhttp/llhttp.gyp
94+
deps/llhttp/README.md
95+
deps/llhttp/common.gypi
96+
deps/llhttp/libllhttp.pc.in
97+
deps/llhttp/LICENSE-MIT
98+
deps/llhttp/src
99+
deps/llhttp/src/api.c
100+
deps/llhttp/src/http.c
101+
deps/llhttp/src/llhttp.c
105102
```
106103

104+
After updating, make sure the version in `CMakeLists.txt` and `include/llhttp.h`
105+
are the same and that they match the one you are expecting.
106+
107107
The low-level implementation is made available in the Node.js API through
108108
JavaScript code in the [lib](https://github.com/nodejs/node/tree/HEAD/lib)
109109
directory and C++ code in the

tools/update-llhttp.sh

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# Shell script to update llhttp in the source tree to specific version
5+
6+
BASE_DIR="$( pwd )"/
7+
DEPS_DIR="${BASE_DIR}deps/"
8+
LLHTTP_VERSION="$1"
9+
10+
if [ "$#" -le 0 ]; then
11+
echo "Error: Please provide an llhttp version to update to."
12+
echo "Error: To download directly from GitHub, use the organization/repository syntax, without the .git suffix."
13+
exit 1
14+
fi
15+
16+
cleanup () {
17+
EXIT_CODE=$?
18+
[ -d "$WORKSPACE" ] && rm -rf "$WORKSPACE"
19+
exit $EXIT_CODE
20+
}
21+
22+
echo "Making temporary workspace ..."
23+
WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp')
24+
trap cleanup INT TERM EXIT
25+
26+
cd "$WORKSPACE"
27+
28+
if echo "$LLHTTP_VERSION" | grep -qs "/" ; then # Download a release
29+
REPO="git@github.com:$LLHTTP_VERSION.git"
30+
BRANCH=$2
31+
[ -z "$BRANCH" ] && BRANCH=main
32+
33+
echo "Cloning llhttp source archive $REPO ..."
34+
git clone "$REPO" llhttp
35+
cd llhttp
36+
echo "Checking out branch $BRANCH ..."
37+
git checkout "$BRANCH"
38+
39+
echo "Building llhtttp ..."
40+
npm install
41+
make release
42+
43+
echo "Copying llhtttp release ..."
44+
rm -rf "$DEPS_DIR/llhttp"
45+
cp -a release "$DEPS_DIR/llhttp"
46+
else
47+
echo "Download llhttp release $LLHTTP_VERSION ..."
48+
curl -sL -o llhttp.tar.gz "https://github.com/nodejs/llhttp/archive/refs/tags/release/v$LLHTTP_VERSION.tar.gz"
49+
gzip -dc llhttp.tar.gz | tar xf -
50+
51+
echo "Copying llhtttp release ..."
52+
rm -rf "$DEPS_DIR/llhttp"
53+
cp -a "llhttp-release-v$LLHTTP_VERSION" "$DEPS_DIR/llhttp"
54+
fi
55+
56+
echo ""
57+
echo "All done!"
58+
echo ""
59+
echo "Please git add llhttp, commit the new version:"
60+
echo ""
61+
echo "$ git add -A deps/llhttp"
62+
echo "$ git commit -m \"deps: update nghttp2 to $LLHTTP_VERSION\""
63+
echo ""

0 commit comments

Comments
 (0)