Skip to content

Commit 8ec270a

Browse files
committed
Update dependencies
1 parent 6bf86e7 commit 8ec270a

21 files changed

+4004
-2300
lines changed

.gitattributes

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
# Prevents Maven wrapper from failing when launched from git bash on a Windows box
2-
maven-wrapper.properties text eol=lf
3-
1+
*.sh text eol=lf
2+
tcrw text eol=lf

cpp/.gitattributes

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cmakew text eol=lf
2+
ctestw text eol=lf
3+
cpackw text eol=lf
4+
*.sh text eol=lf
5+

cpp/GETTING_STARTED.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ This setup script does the following:
4949
- Create a build directory: ***Kata-PascalTriangle/cpp/build***. All build-related files are generated under this directory.
5050
- Download a copy of cmake compatible with your platform.
5151
- Download the dependencies required to build and test the kata (such as GoogleTest).
52-
- Generate the solution file ***Kata-PascalTriangle.sln*** for **Visual Studio 2019** on Windows,
52+
- Generate the solution file ***Kata-PascalTriangle.sln*** for **Visual Studio 2022** on Windows,
5353
or the project file ***Kata-PascalTriangle.xcodeproj*** for **Xcode** on macOS.
5454
- Run an initial build and test of the kata to ensure that everything is set up properly.
5555

