Skip to content

Commit da9c920

Browse files
committed
Add clang-cl toolset.
1 parent 543a4d4 commit da9c920

File tree

3 files changed

+36
-8
lines changed

3 files changed

+36
-8
lines changed

assets/clang-cl/Toolset.props

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<Import Project="..\v141\Toolset.props" />
3+
4+
<PropertyGroup>
5+
<LLVMDir>{{LLVMDir}}</LLVMDir>
6+
<ExecutablePath>$(LLVMDir)\msbuild-bin;$(LLVMDir)\bin;$(ExecutablePath)</ExecutablePath>
7+
<IncludePath>$(LLVMDir)\include;$(IncludePath)</IncludePath>
8+
<LibraryPath>$(LLVMDir)\lib;$(LibraryPath)</LibraryPath>
9+
<ExcludePath>$(LLVMDir)\include;$(ExcludePath)</ExcludePath>
10+
</PropertyGroup>
11+
12+
<ItemDefinitionGroup>
13+
<ClCompile>
14+
<AdditionalOptions Condition="'$(Platform)'=='Win32'">-m32 -fmsc-version=1910 %(AdditionalOptions)</AdditionalOptions>
15+
<AdditionalOptions Condition="'$(Platform)'=='x64'">-m64 -fmsc-version=1910 %(AdditionalOptions)</AdditionalOptions>
16+
</ClCompile>
17+
</ItemDefinitionGroup>
18+
</Project>

assets/clang-cl/Toolset.targets

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<Import Project="..\v141\Toolset.targets"/>
3+
</Project>

scripts/install.ps1

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
param($LLVMDirectory = "", $ToolsetName = ""<#, $ClangClToolsetName = ""#>)
1+
param($LLVMDirectory = "", $ToolsetName = "", $ClangClToolsetName = "")
22
$id=[System.Security.Principal.WindowsIdentity]::GetCurrent()
33
$principal=new-object System.Security.Principal.WindowsPrincipal($id)
44

@@ -92,32 +92,28 @@ do {
9292
}
9393
}
9494

95-
<#
9695
if ($reset -or ($ClangClToolsetName -eq "" -and (Read-Host "Do you want to install a toolset for clang-cl? (y/N)") -match "y|yes")) {
9796
$prompt = "What is the clang-cl toolset name?"
9897
if ($reset) {
9998
$prompt += "(current: $ClangClToolsetName)"
10099
} else {
101-
$prompt += " (default: v100_clang_fafnir)"
100+
$prompt += " (default: fafnir_clang_cl)"
102101
}
103102
$tmp = Read-Host $prompt
104103
if ($tmp -eq "" -and $ClangClToolsetName -eq "") {
105104
$ClangClToolsetName = "fafnir_clang_cl"
106105
}
107106
}
108-
#>
109107

110108
""
111109
"=== Install configuration ==="
112110
"* LLVM install directory: $LLVMDirectory"
113111
"* Toolset name: $ToolsetName"
114-
<#
115112
if ($ClangClToolsetName -eq "") {
116113
"* Clang-cl toolset won't install."
117114
} else {
118115
"* Clang-cl toolset: $ClangClToolsetName"
119116
}
120-
#>
121117
""
122118
$reset = $true
123119
} while((Read-Host "Is it OK to install? (Y/n)") -match "n|no")
@@ -127,10 +123,11 @@ $assets = "$rootDir\assets"
127123
$bin = "$rootDir\bin\clang.exe"
128124

129125
function Install ($arch) {
130-
if (!(Test-Path "$VSInstallDir\Common7\IDE\VC\VCTargets\Platforms\$arch")) {
126+
$platformDir = "$VSInstallDir\Common7\IDE\VC\VCTargets\Platforms\$arch\PlatformToolsets";
127+
if (!(Test-Path $platformDir)) {
131128
return
132129
}
133-
$targetPath = "$VSInstallDir\Common7\IDE\VC\VCTargets\Platforms\$arch\PlatformToolsets\$ToolsetName"
130+
$targetPath = "$platformDir\$ToolsetName"
134131

135132
if (!(Test-Path $targetPath)) {
136133
New-Item -ItemType Directory $targetPath
@@ -144,6 +141,16 @@ function Install ($arch) {
144141
}
145142
Copy-Item $bin "$targetPath\bin"
146143
Set-Content -Path "$targetPath\bin\.target" "$LLVMDirectory\bin\clang.exe" -Encoding UTF8 -NoNewline
144+
145+
if ($ClangClToolsetName -ne "") {
146+
$targetPath = "$platformDir\$ClangClToolsetName"
147+
if (!(Test-Path $targetPath)) {
148+
New-Item -ItemType Directory $targetPath
149+
}
150+
Copy-Item "$assets\clang-cl\Toolset.targets" "$targetPath"
151+
$content = (Get-Content -Encoding UTF8 "$assets\clang-cl\Toolset.props") -replace "{{LLVMDir}}",$LLVMDirectory
152+
Set-Content "$targetPath\Toolset.props" $content -Encoding UTF8 | Out-Null
153+
}
147154
}
148155

149156
Install "Win32"

0 commit comments

Comments
 (0)