summarylogtreecommitdiffstats
path: root/fix_rust_being_rust.sh
blob: c40e65945d63e875768072770c71018a27185bf4 (plain)
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
#!/bin/bash

INCLUDE="#include <cstdint>"

for dir in $(find ~/.cargo/registry/src/ -name 'librocksdb-sys-0.17.1*'); do
  blob_file_meta="$dir/rocksdb/db/blob/blob_file_meta.h"
  trace_record="$dir/rocksdb/include/rocksdb/trace_record.h"
  write_batch_base="$dir/rocksdb/include/rocksdb/write_batch_base.h"

  if ! grep -q "$INCLUDE" "$blob_file_meta"; then
    echo "fixing $blob_file_meta"
    echo
    sed -i '/#include <cassert>/a #include <cstdint>' "$blob_file_meta"
  else
    echo "blob_file_meta.h already fixed"
  fi

  if ! grep -q "$INCLUDE" "$trace_record"; then
    echo "fixing $trace_record"
    echo
    sed -i '/#pragma once/a #include <cstdint>' "$trace_record"
  else
    echo "trace_record.h already fixed"
  fi

  if ! grep -q "$INCLUDE" "$write_batch_base"; then
    echo "fixing $write_batch_base"
    echo
    sed -i '/#include <cstddef>/a #include <cstdint>' "$write_batch_base"
  else
    echo "write_batch_base.h already fixed"
  fi
done