forked from facebookarchive/fb-adb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkstubsc.sh
executable file
·39 lines (34 loc) · 929 Bytes
/
mkstubsc.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
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bash
# Copyright (c) 2014, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in
# the LICENSE file in the root directory of this source tree. An
# additional grant of patent rights can be found in the PATENTS file
# in the same directory.
#
#
# This file takes a list of stub names on its command line and
# writes to stdout the contents of the corresponding stubs.c.
#
set -euo pipefail
: ${XXD=xxd}
cat <<EOF
#include <stdint.h>
#include "stubs.h"
EOF
for stub in "$@"; do
cname=${stub%/stub}
cname=${cname//-/_}
printf 'static const uint8_t %s[] = {\n' "$cname"
$XXD -i < $stub
printf '};\n\n'
done
printf 'const struct fbadb_stub stubs[] = {\n'
for stub in "$@"; do
cname=${stub%/stub}
cname=${cname//-/_}
printf ' { %s, sizeof(%s) },\n' "$cname" "$cname"
done
printf '};\n\n'
printf 'const size_t nr_stubs=%s;\n' $#