-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHog.sh
executable file
·212 lines (187 loc) · 6.7 KB
/
Hog.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#!/usr/bin/env bash
# Copyright 2018-2025 The University of Birmingham
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
. $(dirname "$0")/Other/CommonFunctions.sh
. $(dirname "$0")/Init.sh
. $(dirname "$0")/CreateProject.sh
. $(dirname "$0")/LaunchWorkflow.sh
. $(dirname "$0")/LaunchSimulation.sh
function help_Unic() {
# echo
# echo " Hog - Initialise repository"
echo " ------------------------------------------------------ "
echo " USAGE: ./Hog/Hog.sh [GLOBAL OPTIONS] ACTIVITY PATH_TO_PROJECT [ACTIVITY_OPTIONS]"
echo ""
echo " HOG OPTIONS:"
echo " -h , --help Show this message"
echo " -v LEVEL , --verbose LEVEL "
echo " Sets level of verbose to debug"
echo " If no value is passed verbose is set to 5 - debug"
echo " -l , --logger Enables logger to file"
echo " To make it permanenet and not need to add this option in the calling, please export HOG_LOGGER=1"
echo " -o , --color Enables colorful logs"
echo " To make it permanent and not need to add this option in the calling, please export HOG_COLORED=1"
echo ""
echo " ACTIVITIES:"
echo " -I PATH_TO_PROJECT [ACTIVITY_OPTIONS] , Init PATH_TO_PROJECT [ACTIVITY_OPTIONS]"
echo " Initializes the Hog repository"
echo " -C PATH_TO_PROJECT [ACTIVITY_OPTIONS] , Create PATH_TO_PROJECT [ACTIVITY_OPTIONS]"
echo " Creates a Projects"
echo " -W PATH_TO_PROJECT [ACTIVITY_OPTIONS] , Workflow PATH_TO_PROJECT [ACTIVITY_OPTIONS]"
echo " Launches the tasks to build, synthesize or implement the project "
echo " -S PATH_TO_PROJECT [ACTIVITY_OPTIONS] , Simulation PATH_TO_PROJECT [ACTIVITY_OPTIONS]"
echo " Launches the simulation of the project"
echo " ------------------------------------------------------ "
echo " EXAMPLES:"
echo " "
echo "./Hog/Hog.sh -h Print this help message"
echo "./Hog/Hog.sh -C -h Print Project Creator help"
echo "./Hog/Hog.sh -v 2 -l -C Top/MainBlocks/BA3_ucm_divIP/ "
echo " Creates project with logger, and verbosing errors, critical warnings and warnings"
echo "./Hog/Hog.sh -o -v 6 -l -C Top/MainBlocks/BA3_ucm_divIP/"
echo " Creates project with logger, and verbosing all messages including debug and extra information"
echo ""
exit 0
}
# function help_Init() {
# echo
# echo " Hog - Initialise repository"
# echo " ---------------------------"
# echo " Initialise your Hog-handled firmware repository"
# echo " - (optional) Compile questasim/modelsim/riviera libraries (if questasim executable is found)"
# echo " - (optional) Create vivado projects (if vivado executable is found)"
# echo
# exit 0
# }
# function help_Create() {
# echo
# echo " Hog - Create HDL project"
# echo " ---------------------------"
# echo " Create the specified Vivado, Quartus or PlanAhead project"
# echo
# echo " The project type is selected using the first line of the hog.conf generating the project"
# echo " Following options are available: "
# echo " #vivado "
# echo " #quartus "
# echo " #planahead "
# echo
# echo " Usage: $1 <project name> [OPTIONS]"
# echo " Options:"
# echo " -l/--lib <sim_lib_path> Path to simulation library. If not defined it will be set to the HOG_SIMULATION_LIB_PATH environmental library, or if this does not exist to the default $(pwd)/SimulationLib"
# echo
# echo " Hint: Hog accepts as <project name> both the actual project name and the relative path containing the project configuration. E.g. ./Hog/CreateProject.sh Top/myproj or ./Hog/CreateProject.sh myproj"
# exit 0
# }
msg_counter init
ROOT_PROJECT_FOLDER=$(pwd)
LOG_INFO_FILE=$ROOT_PROJECT_FOLDER"/hog_info.log"
LOG_WAR_ERR_FILE=$ROOT_PROJECT_FOLDER"/hog_warning_errors.log"
if [ $# == 0 ]; then
# help_message $0
help_Unic
return 1
else
declare -a args=($*)
ind_verb=("-v" "--verbose")
if [[ "$*" == *"-v "* ]] || [[ "$*" == *"--verbose "* ]]; then
pos_arg=0
for pos_i_arg in "${args[@]}"; do
if [[ "$pos_i_arg" == $ind_verb ]]; then break; fi
pos_arg=$(($pos_arg+1))
done
if [[ ${args[$((pos_arg+1))]} == "-"* ]]; then
DEBUG_VERBOSE=5
# DEBUG_MODE=5
Msg Warning "No level of verbose fixed, level will be set to 5(debug)"
unset -v 'args[pos_arg]'
else
DEBUG_VERBOSE=${args[$((pos_arg+1))]}
# DEBUG_MODE=5
Msg Debug "Level of verbose set to ($DEBUG_VERBOSE)"
unset -v 'args[pos_arg]'
unset -v 'args[$((pos_arg+1))]'
fi
Msg Debug "Verbose level debug"
delete=("-v" "--verbose")
for del in "${delete[@]}"
do
args=(${args[@]/$del})
done
else
DEBUG_VERBOSE=4
# DEBUG_MODE=0
fi
if [[ "$*" == *"-o "* ]] || [[ "$*" == *"--color "* ]]; then
export HOG_COLORED=1
Msg Debug "Verbose with colors"
delete=("-o" "--color")
for del in "${delete[@]}"
do
args=(${args[@]/$del})
done
fi
if [[ "$*" == *"-l"* ]] || [[ "$*" == *"--logger"* ]]; then
export HOG_LOGGER=1
Msg Debug "logger to file"
delete=("-l" "--logger")
for del in "${delete[@]}"
do
args=(${args[@]/$del})
done
fi
##
Msg Debug "Input parameters (${args[*]}) :: ${#args[*]})"
if [[ -v "$HOG_COLORED" && $HOG_COLORED == "ENABLED" ]]; then
new_print_hog "$(dirname "$0")"
else
print_hog "$(dirname "$0")"
fi
if [[ -v HOG_LOGGER && $HOG_LOGGER == "ENABLED" ]]; then
Logger_Init "$*"
fi
activity=("${args[0]}")
args=("${args[@]:1}")
shift
case "$activity" in
-I|Init)
# echo "Init"
HogInitFunc "${args[*]}"
exit 0
;;
-C|Create)
Msg Info "Create ${args[*]}"
HogCreateFunc "${args[*]}"
Hog_exit
;;
-W|Workflow)
Msg Info " Workflow"
HogLaunchFunc "${args[*]}"
# ./Hog/LaunchWorkflow.sh $*
Hog_exit
;;
-S|Simulation)
Msg Info " Simulation"
# ./Hog/LaunchSimulation.sh $*
HogSimulateFunc "${args[*]}"
Hog_exit
;;
-h|--help)
help_Unic
;;
*)
Msg Error "Activity not recognized"
help_Unic "$0"
;;
esac
fi