Skip to content

Commit e2daaa6

Browse files
Merge pull request #24 from SkylabsAI/rodolphe/dev-check-ver-uv
Refactor [dev/check_ver] + include [uv] + remove [_CoqProject]
2 parents 28dd0f9 + fff4568 commit e2daaa6

File tree

13 files changed

+210
-410
lines changed

13 files changed

+210
-410
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
_build/
22
_opam/
3+
_CoqProject

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ ide-prepare: _CoqProject
2222
FORCE:
2323

2424
_CoqProject: fmdeps/BRiCk/scripts/coq_project_gen/gen-_CoqProject-dune.sh FORCE
25-
$(Q)$< > $@ || { rm -f $@; exit 1; }
25+
$(Q)uv run --with sexpdata --python 3.11 --quiet -- $< > $@ \
26+
|| { rm -f $@; exit 1; }
2627

2728
.PHONY: stage1
2829
stage1: ide-prepare | ast-prepare-bluerock

_CoqProject

Lines changed: 0 additions & 295 deletions
This file was deleted.

dev/activate.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
# Source this file to setup your shell.
22

3+
if [[ -f ".venv/bin/activate" ]]; then
4+
source ".venv/bin/activate"
5+
fi
6+
37
eval $(opam env)

dev/check_ver/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Dependency Checking Infrastructure
2+
==================================
3+
4+
Template
5+
--------
6+
7+
```bash
8+
#!/usr/bin/env bash
9+
10+
PROG="prog" # Program name.
11+
URL="https://prog.html/install/" # Installation instructions.
12+
MIN="42.0.1" # Minimum supported version (included).
13+
MAX="50.0.0" # First version that is not supported (optional).
14+
RECOMMENDED="..." # Recommended version (optional).
15+
16+
# Function that prints the version.
17+
print_ver() {
18+
...
19+
}
20+
21+
# Function that performs extra checks (optional)
22+
extra_checks() {
23+
...
24+
}
25+
26+
source "dev/check_ver/driver.inc.sh"
27+
```

dev/check_ver/clang.sh

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,31 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
#
3-
# Copyright (c) 2024 BlueRock Security, Inc.
3+
# Copyright (c) 2025 SkyLabs AI, Inc.
44
#
5-
# This software is distributed under the terms of the BlueRock Open-Source
6-
# License. See the LICENSE-BlueRock file at the repository root for details.
7-
#
8-
9-
set -euf -o pipefail
10-
11-
MIN_MAJOR_VER="18"
12-
MAX_MAJOR_VER="20"
13-
RECOMMENDED_VER="19"
145

15-
if ! type clang 2> /dev/null > /dev/null; then
16-
echo -e "\033[0;31mCould not find clang."
17-
echo -e "We recommend version ${RECOMMENDED_VER} (see https://apt.llvm.org).\033[0m"
18-
exit 1
19-
fi
6+
PROG="clang"
7+
URL="https://apt.llvm.org"
8+
MIN="18.0.0"
9+
MAX="21.0.0"
10+
RECOMMENDED="19.*.*"
2011

21-
VER="$(clang --version | \
22-
grep "clang version" | \
23-
sed -r 's/^.*clang version ([0-9.]+).*$/\1/' | \
24-
cut -d' ' -f3)"
25-
MAJOR_VER="$(echo ${VER} | cut -d'.' -f1)"
12+
print_ver() {
13+
VER="$(clang --version | grep "clang version" | sed -r 's/^.*clang version ([0-9.]+).*$/\1/')"
14+
if ! [[ "${VER}" =~ ([^\.]*)\.([^\.]*)\.([^\.]*) ]]; then
15+
>&2 echo "Error: could not parse the output of 'clang --version'."
16+
>&2 clang --version
17+
exit 1
18+
fi
19+
echo "${VER}"
20+
}
2621

27-
if seq ${MIN_MAJOR_VER} ${MAX_MAJOR_VER} | grep -q "${MAJOR_VER}"; then
22+
extra_checks() {
2823
if ! echo "int main(){}" | clang++ -xc++ -stdlib=libc++ - 2>/dev/null; then
29-
echo -e "\033[0;31mError: it seems you don't have libc++ installed."
24+
echo -e "\033[0;31mError: libc++ does not seem to be installed.\033[0m"
3025
exit 1
3126
else
3227
rm a.out
3328
fi
29+
}
3430

