summaryrefslogtreecommitdiff
path: root/config-sdk/script/rootstrap_plugin_gen_1.0.sh
blob: bfd663a85b9a721d781ff2166f272477360b1819 (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
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
#!/bin/bash
# Version 1.0.1
function log()
{
    printf "[${SCRIPT_NAME}:${BASH_LINENO[0]}] ${@}\n"
}

function print_usage_exit()
{
echo "$SCRIPT_NAME is rootstrap generator using xml"
echo "Usage: $SCRIPT_NAME [<OPTION>]..."
echo ""
echo "  -t,--type   rootstrap type emulator, target."
echo "  -i,--info   IDE rootstrap info file to get Build Option"
echo "  -p,--profile    mobile, wearable, tv"
echo "  -v,--version    2.3, 2.3.1, 2.4, 3.0"
echo ""
echo "Example 1"
echo ">$SCRIPT_NAME -t \"emulator\" -i \".info\/mobile-2.3-emulator.core.dev.xml\" -p \"mobile\" -v \"2.3\""
echo ""

exit $1
}
function get_build_option()
{
    BUILD_OPT_INC_PATH+=$(xmlstarlet sel -t -m "/rootstrap" -m "include_path" -v "text()" -o "" -n ${1})$'\n';
    BUILD_OPT_LIB_PATH+=$(xmlstarlet sel -t -m "/rootstrap" -m "library_path" -v "text()" -o "" -n ${1})$'\n';
    BUILD_OPT_LIB_NAME+=$(xmlstarlet sel -t -m "/rootstrap" -m "library" -v "text()" -o "" -n ${1})$'\n'$'\n';
    BUILD_OPT_CLI_RS_LIBRARIES+=$(xmlstarlet sel -t -m "/rootstrap" -m "library" -v "text()" -o "" -n ${1})$'\n'$'\n';
}

function get_build_option_from_infofile()
{
    BUILD_OPT_INC_PATH+=$(xmlstarlet sel -t -m "/PackageInfo/DevPackage" -m "include_path" -v "text()" -o "" -n ${1})$'\n';
    BUILD_OPT_LIB_PATH+=$(xmlstarlet sel -t -m "/PackageInfo/DevPackage" -m "library_path" -v "text()" -o "" -n ${1})$'\n';
    BUILD_OPT_LIB_NAME+=$(xmlstarlet sel -t -m "/PackageInfo/DevPackage" -m "library" -v "text()" -o "" -n ${1})$'\n'$'\n';
    BUILD_OPT_CLI_RS_LIBRARIES+=$(xmlstarlet sel -t -m "/PackageInfo/DevPackage" -m "library" -v "text()" -o "" -n ${1})$'\n'$'\n';

    BUILD_OPT_INC_PATH=`echo "$BUILD_OPT_INC_PATH" | sort -d -u`;
    BUILD_OPT_LIB_PATH=`echo "$BUILD_OPT_LIB_PATH" | sort -d -u`;
    BUILD_OPT_LIB_NAME=`echo "$BUILD_OPT_LIB_NAME" | sort -d -u`;
    BUILD_OPT_CLI_RS_LIBRARIES=`echo "$BUILD_OPT_CLI_RS_LIBRARIES" | sort -d -u | sed 's/^lib/-l/g' | sed 's/.so$/ /g'`;
}

function generate_plugin()
{
log "# $FUNCNAME------"
(
echo '<extension point="rootstrapDefinition">
</extension>'| tee $PLUGIN_FILENAME >/dev/null 2>&1
)

xmlstarlet ed -L -s "/extension" -t elem -n "rootstrap" -v "" $PLUGIN_FILENAME
xmlstarlet ed -L -s "/extension/rootstrap" -t attr -n "id" -v "$PLATFORM_PROFILE-$PLATFORM_VERSION-${TYPE}.core" $PLUGIN_FILENAME
xmlstarlet ed -L -s "/extension/rootstrap" -t attr -n "name" -v "Tizen ${TYPE[*]^} $PLATFORM_VERSION" $PLUGIN_FILENAME
xmlstarlet ed -L -s "/extension/rootstrap" -t attr -n "version" -v "${PLATFORM_PROFILE[*]^} $PLATFORM_VERSION" $PLUGIN_FILENAME
xmlstarlet ed -L -s "/extension/rootstrap" -t attr -n "architecture" -v "$ARCH" $PLUGIN_FILENAME
xmlstarlet ed -L -s "/extension/rootstrap" -t attr -n "path" -v "$RS_PATH" $PLUGIN_FILENAME
xmlstarlet ed -L -s "/extension/rootstrap" -t attr -n "supportToolchainType" -v "tizen.core" $PLUGIN_FILENAME

xmlstarlet ed -L -s "/extension/rootstrap" -t elem -n "property" -v "" $PLUGIN_FILENAME
xmlstarlet ed -L -s "/extension/rootstrap/property[last()]" -t attr -n "key" -v "DEV_PACKAGE_CONFIG_PATH" $PLUGIN_FILENAME
xmlstarlet ed -L -s "/extension/rootstrap/property[last()]" -t attr -n "value" -v "$DEV_PACKAGE_CONFIG_PATH" $PLUGIN_FILENAME

xmlstarlet ed -L -s "/extension/rootstrap" -t elem -n "property" -v "" $PLUGIN_FILENAME
xmlstarlet ed -L -s "/extension/rootstrap/property[last()]" -t attr -n "key" -v "LINKER_MISCELLANEOUS_OPTION" $PLUGIN_FILENAME
xmlstarlet ed -L -s "/extension/rootstrap/property[last()]" -t attr -n "value" -v "" $PLUGIN_FILENAME

xmlstarlet ed -L -s "/extension/rootstrap" -t elem -n "property" -v "" $PLUGIN_FILENAME
xmlstarlet ed -L -s "/extension/rootstrap/property[last()]" -t attr -n "key" -v "COMPILER_MISCELLANEOUS_OPTION" $PLUGIN_FILENAME
xmlstarlet ed -L -s "/extension/rootstrap/property[last()]" -t attr -n "value" -v "" $PLUGIN_FILENAME

# OLD tool options
#xmlstarlet ed -L -s "/extension/rootstrap" -t elem -n "property" -v "" $PLUGIN_FILENAME
#xmlstarlet ed -L -s "/extension/rootstrap/property[last()]" -t attr -n "key" -v "RS_LIBRARIES" $PLUGIN_FILENAME
#xmlstarlet ed -L -s "/extension/rootstrap/property[last()]" -t attr -n "value" -v "$RS_LIB_OPT" $PLUGIN_FILENAME

#xmlstarlet ed -L -s "/extension/rootstrap" -t elem -n "property" -v "" $PLUGIN_FILENAME
#xmlstarlet ed -L -s "/extension/rootstrap/property[last()]" -t attr -n "key" -v "EDJE_CC" $PLUGIN_FILENAME
#xmlstarlet ed -L -s "/extension/rootstrap/property[last()]" -t attr -n "value" -v "#{SBI_HOME}/../../platforms/tizen-${PLATFORM_VERSION}/common/efl-tool/efl-tools/bin/edje_cc" $PLUGIN_FILENAME
# end OLD tool option - should be deprecated
GCC_VERSION="4.9"
LLVM_VERSION="3.6"

if [[ "${PLATFORM_VERSION}" = "2.3"* ]]
then
    GCC_VERSION="4.6"
    LLVM_VERSION="3.4"
fi
if [[ "${PLATFORM_VERSION}" = "4.0"* ]]
then
    GCC_VERSION="6.2"
    LLVM_VERSION="4.0"
fi
if [[ "${PLATFORM_VERSION}" = "5.0"* ]]
then
    GCC_VERSION="6.2"
    LLVM_VERSION="4.0"
fi
if [[ "${PLATFORM_VERSION}" = "5.5"* ]]
then
    GCC_VERSION="6.2"
    LLVM_VERSION="4.0"
fi
# Deprecated LLVM version
#xmlstarlet ed -L -s "/extension/rootstrap" -t elem -n "toolchain" -v "" $PLUGIN_FILENAME
#xmlstarlet ed -L -s "/extension/rootstrap/toolchain[last()]" -t attr -n "name" -v "llvm" $PLUGIN_FILENAME
#xmlstarlet ed -L -s "/extension/rootstrap/toolchain[last()]" -t attr -n "version" -v "${LLVM_VERSION}" $PLUGIN_FILENAME

xmlstarlet ed -L -s "/extension/rootstrap" -t elem -n "toolchain" -v "" $PLUGIN_FILENAME
xmlstarlet ed -L -s "/extension/rootstrap/toolchain[last()]" -t attr -n "name" -v "gcc" $PLUGIN_FILENAME
xmlstarlet ed -L -s "/extension/rootstrap/toolchain[last()]" -t attr -n "version" -v "${GCC_VERSION}" $PLUGIN_FILENAME

xmlstarlet ed -L -s "/extension/rootstrap" -t elem -n "tool" -v "" $PLUGIN_FILENAME
xmlstarlet ed -L -s "/extension/rootstrap/tool[last()]" -t attr -n "name" -v "EDJE_CC" $PLUGIN_FILENAME
xmlstarlet ed -L -s "/extension/rootstrap/tool[last()]" -t attr -n "version" -v "" $PLUGIN_FILENAME
xmlstarlet ed -L -s "/extension/rootstrap/tool[last()]" -t attr -n "path" -v "#{SBI_HOME}/../../platforms/tizen-${PLATFORM_VERSION}/common/efl-tool/efl-tools/bin/edje_cc" $PLUGIN_FILENAME

if [ "$INTERNAL" = true ]; then
xmlstarlet ed -L -s "/extension/rootstrap" -t elem -n "property" -v "" $PLUGIN_FILENAME
xmlstarlet ed -L -s "/extension/rootstrap/property[last()]" -t attr -n "key" -v "TYPE" $PLUGIN_FILENAME
xmlstarlet ed -L -s "/extension/rootstrap/property[last()]" -t attr -n "value" -v "private" $PLUGIN_FILENAME

xmlstarlet ed -L -s "/extension/rootstrap" -t elem -n "property" -v "" $PLUGIN_FILENAME
xmlstarlet ed -L -s "/extension/rootstrap/property[last()]" -t attr -n "key" -v "DEFAULT" $PLUGIN_FILENAME
xmlstarlet ed -L -s "/extension/rootstrap/property[last()]" -t attr -n "value" -v "false" $PLUGIN_FILENAME
fi

}
###########################################################################################

#script start
BUILD_OPT_INC_PATH=""
BUILD_OPT_LIB_PATH=""
BUILD_OPT_LIB_NAME=""
BUILD_OPT_CLI_RS_LIBRARIES=""


SCRIPT_NAME=$(basename ${0})
SCRIPT_VER="0.0.1"
SCRIPT_PATH=$(dirname ${0})

INFO_FILE=$1; #OLD

OPTS=`getopt -o -t:i:p:v:h --long type:,info:,profile:,version:,help,internal -- "$@"`
if [ $? != 0 ] ; then log "Failed parsing options." >&2 ; exit 1 ; fi

log "$SCRIPT_NAME PARAMETER : $OPTS"
eval set -- "$OPTS"

ROOTSTRAP_TYPE=""

while true; do
case "$1" in
-t | --type ) ROOTSTRAP_TYPE="$2"; shift;shift ;;
-i | --info ) INFO_FILE="$2"; shift; shift ;;
-p | --profile ) PLATFORM_PROFILE="$2"; shift; shift ;;
-v | --version ) PLATFORM_VERSION="$2"; shift; shift ;;
-h | --help ) exit; shift; shift ;;
--internal ) INTERNAL=true; shift ;;
-- ) shift; break ;;
* ) #print_usage_exit -1;
    break ;;
