mirror of https://github.com/opencv/opencv.git
Open Source Computer Vision Library
https://opencv.org/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
2.9 KiB
90 lines
2.9 KiB
#!/bin/bash |
|
##################################################################### |
|
# This script extracts several properties and then writes them to a |
|
# to a file, 'build.properties'. These properties include: |
|
# |
|
# 1. OpenCV version. |
|
# 2. OpenVC version as a string for use by Maven. |
|
# 3. The CPU binary word size. |
|
# 4. Architecture string. |
|
# 4. OSGi compatible CPU architecture string. |
|
# |
|
# There is no need to execute this script directly as it will be |
|
# called during the Maven build process. |
|
# |
|
# Command-line parameters: |
|
# $1 - Absolute path to the file containing Open CV version |
|
# $2 - The build directory and where the output file will be written |
|
# $3 - The name of the output file to write to. |
|
# |
|
# Returns: |
|
# 0 - Successfully written the properties file. |
|
# 1 - Error occured such as build directory does not exist |
|
# or OpenCV version could not be determined or an |
|
# unexpected error. |
|
# |
|
# Kerry Billingham <contact (at) avionicengineers (d0t) com> |
|
# 20 April 2016 |
|
# |
|
##################################################################### |
|
|
|
majorHashDefine="#define CV_VERSION_MAJOR" |
|
minorHashDefine="#define CV_VERSION_MINOR" |
|
revisionHashDefine="#define CV_VERSION_REVISION" |
|
statusHashDefine="#define CV_VERSION_STATUS" |
|
|
|
#Test build directory exists |
|
if [ ! -n "$2" ] || [ ! -d $2 ];then |
|
echo "Build directory not specified or does not exist!" |
|
exit 1 |
|
fi |
|
|
|
if [ -n "$1" ] && [ -e $1 ];then |
|
minorVersion=$(grep "${minorHashDefine}" $1 | grep -o ".$") |
|
majorVersion=$(grep "${majorHashDefine}" $1 | grep -o ".$") |
|
revision=$(grep "${revisionHashDefine}" $1 | grep -o ".$") |
|
|
|
bits=$(getconf LONG_BIT) |
|
architecture=$(arch) |
|
osgiProcessor="Not Set" |
|
|
|
case ${architecture} in |
|
x86*) |
|
echo "This is x86 (32 | 64) bit" |
|
case ${bits} in |
|
32) |
|
osgiProcessor="x86" |
|
;; |
|
64) |
|
osgiProcessor="x86_64" |
|
;; |
|
*) |
|
osgiProcessor="Unknown" |
|
esac |
|
;; |
|
arm*) |
|
echo "This is ARM" |
|
byteOrder=$(lscpu | grep -i "byte order") |
|
shopt -s nocasematch |
|
if [[ "${byteOrder}" == *little* ]]; then |
|
osgiProcessor="arm_le" |
|
elif [[ "${byteOrder}}" == *big* ]]; then |
|
osgiProcessor="arm_be" |
|
fi |
|
shopt -u nocasematch |
|
;; |
|
*) |
|
echo "This is unknown architecture" |
|
esac |
|
|
|
echo "The version number will be ${majorVersion}.${minorVersion}.${revision}" |
|
echo "opencv.version=${majorVersion}.${minorVersion}.${revision}" > ${2}/${3} |
|
echo "lib.version.string=${majorVersion}${minorVersion}${revision}" >> ${2}/${3} |
|
echo "bits=${bits}" >> ${2}/${3} |
|
echo "architecture=$(arch)" >> ${2}/${3} |
|
echo "osgi.processor=${osgiProcessor}" >> ${2}/${3} |
|
exit 0 |
|
else |
|
echo "Could not locate file $1 to determine versioning." |
|
exit 1 |
|
fi
|
|
|