forked from MaaGF1/GFL-Linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·146 lines (123 loc) · 2.81 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·146 lines (123 loc) · 2.81 KB
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
#!/bin/bash
#################### Section 1 : Echo ####################
RED='\033[1;31m'
CYAN='\033[1;36m'
GREEN='\033[1;32m'
NC='\033[0m'
function echo_error()
{
local string="$1"
echo -e "${CYAN}${ScriptEchoLabel}${RED}${1}${NC}"
}
function echo_info()
{
local string="$1"
echo -e "${CYAN}${ScriptEchoLabel}${GREEN}${1}${NC}"
}
#################### Section 2 : Project Setting ####################
# Project Default Parameters
BuildPath="build"
ProjectPath=$(cd $(dirname $0);pwd)
ScriptEchoLabel="Build.sh: "
#################### Section 3 : Functions ####################
# if no BuildPath, then Create
function func_dir()
{
cd ${ProjectPath}
if [ ! -d "$BuildPath" ]; then
mkdir -p "$BuildPath"
echo_info "Create Build Path: $BuildPath"
fi
}
# camke ..
function func_cmake()
{
echo_info "cmake .."
if cmake ..; then
echo_info "CMake Success."
else
echo_error "CMake Fail."
exit 1
fi
}
# make
function func_make()
{
echo_info "make -j12"
if make -j12; then
echo_info "Make Success."
else
echo_error "Make Fail."
exit 1
fi
}
function func_all
{
cd ${BuildPath}
func_cmake
func_make
}
# clean
function func_clean()
{
echo_info "clean"
if [[ -d "${ProjectPath}/${BuildPath}" ]]; then
rm -r "${ProjectPath}/${BuildPath}"
if [[ $? -eq 0 ]]; then
echo_info "Clean Success."
else
echo_error "Clean Fail."
exit 1
fi
else
echo_info "Directory ${ProjectPath}/${BuildPath} does not exist."
fi
}
# help
function func_help()
{
echo_info "(no parameters) -- create output path, cmake, make"
echo_info "[all] -- clean, create output path, camke, make"
echo_info "[clean] -- rm output path"
echo_info "[help] -- show helps"
}
function func_map()
{
if [[ $1 == 'all' ]]; then
func_clean
func_dir
func_all
elif [[ $1 == "clean" ]]; then
func_clean
elif [[ $1 == "help" ]]; then
func_help
elif [[ -z $1 ]]; then
func_dir
func_all
else
func_help
fi
}
function cf()
{
cd ${ProjectPath}
echo_info "run Clang-Format."
# Exclude list
local exclude=(
"src/abi/autogen_stubs.h"
"src/include/windows.h"
)
find src \( -name '*.cpp' -o -name '*.h' \) \
| grep -v -F -f <(printf "%s\n" "${exclude[@]}") \
| xargs -r -I{} bash -c 'clang-format-16 -style=file {} | diff -u -L "{}" -L "{}" {} -' > .clang-format.diff
}
#################### Section 4 : Main ####################
function main()
{
clear
echo_info "PWD: ${ProjectPath}"
echo_info "Output: ${ProjectPath}/${BuildPath}"
func_map ${1}
cf
}
main $1