Skip to content

Commit 40624c9

Browse files
committed
updated location script to support gcc 15, clang 20, clang 21; updated show-tool-versions script to output JSON, fixed version detection of ltrace
1 parent 0976497 commit 40624c9

File tree

2 files changed

+54
-15
lines changed

2 files changed

+54
-15
lines changed

.devcontainer/scripts/show-tool-locations.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,13 @@ show_tool_locations() {
2929
get_command_paths g++-12
3030
get_command_paths g++-13
3131
get_command_paths g++-14
32+
get_command_paths g++-15
3233
get_command_paths clang++-16
3334
get_command_paths clang++-17
3435
get_command_paths clang++-18
3536
get_command_paths clang++-19
37+
get_command_paths clang++-20
38+
get_command_paths clang++-21
3639
get_command_paths cmake
3740
get_command_paths meson
3841
get_command_paths ninja

.devcontainer/scripts/show-tool-versions.sh

Lines changed: 51 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,38 @@
55
# This file is part of https://github.com/jakoch/cpp-devbox
66

77
# This info script shows the version of tools, compilers and libc.
8-
# Output format is markdown.
8+
# The supported output formats are markdown (default) and JSON.
9+
# You can change to JSON by passing "json" as the first argument.
910

10-
# Function to print a table row in Markdown format
11+
OUTPUT_FORMAT=${1:-markdown}
12+
13+
# Function to call either print_row_markdown or print_row_json based on CLI arg
1114
print_row() {
15+
if [ "$OUTPUT_FORMAT" = "json" ]; then
16+
print_row_json "$@"
17+
else
18+
print_row_markdown "$@"
19+
fi
20+
}
21+
22+
# Function to print a table row in Markdown format
23+
print_row_markdown() {
1224
printf "| %-13s | %-19s |\n" "$1" "$2"
1325
}
1426

27+
# Function to print a JSON row
28+
FIRST_ENTRY=true
29+
print_row_json() {
30+
if [ "$FIRST_ENTRY" = true ]; then
31+
FIRST_ENTRY=false
32+
else
33+
printf ",\n"
34+
fi
35+
printf ' [ "%s", "%s" ]' "$1" "$2"
36+
}
37+
1538
# Function to check and print GCC versions if installed
16-
print_row_gcc() {
39+
print_rows_gcc() {
1740
for version in 12 13 14 15 16; do
1841
gcc_path="/usr/bin/g++-$version"
1942
if [ -x "$gcc_path" ]; then
@@ -23,9 +46,9 @@ print_row_gcc() {
2346
done
2447
}
2548

26-
# Function to check and print GCC versions if installed
27-
print_row_clang() {
28-
for version in 16 17 18 19 20 21; do
49+
# Function to check and print Clang versions if installed
50+
print_rows_clang() {
51+
for version in 16 17 18 19 20 21 22; do
2952
clang_path="/usr/bin/clang++-$version"
3053
if [ -x "$clang_path" ]; then
3154
clang_version=$("$clang_path" --version | head -n1 | awk '{print $4}')
@@ -73,7 +96,7 @@ show_tool_versions() {
7396
gprof_version=$(gprof --version | head -n1 | awk '{print $7}')
7497
perf_version=$(perf --version | awk '{print $3}')
7598
strace_version=$(strace --version | head -n1 | awk '{print $4}')
76-
ltrace_version=$(ltrace --version | head -n1 | awk '{print $2}')
99+
ltrace_version=$(ltrace --version | head -n1 | awk '{print $3}' | sed 's/\.$//' )
77100
lcov=$(lcov --version | head -n1 | awk '{print $4}')
78101
gcov=$(gcov --version | head -n1 | awk '{print $3}' | cut -d'-' -f1)
79102
gcovr=$(gcovr --version | head -n1 | awk '{print $2}')
@@ -86,15 +109,19 @@ show_tool_versions() {
86109
mesa_version=$(dpkg -l | grep "mesa-vulkan-drivers" | awk '{print $3}')
87110
vulkan_version=$(echo $VULKAN_SDK | awk -F '/' '{print $4}')
88111

89-
printf "## Version Overview\n\n"
90-
91-
# Print table header in Markdown format
92-
printf "| Tool | Version |\n"
93-
printf "|:--------------|:--------------------|\n"
112+
if [ "$OUTPUT_FORMAT" = "json" ]; then
113+
# Open JSON array
114+
printf "[\n"
115+
else
116+
# Print table header in Markdown format
117+
printf "## Version Overview\n\n"
118+
printf "| Tool | Version |\n"
119+
printf "|:--------------|:--------------------|\n"
120+
fi;
94121

95122
# Print each row of the table in Markdown format
96-
print_row_gcc
97-
print_row_clang
123+
print_rows_gcc
124+
print_rows_clang
98125
print_row "CMake" "$cmake_version"
99126
print_row "Meson" "$meson_version"
100127
print_row "Ninja" "$ninja_version"
@@ -117,13 +144,22 @@ show_tool_versions() {
117144
print_row "sphinx" "$sphinx_version"
118145
print_row "git" "$git_version"
119146
print_row "gh cli" "$github_cli_version"
120-
printf "|:--------------|:--------------------|\n"
147+
148+
if [ "$OUTPUT_FORMAT" = "markdown" ]; then
149+
printf "|:--------------|:--------------------|\n"
150+
fi
151+
121152
if is_installed_mesa; then
122153
print_row "Mesa" "$mesa_version"
123154
fi
124155
if is_installed_vulkan_sdk; then
125156
print_row "Vulkan SDK" "$vulkan_version"
126157
fi
158+
159+
# Close JSON array
160+
if [ "$OUTPUT_FORMAT" = "json" ]; then
161+
printf "\n]"
162+
fi
127163
}
128164

129165
# Call the function to show the tool versions

0 commit comments

Comments
 (0)