blob: 3d174e702acacad80028cda8ecd91bb785b2d614 (
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
|
#!/bin/bash
# xmake getter
# usage: bash <(curl -s <my location>) [[mirror:]branch] [commit/__install_only__]
set -o pipefail
# print a LOGO!
echo ' _ '
echo ' __ ___ __ __ __ _| | ______ '
echo ' \ \/ / | \/ |/ _ | |/ / __ \ '
echo ' > < | \__/ | /_| | < ___/ '
echo ' /_/\_\_|_| |_|\__ \|_|\_\____| getter '
echo ' '
brew --version >/dev/null 2>&1 && brew install --HEAD xmake && xmake --version && exit
if [ 0 -ne "$(id -u)" ]
then
sudoprefix=sudo
else
sudoprefix=
fi
my_exit(){
rv=$?
if [ "x$1" != x ]
then
echo -ne '\x1b[41;37m'
echo "$1"
echo -ne '\x1b[0m'
fi
rm -rf /tmp/$$xmake_getter 2>/dev/null
if [ "x$2" != x ]
then
if [ $rv -eq 0 ];then rv=$2;fi
fi
exit "$rv"
}
test_tools()
{
prog='#include<stdio.h>\n#include<readline/readline.h>\nint main(){readline(0);return 0;}'
{
git --version &&
make --version &&
{
echo -e "$prog" | cc -xc - -o /dev/null -lreadline ||
echo -e "$prog" | gcc -xc - -o /dev/null -lreadline ||
echo -e "$prog" | clang -xc - -o /dev/null -lreadline
}
} >/dev/null 2>&1
}
install_tools()
{
{ apt-get --version >/dev/null 2>&1 && $sudoprefix apt-get install -y git build-essential libreadline-dev; } ||
{ yum --version >/dev/null 2>&1 && $sudoprefix yum install -y git readline-devel && $sudoprefix yum groupinstall -y 'Development Tools'; } ||
{ zypper --version >/dev/null 2>&1 && $sudoprefix zypper --non-interactive install git readline-devel && $sudoprefix zypper --non-interactive install -t pattern devel_C_C++; } ||
{ pacman -V >/dev/null 2>&1 && $sudoprefix pacman -S --noconfirm --needed git base-devel; }
}
test_tools || { install_tools && test_tools; } || my_exit 'Dependencies Installation Fail' 1
branch=master
mirror=tboox
IFS=':'
if [ x != "x$1" ]
then
brancharr=($1)
if [ ${#brancharr[@]} -eq 1 ]
then
branch=${brancharr[0]}
fi
if [ ${#brancharr[@]} -eq 2 ]
then
branch=${brancharr[1]}
mirror=${brancharr[0]}
fi
echo "Branch: $branch"
fi
if [ 'x__local__' != "x$branch" ]
then
git clone --depth=50 -b "$branch" "https://github.com/$mirror/xmake.git" /tmp/$$xmake_getter || my_exit 'Clone Fail'
if [ x != "x$2" ]
then
cd /tmp/$$xmake_getter || my_exit 'Chdir Error'
git checkout -qf "$2"
cd - || my_exit 'Chdir Error'
fi
else
cp -r "$(git rev-parse --show-toplevel 2>/dev/null || hg root 2>/dev/null || echo "$PWD")" /tmp/$$xmake_getter || my_exit 'Clone Fail'
fi
if [ 'x__install_only__' != "x$2" ]
then
make -C /tmp/$$xmake_getter --no-print-directory build || my_exit 'Build Fail'
fi
PATHclone=$PATH
patharr=($PATHclone)
prefix=
for st in "${patharr[@]}"
do
if [[ "$st" = "$HOME"* ]]
then
cwd=$PWD
mkdir -p "$st"
cd "$st" || continue
echo $$ > $$xmake_getter_test 2>/dev/null || continue
rm $$xmake_getter_test 2>/dev/null || continue
cd .. || continue
mkdir -p share 2>/dev/null || continue
prefix=$(pwd)
cd "$cwd" || my_exit 'Chdir Error'
break
fi
done
if [ "x$prefix" != x ]
then
make -C /tmp/$$xmake_getter --no-print-directory install prefix="$prefix"|| my_exit 'Install Fail'
else
$sudoprefix make -C /tmp/$$xmake_getter --no-print-directory install || my_exit 'Install Fail'
fi
xmake --version
|