From a49f1867d85d743f36620e9d48e4b7653fa89c81 Mon Sep 17 00:00:00 2001 From: Aditya Shastri Date: Wed, 4 May 2022 14:07:57 -0700 Subject: [PATCH] Use -Werror during diff time build (#198) Summary: Pull Request resolved: https://github.com/facebookresearch/fbpcf/pull/198 Differential Revision: D36138984 fbshipit-source-id: caf4d15ed9134048dfd0f8cf9810ed1b5f46aea8 --- build-docker.sh | 11 ++++++++++- docker/Dockerfile.ubuntu | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/build-docker.sh b/build-docker.sh index ea1531bb..71d26dc7 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -22,6 +22,7 @@ Usage: $PROG_NAME [-u] [-f] [-t TAG] -u: builds the docker images against ubuntu (default) -f: forces a rebuild of all docker image dependencies (even if they already exist) +-d: whether to build in dev mode. This sets the -Werror flag during the cmake build. -t TAG: Use the specified tag for the built image (default: latest) EOF exit 1 @@ -32,7 +33,8 @@ OS_RELEASE="${UBUNTU_RELEASE}" DOCKER_EXTENSION=".ubuntu" FORCE_REBUILD=false TAG="latest" -while getopts "u,f,t:" o; do +DEV_MODE=false +while getopts "u,f,d,t:" o; do case $o in u) IMAGE_PREFIX="ubuntu" @@ -40,6 +42,7 @@ while getopts "u,f,t:" o; do DOCKER_EXTENSION=".ubuntu" ;; f) FORCE_REBUILD=true ;; + d) DEV_MODE=true ;; t) TAG=$OPTARG;; *) usage ;; esac @@ -91,11 +94,17 @@ build_dep_image "${FOLLY_IMAGE}" "folly" "--build-arg os_release=${OS_RELEASE} - FOLLY_IMAGE="${RETURN}" printf "\nBuilding fbpcf/%s docker image...\n" ${IMAGE_PREFIX} +CMAKE_FLAGS="" +if [ "${DEV_MODE}" == true ]; then + printf "Using dev mode. Passing -Werror to cmake." + CMAKE_FLAGS="-Werror" +fi docker build \ --build-arg os_release="${OS_RELEASE}" \ --build-arg emp_image="${EMP_IMAGE}" \ --build-arg aws_image="${AWS_IMAGE}" \ --build-arg folly_image="${FOLLY_IMAGE}" \ --build-arg gcp_image="${GCP_IMAGE}" \ + --build-arg cmake_flags="${CMAKE_FLAGS}" \ --compress \ -t "fbpcf/${IMAGE_PREFIX}:${TAG}" -f "docker/Dockerfile${DOCKER_EXTENSION}" . diff --git a/docker/Dockerfile.ubuntu b/docker/Dockerfile.ubuntu index 029a84df..52699810 100644 --- a/docker/Dockerfile.ubuntu +++ b/docker/Dockerfile.ubuntu @@ -8,6 +8,7 @@ ARG emp_image="fbpcf/ubuntu-emp:0.2.3" ARG aws_image="fbpcf/ubuntu-aws-s3-core:1.8.177" ARG folly_image="fbpcf/ubuntu-folly:2021.03.29.00" ARG gcp_image="fbpcf/ubuntu-gcp-cloud-cpp:1.32.1" +ARG cmake_flags="" FROM ${emp_image} as emp FROM ${aws_image} as aws @@ -57,7 +58,7 @@ COPY example/ ./example # Link all libraries post-install RUN ldconfig -RUN cmake . -DTHREADING=ON -DEMP_USE_RANDOM_DEVICE=ON +RUN cmake . -DTHREADING=ON -DEMP_USE_RANDOM_DEVICE=ON $cmake_flags RUN make && make install CMD ["/bin/bash"]