forked from urho3d/urho3d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bash_helpers.sh
112 lines (103 loc) · 6.78 KB
/
.bash_helpers.sh
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
#
# Copyright (c) 2008-2014 the Urho3D project.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# Define helpers
msg() {
echo -e "\n$1\n================================================================================"
}
post_cmake() {
if [ $GENERATOR == "Eclipse CDT4 - Unix Makefiles" ]; then
# Integrate Urho3D documentation into Eclipse IDE
ln -snf $(pwd)/Docs/html ~/.eclipse/$(ls -1t ~/.eclipse |grep org.eclipse.platform_ |head -1)/plugins
# Check if xmlstarlet software package is available for fixing the generated Eclipse project setting
if [ $HAS_XMLSTARLET ]; then
# Common fixes for all builds
#
# Remove build configuration from project name
# Replace deprecated GNU gmake Error Parser with newer version (6.0 -> 7.0) and add GCC Error Parser
#
xmlstarlet ed -P -L \
-u "/projectDescription/name/text()" -x "concat(substring-before(., '-Release'), substring-before(., '-Debug'), substring-before(., '-RelWithDebInfo'))" \
-u "/projectDescription/buildSpec/buildCommand/arguments/dictionary/value[../key/text() = 'org.eclipse.cdt.core.errorOutputParser']" -x "concat('org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;', substring-after(., 'org.eclipse.cdt.core.MakeErrorParser'))" \
$1/.project
# Build-specific fixes
if [ $1 == "android-Build" ]; then
# For Android build, add the Android and Java nature to the project setting as it would be done by Eclipse during project import
# This fix avoids the step to reimport the project everytime the Eclipse project setting is regenerated by cmake_gcc.sh invocation
echo -- Add Android and Java nature to Eclipse project setting files in $( pwd )/$1
#
# Add natures (Android nature must be inserted as first nature)
#
xmlstarlet ed -P -L \
-i "/projectDescription/natures/nature[1]" -t elem -n nature -v "com.android.ide.eclipse.adt.AndroidNature" \
-s "/projectDescription/natures" -t elem -n nature -v "org.eclipse.jdt.core.javanature" \
$1/.project
#
# Add build commands
#
for c in com.android.ide.eclipse.adt.ResourceManagerBuilder com.android.ide.eclipse.adt.PreCompilerBuilder org.eclipse.jdt.core.javabuilder com.android.ide.eclipse.adt.ApkBuilder; do
xmlstarlet ed -P -L \
-s "/projectDescription/buildSpec" -t elem -n buildCommandNew -v "" \
-s "/projectDescription/buildSpec/buildCommandNew" -t elem -n name -v $c \
-s "/projectDescription/buildSpec/buildCommandNew" -t elem -n arguments -v "" \
-r "/projectDescription/buildSpec/buildCommandNew" -v "buildCommand" \
$1/.project
done
elif [ $1 == "raspi-Build" ]; then
# For Raspberry Pi build, add [Bin-CC] linked resource
#
# Replace [Subprojects]/Urho3D linked resource to [Targets]/[Bin-CC] instead
#
xmlstarlet ed -P -L \
-u "/projectDescription/linkedResources/link/name/text()[. = '[Subprojects]/Urho3D']" -v "[Targets]/[Bin-CC]" \
-u "/projectDescription/linkedResources/link/location[../name/text() = '[Targets]/[Bin-CC]']" -v "$( pwd )/Bin-CC" \
$1/.project
else
# For native build, move the Eclipse project setting files back to Source folder to fix source code versioning
echo -- Eclipse project setting files have been relocated to: $( pwd )/Source
for f in .project .cproject; do mv $1/$f Source; done
#
# Replace [Source directory] linked resource to [Build] instead
# Modify build argument to first change directory to Build folder
# Replace [Subprojects]/Urho3D linked resource to [Build]/[Bin] instead
#
xmlstarlet ed -P -L \
-u "/projectDescription/linkedResources/link/name/text()[. = '[Source directory]']" -v "[Build]" \
-u "/projectDescription/linkedResources/link/location[../name/text() = '[Build]']" -v "$( pwd )/$1" \
-u "/projectDescription/buildSpec/buildCommand/arguments/dictionary/value[../key/text() = 'org.eclipse.cdt.make.core.build.arguments']" -x "concat('-C ../$1 ', .)" \
-u "/projectDescription/linkedResources/link/name/text()[. = '[Subprojects]/Urho3D']" -v "[Build]/[Bin]" \
-u "/projectDescription/linkedResources/link/location[../name/text() = '[Build]/[Bin]']" -v "$( pwd )/Bin" \
Source/.project
#
# Fix source path entry to Source folder and modify its filter condition
# Fix output path entry to [Build] linked resource and modify its filter condition
#
xmlstarlet ed -P -L \
-u "/cproject/storageModule/cconfiguration/storageModule/pathentry[@kind = 'src']/@path" -v "" \
-s "/cproject/storageModule/cconfiguration/storageModule/pathentry[@kind = 'src']" -t attr -n "excluding" -v "[Subprojects]/|[Targets]/" \
-u "/cproject/storageModule/cconfiguration/storageModule/pathentry[@kind = 'out']/@path" -v "[Build]" \
-u "/cproject/storageModule/cconfiguration/storageModule/pathentry[@kind = 'out']/@excluding" -x "substring-after(., '[Source directory]/|')" \
Source/.cproject
fi
fi
fi
}
# vi: set ts=4 sw=4 expandtab: