1#!/usr/bin/env bash
2# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
3if [ "$#" = "0" ]; then
4  echo "Usage: $0 major|minor|patch|full"
5  exit 1
6fi
7
8if [ "$1" = "major" ]; then
9  cat include/rocksdb/version.h  | grep MAJOR | head -n1 | awk '{print $3}'
10fi
11if [ "$1" = "minor" ]; then
12  cat include/rocksdb/version.h  | grep MINOR | head -n1 | awk '{print $3}'
13fi
14if [ "$1" = "patch" ]; then
15  cat include/rocksdb/version.h  | grep PATCH | head -n1 | awk '{print $3}'
16fi
17if [ "$1" = "full" ]; then
18  awk '/#define ROCKSDB/ { env[$2] = $3 }
19       END { printf "%s.%s.%s\n", env["ROCKSDB_MAJOR"],
20                                  env["ROCKSDB_MINOR"],
21                                  env["ROCKSDB_PATCH"] }'  \
22      include/rocksdb/version.h
23fi
24