esac
done

log "INFO_FILE = $INFO_FILE"
log "ROOTSTRAP_TYPE = $ROOTSTRAP_TYPE"
log "PLATFORM_PROFILE = $PLATFORM_PROFILE"
log "PLATFORM_VERSION = $PLATFORM_VERSION"

if [ -z "$PLATFORM_PROFILE" ] || [ -z "$PLATFORM_VERSION" ] #to support old version
then
    source "$SCRIPT_PATH/../.rs-config"
fi

if [[ -z ${INFO_FILE} ]] || [[ ! -e ${INFO_FILE} ]]
then
    print_usage_exit
fi


PWD_BACKUP=`pwd`

INFO_DEST=${PWD_BACKUP}/".info"
PLUGIN_DEST=${PWD_BACKUP}/".plugin"

log "################# Start Generate Rootstrap Plugin#################"

#0. get build option from info file
get_build_option_from_infofile $INFO_FILE

#generate rootstrap plugin
if [ ! -e ${PLUGIN_DEST} ]
then
    mkdir ${PLUGIN_DEST};
fi



TEST=""
for i in $BUILD_OPT_CLI_RS_LIBRARIES
do
    TEST+="$i ";
done;

RS_LIB_OPT=`echo "$TEST" | sed 's/ $//g'`;

