diff --git a/Dockerfile b/Dockerfile index ad2f0e6..2ddea8c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,7 +43,7 @@ ENV CC="$C_COMPILER" ENV CXX="$CXX_COMPILER" # Install b2 using Conan -RUN printf '[requires]\nb2/4.10.1\n[options]\nb2*:toolset=%s' \ +RUN printf '[requires]\nb2/5.2.1\n[options]\nb2*:toolset=%s' \ "$(basename "$(which "$CC")")" | cut -f 1 -d - > /tmp/conanfile.txt RUN conan install /tmp/conanfile.txt \ @@ -92,6 +92,7 @@ RUN cmake -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_PREFIX_PATH="$build_dir" \ -DENABLE_DEVELOPER_MODE=OFF \ -DCMAKE_INSTALL_PREFIX="$staging_dir" \ + -DNCHG_ENABLE_TESTING=OFF \ -DGIT_RETRIEVED_STATE=true \ -DGIT_TAG="$GIT_TAG" \ -DGIT_IS_DIRTY="$GIT_IS_DIRTY" \ @@ -103,7 +104,7 @@ RUN cmake -DCMAKE_BUILD_TYPE=Release \ # Build and install project RUN cmake --build "$build_dir" -t NCHG -j "$(nproc)" \ -&& cmake --install "$build_dir" --component Runtime \ +&& cmake --install "$build_dir" --component Runtime \ && rm -rf "$build_dir/include" "$build_dir/lib" ARG FINAL_BASE_IMAGE diff --git a/src/nchg/include/nchg/tools/common.hpp b/src/nchg/include/nchg/tools/common.hpp index dc30e43..bcb8d78 100644 --- a/src/nchg/include/nchg/tools/common.hpp +++ b/src/nchg/include/nchg/tools/common.hpp @@ -26,7 +26,12 @@ namespace nchg { namespace internal { + +#ifdef __cpp_lib_constexpr_string [[nodiscard]] constexpr std::string strip_leading_zero(std::string s) { +#else +[[nodiscard]] inline std::string strip_leading_zero(std::string s) { +#endif if (s.front() != '0') { return s; } @@ -35,7 +40,11 @@ namespace internal { } // namespace internal template +#ifdef __cpp_lib_constexpr_string [[nodiscard]] constexpr std::string format_duration(const Duration& duration) { +#else +[[nodiscard]] inline std::string format_duration(const Duration& duration) { +#endif if (duration < std::chrono::microseconds(1)) { return fmt::to_string(std::chrono::duration_cast(duration)); } diff --git a/utils/devel/build_dockerfile.sh b/utils/devel/build_dockerfile.sh index a453b62..ee98678 100755 --- a/utils/devel/build_dockerfile.sh +++ b/utils/devel/build_dockerfile.sh @@ -24,10 +24,16 @@ set -o pipefail IMAGE_NAME='nchg' +if [ "$(uname)" == "Darwin" ]; then + BUILD_USER="$USER" +else + BUILD_USER='root' +fi + GIT_HASH="$(git rev-parse HEAD)" GIT_SHORT_HASH="$(git rev-parse --short HEAD)" -GIT_TAG="$(git for-each-ref 'refs/tags/v*.*.*' --count 1 --sort=-v:refname --format "%(refname:short)" --points-at HEAD)" -CREATION_DATE="$(date --iso-8601)" +GIT_TAG="$(git for-each-ref 'refs/tags/v*.*.*' --count 1 --sort=-v:refname --format "%(refname:short)" --points-at HEAD)" +CREATION_DATE="$(date -I)" if [[ $(git status --porcelain -uno) ]]; then GIT_IS_DIRTY=1 @@ -48,21 +54,21 @@ fi 2>&1 echo "Building \"$IMAGE_NAME:$IMAGE_TAG\"..." -sudo docker pull docker.io/library/ubuntu:22.04 -FINAL_BASE_IMAGE_DIGEST="$(sudo docker inspect --format='{{index .RepoDigests 0}}' docker.io/library/ubuntu:22.04 | grep -o '[[:alnum:]:]\+$')" +sudo -u "$BUILD_USER" docker pull docker.io/library/ubuntu:22.04 +FINAL_BASE_IMAGE_DIGEST="$(sudo -u "$BUILD_USER" docker inspect --format='{{index .RepoDigests 0}}' docker.io/library/ubuntu:22.04 | grep -o '[[:alnum:]:]\+$')" -BUILD_BASE_IMAGE='ghcr.io/paulsengroup/ci-docker-images/ubuntu-22.04-cxx-clang-18:latest' +BUILD_BASE_IMAGE='ghcr.io/paulsengroup/ci-docker-images/ubuntu-22.04-cxx-clang-19:latest' -sudo docker pull "$BUILD_BASE_IMAGE" +sudo -u "$BUILD_USER" docker pull "$BUILD_BASE_IMAGE" -# sudo docker buildx build --platform linux/amd64,linux/arm64 \ -sudo docker buildx build --platform linux/amd64 \ +# sudo -u "$BUILD_USER" docker buildx build --platform linux/amd64,linux/arm64 \ +sudo -u "$BUILD_USER" docker buildx build --platform linux/amd64 \ --build-arg "BUILD_BASE_IMAGE=$BUILD_BASE_IMAGE" \ --build-arg "FINAL_BASE_IMAGE=docker.io/library/ubuntu" \ --build-arg "FINAL_BASE_IMAGE_TAG=22.04" \ --build-arg "FINAL_BASE_IMAGE_DIGEST=$FINAL_BASE_IMAGE_DIGEST" \ - --build-arg "C_COMPILER=clang-18" \ - --build-arg "CXX_COMPILER=clang++-18" \ + --build-arg "C_COMPILER=clang-19" \ + --build-arg "CXX_COMPILER=clang++-19" \ --build-arg "GIT_HASH=$GIT_HASH" \ --build-arg "GIT_SHORT_HASH=$GIT_SHORT_HASH" \ --build-arg "GIT_TAG=$GIT_TAG" \ @@ -73,5 +79,5 @@ sudo docker buildx build --platform linux/amd64 \ -t "$IMAGE_NAME:$IMAGE_TAG" \ "$(git rev-parse --show-toplevel)" - # sudo singularity build -F "${img_name}_v${ver}.sif" \ + # sudo -u "$BUILD_USER" singularity build -F "${img_name}_v${ver}.sif" \ # "docker-daemon://${img_name}:${ver}"