From 95b7e57e120c8e02815934423ea2612b8a23ed77 Mon Sep 17 00:00:00 2001 From: Nathan Pierce Date: Fri, 28 Jun 2019 14:03:58 -0400 Subject: [PATCH 1/7] Final changes + bats test for this --- scripts/.build_vars | 1 + scripts/eosio_build.sh | 7 ++++++- tests/bash-bats/eosio_build.sh | 2 +- tests/bash-bats/modules/cmake.sh | 3 +++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/.build_vars b/scripts/.build_vars index 585c521c935..b466e3e0088 100644 --- a/scripts/.build_vars +++ b/scripts/.build_vars @@ -7,6 +7,7 @@ export LIB_DIR=${EOSIO_INSTALL_DIR}/lib export DATA_DIR=${EOSIO_INSTALL_DIR}/data # CMAKE +export CMAKE_REQUIRED_VERSION=$(cat $REPO_ROOT/CMakeLists.txt | grep -E "cmake_minimum_required\([[:blank:]]*VERSION" | tail -1 | sed 's/.*VERSION //g' | cut -d\) -f1 | sed 's/ //g') export CMAKE_VERSION_MAJOR=3 export CMAKE_VERSION_MINOR=13 export CMAKE_VERSION_PATCH=2 diff --git a/scripts/eosio_build.sh b/scripts/eosio_build.sh index d404236657d..f20e070f4d0 100755 --- a/scripts/eosio_build.sh +++ b/scripts/eosio_build.sh @@ -144,7 +144,12 @@ execute cd $REPO_ROOT ensure-submodules-up-to-date # Check if cmake already exists -( [[ -z "${CMAKE}" ]] && [[ ! -z $(command -v cmake 2>/dev/null) ]] ) && export CMAKE=$(command -v cmake 2>/dev/null) +( [[ -z "${CMAKE}" ]] && [[ ! -z $(command -v cmake 2>/dev/null) ]] ) && export CMAKE=$(command -v cmake 2>/dev/null) && export CMAKE_CURRENT_VERSION=$($CMAKE --version | grep -E "cmake version[[:blank:]]*" | sed 's/.*cmake version //g') +# If it exists, check that it's > required version +if [[ ! -z $CMAKE_CURRENT_VERSION ]] && [[ $( echo $CURRENT_CMAKE_VERSION | awk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }' ) < $( echo $CMAKE_REQUIRED_VERSION | awk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }' ) ]]; then + echo "${COLOR_YELLOW}The currently installed cmake version ($CMAKE_CURRENT_VERSION) is less than the required version ($CMAKE_REQUIRED_VERSION). We will be installing $CMAKE_VERSION.${COLOR_NC}" + export CMAKE= +fi # Use existing cmake on system (either global or specific to eosio) # Setup based on architecture diff --git a/tests/bash-bats/eosio_build.sh b/tests/bash-bats/eosio_build.sh index fe1e8f8c8c2..f4f75593f3b 100644 --- a/tests/bash-bats/eosio_build.sh +++ b/tests/bash-bats/eosio_build.sh @@ -24,7 +24,7 @@ TEST_LABEL="[eosio_build]" run bash -c "printf \"y\ny\ny\nn\nn\n\" | ./${SCRIPT_LOCATION}" [[ ! -z $(echo "${output}" | grep "Unable to find .* compiler") ]] || exit fi - fi + fi cd ./scripts # Also test that we can run the script from a directory other than the root run bash -c "./eosio_build.sh -y -P" diff --git a/tests/bash-bats/modules/cmake.sh b/tests/bash-bats/modules/cmake.sh index 89b5b6dd883..b2a932d3ed3 100755 --- a/tests/bash-bats/modules/cmake.sh +++ b/tests/bash-bats/modules/cmake.sh @@ -7,6 +7,9 @@ load ../helpers/functions touch $CMAKE run bash -c " ./$SCRIPT_LOCATION -y -P" [[ ! -z $(echo "${output}" | grep "Executing: bash -c ${HOME}/cmake") ]] || exit + export CMAKE_CURRENT_VERSION=3.7.1 + run bash -c " ./$SCRIPT_LOCATION -y -P" + [[ ! -z $(echo "${output}" | grep "We will be installing $CMAKE_VERSION") ]] || exit # Testing for if cmake doesn't exist to be sure it's set properly export CMAKE= run bash -c "./$SCRIPT_LOCATION -y -P" From 38488c657f66f3db4a8c9184d3c48383c1a1a988 Mon Sep 17 00:00:00 2001 From: Nathan Pierce Date: Fri, 28 Jun 2019 14:25:45 -0400 Subject: [PATCH 2/7] support for darwin's cmake being < required (since we don't source install) + bats --- scripts/eosio_build.sh | 7 ++++++- tests/bash-bats/modules/cmake.sh | 18 +++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/scripts/eosio_build.sh b/scripts/eosio_build.sh index f20e070f4d0..c39adacd891 100755 --- a/scripts/eosio_build.sh +++ b/scripts/eosio_build.sh @@ -147,8 +147,13 @@ ensure-submodules-up-to-date ( [[ -z "${CMAKE}" ]] && [[ ! -z $(command -v cmake 2>/dev/null) ]] ) && export CMAKE=$(command -v cmake 2>/dev/null) && export CMAKE_CURRENT_VERSION=$($CMAKE --version | grep -E "cmake version[[:blank:]]*" | sed 's/.*cmake version //g') # If it exists, check that it's > required version if [[ ! -z $CMAKE_CURRENT_VERSION ]] && [[ $( echo $CURRENT_CMAKE_VERSION | awk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }' ) < $( echo $CMAKE_REQUIRED_VERSION | awk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }' ) ]]; then - echo "${COLOR_YELLOW}The currently installed cmake version ($CMAKE_CURRENT_VERSION) is less than the required version ($CMAKE_REQUIRED_VERSION). We will be installing $CMAKE_VERSION.${COLOR_NC}" export CMAKE= + if [[ $ARCH == 'Darwin' ]]; then + echo "${COLOR_RED}The currently installed cmake version ($CMAKE_CURRENT_VERSION) is less than the required version ($CMAKE_REQUIRED_VERSION). Cannot proceed." + exit + else + echo "${COLOR_YELLOW}The currently installed cmake version ($CMAKE_CURRENT_VERSION) is less than the required version ($CMAKE_REQUIRED_VERSION). We will be installing $CMAKE_VERSION.${COLOR_NC}" + fi fi # Use existing cmake on system (either global or specific to eosio) diff --git a/tests/bash-bats/modules/cmake.sh b/tests/bash-bats/modules/cmake.sh index b2a932d3ed3..8c1e3e3d963 100755 --- a/tests/bash-bats/modules/cmake.sh +++ b/tests/bash-bats/modules/cmake.sh @@ -5,14 +5,26 @@ load ../helpers/functions # Testing for if CMAKE already exists export CMAKE=${HOME}/cmake touch $CMAKE - run bash -c " ./$SCRIPT_LOCATION -y -P" - [[ ! -z $(echo "${output}" | grep "Executing: bash -c ${HOME}/cmake") ]] || exit export CMAKE_CURRENT_VERSION=3.7.1 run bash -c " ./$SCRIPT_LOCATION -y -P" - [[ ! -z $(echo "${output}" | grep "We will be installing $CMAKE_VERSION") ]] || exit + if [[ $ARCH == "Darwin" ]]; then + [[ ! -z $(echo "${output}" | grep "($CMAKE_REQUIRED_VERSION). Cannot proceed") ]] || exit # Test the required version + else + [[ ! -z $(echo "${output}" | grep "We will be installing $CMAKE_VERSION") ]] || exit # Test the required version + [[ ! -z $(echo "${output}" | grep "Executing: bash -c ${HOME}/cmake") ]] || exit + fi # Testing for if cmake doesn't exist to be sure it's set properly export CMAKE= run bash -c "./$SCRIPT_LOCATION -y -P" + if [[ $ARCH == "Darwin" ]]; then + [[ ! -z $(echo "${output}" | grep "($CMAKE_REQUIRED_VERSION). Cannot proceed") ]] || exit # Test the required version + else + [[ ! -z $(echo "${output}" | grep "We will be installing $CMAKE_VERSION") ]] || exit # Test the required version + [[ ! -z $(echo "${output}" | grep "Executing: bash -c ${BIN_DIR}/cmake") ]] || exit + [[ ! -z $(echo "${output}" | grep "CMAKE successfully installed") ]] || exit + fi + export CMAKE_CURRENT_VERSION= + run bash -c "./$SCRIPT_LOCATION -y -P" if [[ $ARCH == "Darwin" ]]; then [[ ! -z $(echo "${output}" | grep "Executing: bash -c /usr/local/bin/cmake -DCMAKE_BUILD") ]] || exit else From 09daee1cdc349c9c5bde2f749895aa84666fbb86 Mon Sep 17 00:00:00 2001 From: Nathan Pierce Date: Fri, 28 Jun 2019 14:39:17 -0400 Subject: [PATCH 3/7] bats test fixes --- scripts/.build_vars | 2 +- tests/bash-bats/modules/cmake.sh | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/.build_vars b/scripts/.build_vars index b466e3e0088..70b39c5035b 100644 --- a/scripts/.build_vars +++ b/scripts/.build_vars @@ -7,7 +7,7 @@ export LIB_DIR=${EOSIO_INSTALL_DIR}/lib export DATA_DIR=${EOSIO_INSTALL_DIR}/data # CMAKE -export CMAKE_REQUIRED_VERSION=$(cat $REPO_ROOT/CMakeLists.txt | grep -E "cmake_minimum_required\([[:blank:]]*VERSION" | tail -1 | sed 's/.*VERSION //g' | cut -d\) -f1 | sed 's/ //g') +export CMAKE_REQUIRED_VERSION=$(cat $REPO_ROOT/CMakeLists.txt | grep -E "^[[:blank:]]*cmake_minimum_required[[:blank:]]*\([[:blank:]]*VERSION" | tail -1 | sed 's/.*VERSION //g' | sed 's/ //g' | sed 's/"//g' | cut -d\) -f1) export CMAKE_VERSION_MAJOR=3 export CMAKE_VERSION_MINOR=13 export CMAKE_VERSION_PATCH=2 diff --git a/tests/bash-bats/modules/cmake.sh b/tests/bash-bats/modules/cmake.sh index 8c1e3e3d963..171e48c5c50 100755 --- a/tests/bash-bats/modules/cmake.sh +++ b/tests/bash-bats/modules/cmake.sh @@ -2,6 +2,7 @@ load ../helpers/functions @test "${TEST_LABEL} > Testing CMAKE" { + # Testing for if CMAKE already exists export CMAKE=${HOME}/cmake touch $CMAKE @@ -11,10 +12,18 @@ load ../helpers/functions [[ ! -z $(echo "${output}" | grep "($CMAKE_REQUIRED_VERSION). Cannot proceed") ]] || exit # Test the required version else [[ ! -z $(echo "${output}" | grep "We will be installing $CMAKE_VERSION") ]] || exit # Test the required version - [[ ! -z $(echo "${output}" | grep "Executing: bash -c ${HOME}/cmake") ]] || exit + [[ ! -z $(echo "${output}" | grep "Executing: bash -c ${BIN_DIR}/cmake") ]] || exit + fi + export CMAKE_CURRENT_VERSION= + run bash -c " ./$SCRIPT_LOCATION -y -P" + [[ ! -z $(echo "${output}" | grep "Executing: bash -c ${HOME}/cmake") ]] || exit + if [[ $ARCH != "Darwin" ]]; then + [[ -z $(echo "${output}" | grep "CMAKE successfully installed") ]] || exit fi + # Testing for if cmake doesn't exist to be sure it's set properly export CMAKE= + export CMAKE_CURRENT_VERSION=3.6 run bash -c "./$SCRIPT_LOCATION -y -P" if [[ $ARCH == "Darwin" ]]; then [[ ! -z $(echo "${output}" | grep "($CMAKE_REQUIRED_VERSION). Cannot proceed") ]] || exit # Test the required version From d096432ca3f50a49209bef7134c6a0acc2b9081d Mon Sep 17 00:00:00 2001 From: Nathan Pierce Date: Fri, 28 Jun 2019 14:40:04 -0400 Subject: [PATCH 4/7] CMAKE_REQUIRED_VERSION -> .environment --- scripts/.build_vars | 1 - scripts/.environment | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/.build_vars b/scripts/.build_vars index 70b39c5035b..585c521c935 100644 --- a/scripts/.build_vars +++ b/scripts/.build_vars @@ -7,7 +7,6 @@ export LIB_DIR=${EOSIO_INSTALL_DIR}/lib export DATA_DIR=${EOSIO_INSTALL_DIR}/data # CMAKE -export CMAKE_REQUIRED_VERSION=$(cat $REPO_ROOT/CMakeLists.txt | grep -E "^[[:blank:]]*cmake_minimum_required[[:blank:]]*\([[:blank:]]*VERSION" | tail -1 | sed 's/.*VERSION //g' | sed 's/ //g' | sed 's/"//g' | cut -d\) -f1) export CMAKE_VERSION_MAJOR=3 export CMAKE_VERSION_MINOR=13 export CMAKE_VERSION_PATCH=2 diff --git a/scripts/.environment b/scripts/.environment index d5542098253..7c54a699445 100644 --- a/scripts/.environment +++ b/scripts/.environment @@ -13,6 +13,8 @@ else export EOSIO_VERSION_FULL="${EOSIO_VERSION_MAJOR}.${EOSIO_VERSION_MINOR}.${EOSIO_VERSION_PATCH}-${EOSIO_VERSION_SUFFIX}" fi +export CMAKE_REQUIRED_VERSION=$(cat $REPO_ROOT/CMakeLists.txt | grep -E "^[[:blank:]]*cmake_minimum_required[[:blank:]]*\([[:blank:]]*VERSION" | tail -1 | sed 's/.*VERSION //g' | sed 's/ //g' | sed 's/"//g' | cut -d\) -f1) + export EOSIO_INSTALL_DIR="${EOSIO_INSTALL_DIR:-${HOME}/eosio/${EOSIO_VERSION}}" export TEMP_DIR="${TEMP_DIR:-${HOME}/tmp}" From cdcfdb6784cafe3089234b3779981fa3db89651d Mon Sep 17 00:00:00 2001 From: Nathan Pierce Date: Fri, 28 Jun 2019 15:16:42 -0400 Subject: [PATCH 5/7] exit 1 --- scripts/eosio_build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/eosio_build.sh b/scripts/eosio_build.sh index c39adacd891..830036575ad 100755 --- a/scripts/eosio_build.sh +++ b/scripts/eosio_build.sh @@ -150,7 +150,7 @@ if [[ ! -z $CMAKE_CURRENT_VERSION ]] && [[ $( echo $CURRENT_CMAKE_VERSION | awk export CMAKE= if [[ $ARCH == 'Darwin' ]]; then echo "${COLOR_RED}The currently installed cmake version ($CMAKE_CURRENT_VERSION) is less than the required version ($CMAKE_REQUIRED_VERSION). Cannot proceed." - exit + exit 1 else echo "${COLOR_YELLOW}The currently installed cmake version ($CMAKE_CURRENT_VERSION) is less than the required version ($CMAKE_REQUIRED_VERSION). We will be installing $CMAKE_VERSION.${COLOR_NC}" fi From 2b0b9177d905fc48a6286ea9301fde044182e345 Mon Sep 17 00:00:00 2001 From: Nathan Pierce Date: Fri, 28 Jun 2019 15:26:15 -0400 Subject: [PATCH 6/7] numeric less than fix test --- scripts/eosio_build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/eosio_build.sh b/scripts/eosio_build.sh index 830036575ad..1e02f0ac994 100755 --- a/scripts/eosio_build.sh +++ b/scripts/eosio_build.sh @@ -146,7 +146,7 @@ ensure-submodules-up-to-date # Check if cmake already exists ( [[ -z "${CMAKE}" ]] && [[ ! -z $(command -v cmake 2>/dev/null) ]] ) && export CMAKE=$(command -v cmake 2>/dev/null) && export CMAKE_CURRENT_VERSION=$($CMAKE --version | grep -E "cmake version[[:blank:]]*" | sed 's/.*cmake version //g') # If it exists, check that it's > required version -if [[ ! -z $CMAKE_CURRENT_VERSION ]] && [[ $( echo $CURRENT_CMAKE_VERSION | awk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }' ) < $( echo $CMAKE_REQUIRED_VERSION | awk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }' ) ]]; then +if [[ ! -z $CMAKE_CURRENT_VERSION ]] && (( $( echo $CURRENT_CMAKE_VERSION | awk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }' ) < $( echo $CMAKE_REQUIRED_VERSION | awk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }' ) )); then export CMAKE= if [[ $ARCH == 'Darwin' ]]; then echo "${COLOR_RED}The currently installed cmake version ($CMAKE_CURRENT_VERSION) is less than the required version ($CMAKE_REQUIRED_VERSION). Cannot proceed." From cee9752733b902d8edf2a4b63d91c28db4cb2cf7 Mon Sep 17 00:00:00 2001 From: Nathan Pierce Date: Fri, 28 Jun 2019 15:52:25 -0400 Subject: [PATCH 7/7] bats tests to support darwin cmake requirement --- scripts/eosio_build.sh | 4 ++-- tests/bash-bats/modules/cmake.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/eosio_build.sh b/scripts/eosio_build.sh index 1e02f0ac994..c252d0595e0 100755 --- a/scripts/eosio_build.sh +++ b/scripts/eosio_build.sh @@ -145,8 +145,8 @@ ensure-submodules-up-to-date # Check if cmake already exists ( [[ -z "${CMAKE}" ]] && [[ ! -z $(command -v cmake 2>/dev/null) ]] ) && export CMAKE=$(command -v cmake 2>/dev/null) && export CMAKE_CURRENT_VERSION=$($CMAKE --version | grep -E "cmake version[[:blank:]]*" | sed 's/.*cmake version //g') -# If it exists, check that it's > required version -if [[ ! -z $CMAKE_CURRENT_VERSION ]] && (( $( echo $CURRENT_CMAKE_VERSION | awk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }' ) < $( echo $CMAKE_REQUIRED_VERSION | awk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }' ) )); then +# If it exists, check that it's > required version + +if [[ ! -z $CMAKE_CURRENT_VERSION ]] && [[ $((10#$( echo $CMAKE_CURRENT_VERSION | awk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }' ))) -lt $((10#$( echo $CMAKE_REQUIRED_VERSION | awk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }' ))) ]]; then export CMAKE= if [[ $ARCH == 'Darwin' ]]; then echo "${COLOR_RED}The currently installed cmake version ($CMAKE_CURRENT_VERSION) is less than the required version ($CMAKE_REQUIRED_VERSION). Cannot proceed." diff --git a/tests/bash-bats/modules/cmake.sh b/tests/bash-bats/modules/cmake.sh index 171e48c5c50..e726fce9dc3 100755 --- a/tests/bash-bats/modules/cmake.sh +++ b/tests/bash-bats/modules/cmake.sh @@ -9,7 +9,7 @@ load ../helpers/functions export CMAKE_CURRENT_VERSION=3.7.1 run bash -c " ./$SCRIPT_LOCATION -y -P" if [[ $ARCH == "Darwin" ]]; then - [[ ! -z $(echo "${output}" | grep "($CMAKE_REQUIRED_VERSION). Cannot proceed") ]] || exit # Test the required version + [[ "${output##*$'\n'}" =~ "($CMAKE_REQUIRED_VERSION). Cannot proceed" ]] || exit # Test the required version else [[ ! -z $(echo "${output}" | grep "We will be installing $CMAKE_VERSION") ]] || exit # Test the required version [[ ! -z $(echo "${output}" | grep "Executing: bash -c ${BIN_DIR}/cmake") ]] || exit @@ -26,7 +26,7 @@ load ../helpers/functions export CMAKE_CURRENT_VERSION=3.6 run bash -c "./$SCRIPT_LOCATION -y -P" if [[ $ARCH == "Darwin" ]]; then - [[ ! -z $(echo "${output}" | grep "($CMAKE_REQUIRED_VERSION). Cannot proceed") ]] || exit # Test the required version + [[ "${output##*$'\n'}" =~ "($CMAKE_REQUIRED_VERSION). Cannot proceed" ]] || exit # Test the required version else [[ ! -z $(echo "${output}" | grep "We will be installing $CMAKE_VERSION") ]] || exit # Test the required version [[ ! -z $(echo "${output}" | grep "Executing: bash -c ${BIN_DIR}/cmake") ]] || exit