Skip to content
Myr

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

2 files+69 added−3 removed

added:test/fast/Unit tests/nvm_clang_version+62 added
1#!/bin/sh23cleanup () {4 unset -f die5}67die () { echo -e "$@" ; cleanup ; exit 1; }89if type "clang" > /dev/null 2>&1 ; then10 clang_exec="$(type "clang")"11 sudo rm -rf "${clang_exec}"12fi13if type "clang++" > /dev/null 2>&1 ; then14 clangxx_exec="$(type "clang++")"15 sudo rm -rf "${clangxx_exec}"16fi1718NVM_ENV=testing \. ../../../nvm.sh1920clang() {21 if [ "$1" = "--version" ]; then22 echo "${VERSION_MESSAGE}"23 fi24}2526assert_version_is() {27 if [ "${1}" != "${2}" ]; then28 die "Expected ${2}, got ${1}, origin version message:\n${VERSION_MESSAGE}"29 return 130 fi31}3233CLANG_VERSION_ON_DEBIAN_JESSIE="Debian clang version 3.5.0-10 (tags/RELEASE_350/final) (based on LLVM 3.5.0)34Target: x86_64-pc-linux-gnu35Thread model: posix"3637CLANG_VERSION_ON_UBUNTU_TRUSTY="Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)38Target: x86_64-pc-linux-gnu39Thread model: posix"4041CLANG_VERSION_ON_ARCHLINUX="clang version 3.9.0 (tags/RELEASE_390/final)42Target: x86_64-unknown-linux-gnu43Thread model: posix44InstalledDir: /usr/sbin"4546CLANG_VERSION_ON_FREEBSD="FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 2014051247Target: x86_64-unknown-freebsd10.348Thread model: posix"4950VERSION_MESSAGE="${CLANG_VERSION_ON_DEBIAN_JESSIE}"51assert_version_is "$(nvm_clang_version)" "3.5.0"5253VERSION_MESSAGE="${CLANG_VERSION_ON_UBUNTU_TRUSTY}"54assert_version_is "$(nvm_clang_version)" "3.4"5556VERSION_MESSAGE="${CLANG_VERSION_ON_ARCHLINUX}"57assert_version_is "$(nvm_clang_version)" "3.9.0"5859VERSION_MESSAGE="${CLANG_VERSION_ON_FREEBSD}"60assert_version_is "$(nvm_clang_version)" "3.4.1"6162cleanup
modified:nvm.sh+7 added-3 removed
190 unmodified lines
191 return 1192 fi193}194195nvm_clang_version() {196 clang --version | command awk '{ if ($2 == "version") print $3; else if ($3 == "version") print $4 }' | command sed 's/-.*$//g'197}198199nvm_version_greater() {200 command awk 'BEGIN {201 if (ARGV[1] == "" || ARGV[2] == "") exit(1)202 split(ARGV[1], a, /\./);
1654 unmodified lines
1857 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 fi18651866 local tar_compression_flag
1281 unmodified lines
3148 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