Removed hard-coded version from integration test. (#9335)
[platform/upstream/opencv.git] / platforms / maven / opencv / scripts / properties
1 #!/bin/bash
2 #####################################################################
3 # This script extracts several properties and then writes them to a
4 # to a file, 'build.properties'. These properties include:
5 #
6 #       1. OpenCV version.
7 #       2. OpenVC version as a string for use by Maven.
8 #       3. The CPU binary word size.
9 #       4. Architecture string.
10 #       4. OSGi compatible CPU architecture string.
11 #
12 # There is no need to execute this script directly as it will be
13 # called during the Maven build process.
14 #
15 # Command-line parameters:
16 #   $1 - The build directory and where the output file will be written
17 #   $2 - The name of the output file to write to.
18 #
19 # Returns:
20 #   0 - Successfully written the properties file.
21 #   1 - Error occured such as build directory does not exist
22 #       or OpenCV version could not be determined or an
23 #       unexpected error.
24 #
25 #   Kerry Billingham <contact (at) avionicengineers (d0t) com>
26 #   20 April 2016
27 #
28 #####################################################################
29
30 # Include some external functions and variables
31 . ./functions
32
33 #Test build directory exists
34 if [  ! -n "$1" ] || [ ! -d $1 ];then
35     echo "Build directory not specified or does not exist!"
36     exit 1
37 fi
38
39 if [ -n "${versionHeader}" ] && [ -e ${versionHeader} ];then
40
41     extract_version
42
43     bits=$(getconf LONG_BIT)
44     architecture=$(arch)
45     osgiProcessor="Not Set"
46
47     case ${architecture} in
48         x86*)
49             echo "This is x86 (32 | 64) bit"
50             case ${bits} in
51                 32)
52                     osgiProcessor="x86"
53                     ;;
54                 64)
55                     osgiProcessor="x86_64"
56                     ;;
57                 *)
58                     osgiProcessor="Unknown"
59             esac
60             ;;
61         arm*)
62             echo "This is ARM"
63             byteOrder=$(lscpu | grep -i "byte order")
64             shopt -s nocasematch
65             if [[ "${byteOrder}" == *little* ]]; then
66                 osgiProcessor="arm_le"
67             elif [[ "${byteOrder}}" == *big* ]]; then
68                 osgiProcessor="arm_be"
69             fi
70             shopt -u nocasematch
71             ;;
72         *)
73             echo "This is unknown architecture"
74         esac
75
76     echo "The version number will be ${majorVersion}.${minorVersion}.${revision}"
77     echo "opencv.version=${majorVersion}.${minorVersion}.${revision}" > ${1}/${2}
78     echo "lib.version.string=${majorVersion}${minorVersion}${revision}" >> ${1}/${2}
79     echo "bits=${bits}" >> ${1}/${2}
80     echo "architecture=$(arch)" >> ${1}/${2}
81     echo "osgi.processor=${osgiProcessor}" >> ${1}/${2}
82     exit 0
83 else
84     echo "Could not locate file ${versionHeader} to determine versioning."
85     exit 1
86 fi