Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Commit

Permalink
[Linux] Auto-detect clang version
Browse files Browse the repository at this point in the history
	- Auto-detect if there is clang symlink and version is not specified
	- Remove hardcode clang version from msbuild file

Signed-off-by: Petr Bred <bredpetr@gmail.com>
  • Loading branch information
BredPet committed Feb 5, 2018
1 parent e89bb7a commit f0e80e4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
22 changes: 22 additions & 0 deletions buildscripts/buildvars-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ export __CrossBuild=0

__BuildArch=$__HostArch

# Checking for any clang versions, if there is a symlink
if [ -x "$(command -v clang)" ]; then
__ClangMajorVersion="$(echo | clang -dM -E - | grep __clang_major__ | cut -f3 -d ' ')"
__ClangMinorVersion="$(echo | clang -dM -E - | grep __clang_minor__ | cut -f3 -d ' ')"
fi

while [ "$1" != "" ]; do
lowerI="$(echo $1 | awk '{print tolower($0)}')"
case $lowerI in
Expand Down Expand Up @@ -171,6 +177,22 @@ while [ "$1" != "" ]; do
export __ClangMajorVersion=3
export __ClangMinorVersion=9
;;
clang4.0)
export __ClangMajorVersion=4
export __ClangMinorVersion=0
;;
clang5.0)
export __ClangMajorVersion=5
export __ClangMinorVersion=0
;;
clang6.0)
export __ClangMajorVersion=6
export __ClangMinorVersion=0
;;
clang7.0)
export __ClangMajorVersion=7
export __ClangMinorVersion=0
;;
cross)
export __CrossBuild=1
;;
Expand Down
6 changes: 4 additions & 2 deletions src/BuildIntegration/Microsoft.NETCore.Native.Unix.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ See the LICENSE file in the project root for more information.
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<CppCompilerAndLinker Condition="'$(CppCompilerAndLinker)' == '' and '$(TargetOS)' == 'OSX'">clang</CppCompilerAndLinker>
<CppCompilerAndLinker Condition="'$(CppCompilerAndLinker)' == ''">clang-3.9</CppCompilerAndLinker>
<CppCompilerAndLinker Condition="'$(CppCompilerAndLinker)' == '' and '$(TargetOS)' == 'Linux' and '$(__ClangMajorVersion)' != '' and $(__ClangMinorVersion) != ''">clang-$(__ClangMajorVersion).$(__ClangMinorVersion)</CppCompilerAndLinker>
<CppCompilerAndLinker Condition="'$(CppCompilerAndLinker)' == ''">clang-$(__ClangMajorVersion).$(__ClangMinorVersion)</CppCompilerAndLinker>
<CppCompiler>$(CppCompilerAndLinker)</CppCompiler>
<CppLinker>$(CppCompilerAndLinker)</CppLinker>
<CppLibCreator>ar</CppLibCreator>
Expand All @@ -26,7 +27,8 @@ See the LICENSE file in the project root for more information.
<!-- Ensure that runtime-specific paths have already been set -->
<PropertyGroup>
<CppCompilerAndLinker Condition="'$(CppCompilerAndLinker)' == '' and '$(TargetOS)' == 'OSX'">clang</CppCompilerAndLinker>
<CppCompilerAndLinker Condition="'$(CppCompilerAndLinker)' == ''">clang-3.9</CppCompilerAndLinker>
<CppCompilerAndLinker Condition="'$(CppCompilerAndLinker)' == '' and '$(TargetOS)' == 'Linux' and '$(__ClangMajorVersion)' != '' and $(__ClangMinorVersion) != ''">clang-$(__ClangMajorVersion).$(__ClangMinorVersion)</CppCompilerAndLinker>
<CppCompilerAndLinker Condition="'$(CppCompilerAndLinker)' == ''">clang-$(__ClangMajorVersion).$(__ClangMinorVersion)</CppCompilerAndLinker>
<CppCompiler>$(CppCompilerAndLinker)</CppCompiler>
<CppLinker>$(CppCompilerAndLinker)</CppLinker>
<CppLibCreator>ar</CppLibCreator>
Expand Down

0 comments on commit f0e80e4

Please sign in to comment.