@@ -113,7 +113,7 @@ Refer to [Using TCR](#using-tcr) section for additional details about TCR and av
113113
<a name="running-the-kata-from-visual-studio"/></a>
114114
### Running the kata from Visual Studio
115115

116-
> ***Supported Versions***: Visual Studio 2019 or later
116+
> ***Supported Versions***: Visual Studio 2022 or later
117117
118118
Open Visual Studio, choose `Open a project or solution`, navigate to
119119
the location containing the cloned kata repository, and open the solution file:
@@ -133,7 +133,7 @@ TCR is provided as a command line utility running in a terminal.
133133
You can run it from Visual Studio directly, through leveraging on its built-in terminal.
134134

135135
> ***Notes***
136-
> - Supported Versions: Visual Studio 2019 or later
136+
> - Supported Versions: Visual Studio 2022 or later
137137
> - Visual Studio 2017 and earlier versions are not supported as they do not have a built-in terminal.
138138
139139
#### 1. Open the kata

cpp/cmake/.gitattributes

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version.txt text eol=lf
2+
*.sh text eol=lf
3+

cpp/cmake/cmake-wrapper.sh

+226
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright (c) 2024 Murex
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
23+
set -u
24+
25+
base_dir="$(cd "$(dirname -- "$0")" && pwd)"
26+
if [ -z "${CMAKEW_BASE_DIR+x}" ]; then CMAKEW_BASE_DIR="${base_dir}"; fi
27+
if [ -z "${CMAKEW_CACHE_DIR+x}" ]; then CMAKEW_CACHE_DIR="$(dirname "${base_dir}")/.cmake"; fi
28+
if [ -z "${CMAKEW_CMD+x}" ]; then CMAKEW_CMD="cmake"; fi
29+
30+
# ------------------------------------------------------------------------------
31+
# cmake directory structure and information
32+
# ------------------------------------------------------------------------------
33+
34+
CMAKEW_VERSION_FILE="${CMAKEW_BASE_DIR}/version.txt"
35+
36+
# ------------------------------------------------------------------------------
37+
# Trace messages
38+
# ------------------------------------------------------------------------------
39+
40+
print_info() {
41+
message="$1"
42+
printf "%b" "${message}\n" | while IFS= read -r line; do >&2 printf "%b" "\e[1;34m>>> ${line} \e[0m\n"; done
43+
}
44+
45+
print_warning() {
46+
message="$1"
47+
printf "%b" "${message}\n" | while IFS= read -r line; do >&2 printf "%b" "\e[1;33m>>> ${line} \e[0m\n"; done
48+
}
49+
50+
print_error() {
51+
message="$1"
52+
printf "%b" "${message}\n" | while IFS= read -r line; do >&2 printf "%b" "\e[1;31m>>> ${line} \e[0m\n"; done
53+
}
54+
55+
print_horizontal_line() {
56+
term_columns=$(tput cols)
57+
repeated=$((term_columns - 5))
58+
line=$(head -c "${repeated}" </dev/zero | tr '\0' '-')
59+
print_info "$line"
60+
}
61+
62+
# ------------------------------------------------------------------------------
63+
# Download cmake from cmake website
64+
# ------------------------------------------------------------------------------
65+
66+
download_cmake() {
67+
version="$1"
68+
os="$2"
69+
arch="$3"
70+
archive_extension="$4"
71+
exe_path="$5"
72+
73+
# ----------------------------------------------------------------------------
74+
# 1) create and enter cache directory
75+
# ----------------------------------------------------------------------------
76+
77+
mkdir -p "${CMAKEW_CACHE_DIR}"
78+
pushd "${CMAKEW_CACHE_DIR}" >/dev/null 2>/dev/null || return 1
79+
80+
# ----------------------------------------------------------------------------
81+
# 2) download cmake archive
82+
# ----------------------------------------------------------------------------
83+
84+
cmake_version="${version}"
85+
cmake_expected_dir="cmake-${cmake_version}-${os}-${arch}"
86+
cmake_expected_archive_file="${cmake_expected_dir}.${archive_extension}"
87+
cmake_archive_url="http://github.com/Kitware/CMake/releases/download/v${cmake_version}/${cmake_expected_archive_file}"
88+
cmake_home="cmake-${os}-${arch}"
89+
90+
if ! [ -f "${cmake_expected_archive_file}" ]
91+
then
92+
print_info "downloading ${cmake_expected_archive_file}"
93+
if ! curl -f -# -L "${cmake_archive_url}" -o "${cmake_expected_archive_file}"; then
94+
print_error "failed to download ${cmake_archive_url}"
95+
return 1
96+
fi
97+
fi
98+
99+
# ----------------------------------------------------------------------------
100+
# 3) expand cmake archive
101+
# ----------------------------------------------------------------------------
102+
103+
print_info "extracting cmake ${cmake_version}"
104+
case "${archive_extension}" in
105+
zip)
106+
if ! unzip -q -o "${cmake_expected_archive_file}"; then
107+
print_error "failed to expand ${cmake_expected_archive_file}"
108+
return 1
109+
fi
110+
;;
111+
tar.gz)
112+
if ! tar zxf "${cmake_expected_archive_file}"; then
113+
print_error "failed to expand ${cmake_expected_archive_file}"
114+
return 1
115+
fi
116+
;;
117+
*)
118+
print_error "archive format ${archive_extension} is currently not supported"
119+
exit 1
120+
;;
121+
esac
122+
123+
# ----------------------------------------------------------------------------
124+
# 4) make the expanded archive the current version in cache
125+
# ----------------------------------------------------------------------------
126+
127+
[ -d "${cmake_home}" ] && rm -Rf "${cmake_home}"
128+
mv "${cmake_expected_dir}" "${cmake_home}"
129+
130+
popd >/dev/null 2>/dev/null || return 1
131+
}
132+
133+
# ------------------------------------------------------------------------------
134+
# Return expected cmake version
135+
# ------------------------------------------------------------------------------
136+
137+
retrieve_expected_cmake_version() {
138+
if [ -f "${CMAKEW_VERSION_FILE}" ]; then
139+
expected_version=$(awk '{ print $2 }' < "${CMAKEW_VERSION_FILE}")
140+
# print_info "expected cmake version: ${expected_version}"
141+
echo "${expected_version}"
142+
return 0
143+
else
144+
print_error "version file not found: ${CMAKEW_VERSION_FILE}"
145+
return 1
146+
fi
147+
}
148+
149+
# ------------------------------------------------------------------------------
150+
# Return current cmake version
151+
# ------------------------------------------------------------------------------
152+
153+
retrieve_current_cmake_version() {
154+
exe_path="$1"
155+
current_version=$("${exe_path}" --version | head -1 | awk '{ print $3 }')
156+
# print_info "current cmake version: ${current_version}"
157+
echo "${current_version}"
158+
return 0
159+
}
160+
161+
# ------------------------------------------------------------------------------
162+
# Retrieve the path to the cmake command to be launched
163+
# depending on local machine's OS and architecture
164+
# ------------------------------------------------------------------------------
165+
166+
retrieve_command_path() {
167+
case $(uname -s) in
168+
Darwin)
169+
os="macos"
170+
arch="universal"
171+
archive_extension="tar.gz"
172+
cmake_bin_dir="CMake.app/Contents/bin"
173+
cmd="${CMAKEW_CMD}"
174+
;;
175+
Linux)
176+
os="linux"
177+
arch="x86_64"
178+
archive_extension="tar.gz"
179+
cmake_bin_dir="bin"
180+
cmd="${CMAKEW_CMD}"
181+
;;
182+
MINGW64_NT-*)
183+
os="windows"
184+
arch="x86_64"
185+
archive_extension="zip"
186+
cmake_bin_dir="bin"
187+
cmd="${CMAKEW_CMD}.exe"
188+
;;
189+
*)
190+
print_error "os $(uname -s) is currently not supported"
191+
exit 1
192+
;;
193+
esac
194+
195+
# Expected cmake version
196+
expected_version=$(retrieve_expected_cmake_version) || return 1
197+
198+
cmake_home="cmake-${os}-${arch}"
199+
cmake_bin_path="${CMAKEW_CACHE_DIR}/${cmake_home}/${cmake_bin_dir}"
200+
cmake_exe_path="${cmake_bin_path}/${cmd}"
201+
202+
file_missing=$(type "${cmake_exe_path}" >/dev/null 2>/dev/null; echo $?)
203+
# If the file already exists, check its current version
204+
version_mismatch=0
205+
if [ "${file_missing}" -eq 0 ]; then
206+
current_version=$(retrieve_current_cmake_version "${cmake_exe_path}")
207+
version_mismatch="$( [ "${current_version}" = "${expected_version}" ]; echo $? )"
208+
fi
209+
# If the file does not exist or if versions do not match, download it from CMAKE GitHub repository
210+
if [ "${file_missing}" -ne 0 ] || [ "${version_mismatch}" -ne 0 ]; then
211+
download_cmake "${expected_version}" "${os}" "${arch}" "${archive_extension}" "${cmake_bin_path}" || return 1
212+
fi
213+
214+
echo "${cmake_exe_path}"
215+
return 0
216+
}
217+
218+
# ------------------------------------------------------------------------------
219+
# Main
220+
# ------------------------------------------------------------------------------
221+
222+
cmd_path="$(retrieve_command_path)"
223+
# shellcheck disable=SC2181
224+
[ $? -ne 0 ] && print_error "aborting" && exit 1
225+
# shellcheck disable=SC2086
226+
"${cmd_path}" "$@"

cpp/cmake/set-options.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
CMAKE_BUILD_DIR="./build"
4+
CMAKE_CONFIG="Debug"
5+
case $(uname -s) in
6+
Darwin) CMAKE_GENERATOR='Xcode';;
7+
Linux) CMAKE_GENERATOR='Unix Makefiles';;
8+
MINGW64_NT-*) CMAKE_GENERATOR='Visual Studio 17 2022';;
9+
*) echo "os $(uname -s) not supported." && exit 1;;
10+
esac
11+
12+
export CMAKE_BUILD_DIR
13+
export CMAKE_CONFIG
14+
export CMAKE_GENERATOR

cpp/cmake/version.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cmake 3.30.0

cpp/cmakew

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright (c) 2024 Murex
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
23+
base_dir="$(cd "$(dirname -- "$0")" && pwd)"
24+
CMAKEW_BASE_DIR="${base_dir}/cmake"
25+
CMAKEW_CACHE_DIR="${base_dir}/.cmake"
26+
CMAKEW_CMD="$(basename "$0" | sed -e 's/w$//g')"
27+
28+
. "${CMAKEW_BASE_DIR}/cmake-wrapper.sh"

0 commit comments

Comments
 (0)