-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sh
executable file
·145 lines (124 loc) · 3.13 KB
/
build.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
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
#!/usr/bin/env bash
# build.sh
# ddos2
#
# Created by Andre Zay on 16/01/2020.
# Copyright © 2020 Andre Zay. All rights reserved.
#!/bin/bash
cd $(dirname `which $0`)
# Colors
if test -t 1; then
bold=$(tput bold)
normal=$(tput sgr0)
red=$(tput setaf 1)
green=$(tput setaf 2)
blue=$(tput setaf 4)
yellow=$(tput setaf 11)
else
echo "[!]: No colors will be available: not supported."
fi
echo " ______ ______ _______ _______ _______"
echo "( __ \ ( __ \ ( ___ )( ____ \/ ___ )"
echo "| ( \ )| ( \ )| ( ) || ( \/\/ ) |"
echo "| | ) || | ) || | | || (_____ / )"
echo "| | | || | | || | | |(_____ ) _/ /"
echo "| | ) || | ) || | | | ) | / _/"
echo "| (__/ )| (__/ )| (___) |/\\____) |( (__/\\"
echo "(______/ (______/ (_______)\\_______)\_______/"
echo " Build System v2.0-alpha"
error(){
echo "${bold}${red}[-]:${normal}${1}"
}
success(){
echo "${bold}${green}[+]:${normal}${1}"
}
warn(){
echo "${bold}${yellow}[!]:${normal}${1}"
}
info(){
echo "${bold}${blue}[*]:${normal}${1}"
}
exec(){
info "${1}"
eval "${1}"
code=$?
if [ ! $code -eq 0 ]; then
error "Exec: ${1} failed with non-zero exit code: ${code}"
exit -1
fi
}
require_directory(){ # Creates directory if not exist
if [ ! -d $1 ]; then
warn "Directory not found: ${1}. Will create it now."
exec "mkdir ${1}"
fi
}
change_dir(){
if [ ! -d $1 ]; then
error "No such directory: ${1}"
exit -1
fi
info "Entering directory: ${1}"
cd $1
}
leave_dir(){
info "Leaving directory: $(pwd)"
cd $BASEDIR
}
check_equal(){
printf "${bold}${blue}[*]:${normal}Checking equality: ${1} and ${2}..."
if ! cmp $1 $2 >/dev/null 2>&1
then
printf "${bold}${red}FAILED${normal}\n"
return -1
fi
printf "${bold}${green}OK${normal}\n"
return 0
}
require_equal(){
check_equal $1 $2
local r=$?
if [ ! $r -eq 0 ]; then
error "Files ${1} and ${2} are not equal."
exit -1
fi
}
check_command(){
printf "${bold}${blue}[*]:${normal}Checking that ${1} avail..."
if ! [ -x "$(command -v ${1})" ]; then
printf "${bold}${red}FAILED${normal}\n"
return -1
fi
printf "${bold}${green}OK${normal}\n"
return 0
}
require_command(){
check_command $1
local r=$?
if [ ! $r -eq 0 ]; then
error "Command ${1} is not avail."
exit -1
fi
}
if [ $# -eq 0 ]; then
error "Please specify target. Use -h option for help."
exit -1
fi
if [[ $1 == "-h" ]]; then
echo "Usage:"$0" <-h> [all|debug|release|clean|library]"
echo "-h Display this help message and exit."
echo "debug Build in debug mode"
echo "release Build in release mode"
echo "library Build libddos2"
echo "all Build all in release mode"
echo "all-debug Build all in debug mode"
echo "clean Remove obj/ bin/ directories."
exit 0
fi
source Buildfile
if [[ `type -t "target_${1}"` == "function" ]]; then
eval "target_${1}"
success "Done."
else
error "No such target:${1}."
fi