forked from stellar/stellar-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hash-xdrs.sh
executable file
·28 lines (24 loc) · 886 Bytes
/
hash-xdrs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh
#
# This file generates a C++ file which contains (filename, hash) pairs for XDR
# files included in the build. These are included in the stellar-core build to
# be checked against similar hashes produced by xdrgen when it is compiling XDR
# definitions for Rust code.
#
# The goal is to detect the (unfortunately easy) condition of C++ and Rust code
# communicating with each other using different XDR definitions.
if [ ! -d $1/xdr ]; then
echo "usage: $0 XDR_PROTOCOL_DIR"
exit 1
fi
cat <<EOF
// DO NOT EDIT: this file is automatically generated from $0
#include <string>
#include <vector>
#include <filesystem>
namespace stellar {
extern const std::vector<std::pair<std::filesystem::path, std::string>> XDR_FILES_SHA256 = {
EOF
sha256sum -b $1/xdr/*.x | grep -v Stellar-internal | sed -e 's/\([a-f0-9]\+\)[ \*]*\(.*\)/{"\2", "\1"},/'
echo '{"", ""}};'
echo '}'