-
Notifications
You must be signed in to change notification settings - Fork 233
/
Copy pathclonetb
executable file
·160 lines (130 loc) · 3.62 KB
/
clonetb
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
#!/bin/sh
# Copyright 2023 Silicon Laboratories Inc.
#
# SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
#
# Licensed under the Solderpad Hardware License v 2.1 (the "License"); you may
# not use this file except in compliance with the License, or, at your option,
# the Apache License version 2.0.
#
# You may obtain a copy of the License at
# https://solderpad.org/licenses/SHL-2.1/
#
# Unless required by applicable law or agreed to in writing, any work
# 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.
# Description:
# This script clones core-specific verification environments.
# (E.g. "core-v-verif/cv32e40x/".)
# Try running it, and it will assist you with helpful messages.
#
# Examples:
# "$ ./bin/clonetb"
# "$ ./bin/clonetb -x"
# "$ CV_CORE=cv32e40x ./bin/clonetb --unignore"
#
# Environment:
# (Typical usage does not require these to be set.)
# CV_CORE - Name of the core to use.
# VERIF_ENV_REPO - URL to external verif env repo.
# VERIF_ENV_REF - Branch/hash/tag of external verif env repo.
usage() {
echo "usage: $0 [-x] [--clone] [--ignore] [--unignore]"
echo " -x clone cv32e40x subtree, known stable hash"
echo " --x-main clone cv32e40x subtree, latest main branch"
echo " --s-main clone cv32e40s subtree, latest main branch"
echo " --clone clone a subtree based on env vars"
echo " --ignore tell git to ignore the cloned subtree"
echo " --unignore tell git to not ignore the cloned subtree"
exit 1
}
check_env_vars_cvcore() {
if [ -z "${CV_CORE}" ]; then
echo "error: 'CV_CORE' not defined"
exit 1
fi
}
check_env_vars() {
check_env_vars_cvcore
if [ -z "${VERIF_ENV_REPO}" ]; then
echo "error: 'VERIF_ENV_REPO' not defined"
exit 1
fi
if [ -z "${VERIF_ENV_REF}" ]; then
echo "error: 'VERIF_ENV_REF' not defined"
exit 1
fi
}
clone() {
check_env_vars
rm -rf ${CV_CORE}
git clone ${VERIF_ENV_REPO} ${CV_CORE}
cd ${CV_CORE} && git checkout ${VERIF_ENV_REF} && cd -
}
clone_cv32e40x() {
CV_CORE=cv32e40x
VERIF_ENV_REPO=https://github.com/openhwgroup/cv32e40x-dv.git
VERIF_ENV_REF=be17b8902002f91803abde4bfb8caa91088575e1
clone
ignore_cloned_directory
}
clone_cv32e40x_main() {
CV_CORE=cv32e40x
VERIF_ENV_REPO=https://github.com/openhwgroup/cv32e40x-dv.git
VERIF_ENV_REF=main
clone
ignore_cloned_directory
}
clone_cv32e40s_main() {
CV_CORE=cv32e40s
VERIF_ENV_REPO=https://github.com/openhwgroup/cv32e40s-dv.git
VERIF_ENV_REF=main
clone
ignore_cloned_directory
}
ignore_cloned_directory() {
check_env_vars_cvcore
# Add CV_CORE to git exclude
echo ${CV_CORE} >> .git/info/exclude
# Set "skip-worktree" git flag
git ls-files ${CV_CORE} | xargs git update-index --skip-worktree
}
unignore_cloned_directory() {
check_env_vars_cvcore
# Delete CV_CORE from git exclude
sed -i "/^${CV_CORE}$/d" .git/info/exclude
# Unset "skip-worktree" git flag
git ls-files -t | # Get git file status "tags"
grep '^S' | # Filter "skip-worktree" files
awk '{print $2}' | # Filter filename
xargs git update-index --no-skip-worktree
}
main() {
case $1 in
"-x")
clone_cv32e40x
;;
"--x-main")
clone_cv32e40x_main
;;
"--s-main")
clone_cv32e40s_main
;;
"--clone")
clone
;;
"--ignore")
ignore_cloned_directory
;;
"--unignore")
unignore_cloned_directory
;;
*)
usage
;;
esac
}
main "$@"