forked from iabudiab/ObjectiveRocks
-
Notifications
You must be signed in to change notification settings - Fork 2
/
clean_rocksdb_source.sh
executable file
·76 lines (62 loc) · 2.11 KB
/
clean_rocksdb_source.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
# Creates a copy of the `rocksdb` submodule dir and cleans it
# of all extraneous files so the actual sources can be easily
# included and updated in the frameworks.
# Submodule source directory
SRC=rocksdb
# Cleaned container directory
SRC_CLEANED=rocksdb_src
# Cleaned source copy
SRC_COPY=$PWD/$SRC_CLEANED/$SRC
# Return early if already generated
if [ -d $SRC_COPY ]; then
exit 0
fi
# Clean everything
rm -rf $PWD/$SRC_CLEANED
mkdir $PWD/$SRC_CLEANED
# Make a rocksdb directory within
# the SRC_COPY directory
cp -R $PWD/$SRC $SRC_COPY
# Delete unused folders
rm -rf $SRC_COPY/.git
rm -rf $SRC_COPY/buckifier
rm -rf $SRC_COPY/cmake
rm -rf $SRC_COPY/docs
rm -rf $SRC_COPY/examples
rm -rf $SRC_COPY/hdfs
rm -rf $SRC_COPY/java
rm -rf $SRC_COPY/port/win
rm -rf $SRC_COPY/third-party/gtest-1.7.0
rm -rf $SRC_COPY/utilities/cassandra
# Delete any files that aren't source files
find $SRC_COPY -not -name '*.cc' -type f -not -name '*.cpp' -type f -not -name '*.c' -type f -not -name '*.h' -type f -delete
# Delete any test files
find $SRC_COPY -name '*test*' -type f -delete
find $SRC_COPY -name '*mock*' -type f -delete
# Delete any additional files we don't need
rm -f $SRC_COPY/db/c.cc
rm -f $SRC_COPY/include/rocksdb/c.h
rm -f $SRC_COPY/port/dirent.h
rm -f $SRC_COPY/env/env_hdfs.cc
find $SRC_COPY/tools -not -name 'sst_dump_tool*' -type f -delete
find $SRC_COPY/util -name '*ppc*' -type f -delete
find $SRC_COPY -name '*bench*' -type f -delete
find $SRC_COPY -name '*rados*' -type f -delete
# Delete any empty folders
find $SRC_COPY -type d -empty -delete
# Create build_version.cc from the original source
ROCKSDB_GIT_DIR=$PWD/$SRC/.git
OUTFILE=$SRC_COPY/util/build_version.cc
GIT_SHA=""
if command -v git >/dev/null 2>&1; then
GIT_SHA=$(git --git-dir="$ROCKSDB_GIT_DIR" rev-parse HEAD 2>/dev/null)
fi
cat > "${OUTFILE}" <<EOF
#include "build_version.h"
const char* rocksdb_build_git_sha = "rocksdb_build_git_sha:${GIT_SHA}";
const char* rocksdb_build_git_datetime = "rocksdb_build_git_datetime:$(date)";
const char* rocksdb_build_compile_date = "$(date)";
EOF
# Get rid of the original source submodule
rm -rf $PWD/$SRC