From bb1c34baf3d71ddd6b11265a630639e47c764aca Mon Sep 17 00:00:00 2001 From: Prasanna Loganathar Date: Wed, 22 Sep 2021 00:05:18 +0530 Subject: [PATCH 1/8] Split make.sh build, fix lints, cleanup --- .../arm-linux-gnueabihf.dockerfile | 4 +- .../x86_64-apple-darwin11.dockerfile | 4 +- .../x86_64-pc-linux-gnu.dockerfile | 4 +- .../dockerfiles/x86_64-w64-mingw32.dockerfile | 4 +- make.sh | 67 +++++++++++++------ 5 files changed, 55 insertions(+), 28 deletions(-) diff --git a/contrib/dockerfiles/arm-linux-gnueabihf.dockerfile b/contrib/dockerfiles/arm-linux-gnueabihf.dockerfile index b88681707a..6c194fa94e 100644 --- a/contrib/dockerfiles/arm-linux-gnueabihf.dockerfile +++ b/contrib/dockerfiles/arm-linux-gnueabihf.dockerfile @@ -29,8 +29,8 @@ LABEL org.defichain.arch=${TARGET} WORKDIR /work/depends COPY ./depends . -# XREF: #depends-make -RUN make HOST=${TARGET} NO_QT=1 -j $(nproc) +# XREF: #make-deps +RUN make HOST=${TARGET} -j $(nproc) # ----------- FROM builder-base as builder diff --git a/contrib/dockerfiles/x86_64-apple-darwin11.dockerfile b/contrib/dockerfiles/x86_64-apple-darwin11.dockerfile index c42737cae4..b25de093e8 100644 --- a/contrib/dockerfiles/x86_64-apple-darwin11.dockerfile +++ b/contrib/dockerfiles/x86_64-apple-darwin11.dockerfile @@ -29,8 +29,8 @@ LABEL org.defichain.arch=${TARGET} WORKDIR /work/depends COPY ./depends . -# XREF: #depends-make -RUN make HOST=${TARGET} NO_QT=1 -j $(nproc) +# XREF: #make-deps +RUN make HOST=${TARGET} -j $(nproc) # ----------- FROM builder-base as builder diff --git a/contrib/dockerfiles/x86_64-pc-linux-gnu.dockerfile b/contrib/dockerfiles/x86_64-pc-linux-gnu.dockerfile index 09e86d6c88..fc8a72e620 100644 --- a/contrib/dockerfiles/x86_64-pc-linux-gnu.dockerfile +++ b/contrib/dockerfiles/x86_64-pc-linux-gnu.dockerfile @@ -35,8 +35,8 @@ LABEL org.defichain.arch=${TARGET} WORKDIR /work/depends COPY ./depends . -# XREF: #depends-make -RUN make HOST=${TARGET} NO_QT=1 -j $(nproc) +# XREF: #make-deps +RUN make HOST=${TARGET} -j $(nproc) # ----------- FROM builder-base as builder diff --git a/contrib/dockerfiles/x86_64-w64-mingw32.dockerfile b/contrib/dockerfiles/x86_64-w64-mingw32.dockerfile index 7729bb74f9..002d96e24f 100644 --- a/contrib/dockerfiles/x86_64-w64-mingw32.dockerfile +++ b/contrib/dockerfiles/x86_64-w64-mingw32.dockerfile @@ -32,8 +32,8 @@ LABEL org.defichain.arch=${TARGET} WORKDIR /work/depends COPY ./depends . -# XREF: #depends-make -RUN make HOST=${TARGET} NO_QT=1 -j $(nproc) +# XREF: #make-deps +RUN make HOST=${TARGET} -j $(nproc) # ----------- FROM builder-base as builder diff --git a/make.sh b/make.sh index 9ead1fa94a..4299dc5fe7 100755 --- a/make.sh +++ b/make.sh @@ -16,9 +16,10 @@ setup_vars() { DOCKERFILES_DIR=${DOCKERFILES_DIR:-"./contrib/dockerfiles"} RELEASE_DIR=${RELEASE_DIR:-"./build"} - EXTRA_CONF_ARGS=${EXTRA_CONF_ARGS:-} - EXTRA_MAKE_ARGS=${EXTRA_MAKE_ARGS:-} - EXTRA_MAKE_DEPENDS_ARGS=${EXTRA_MAKE_DEPENDS_ARGS:-} + MAKE_JOBS=${MAKE_JOBS:-$(nproc)} + MAKE_CONF_ARGS=${MAKE_CONF_ARGS:-} + MAKE_ARGS=${MAKE_ARGS:-} + MAKE_DEPS_ARGS=${MAKE_DEPS_ARGS:-} # shellcheck disable=SC2206 # This intentionally word-splits the array as env arg can only be strings. @@ -73,22 +74,45 @@ help() { # ----------- Direct builds --------------- +build_deps() { + local make_deps_args=${MAKE_DEPS_ARGS:-} + local make_jobs=${MAKE_JOBS} -build() { + echo "> build-deps" + pushd ./depends >/dev/null + # XREF: #make-deps + # shellcheck disable=SC2086 + make -j${make_jobs} ${make_deps_args} + popd >/dev/null +} + +build_conf() { local target=${1:-"x86_64-pc-linux-gnu"} - local extra_conf_opts=${EXTRA_CONF_ARGS:-} - local extra_make_args=${EXTRA_MAKE_ARGS:--j $(nproc)} - local extra_make_depends_args=${EXTRA_MAKE_DEPENDS_ARGS:--j $(nproc)} + local make_conf_opts=${MAKE_CONF_ARGS:-} + local make_jobs=${MAKE_JOBS} - echo "> build: ${target}" - pushd ./depends >/dev/null - # XREF: #depends-make - make NO_QT=1 ${extra_make_depends_args} - popd >/dev/null + echo "> build-conf: ${target}" + ./autogen.sh # XREF: #make-configure - ./configure CC=clang-11 CXX=clang++-11 --prefix="$(pwd)/depends/${target}" ${extra_conf_opts} - make ${extra_make_args} + # shellcheck disable=SC2086 + ./configure --prefix="$(pwd)/depends/${target}" ${make_conf_opts} +} + +build_make() { + local target=${1:-"x86_64-pc-linux-gnu"} + local make_args=${MAKE_ARGS:-} + local make_jobs=${MAKE_JOBS} + + echo "> build: ${target}" + # shellcheck disable=SC2086 + make -j${make_jobs} ${make_args} +} + +build() { + build_deps + build_conf "$@" + build_make "$@" } deploy() { @@ -107,7 +131,7 @@ deploy() { echo "> deploy into: ${release_dir} from ${versioned_release_path}" pushd "${release_dir}" >/dev/null - rm -rf ./${versioned_name} && mkdir "${versioned_name}" + rm -rf "./${versioned_name}" && mkdir "${versioned_name}" popd >/dev/null make prefix=/ DESTDIR="${versioned_release_path}" install && cp README.md "${versioned_release_path}/" @@ -128,7 +152,7 @@ package() { local pkg_tar_file_name="${pkg_name}.tar.gz" local pkg_path - pkg_path="$(readlink -m ${release_dir}/${pkg_tar_file_name})" + pkg_path="$(readlink -m "${release_dir}/${pkg_tar_file_name}")" local versioned_name="${img_prefix}-${img_version}" local versioned_release_dir="${release_dir}/${versioned_name}" @@ -319,19 +343,22 @@ git_version() { fi echo "> version: ${IMAGE_VERSION}" - echo "BUILD_VERSION=${IMAGE_VERSION}" >> $GITHUB_ENV # GitHub Actions + echo "BUILD_VERSION=${IMAGE_VERSION}" >> "$GITHUB_ENV" # GitHub Actions } pkg_install_deps() { - sudo apt update && sudo apt dist-upgrade -y - sudo apt install -y software-properties-common build-essential libtool autotools-dev automake \ + apt update && apt install -y \ + software-properties-common build-essential libtool autotools-dev automake \ pkg-config bsdmainutils python3 libssl-dev libevent-dev libboost-system-dev \ libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev \ libminiupnpc-dev libzmq3-dev libqrencode-dev wget \ curl cmake +} + +pkg_install_llvm() { wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh - sudo ./llvm.sh 11 + ./llvm.sh 11 } pkg_ensure_mac_sdk() { From f802c6f56b989c2b081da8d0415dbfba8c7fb958 Mon Sep 17 00:00:00 2001 From: Prasanna Loganathar Date: Wed, 22 Sep 2021 00:22:52 +0530 Subject: [PATCH 2/8] Add HOST to deps to carry forward target --- make.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/make.sh b/make.sh index 4299dc5fe7..68f50e4cab 100755 --- a/make.sh +++ b/make.sh @@ -75,6 +75,7 @@ help() { # ----------- Direct builds --------------- build_deps() { + local target=${1:-"x86_64-pc-linux-gnu"} local make_deps_args=${MAKE_DEPS_ARGS:-} local make_jobs=${MAKE_JOBS} @@ -82,7 +83,7 @@ build_deps() { pushd ./depends >/dev/null # XREF: #make-deps # shellcheck disable=SC2086 - make -j${make_jobs} ${make_deps_args} + make HOST="${target}" -j${make_jobs} ${make_deps_args} popd >/dev/null } @@ -110,7 +111,7 @@ build_make() { } build() { - build_deps + build_deps "$@" build_conf "$@" build_make "$@" } From 88fd3b5a09548a48a72d5c662c3be1825628a706 Mon Sep 17 00:00:00 2001 From: Prasanna Loganathar Date: Fri, 11 Feb 2022 16:04:08 +0530 Subject: [PATCH 3/8] Add compiler args --- make.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/make.sh b/make.sh index 70c3e61301..280955dc7e 100755 --- a/make.sh +++ b/make.sh @@ -17,7 +17,8 @@ setup_vars() { RELEASE_DIR=${RELEASE_DIR:-"./build"} MAKE_JOBS=${MAKE_JOBS:-$(nproc)} - MAKE_CONF_ARGS=${MAKE_CONF_ARGS:-} + MAKE_COMPILER=${MAKE_COMPILER:-"CC=clang CXX=clang++"} + MAKE_CONF_ARGS="${MAKE_COMPILER}${MAKE_CONF_ARGS:-}" MAKE_ARGS=${MAKE_ARGS:-} MAKE_DEPS_ARGS=${MAKE_DEPS_ARGS:-} @@ -79,7 +80,7 @@ build_deps() { local make_deps_args=${MAKE_DEPS_ARGS:-} local make_jobs=${MAKE_JOBS} - echo "> build-deps" + echo "> build-deps: target: ${target} / deps_args: ${make_deps_args} / jobs: ${make_jobs}" pushd ./depends >/dev/null # XREF: #make-deps # shellcheck disable=SC2086 @@ -92,10 +93,11 @@ build_conf() { local make_conf_opts=${MAKE_CONF_ARGS:-} local make_jobs=${MAKE_JOBS} - echo "> build-conf: ${target}" + echo "> build-conf: target: ${target} / conf_args: ${make_conf_opts} / jobs: ${make_jobs}" ./autogen.sh # XREF: #make-configure + # ./configure --prefix="$(pwd)/depends/x86_64-pc-linux-gnu" # shellcheck disable=SC2086 ./configure --prefix="$(pwd)/depends/${target}" ${make_conf_opts} } @@ -105,7 +107,7 @@ build_make() { local make_args=${MAKE_ARGS:-} local make_jobs=${MAKE_JOBS} - echo "> build: ${target}" + echo "> build: target: ${target} / args: ${make_args} / jobs: ${make_jobs}" # shellcheck disable=SC2086 make -j${make_jobs} ${make_args} } From 2a17c60319cd976ea14bb9176c827a6a5c15d92b Mon Sep 17 00:00:00 2001 From: Prasanna Loganathar Date: Fri, 11 Feb 2022 16:10:16 +0530 Subject: [PATCH 4/8] Add debug variant --- make.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/make.sh b/make.sh index 280955dc7e..db6b5e6217 100755 --- a/make.sh +++ b/make.sh @@ -18,9 +18,13 @@ setup_vars() { MAKE_JOBS=${MAKE_JOBS:-$(nproc)} MAKE_COMPILER=${MAKE_COMPILER:-"CC=clang CXX=clang++"} - MAKE_CONF_ARGS="${MAKE_COMPILER}${MAKE_CONF_ARGS:-}" + MAKE_CONF_ARGS="${MAKE_COMPILER} ${MAKE_CONF_ARGS:-}" MAKE_ARGS=${MAKE_ARGS:-} MAKE_DEPS_ARGS=${MAKE_DEPS_ARGS:-} + MAKE_DEBUG=${MAKE_DEBUG:-0} + if [[ "${MAKE_DEBUG}" == 1 ]]; then + MAKE_CONF_ARGS="${MAKE_CONF_ARGS} --enable-debug"; + fi # shellcheck disable=SC2206 # This intentionally word-splits the array as env arg can only be strings. From 0fa299e2523b66bba93c777860326d5a05011ed1 Mon Sep 17 00:00:00 2001 From: Prasanna Loganathar Date: Fri, 11 Feb 2022 16:14:24 +0530 Subject: [PATCH 5/8] Make debug var into string --- make.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/make.sh b/make.sh index db6b5e6217..d6953cd22d 100755 --- a/make.sh +++ b/make.sh @@ -21,8 +21,8 @@ setup_vars() { MAKE_CONF_ARGS="${MAKE_COMPILER} ${MAKE_CONF_ARGS:-}" MAKE_ARGS=${MAKE_ARGS:-} MAKE_DEPS_ARGS=${MAKE_DEPS_ARGS:-} - MAKE_DEBUG=${MAKE_DEBUG:-0} - if [[ "${MAKE_DEBUG}" == 1 ]]; then + MAKE_DEBUG=${MAKE_DEBUG:-"0"} + if [[ "${MAKE_DEBUG}" == "1" ]]; then MAKE_CONF_ARGS="${MAKE_CONF_ARGS} --enable-debug"; fi From edd1ad0a7f6fc647bea890ace7d4ad0800128877 Mon Sep 17 00:00:00 2001 From: Prasanna Loganathar Date: Fri, 11 Feb 2022 16:16:25 +0530 Subject: [PATCH 6/8] Fix shell lints --- make.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/make.sh b/make.sh index d6953cd22d..c4b6a2d561 100755 --- a/make.sh +++ b/make.sh @@ -346,7 +346,7 @@ git_version() { # prefix it with the last available tag. git fetch --tags local last_tag - last_tag="$(git describe --tags $(git rev-list --tags --max-count=1))" + last_tag="$(git describe --tags "$(git rev-list --tags --max-count=1)")" echo "> last tag: ${last_tag}" if [[ -n "${last_tag}" ]]; then IMAGE_VERSION="${last_tag}-${IMAGE_VERSION}" @@ -366,7 +366,7 @@ git_version() { if [[ -n "${GITHUB_ACTIONS-}" ]]; then # GitHub Actions - echo "BUILD_VERSION=${IMAGE_VERSION}" >> $GITHUB_ENV + echo "BUILD_VERSION=${IMAGE_VERSION}" >> "$GITHUB_ENV" fi } From 119d6df59a8a63bb6d9f34fe122510aad95f8b97 Mon Sep 17 00:00:00 2001 From: Prasanna Loganathar Date: Fri, 11 Feb 2022 16:19:27 +0530 Subject: [PATCH 7/8] Remove redundant GH actions --- make.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/make.sh b/make.sh index c4b6a2d561..2c9df0e54b 100755 --- a/make.sh +++ b/make.sh @@ -362,7 +362,6 @@ git_version() { echo "> git branch: ${current_branch}" echo "> version: ${IMAGE_VERSION}" - echo "BUILD_VERSION=${IMAGE_VERSION}" >> "$GITHUB_ENV" # GitHub Actions if [[ -n "${GITHUB_ACTIONS-}" ]]; then # GitHub Actions From dbee05d1e1008576b27415d37c92bf6bdd5b7ebe Mon Sep 17 00:00:00 2001 From: Prasanna Loganathar Date: Fri, 11 Feb 2022 16:27:04 +0530 Subject: [PATCH 8/8] Add clang versions --- make.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make.sh b/make.sh index 2c9df0e54b..143cf58888 100755 --- a/make.sh +++ b/make.sh @@ -17,7 +17,7 @@ setup_vars() { RELEASE_DIR=${RELEASE_DIR:-"./build"} MAKE_JOBS=${MAKE_JOBS:-$(nproc)} - MAKE_COMPILER=${MAKE_COMPILER:-"CC=clang CXX=clang++"} + MAKE_COMPILER=${MAKE_COMPILER:-"CC=clang-11 CXX=clang++-11"} MAKE_CONF_ARGS="${MAKE_COMPILER} ${MAKE_CONF_ARGS:-}" MAKE_ARGS=${MAKE_ARGS:-} MAKE_DEPS_ARGS=${MAKE_DEPS_ARGS:-}