diff --git a/contrib/dockerfiles/arm-linux-gnueabihf.dockerfile b/contrib/dockerfiles/arm-linux-gnueabihf.dockerfile index c8b8d31d04..161bda04b7 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 d0dae897ae..48aba70193 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 649ca6badf..d5ac4475e9 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 df41c88370..6133c4ebae 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 1278aa279d..143cf58888 100755 --- a/make.sh +++ b/make.sh @@ -16,9 +16,15 @@ 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_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:-} + 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. @@ -73,28 +79,47 @@ help() { # ----------- Direct builds --------------- - -build_prepare() { +build_deps() { local target=${1:-"x86_64-pc-linux-gnu"} - local extra_conf_opts=${EXTRA_CONF_ARGS:-} - local extra_make_depends_args=${EXTRA_MAKE_DEPENDS_ARGS:--j $(nproc)} + local make_deps_args=${MAKE_DEPS_ARGS:-} + local make_jobs=${MAKE_JOBS} - echo "> build: ${target}" + echo "> build-deps: target: ${target} / deps_args: ${make_deps_args} / jobs: ${make_jobs}" pushd ./depends >/dev/null - # XREF: #depends-make - make NO_QT=1 ${extra_make_depends_args} + # XREF: #make-deps + # shellcheck disable=SC2086 + make HOST="${target}" -j${make_jobs} ${make_deps_args} popd >/dev/null +} + +build_conf() { + local target=${1:-"x86_64-pc-linux-gnu"} + local make_conf_opts=${MAKE_CONF_ARGS:-} + local make_jobs=${MAKE_JOBS} + + echo "> build-conf: target: ${target} / conf_args: ${make_conf_opts} / jobs: ${make_jobs}" + ./autogen.sh # XREF: #make-configure - # ./configure CC=clang-11 CXX=clang++-11 --prefix="$(pwd)/depends/x86_64-pc-linux-gnu" - ./configure CC=clang-11 CXX=clang++-11 --prefix="$(pwd)/depends/${target}" ${extra_conf_opts} + # ./configure --prefix="$(pwd)/depends/x86_64-pc-linux-gnu" + # shellcheck disable=SC2086 + ./configure --prefix="$(pwd)/depends/${target}" ${make_conf_opts} } -build() { - local extra_make_args=${EXTRA_MAKE_ARGS:--j $(nproc)} +build_make() { + local target=${1:-"x86_64-pc-linux-gnu"} + local make_args=${MAKE_ARGS:-} + local make_jobs=${MAKE_JOBS} - build_prepare "$@" - make ${extra_make_args} + echo "> build: target: ${target} / args: ${make_args} / jobs: ${make_jobs}" + # shellcheck disable=SC2086 + make -j${make_jobs} ${make_args} +} + +build() { + build_deps "$@" + build_conf "$@" + build_make "$@" } deploy() { @@ -113,7 +138,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}/" @@ -134,7 +159,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}" @@ -317,11 +342,11 @@ git_version() { # Replace `/` in branch names with `-` as / is trouble IMAGE_VERSION="${current_branch//\//-}-${current_commit}" if [[ "${current_branch}" == "hotfix" ]]; then - # If the current branch is hotfix branch, - # prefix it with the last available tag. + # If the current branch is hotfix branch, + # 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}" @@ -340,20 +365,23 @@ git_version() { if [[ -n "${GITHUB_ACTIONS-}" ]]; then # GitHub Actions - echo "BUILD_VERSION=${IMAGE_VERSION}" >> $GITHUB_ENV + echo "BUILD_VERSION=${IMAGE_VERSION}" >> "$GITHUB_ENV" fi } 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() {