#echo "BUILD_OPT_INC_PATH=$BUILD_OPT_INC_PATH"
#echo "BUILD_OPT_LIB_PATH=$BUILD_OPT_LIB_PATH"
#echo "BUILD_OPT_LIB_NAME=$BUILD_OPT_LIB_NAME"
#echo "RS_LIB_OPT=$RS_LIB_OPT"
log "${INFO_FILE}"

if [[ "${INFO_FILE}" == *"emulator.core.dev.xml"* ]] || [[ "${INFO_FILE}" == *"emulator.core.private.dev.xml"* ]]
then

#emulator
TYPE="emulator"
ARCH="i386"

RS_PATH="#{SBI_HOME}/../../platforms/tizen-${PLATFORM_VERSION}/${PLATFORM_PROFILE}/rootstraps/${PLATFORM_PROFILE}-${PLATFORM_VERSION}-${TYPE}.core"
DEV_PACKAGE_CONFIG_PATH="#{SBI_HOME}/../../platforms/tizen-${PLATFORM_VERSION}/${PLATFORM_PROFILE}/rootstraps/info/${PLATFORM_PROFILE}-${PLATFORM_VERSION}-${TYPE}.core.dev.xml"
PLUGIN_FILENAME=${PLUGIN_DEST}/"$PLATFORM_PROFILE-$PLATFORM_VERSION-${TYPE}.core.xml"