35-
echo "Using clang version ${VER}."
36-
else
37-
echo -e "\033[0;31mError: clang version ${VER} is not supported."
38-
echo -e "A major version between ${MIN_MAJOR_VER} and ${MAX_MAJOR_VER} is expected.\033[0m"
39-
exit 1
40-
fi
31+
source "dev/check_ver/driver.inc.sh"

dev/check_ver/driver.inc.sh

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#
2+
# Copyright (c) 2025 SkyLabs AI, Inc.
3+
#
4+
5+
set -euf -o pipefail
6+
7+
# Check that the expected variables are defined and non-empty.
8+
for VAR in PROG URL MIN; do
9+
if [[ ! -v ${VAR} ]] ; then
10+
echo "Bug: variable ${VAR} not defined."
11+
exit 2
12+
fi
13+
done
14+
15+
# Check that the print_ver function is defined.
16+
if [[ ! $(type -t print_ver) == "function" ]]; then
17+
echo "Bug: function print_ver not defined."
18+
exit 2
19+
fi
20+
21+
# Usage: available PROG
22+
# Description: indicates whether PROG exists in PATH.
23+
available() {
24+
type $1 2> /dev/null > /dev/null
25+
}
26+
27+
# Usage: appropriate_version MIN VER [MAX]
28+
# Description: indicates whether MIN ≤ VER < MAX, using version order.
29+
appropriate_version() {
30+
if [[ "$2" == "$1" ]]; then
31+
# Version equal to the (included) lower bound.
32+
true
33+
elif [[ "$2" != "$(echo -e "$1\n$2" | sort -V | tail -n1)" ]]; then
34+
# Lower bound constraint violated.
35+
false
36+
elif [[ "$#" != "3" ]]; then
37+
# No upper-bound constraint.
38+
true
39+
elif [[ "$2" == "$3" ]]; then
40+
# Version equal to (excluded) upper bound.
41+
false
42+
else
43+
[[ "$2" == "$(echo -e "$2\n$3" | sort -V | head -n1)" ]]
44+
fi
45+
}
46+
47+
instructions() {
48+
echo -e "\033[0;31m$1"
49+
if [[ -v MAX ]]; then
50+
echo -e "Install a version VER such that: ${MIN} ≤ VER < ${MAX}."
51+
else
52+
echo -e "Install a version VER such that: ${MIN} ≤ VER."
53+
fi
54+
if [[ -v RECOMMENDED ]]; then
55+
echo -e "Recommended version: ${RECOMMENDED}."
56+
fi
57+
echo -e "See ${URL} for instructions.\033[0m"
58+
exit 1
59+
}
60+
61+
if ! available "${PROG}"; then
62+
instructions "Could not find ${PROG}."
63+
fi
64+
65+
VER=$(print_ver)
66+
if [[ -v MAX ]]; then
67+
if ! appropriate_version ${MIN} ${VER} ${MAX}; then
68+
instructions "Your version of ${PROG} (${VER}) is not supported."
69+
fi
70+
else
71+
if ! appropriate_version ${MIN} ${VER}; then
72+
instructions "Your version of ${PROG} (${VER}) is not supported."
73+
fi
74+
fi
75+
76+
if [[ $(type -t extra_checks) == "function" ]]; then
77+
extra_checks
78+
fi
79+
80+
echo "Using ${PROG} version ${VER}."

dev/check_ver/opam.sh

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,14 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
#
3-
# Copyright (c) 2024 BlueRock Security, Inc.
3+
# Copyright (c) 2025 SkyLabs AI, Inc.
44
#
5-
# This software is distributed under the terms of the BlueRock Open-Source
6-
# License. See the LICENSE-BlueRock file at the repository root for details.
7-
#
8-
9-
set -euf -o pipefail
105

11-
MIN_VERSION="2.2.1"
6+
PROG="opam"
7+
URL="https://opam.ocaml.org/doc/Install.html"
8+
MIN="2.2.1"
129

13-
if ! type opam 2> /dev/null > /dev/null; then
14-
echo -e "\033[0;31mCould not find opam."
15-
echo -e "We require at least version ${MIN_VERSION}."
16-
echo -e "See https://opam.ocaml.org/doc/Install.html for installation instructions.\033[0m"
17-
exit 1
18-
fi
10+
print_ver() {
11+
opam --version
12+
}
1913

