This repository was archived by the owner on Jul 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathversioner.sh
More file actions
executable file
·151 lines (127 loc) · 5.39 KB
/
versioner.sh
File metadata and controls
executable file
·151 lines (127 loc) · 5.39 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash
if [ $# -lt 1 ]; then
echo "Usage:"
echo "$0 [path to versions.txt file]"
exit -1
fi
VERSIONSFILE=$1 # input file : versions.txt
WITHWARNING=1 # 1 to print warnings
DONOTHING=0 # 1 to display current versions only
VERBOSE=0 # 1 to enable verbose logs
# $1: message string
function log_verbose()
{
if [ $VERBOSE -ne 0 ]; then echo "$1"; fi
}
pushd () {
command pushd "$@" > /dev/null
}
popd () {
command popd "$@" > /dev/null
}
# read required versions and store them in associative array
declare -A ARRAYVER
echo "Loading version file"
while read line; do
if [[ $line == *\|* ]]; then
componentName=`echo $line | cut -d "|" -f1`
componentVersion=`echo $line | cut -d "|" -f2`
ARRAYVER[$componentName]=$componentVersion
log_verbose " $componentName: $componentVersion"
fi
done < $VERSIONSFILE
log_verbose
echo "Updating .pro and .pc.in files"
rm -f version-gen.txt
for qt_project_file in `find . -path "**/deploy" -prune -o -type f -name "*.pro" -print`
do
target=`grep "^TARGET" $qt_project_file | cut -d '=' -f2 | tr -d ' '`
version=`grep "^VERSION" $qt_project_file | cut -d '=' -f2 | tr -d ' '`
if [[ $target == "" ]]; then continue; fi
log_verbose
log_verbose "Updating $qt_project_file"
if [[ $version == "" ]]; then
if [ $WITHWARNING -eq 1 ]; then
echo "(WARN) $file does not contain version number in $file"
fi
else
if [[ ${ARRAYVER[$target]} == "" ]]; then
echo "Enter new version for $target (current: $version):"
read newversion
ARRAYVER[$target]=$newversion
echo "$target|$newversion" >> version-gen.txt
else
newversion=${ARRAYVER[$target]}
fi
log_verbose " $target: $version -> $newversion"
if [ $DONOTHING -ne 0 ]; then continue; fi
sed -i -e "s/VERSION\s\?=\s\?$version/VERSION=$newversion/g" $qt_project_file > /dev/null
pushd $(dirname "$qt_project_file")
# TODO: there should be no need to update .pc.in files. Use place holders:
# libnaame=@TARGET@, Name: @TARGET@, Version: @VERSION@
# so that remaken takes care of dealing with them
# change in .pc.in if exists
for pcin in `find . -name "*.pc.in"`; do
log_verbose " Updating $pcin" && sed -i -e "s/Version: [0-9]\+\.[0-9]\+\.[0-9]\+/Version: $newversion/g" $pcin
done
popd
fi
done
log_verbose
log_verbose "Newly defined versions can be found in 'version-gen.txt' to update version file with missing entries"
log_verbose
if [ $DONOTHING -ne 0 ]; then exit 0; fi
# Cannot deduce version from particular .pro file -> take framework version as it is what we usually do (c.f. samples/Sample-Mapping)
echo "Updating bundleSamples* files"
for bundleSamples in `find . -name "*bundleSamples.*"`
do
# /!\ .bat have "version", .sh have "Version"
log_verbose " Updating $bundleSamples"
sed -i -e "s/ersion\s\?=.*[0-9]\+\.[0-9]\+\.[0-9]\+.*/ersion=${ARRAYVER["SolARFramework"]}/g" $bundleSamples
done
log_verbose
# Uncomment to have completely updated version file
# echo "Generating updated version file to 'version-gen.txt'"
# rm -f version-gen.txt
# for key in ${!ARRAYVER[@]}; do
# echo "$key|${ARRAYVER[$key]}" >> version-gen.txt
# done
echo "Updating *.xml files"
for xmlfile in `find . -path **/deploy -prune -o -name "*.xml" -print`
do
log_verbose " Updating $xmlfile"
for key in ${!ARRAYVER[@]}; do
sed -i -e "s/$key\/[0-9]\+\.[0-9]\+\.[0-9]\+/$key\/${ARRAYVER[$key]}/g" $xmlfile
done
done
log_verbose
echo "Updating packagedependencies files"
for packagedepfile in `find . -path **/deploy -prune -o -path **/.build-rules -prune -o -name "packagedependencies*.txt" -print`
do
log_verbose " Updating $packagedepfile"
for key in ${!ARRAYVER[@]}; do
# Handle cases like 'pcl#boost_1_76|1.12.0|pcl'
sed -i -e "s/\(^$key.*\)|.*|$key/\1|${ARRAYVER[$key]}|$key/g" $packagedepfile
done
done
log_verbose
echo "Updating SolARWrapper *_build* scripts"
for script in `find core/SolARFramework/SolARWrapper -path **/deploy -prune -o -name "_build*" -print`
do
log_verbose " Updating $script"
sed -i -e "s/SOLAR_WRAPPER_VERSION\s\?=\s\?[0-9]\+\.[0-9]\+\.[0-9]\+/SOLAR_WRAPPER_VERSION=${ARRAYVER["SolARWrapper"]}/g" $script
sed -i -e "s/SOLAR_VERSION\s\?=\s\?[0-9]\+\.[0-9]\+\.[0-9]\+/SOLAR_VERSION=${ARRAYVER["SolARFramework"]}/g" $script
sed -i -e "s/XPCF_VERSION\s\?=\s\?[0-9]\+\.[0-9]\+\.[0-9]\+/XPCF_VERSION=${ARRAYVER["xpcf"]}/g" $script
done
log_verbose
echo "Updating SolARPipelineManager BuildCSharp* scripts"
for script in `find core/SolARPipelineManager -path **/deploy -prune -o -name "BuildCSharp*" -print`
do
log_verbose " Updating $script"
sed -i -e "s/SOLAR_VERSION\s\?=\s\?[0-9]\+\.[0-9]\+\.[0-9]\+/SOLAR_VERSION=${ARRAYVER["SolARFramework"]}/g" $script
sed -i -e "s/XPCF_VERSION\s\?=\s\?[0-9]\+\.[0-9]\+\.[0-9]\+/XPCF_VERSION=${ARRAYVER["xpcf"]}/g" $script
done
log_verbose
echo "Updating plugin/unity/SolARUnityPlugin/Bundle.bat"
sed -i -e "s/SOLAR_PIPELINE_MANAGER_VERSION\s\?=\s\?[0-9]\+\.[0-9]\+\.[0-9]\+/SOLAR_PIPELINE_MANAGER_VERSION=${ARRAYVER["SolARPipelineManager"]}/g" plugin/unity/SolARUnityPlugin/Bundle.bat
sed -i -e "s/SOLAR_WRAPPER_VERSION\s\?=\s\?[0-9]\+\.[0-9]\+\.[0-9]\+/SOLAR_WRAPPER_VERSION=${ARRAYVER["SolARWrapper"]}/g" plugin/unity/SolARUnityPlugin/Bundle.bat