diff --git a/build.sh b/build.sh index 6b93c25abd2..4a0fe67297b 100755 --- a/build.sh +++ b/build.sh @@ -303,6 +303,10 @@ while [[ $# -gt 0 ]]; do VALGRIND="-DENABLE_VALGRIND_SH=1" ;; + -y | -Y) + ALWAYS_YES=1 + ;; + *) echo "Unknown option $1" PRINT_USAGE @@ -375,10 +379,26 @@ if [[ ${#_VERBOSE} > 0 ]]; then fi # if LTO build is enabled and cc-toolchain/clang was compiled, use it instead -if [[ $HAS_LTO == 1 && -f cc-toolchain/build/bin/clang++ ]]; then - SELF=`pwd` - _CXX="$SELF/cc-toolchain/build/bin/clang++" - _CC="$SELF/cc-toolchain/build/bin/clang" +if [[ $HAS_LTO == 1 ]]; then + if [[ -f cc-toolchain/build/bin/clang++ ]]; then + SELF=`pwd` + _CXX="$CHAKRACORE_DIR/cc-toolchain/build/bin/clang++" + _CC="$CHAKRACORE_DIR/cc-toolchain/build/bin/clang" + else + # Linux LD possibly doesn't support LLVM LTO, check.. and compile clang if not + if [[ $OS_LINUX == 1 ]]; then + if [[ ! `ld -v` =~ 'GNU gold' ]]; then + $CHAKRACORE_DIR/tools/compile_clang.sh + if [[ $? != 0 ]]; then + echo -e "tools/compile_clang.sh has failed.\n" + echo "Try with 'sudo' ?" + exit 1 + fi + _CXX="$CHAKRACORE_DIR/cc-toolchain/build/bin/clang++" + _CC="$CHAKRACORE_DIR/cc-toolchain/build/bin/clang" + fi + fi + fi fi if [ "${HAS_LTO}${OS_LINUX}" == "11" ]; then diff --git a/tools/XPlatInstall/install_ch.sh b/tools/XPlatInstall/install_ch.sh index 49f5ef2fcdb..52a950787c6 100755 --- a/tools/XPlatInstall/install_ch.sh +++ b/tools/XPlatInstall/install_ch.sh @@ -52,7 +52,6 @@ GET_OS() exit } - GET_LATEST() { GET_OS @@ -61,12 +60,13 @@ GET_LATEST() CHAKRA_VERSION=$(curl -k -s -SL "https://aka.ms/chakracore/version") if [[ "$CHAKRA_VERSION" == *"Error"* ]]; then - PRINT $ERROR_COLOR "] Download Failed. Do you have an Internet connection?" + PRINT $ERROR_COLOR "] Please ensure you are connected to the internet and try again." exit 1 fi PRINT $SUCCESS_COLOR "] Found ChakraCore ${CHAKRA_VERSION//_/.} for ${CURRENT_OS}" - BINARY_NAME="https://aka.ms/chakracore/${BINARY_NAME}_${CHAKRA_VERSION}.tar.gz" + BINARY_NAME="https://aka.ms/chakracore/${BINARY_NAME}_${CHAKRA_VERSION}" + SHASUM_NAME="${BINARY_NAME}_s" } PRINT $DEFAULT_COLOR "ChakraCore Installation Script 0.1b\n" @@ -75,11 +75,11 @@ PRINT $DEFAULT_COLOR "Visit https://aka.ms/WhatIs/ChakraCore for more informatio GET_LATEST PRINT $DEFAULT_COLOR "----------------------------------------------------------------" -PRINT $SUCCESS_COLOR "\nThis script will download ChakraCore from" -PRINT $DEFAULT_COLOR "${BINARY_NAME}\n" +PRINT $SUCCESS_COLOR "\nThis script will download & execute ChakraCore binary" +PRINT $DEFAULT_COLOR "located at ${BINARY_NAME}\n" PRINT $DEFAULT_COLOR "----------------------------------------------------------------" PRINT $DEFAULT_COLOR "If you don't agree, press Ctrl+C to terminate" -read -t 10 -p "Hit ENTER to continue (or wait 10 seconds)" +read -t 20 -p "Hit ENTER to continue (or wait 20 seconds)" if [ -d "./ChakraCoreFiles" ]; then PRINT $ERROR_COLOR "] Found 'ChakraCoreFiles' folder on the current path." @@ -87,29 +87,65 @@ if [ -d "./ChakraCoreFiles" ]; then exit 1 fi +CHECK_DOWNLOAD_FAIL() +{ + if [[ $? != 0 ]]; then + PRINT $ERROR_COLOR "] Download failed." + PRINT $DEFAULT_COLOR "] ${___}" + exit 1 + fi +} + PRINT $DEFAULT_COLOR "\n] Downloading ChakraCore" PRINT $SUCCESS_COLOR "] ${BINARY_NAME}" - ___=$(curl -kSL -o "chakracore.tar.gz" "${BINARY_NAME}" 2>&1) +CHECK_DOWNLOAD_FAIL -if [[ $? != 0 ]]; then - PRINT $ERROR_COLOR "] Download failed." - PRINT $DEFAULT_COLOR "] ${___}" - exit 1 -fi +PRINT $DEFAULT_COLOR "\n] Downloading ChakraCore shasum" +PRINT $SUCCESS_COLOR "] ${SHASUM_NAME}" +___=$(curl -kSL -o "chakracore_s.tar.gz" "${SHASUM_NAME}" 2>&1) +CHECK_DOWNLOAD_FAIL PRINT $SUCCESS_COLOR "] Download completed" -___=$(tar -xzf chakracore.tar.gz 2>&1) +CHECK_EXT_FAIL() +{ + if [[ $? != 0 ]]; then + PRINT $ERROR_COLOR "] Extracting the compressed file failed." + PRINT $DEFAULT_COLOR "] ${___}" + rm -rf ChakraCoreFiles/ + rm -rf chakracore.tar.gz + rm -rf chakracore_s.tar.gz + exit 1 + fi +} -if [[ $? != 0 ]]; then - PRINT $ERROR_COLOR "] Extracting the compressed file is failed." - PRINT $DEFAULT_COLOR "] ${___}" - rm -rf ChakraCoreFiles/ +___=$(tar -xzf chakracore_s.tar.gz 2>&1) +CHECK_EXT_FAIL + +SUM1=`shasum -a 512256 chakracore.tar.gz` +SUM2=`cat ChakraCoreFiles/shasum` +SUM1="${SUM1}@" +SUM2="${SUM2}@" + +if [[ ! $SUM1 =~ $SUM2 ]]; then + PRINT $ERROR_COLOR "] Corrupted binary package." + PRINT $DEFAULT_COLOR "] Check your network connection." + PRINT $ERROR_COLOR "] If you suspect there is some other problem,\ + https://github.com/Microsoft/ChakraCore#contact-us" rm -rf chakracore.tar.gz + rm -rf chakracore_s.tar.gz + rm -rf ChakraCoreFiles/ exit 1 fi +rm -rf chakracore_s.tar.gz + +PRINT $SUCCESS_COLOR "] ChakraCore package SHASUM matches" + +___=$(tar -xzf chakracore.tar.gz 2>&1) +CHECK_EXT_FAIL + rm -rf chakracore.tar.gz # test ch diff --git a/tools/create_package.sh b/tools/create_package.sh index 4fb15ee0c07..adf0a964f85 100755 --- a/tools/create_package.sh +++ b/tools/create_package.sh @@ -82,7 +82,7 @@ echo -e "\n***** Third Party Notices [ for PreBuilt Binaries ] *****\n" >> out/C cat tools/XPlatInstall/BINARY-DIST-ONLY-NOTICES.txt >> out/ChakraCoreFiles/LICENSE # sample cp "tools/XPlatInstall/sample/README.md" out/ChakraCoreFiles/sample/README.md -cp "tools/XPlatInstall/sample/Makefile.txt" out/ChakraCoreFiles/sample/Makefile +cp "tools/XPlatInstall/sample/Makefile" out/ChakraCoreFiles/sample/Makefile cp "tools/XPlatInstall/sample/sample.cpp.txt" out/ChakraCoreFiles/sample/sample.cpp ## Test @@ -97,7 +97,16 @@ IF_ERROR_EXIT $? "CH binary test failed" pushd out/ > /dev/null PACKAGE_FILE="cc_${HOST_OS}_x64_${CHAKRA_VERSION}.tar.gz" tar -czf "${PACKAGE_FILE}" ChakraCoreFiles/ +mkdir -p temp/ChakraCoreFiles/ +cp "${PACKAGE_FILE}" temp/chakracore.tar.gz +cd temp +SHASUM_FILE="cc_${HOST_OS}_x64_${CHAKRA_VERSION}_s.tar.gz" +shasum -a 512256 chakracore.tar.gz > ChakraCoreFiles/shasum +tar -czf "$SHASUM_FILE" ChakraCoreFiles +mv $SHASUM_FILE ../ +cd .. +rm -rf temp/ popd > /dev/null ## Credits -echo -e "\nPackage file is ready at ${GREEN_COLOR}${PACKAGE_FILE}${DEFAULT_COLOR}" +echo -e "\nPackage & Shasum files are ready under ${GREEN_COLOR}out/${DEFAULT_COLOR}"