20-
VER=$(opam --version)
21-
if [[ "${MIN_VERSION}" != \
22-
"$(echo -e "${VER}\n${MIN_VERSION}" | sort -V | head -n1)" ]]; then
23-
echo -e "\033[0;31mYour version of opam (${VER}) is too old."
24-
echo -e "Version ${MIN_VERSION} at least is required."
25-
echo -e "See https://opam.ocaml.org/doc/Install.html for upgrade instructions.\033[0m"
26-
else
27-
echo "Using opam version ${VER}."
28-
fi
14+
source "dev/check_ver/driver.inc.sh"

dev/check_ver/rust.sh

Lines changed: 17 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,22 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
#
3-
# Copyright (c) 2024 BlueRock Security, Inc.
3+
# Copyright (c) 2025 SkyLabs AI, Inc.
44
#
5-
# This software is distributed under the terms of the BlueRock Open-Source
6-
# License. See the LICENSE-BlueRock file at the repository root for details.
7-
#
8-
9-
set -euf -o pipefail
10-
11-
EXP_MAJOR_VER="1" # we could have min and max here as well but the range check becomes more complicated
12-
MIN_MINOR_VER="85"
13-
MAX_MINOR_VER="90"
14-
RECOMMENDED_MINOR_VER="90"
155

16-
RECOMMENDED_VER="${EXP_MAJOR_VER}.${RECOMMENDED_MINOR_VER}"
17-
MIN_VER="${EXP_MAJOR_VER}.${MIN_MINOR_VER}"
18-
MAX_VER="${EXP_MAJOR_VER}.${MAX_MINOR_VER}"
19-
20-
usage () {
21-
echo -e "A version between ${MIN_VER} and ${MAX_VER} is expected.\033[0m"
22-
echo -e "We recommend version ${RECOMMENDED_VER} (see https://rust-lang.org/tools/install/).\033[0m"
23-
}
24-
25-
if ! type rustc 2> /dev/null > /dev/null; then
26-
echo -e "\033[0;31mCould not find rustc."
27-
usage
28-
exit 1
29-
fi
30-
31-
VER="$(rustc --version | \
32-
grep "rustc" | \
33-
sed -r 's/^.*rustc ([0-9.]+).*$/\1/' | \
34-
cut -d' ' -f3)"
35-
if ! [[ $VER =~ ([^\.]*)\.([^\.]*)\.([^\.]*) ]]; then
36-
echo "Unable to parse the output of 'rustc --version':"
37-
rustc --version
38-
usage
6+
PROG="rustc"
7+
URL="https://rust-lang.org/tools/install/"
8+
MIN="1.85.0"
9+
MAX="1.91.0"
10+
RECOMMENDED="1.90.*"
11+
12+
print_ver() {
13+
VER="$(rustc --version | grep "rustc " | cut -d' ' -f2)"
14+
if ! [[ "${VER}" =~ ([^\.]*)\.([^\.]*)\.([^\.]*) ]]; then
15+
>&2 echo "Error: could not parse the output of 'rustc --version'."
16+
>&2 rustc --version
3917
exit 1
40-
fi
41-
MAJOR_VER="${BASH_REMATCH[1]}"
42-
MINOR_VER="${BASH_REMATCH[2]}"
43-
44-
if ! (( EXP_MAJOR_VER == MAJOR_VER && \
45-
MIN_MINOR_VER <= MINOR_VER && MINOR_VER <= MAX_MINOR_VER )); then
46-
echo -e "\033[0;31mError: rustc version ${VER} is not supported."
47-
usage
48-
exit 1
49-
fi
18+
fi
19+
echo "${VER}"
20+
}
5021

51-
echo "Using rustc version ${VER}."
22+
source "dev/check_ver/driver.inc.sh"

dev/check_ver/uv.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright (c) 2025 SkyLabs AI, Inc.
4+
#
5+
6+
PROG="uv"
7+
URL="https://github.com/astral-sh/uv/blob/main/README.md"
8+
MIN="0.9.0"
9+
MAX="0.10.0"
10+
11+
print_ver() {
12+
uv self version --short | cut -d' ' -f1
13+
}
14+
15+
source "dev/check_ver/driver.inc.sh"

0 commit comments

Comments
 (0)