summaryrefslogtreecommitdiff
path: root/tools/update_version/update-version
blob: 41693278ba6ec7fb56d23a12b8c4236ef9a2a099 (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash

set -eu

progname=$(basename "${BASH_SOURCE[0]}")
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
nnfw_root="$( cd "${script_dir%*/*/*}" && pwd )"

usage() {
  echo "Usage: $progname version"
  echo "Update all version information"
  echo ""
  echo "Options:"
  echo "    -h   show this help"
  echo ""
  echo "Examples:"
  echo "    $progname 1.6.0"
  exit 1
}

if [ $# -eq 0 ]; then
  echo "For help, type $progname -h"
  exit 1
fi

while getopts "ho:" OPTION; do
case "${OPTION}" in
    h) usage;;
    ?) exit 1;;
esac
done

shift $((OPTIND-1))

if [ $# -ne 1 ]; then
  echo "error: wrong argument (no argument or too many arguments)."
  echo "For help, type $progname -h"
  exit 1
fi

version=$1

sed -i "s/^release = .*/release = \'$version\'/" ${nnfw_root}/docs/conf.py
sed -i "s/^Version: .*/Version: $version/" ${nnfw_root}/packaging/nnfw.spec

IFS=. read M m p <<< $version
hex=$(printf '0x%08x' $(( (($M << 24)) | (($m << 8)) | $p )))
sed -i "s/^#define NNFW_VERSION.*/#define NNFW_VERSION $hex/" ${nnfw_root}/runtime/onert/api/include/nnfw_version.h

sed -i "s/versionName .*$/versionName \"$version\"/" ${nnfw_root}/runtime/contrib/android/api/build.gradle