| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
set -eo pipefail |
| 4 |
|
| 5 |
# Parse command-line argument |
| 6 |
if [ $# -ne 1 ]; then |
| 7 |
echo "Usage: $0 [static|cpp98]" >&2 |
| 8 |
echo " static - Build and test static variant" >&2 |
| 9 |
echo " cpp98 - Build and test C++98 variant" >&2 |
| 10 |
exit 1 |
| 11 |
fi |
| 12 |
|
| 13 |
variant="$1" |
| 14 |
|
| 15 |
# Dockerfile is in the root director one level up from this script |
| 16 |
dockerfile="$(dirname "${BASH_SOURCE[0]}")/../Dockerfile.build-variants" |
| 17 |
context="$(dirname "${BASH_SOURCE[0]}")/.." |
| 18 |
|
| 19 |
case "$variant" in |
| 20 |
"static") |
| 21 |
echo "Building and testing static variant..." |
| 22 |
docker build -f "$dockerfile" "$context" \ |
| 23 |
--build-arg UBUNTU_VARIANT=noble \ |
| 24 |
--build-arg CXX_STANDARD=17 \ |
| 25 |
--build-arg BUILD_STATIC=On \ |
| 26 |
-t ismrmrd-static |
| 27 |
|
| 28 |
test_command="set -euo pipefail \ |
| 29 |
&& export PATH=$PATH:/opt/package/bin \ |
| 30 |
&& test -f /opt/package/lib/libismrmrd.a \ |
| 31 |
&& ! test -e /opt/package/lib/libismrmrd.so \ |
| 32 |
&& ismrmrd_generate_cartesian_shepp_logan -o testdata.h5 \ |
| 33 |
&& ismrmrd_hdf5_to_stream -i testdata.h5 --use-stdout \ |
| 34 |
| ismrmrd_stream_recon_cartesian_2d --use-stdin --use-stdout \ |
| 35 |
| ismrmrd_stream_to_hdf5 --use-stdin -o result.h5" |
| 36 |
docker run --rm ismrmrd-static /bin/bash -c "$test_command" |
| 37 |
;; |
| 38 |
|
| 39 |
"cpp98") |
| 40 |
echo "Building and testing C++98 variant..." |
| 41 |
docker build -f "$dockerfile" "$context" \ |
| 42 |
--build-arg UBUNTU_VARIANT=jammy \ |
| 43 |
--build-arg CXX_STANDARD=98 \ |
| 44 |
--build-arg BUILD_STATIC=Off \ |
| 45 |
-t ismrmrd-cpp98 |
| 46 |
|
| 47 |
test_command="set -euo pipefail \ |
| 48 |
&& export PATH=$PATH:/opt/package/bin \ |
| 49 |
&& ismrmrd_generate_cartesian_shepp_logan -o testdata.h5 \ |
| 50 |
&& ismrmrd_hdf5_to_stream -i testdata.h5 --use-stdout \ |
| 51 |
| ismrmrd_stream_recon_cartesian_2d --use-stdin --use-stdout \ |
| 52 |
| ismrmrd_stream_to_hdf5 --use-stdin -o result.h5" |
| 53 |
docker run --rm ismrmrd-cpp98 /bin/bash -c "$test_command" |
| 54 |
;; |
| 55 |
|
| 56 |
*) |
| 57 |
echo "Error: Invalid argument '$variant'. Must be either 'static' or 'cpp98'." >&2 |
| 58 |
echo "Usage: $0 [static|cpp98]" >&2 |
| 59 |
exit 1 |
| 60 |
;; |
| 61 |
esac |