-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·75 lines (62 loc) · 1.61 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
#!/bin/bash
EXEC=dam
while true; do
case ${1} in
--version)
shift
VERSION="${1}"
;;
*)
break
;;
esac
shift
done
if [[ ! -d .git ]] && [[ -z ${VERSION+x} ]]; then echo "Not in git environement, please specify version via --version argument"; exit 1; fi
[[ -z ${VERSION+x} ]] && VERSION=$(git describe --tags)
test_function() {
local functionList=(${@})
source src/env
for function in ${functionList[@]}; do
local dependencyList=($(grep "# DEPENDENCIES" ${function} | sed 's|# DEPENDENCIES||'))
for dependency in ${dependencyList[@]}; do
eval source ${dependency}
done
bash ${function}
done
}
gen_help() {
for file in $(find help/ -type f -printf "%P\n"); do
echo -e "
# ${file} help
help_${file}() {
echo -e \""
cat help/${file}
echo -e "\"
}"
done
}
gen_env() {
echo -e "#!/bin/bash\n"
echo "VERSION=${VERSION}"
echo "REPO_VERSION=1"
awk '!/^ *#/ && NF' src/env
}
gen_function() {
local functionList=(${@})
for function in ${functionList[@]}; do
awk '!/^ *#/ && NF' ${function}
done
}
gen_parser() {
awk '!/^ *#/ && NF' src/parser
}
test_function $(find src/ -type f -not -name env -not -name parser)
# test_function src/import_track
gen_env > ${EXEC}
gen_help >> ${EXEC}
gen_function $(find src/ -type f -not -name env -not -name parser) >> ${EXEC}
gen_function $(find bunc/src/ -type f) >> ${EXEC}
gen_parser >> ${EXEC}
echo ${@} >> ${EXEC}
chmod +x ${EXEC}