@@ -92,15 +92,26 @@ read_commit_from_toml() {
92
92
echo " $commit "
93
93
}
94
94
95
- clone_kani_repo () {
95
+ setup_kani_repo () {
96
96
local repo_url=" $1 "
97
97
local directory=" $2 "
98
98
local branch=" $3 "
99
99
local commit=" $4 "
100
- git clone " $repo_url " " $directory "
101
- pushd " $directory "
102
- git checkout " $commit "
103
- popd
100
+
101
+ if [[ ! -d " ${directory} " ]]; then
102
+ mkdir -p " ${directory} "
103
+ pushd " ${directory} " > /dev/null
104
+
105
+ git init . >& /dev/null
106
+ git remote add origin " ${repo_url} " >& /dev/null
107
+ else
108
+ pushd " ${directory} " > /dev/null
109
+ fi
110
+
111
+ git fetch --depth 1 origin " $commit " --quiet
112
+ git checkout " $commit " --quiet
113
+ git submodule update --init --recursive --depth 1 --quiet
114
+ popd > /dev/null
104
115
}
105
116
106
117
get_current_commit () {
@@ -115,17 +126,22 @@ get_current_commit() {
115
126
build_kani () {
116
127
local directory=" $1 "
117
128
pushd " $directory "
118
- os_name=$( uname -s)
119
-
120
- if [[ " $os_name " == " Linux" ]]; then
121
- ./scripts/setup/ubuntu/install_deps.sh
122
- elif [[ " $os_name " == " Darwin" ]]; then
123
- ./scripts/setup/macos/install_deps.sh
129
+ source " kani-dependencies"
130
+ # Check if installed versions are correct.
131
+ if ./scripts/check-cbmc-version.py --major ${CBMC_MAJOR} --minor ${CBMC_MINOR} && ./scripts/check_kissat_version.sh; then
132
+ echo " Dependencies are up-to-date"
124
133
else
125
- echo " Unknown operating system"
134
+ os_name=$( uname -s)
135
+
136
+ if [[ " $os_name " == " Linux" ]]; then
137
+ ./scripts/setup/ubuntu/install_deps.sh
138
+ elif [[ " $os_name " == " Darwin" ]]; then
139
+ ./scripts/setup/macos/install_deps.sh
140
+ else
141
+ echo " Unknown operating system"
142
+ fi
126
143
fi
127
144
128
- git submodule update --init --recursive
129
145
cargo build-dev --release
130
146
popd
131
147
}
@@ -147,19 +163,22 @@ check_binary_exists() {
147
163
local expected_commit=" $2 "
148
164
local kani_path=$( get_kani_path " $build_dir " )
149
165
150
- if [[ -f " $kani_path " ]]; then
166
+ if [[ -d " ${build_dir} " ]]; then
151
167
local current_commit=$( get_current_commit " $build_dir " )
152
168
if [[ " $current_commit " = " $expected_commit " ]]; then
153
169
return 0
170
+ else
171
+ echo " Kani repository is out of date. Rebuilding..."
154
172
fi
173
+ else
174
+ echo " Kani repository not found. Creating..."
155
175
fi
156
176
return 1
157
177
}
158
178
159
179
160
180
main () {
161
181
local build_dir=" $WORK_DIR /kani_build"
162
- local temp_dir_target=$( mktemp -d)
163
182
164
183
echo " Using TOML file: $TOML_FILE "
165
184
echo " Using repository URL: $REPO_URL "
@@ -173,12 +192,8 @@ main() {
173
192
else
174
193
echo " Building Kani from commit: $commit "
175
194
176
- # Remove old build directory if it exists
177
- rm -rf " $build_dir "
178
- mkdir -p " $build_dir "
179
-
180
195
# Clone repository and checkout specific commit
181
- clone_kani_repo " $REPO_URL " " $build_dir " " $BRANCH_NAME " " $commit "
196
+ setup_kani_repo " $REPO_URL " " $build_dir " " $BRANCH_NAME " " $commit "
182
197
183
198
# Build project
184
199
build_kani " $build_dir "
@@ -195,7 +210,7 @@ main() {
195
210
196
211
if [[ " $run_command " == " verify-std" ]]; then
197
212
echo " Running Kani verify-std command..."
198
- " $kani_path " verify-std -Z unstable-options ./library --target-dir " $temp_dir_target " \
213
+ " $kani_path " verify-std -Z unstable-options ./library \
199
214
-Z function-contracts \
200
215
-Z mem-predicates \
201
216
-Z loop-contracts \
@@ -211,9 +226,3 @@ main() {
211
226
212
227
main
213
228
214
- cleanup ()
215
- {
216
- rm -rf " $temp_dir_target "
217
- }
218
-
219
- trap cleanup EXIT
0 commit comments