Skip to content

Commit 74dfc27

Browse files
committed
Auto-rustfmt generated msg_targets
1 parent dd04f90 commit 74dfc27

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ jobs:
184184
run: |
185185
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ env.TOOLCHAIN }}
186186
rustup override set ${{ env.TOOLCHAIN }}
187+
- name: Install rustfmt
188+
run: |
189+
rustup component add rustfmt
187190
- name: Install dependencies for honggfuzz
188191
run: |
189192
sudo apt-get update

fuzz/src/bin/gen_target.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
#!/bin/sh
22

3+
RUSTFMT() {
4+
VERS=""
5+
[ "$(which rustup)" != "" ] && VERS="+1.63.0"
6+
7+
rustfmt "$VERS" -- "$1"
8+
}
9+
310
echo "#include <stdint.h>" > ../../targets.h
411
GEN_TEST() {
5-
cat target_template.txt | sed s/TARGET_NAME/$1/ | sed s/TARGET_MOD/$2$1/ > $1_target.rs
12+
cat target_template.txt | sed s/TARGET_NAME/$1/ | sed s/TARGET_MOD/$2$1/ > "$1_target.rs"
613
echo "void $1_run(const unsigned char* data, size_t data_len);" >> ../../targets.h
14+
RUSTFMT "$1_target.rs"
715
}
816

917
GEN_TEST bech32_parse

fuzz/src/msg_targets/gen_target.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
#!/bin/sh
22

3+
RUSTFMT() {
4+
VERS=""
5+
[ "$(which rustup)" != "" ] && VERS="+1.63.0"
6+
7+
rustfmt "$VERS" -- "$1"
8+
}
9+
310
GEN_TEST() {
411
tn=msg_$(echo $1 | sed s'/.*:://g' | sed 's/\([a-z0-9]\)\([A-Z]\)/\1_\2/g' | tr '[:upper:]' '[:lower:]')
512
fn=${tn}.rs
613
cat msg_target_template.txt | sed s/MSG_TARGET/$1/ | sed "s/TARGET_NAME/$tn/" | sed "s/TEST_MSG/$2/" | sed "s/EXTRA_ARGS/$3/" > $fn
14+
RUSTFMT $fn
715
echo "pub mod $tn;" >> mod.rs
816
}
917

10-
echo "mod utils;" > mod.rs
18+
{
19+
echo "#[rustfmt::skip]"
20+
echo "mod utils;"
21+
} > mod.rs
1122

1223
# Note when adding new targets here you should add a similar line in src/bin/gen_target.sh
1324

@@ -64,3 +75,5 @@ GEN_TEST lightning::ln::msgs::Stfu test_msg_simple ""
6475
GEN_TEST lightning::ln::msgs::Splice test_msg_simple ""
6576
GEN_TEST lightning::ln::msgs::SpliceAck test_msg_simple ""
6677
GEN_TEST lightning::ln::msgs::SpliceLocked test_msg_simple ""
78+
79+
RUSTFMT mod.rs

0 commit comments

Comments
 (0)