Add `nvm_clang_version` to ensure clang version > 3.5
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Peter Dave Hello · committed by Jordan Harband · parent 9f67d3e · Browse files · 2 files·+69 added−3 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+69 added−3 removed
- tests:+62 added−0 removed
- other:+7 added−3 removed
Provenance
- Commit
65acb40- Tree
2db5533- Author
Peter Dave Hello <hsu@peterdavehello.org>- Committer
Jordan Harband <ljharb@gmail.com>- Parent
9f67d3e
2 files changed+69 added−3 removed
added:test/fast/Unit tests/nvm_clang_version+62 added
1+#!/bin/sh2+3+cleanup () {4+ unset -f die5+}6+7+die () { echo -e "$@" ; cleanup ; exit 1; }8+9+if type "clang" > /dev/null 2>&1 ; then10+ clang_exec="$(type "clang")"11+ sudo rm -rf "${clang_exec}"12+fi13+if type "clang++" > /dev/null 2>&1 ; then14+ clangxx_exec="$(type "clang++")"15+ sudo rm -rf "${clangxx_exec}"16+fi17+18+NVM_ENV=testing \. ../../../nvm.sh19+20+clang() {21+ if [ "$1" = "--version" ]; then22+ echo "${VERSION_MESSAGE}"23+ fi24+}25+26+assert_version_is() {27+ if [ "${1}" != "${2}" ]; then28+ die "Expected ${2}, got ${1}, origin version message:\n${VERSION_MESSAGE}"29+ return 130+ fi31+}32+33+CLANG_VERSION_ON_DEBIAN_JESSIE="Debian clang version 3.5.0-10 (tags/RELEASE_350/final) (based on LLVM 3.5.0)34+Target: x86_64-pc-linux-gnu35+Thread model: posix"36+37+CLANG_VERSION_ON_UBUNTU_TRUSTY="Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)38+Target: x86_64-pc-linux-gnu39+Thread model: posix"40+41+CLANG_VERSION_ON_ARCHLINUX="clang version 3.9.0 (tags/RELEASE_390/final)42+Target: x86_64-unknown-linux-gnu43+Thread model: posix44+InstalledDir: /usr/sbin"45+46+CLANG_VERSION_ON_FREEBSD="FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 2014051247+Target: x86_64-unknown-freebsd10.348+Thread model: posix"49+50+VERSION_MESSAGE="${CLANG_VERSION_ON_DEBIAN_JESSIE}"51+assert_version_is "$(nvm_clang_version)" "3.5.0"52+53+VERSION_MESSAGE="${CLANG_VERSION_ON_UBUNTU_TRUSTY}"54+assert_version_is "$(nvm_clang_version)" "3.4"55+56+VERSION_MESSAGE="${CLANG_VERSION_ON_ARCHLINUX}"57+assert_version_is "$(nvm_clang_version)" "3.9.0"58+59+VERSION_MESSAGE="${CLANG_VERSION_ON_FREEBSD}"60+assert_version_is "$(nvm_clang_version)" "3.4.1"61+62+cleanupmodified:nvm.sh+7 added-3 removed
190 unmodified lines191 return 1192 fi193 }194 195+nvm_clang_version() {196+ clang --version | command awk '{ if ($2 == "version") print $3; else if ($3 == "version") print $4 }' | command sed 's/-.*$//g'197+}198+199 nvm_version_greater() {200 command awk 'BEGIN {201 if (ARGV[1] == "" || ARGV[2] == "") exit(1)202 split(ARGV[1], a, /\./);1654 unmodified lines1857 MAKE_CXX='CXX=c++' 1858 elif [ "${NVM_OS}" = 'aix' ]; then1859 make='gmake'1860 fi1857- if nvm_has "clang++" && nvm_has "clang" ; then1858- nvm_echo "Clang detected! Use Clang as c/c++ compiler!"1861+ if nvm_has "clang++" && nvm_has "clang" && nvm_version_greater_than_or_equal_to nvm_clang_version 3.5 ; then1862+ nvm_echo "Clang v3.5+ detected! Use Clang as c/c++ compiler!"1863 MAKE_CXX='CC=clang CXX=clang++'1864 fi1865 1866 local tar_compression_flag1281 unmodified lines3148 nvm_add_iojs_prefix nvm_strip_iojs_prefix \3149 nvm_is_iojs_version nvm_is_alias \3150 nvm_ls_remote nvm_ls_remote_iojs nvm_ls_remote_index_tab \3151 nvm_ls nvm_remote_version nvm_remote_versions \3148- nvm_install_binary \3152+ nvm_install_binary nvm_clang_version \3153 nvm_get_mirror nvm_get_download_slug nvm_download_artifact \3154 nvm_install_source nvm_check_file_permissions \3155 nvm_print_versions nvm_compute_checksum nvm_checksum \3156 nvm_get_checksum_alg nvm_get_checksum nvm_compare_checksum \116 unmodified lines