#if [ "$INTERNAL" = true ]; then
#DEV_PACKAGE_CONFIG_PATH="#{SBI_HOME}/../../platforms/tizen-${PLATFORM_VERSION}/${PLATFORM_PROFILE}/rootstraps/info/${PLATFORM_PROFILE}-${PLATFORM_VERSION}-${TYPE}.core.private.dev.xml"
#PLUGIN_FILENAME=${PLUGIN_DEST}/"$PLATFORM_PROFILE-$PLATFORM_VERSION-${TYPE}.core.private.xml"
#fi

log "TYPE = $TYPE"
log "ARCH = $ARCH"
log "RS_PATH = $RS_PATH"
log "DEV_PACKAGE_CONFIG_PATH = $DEV_PACKAGE_CONFIG_PATH"
log "PLUGIN_FILENAME = $PLUGIN_FILENAME"

if [ -e ${PLUGIN_FILENAME} ]
then
    rm ${PLUGIN_FILENAME};
fi

generate_plugin
fi

if [[ "{$INFO_FILE}" == *"device.core.dev.xml"* ]] || [[ "$INFO_FILE" == *"device.core.private.dev.xml"* ]]
then

#device
TYPE="device"
ARCH="armel"

RS_PATH="#{SBI_HOME}/../../platforms/tizen-${PLATFORM_VERSION}/${PLATFORM_PROFILE}/rootstraps/${PLATFORM_PROFILE}-${PLATFORM_VERSION}-${TYPE}.core"
DEV_PACKAGE_CONFIG_PATH="#{SBI_HOME}/../../platforms/tizen-${PLATFORM_VERSION}/${PLATFORM_PROFILE}/rootstraps/info/${PLATFORM_PROFILE}-${PLATFORM_VERSION}-${TYPE}.core.dev.xml"
PLUGIN_FILENAME=${PLUGIN_DEST}/"$PLATFORM_PROFILE-$PLATFORM_VERSION-${TYPE}.core.xml"


#if [ "$INTERNAL" = true ]; then
#DEV_PACKAGE_CONFIG_PATH="#{SBI_HOME}/../../platforms/tizen-${PLATFORM_VERSION}/${PLATFORM_PROFILE}/rootstraps/info/${PLATFORM_PROFILE}-${PLATFORM_VERSION}-${TYPE}.core.private.dev.xml"
#PLUGIN_FILENAME=${PLUGIN_DEST}/"$PLATFORM_PROFILE-$PLATFORM_VERSION-${TYPE}.core.private.xml"
#fi

log "TYPE = $TYPE"
log "ARCH = $ARCH"
log "RS_PATH = $RS_PATH"
log "DEV_PACKAGE_CONFIG_PATH = $DEV_PACKAGE_CONFIG_PATH"
log "PLUGIN_FILENAME = $PLUGIN_FILENAME"

if [ -e ${PLUGIN_FILENAME} ]
then
    rm ${PLUGIN_FILENAME};
fi

generate_plugin

else
log "No File : $INFO_FILE"
fi

#log "######################## END  [$SECONDS] Sec ##############################" 1>&2

exit 0