Browse Source

Add toolchain selection menu

Add info function to show important information on update menu
pull/8/head
WXbet 5 years ago
parent
commit
66572749b3
  1. 111
      support/functions/_plugin_update_toolchain

111
support/functions/_plugin_update_toolchain

@ -1,23 +1,61 @@
#!/bin/bash #!/bin/bash
#simplebuild_plugin tcupdate 0.1.7 #simplebuild_plugin tcupdate 0.2.0
tcupdate(){ tcupdate(){
clear; clear;
if [ "$1" == "" ];then
_fill_tc_array;
IFS="#";
unset MENU_OPTIONS;COUNT=0
if [ "$systype" == "ok" ];then
if [ "$tcempty" == "0" ];then
for i in "${INST_TCLIST[@]}";do
if [ ! "$i" == "native" ];then
source "$tccfgdir/$i";
MENU_OPTIONS+="$_toolchainname#$_description#";
counter;
fi;
done;
fi;
fi;
out=$(
"$gui" "$st_" "$bt_" "$title_" "--cancel-label" "EXIT" "--help-button" "--help-label" "INFO" "--title" "-[ Toolchain $txt_menu ]-" --menu "\nChoose on of the installed toolchains you want to update:\n " "${COUNT+10}" 0 0 ${MENU_OPTIONS});
IFS=$OIFS;
[ "$out" == "" ] && bye;
first=$(echo "$out" | awk '{printf $1}');
tc_info=$(echo "$out" | awk '{printf $2}';);
case $first in
HELP)
if [ -f "$tccfgdir/$tc_info" ];then
source "$tccfgdir/$tc_info";
"$gui" "$st_" "$nc_" "$bt_" "$title_" "--msgbox" "$_tc_info" $((_tc_infolines + 5)) 65;
fi;
tcupdate;;
*)
tc="$first";
tc_menu="1";
esac;
else
tc="$1"
[ "$2" == "" ] && tc_menu="0" || tc_menu="$2";
fi;
#toolchain native not supported #toolchain native not supported
if [ "$1" == "native" ];then if [ "$tc" == "native" ];then
echo -e "$r_l $txt_error:$y_l $1$w_l Toolchain library update not supported!""$rs_"; echo -e "$r_l $txt_error:$y_l $tc$w_l Toolchain library update not supported!""$rs_";
_nl; _nl;
exit; exit;
fi; fi;
#toolchain exists check #toolchain exists check
[ -f "$tccfgdir/$1" ] && source "$tccfgdir/$1"; [ -f "$tccfgdir/$tc" ] && source "$tccfgdir/$tc";
if [ -d "$tcdir/$1/bin" ];then if [ -d "$tcdir/$tc/bin" ];then
cd "$tcdir/$1/bin"; cd "$tcdir/$tc/bin";
else else
echo -e "$r_l $txt_error:$y_l $1$w_l Toolchain $txt_n_installed""$rs_"; echo -e "$r_l $txt_error:$y_l $tc$w_l Toolchain $txt_n_installed""$rs_";
_nl; _nl;
exit; exit;
fi; fi;
@ -38,11 +76,12 @@ tcupdate(){
ranlibname="$_compiler""ranlib";ranlibname=$(realpath $ranlibname); ranlibname="$_compiler""ranlib";ranlibname=$(realpath $ranlibname);
hostname=${_compiler%?}; hostname=${_compiler%?};
sr=$("$compilername" -print-sysroot 2>/dev/null); sr=$("$compilername" -print-sysroot 2>/dev/null);
sr=$(realpath -sm "$sr");
if [ ${#sr} -gt ${#tcdir} ];then if [ ${#sr} -gt ${#tcdir} ];then
[ -d "$sr/include" ] && cd "$sr" [ -d "$sr/include" ] && cd "$sr"
[ -d "$sr/usr/include" ] && cd "$sr/usr" [ -d "$sr/usr/include" ] && cd "$sr/usr"
else else
cd "$tcdir/$1/$_sysroot" cd "$tcdir/$tc/$_sysroot"
fi; fi;
prefixdir="$PWD" prefixdir="$PWD"
pkg=$(find * | grep -m1 "/pkgconfig") && pkgdir="$prefixdir/$pkg"; pkg=$(find * | grep -m1 "/pkgconfig") && pkgdir="$prefixdir/$pkg";
@ -73,12 +112,29 @@ tcupdate(){
libs+=("(${lib[*]@Q})"); libs+=("(${lib[*]@Q})");
done; done;
opts=$("$gui" "--item-help" "$st_" "$bt_" "$title_" --title "-[ Library Update for Toolchain $1 ]-" "$cl_" \ opts=$("$gui" "--item-help" "--help-tags" "$st_" "$bt_" "$title_" "--help-button" "--help-label" "INFO" "--cancel-label" "$([ "$tc_menu" == "1" ] && echo "BACK" || echo "EXIT")" --title "-[ Library Update for Toolchain $tc ]-" "$cl_"\
"\nSelect all libraries to update in toolchain's SYSROOT folder:\n$prefixdir\n\n library version NEW CURRENT" \ "\nSelect all libraries to update in toolchain's SYSROOT folder:\n$prefixdir\n\n library version NEW CURRENT" \
"${COUNT+12}" 70 0 "${MENU_OPTIONS[@]}"); "${COUNT+12}" 70 0 "${MENU_OPTIONS[@]}");
[ $(echo $opts | tr ' ' '\n' | grep -c "SSL_") -gt 1 ] && echo -e $r_l"\n\nPlease select only one SSL version!"$re_ && sleep 3 && tcupdate $1; #SSL select check
[ $(echo $opts | tr ' ' '\n' | grep -c "SSL_") -gt 1 ] && echo -e $r_l"\n\nPlease select only one SSL version!"$re_ && sleep 3 && tcupdate $tc;
#HELP section
first=$(echo "$opts" | awk '{printf $1}');
libkey=$(echo "$opts" | awk '{printf $2}';);
if [ "$first" == "HELP" ];then
sp=$(printf '%*s' 90 | tr ' ' '=')
txt=$(cat "$configname" | grep ""$libkey"=\|"$libkey"_");
bcd=$(cat "$configname" | grep ""$libkey"_tasks");
txt=$(echo -e "Toolchain: $tcdir/$tc\nCompiler: $compilername\nSysroot: $sr\nPrefix: $prefixdir\n$sp\n\nLibrary configuration:\n$txt\n\nBuild command:\n$(_replace_tokens "$(_tidy_tasks "$bcd" "$libkey")")")
tempfile=$(mktemp) && echo -e "$txt" > "$tempfile"
"$gui" "$st_" "$nc_" "$bt_" "$title_" "--textbox" "$tempfile" 30 80;
rm "$tempfile" 2>/dev/null;
tcupdate $tc $tc_menu;
fi;
#BUILD section
icount=$(echo $opts | wc -w);i=0; icount=$(echo $opts | wc -w);i=0;
for o in $opts;do for o in $opts;do
unset buildtasks; unset buildtasks;
@ -89,13 +145,8 @@ tcupdate(){
#generate build command list #generate build command list
declare -a libtasks="${lib[7]}"; #populate tasks array element declare -a libtasks="${lib[7]}"; #populate tasks array element
for task in "${libtasks[@]}";do #replace tokens for task in "${libtasks[@]}";do
task=$(echo $task | sed -e "s#@TOOLCHAIN@#$tcdir/$1#g; \ task=$(_replace_tokens "$task"); #replace tokens
s#@CC@#$compilername#g; \
s#@RANLIB@#$ranlibname#g; \
s#@PREFIX@#$prefixdir#g; \
s#@HOST@#$hostname#g" \
);
buildtasks+=("$task"); buildtasks+=("$task");
done done
@ -104,12 +155,13 @@ tcupdate(){
done; done;
#Reopen update menu #Reopen update menu
[ ${#opts} -gt 0 ] && tcupdate $1; if [ ${#opts} -gt 0 ];then
tcupdate $tc;
else
[ "$tc_menu" == "1" ] && tcupdate;
fi;
clear; bye;
echo -e "$w_l";
s3logo;
exit;
}; };
_build(){ _build(){
@ -194,6 +246,21 @@ _extract(){
done done
exit; exit;
}; };
_replace_tokens(){
echo -e "$1" | sed -e "s#@TOOLCHAIN@#$tcdir/$tc#g; \
s#@CC@#$compilername#g; \
s#@RANLIB@#$ranlibname#g; \
s#@PREFIX@#$prefixdir#g; \
s#@HOST@#$hostname#g";
};
_tidy_tasks(){
echo -e "$1" | sed -e "s#$2"_tasks=\(\""##g; \
s#$2"_tasks=\(\'"##g; \
s#$2"_tasks+=\(\""##g; \
s#$2"_tasks+=\(\'"##g; \
s#"\"\)\;"##g; \
s#"\'\)\;"##g;";
};
_get_version(){ _get_version(){
r=""; r="";
if [ -f "$1" ];then if [ -f "$1" ];then

Loading…
Cancel
Save