Skip to content
This repository was archived by the owner on Jun 5, 2019. It is now read-only.

Commit 96d3783

Browse files
authored
Merge LLVM_4_01 branch (#17)
LLVM 4.01 support along with Appveyor builds for better community contribution support * Major re-rwite of the attribute support, while this break scompatibility it makes things a lot simpler to use and leverages officially supported LLVM-C APIs. AttributeBuilder and AttributeSet are no longer available (The immutability of AttributeSet just made it harder to use) - added analyzer nuget packges and update rulesets for style and analysis validation. - lots of styleCop FxCop/Analyzer clean up * Updated to get TestDebugInfo to generate comparible output with clang (One minor difference in a "distinct" MD node for debug info left to resolve) * Fixed support of DIGlobalVariableExpressions to re-enable debug info on global variables * Removed automatic use of layout to determine alignement. Relying on default implementation can be done with an Alignment value of 0 * major re-work of LLVM libs as NUGET package to support building with AppVeyor and other public servers * Updated to use new CSPROJ format and prepare for netstandard2.0 enabled build * Proper build of LLVM libs and headers into a NUGET package * Updated to use powershell as top level build mechanism * Major update to build infrastructure to better support CSemVer on automated and CI builds while still supporting versioned local builds * Moved TestDebugInfo to samples folder so it can be used to validate the generated NuGet files as part of a post build test. * Added standard analyzers and rule sets to common build props file so they are applied consistently for all projects. * Added tests to the build * Added publishing of packages for CI builds * updated readme.md to correctly show build badges for branches along with adding skip_commits to skip builds of only markdown changes. Large scale re-work of build support to leverage NuGet and msbuild. Including the build versioning task as a nuget package. * removed Nuget packaging and build of LLVM libs (They are now in the detached branch dedicated to the Nuget packages) * Converted test project to new SDK based CSproj format * Updated gitignore to not block the LL file (Test output files should generate to locations outside the build tree) * Removed unnecessary and hardcoded link to LibLLVM dll in test project * Set LibLLVM to use content items instead of "none" for LibLLVM.DLL * Added hopefully more meaningful diagnostic message on exception if LibLLVM.dll cannot be loaded * Removed use of DeploymentItem attribute on tests as it causes the test runner to deploy the binaries but the test runner doesn't know about all the proper nuget binary dependencies and therefore won't run without them. Without those attributes the tests run in place in the build output, which will have everything correctly copied already)
1 parent 2b091de commit 96d3783

File tree

251 files changed

+16786
-13157
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

251 files changed

+16786
-13157
lines changed

.editorconfig

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#Primary settings apply to all files unless overridden below
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 4
7+
insert_final_newline = true
8+
9+
# match VS generated formatting for MSBuild project files
10+
[*.*proj,*.props,*.targets]
11+
indent_size = 2
12+
13+
# match ISO standard requirement for C/C++
14+
[*.c,*.h,*.cpp]
15+
insert_final_newline = true
16+
17+
[*.cs]
18+
csharp_style_conditional_delegate_call = true:warning
19+
csharp_style_expression_bodied_accessors = true:suggestion
20+
csharp_style_expression_bodied_indexers = true:suggestion
21+
csharp_style_expression_bodied_methods = true:suggestion
22+
csharp_style_expression_bodied_operators = true:suggestion
23+
csharp_style_expression_bodied_properties = true:warning
24+
csharp_style_inlined_variable_declaration = true:warning
25+
csharp_style_pattern_matching_over_as_with_null_check = true:warning
26+
csharp_style_pattern_matching_over_is_with_cast_check = true:warning
27+
csharp_style_throw_expression = true:warning
28+
csharp_style_var_for_built_in_types = false:error
29+
csharp_style_var_when_type_is_apparent = true:warning
30+
csharp_style_var_elsewhere = false:none
31+
csharp_new_line_before_catch = true
32+
csharp_new_line_before_else = true
33+
csharp_new_line_before_finally = true
34+
csharp_new_line_before_open_brace = all
35+
csharp_new_line_between_query_expression_clauses = true
36+
dotnet_sort_system_directives_first = true
37+
dotnet_style_coalesce_expression = true:warning
38+
dotnet_style_collection_initializer = true:warning
39+
dotnet_style_explicit_tuple_names = true:warning
40+
dotnet_style_null_propagation = true:warning
41+
dotnet_style_qualification_for_event = false:error
42+
dotnet_style_qualification_for_field = false:error
43+
dotnet_style_qualification_for_property = false:error
44+
csharp_indent_block_contents = true
45+
csharp_indent_case_contents = true
46+
csharp_indent_labels = one_less_than_current
47+
csharp_indent_switch_labels = false
48+
csharp_space_after_cast = false
49+
csharp_space_after_colon_in_inheritance_clause = true
50+
csharp_space_after_comma = true
51+
csharp_space_after_keywords_in_control_flow_statements = false
52+
csharp_space_after_semicolon_in_for_statement = true
53+
csharp_space_around_binary_operators = before_and_after
54+
csharp_space_between_method_call_name_and_opening_parenthesis = false
55+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
56+
csharp_space_around_declaration_statements = ignore
57+
csharp_space_between_method_call_parameter_list_parentheses = true
58+
csharp_space_between_square_brackets = true

.gitignore

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ publish/
128128
# Publish Web Output
129129
*.[Pp]ublish.xml
130130
*.azurePubxml
131-
# TODO: Comment the next line if you want to checkin your web deploy settings
131+
# TODO: Comment the next line if you want to checkin your web deploy settings
132132
# but database connection strings (with potential passwords) will be unencrypted
133133
*.pubxml
134134
*.publishproj
@@ -203,10 +203,10 @@ FakesAssemblies/
203203

204204
# VS2015 support file
205205
*.opendb
206-
/src/.tools
207206
/src/LibLLVM/generatedversioninfo.h
208207
*.db
209-
/src/Llvm.NETTests/TestDebugInfo/test.s
210-
/src/Llvm.NETTests/TestDebugInfo/test.o
211-
/src/Llvm.NETTests/TestDebugInfo/test.ll
212-
/src/Llvm.NETTests/TestDebugInfo/test.bc
208+
*.exe
209+
**/launchSettings.json
210+
*.bc
211+
*.o
212+
*.s

BuildAll.ps1

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
# invokes nuget.exe, handles downloading it to the script root if it isn't already on the path
2+
function Invoke-Nuget
3+
{
4+
#update system search path to include the directory of this script for nuget.exe
5+
$oldPath = $env:Path
6+
$env:Path = "$PSScriptRoot;$env:Path"
7+
try
8+
{
9+
$nugetPaths = where.exe nuget.exe 2>$null
10+
if( !$nugetPaths )
11+
{
12+
# Download it from official nuget release location
13+
Invoke-WebRequest -UseBasicParsing -Uri https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile "$PSScriptRoot\nuget.exe"
14+
}
15+
Write-Information "nuget $args"
16+
nuget $args
17+
$err = $LASTEXITCODE
18+
if($err -ne 0)
19+
{
20+
throw "Error running nuget: $err"
21+
}
22+
}
23+
finally
24+
{
25+
$env:Path = $oldPath
26+
}
27+
}
28+
29+
function Invoke-msbuild([string]$project, [hashtable]$properties, [string[]]$targets, [string[]]$loggerArgs=@(), [string[]]$additionalArgs=@())
30+
{
31+
$msbuildArgs = @($project) + $loggerArgs + $additionalArgs + @("/t:$($targets -join ';')")
32+
if( $properties )
33+
{
34+
$msbuildArgs += @( "/p:$(ConvertTo-PropertyList $properties)" )
35+
}
36+
Write-Information "msbuild $($msbuildArgs -join ' ')"
37+
msbuild $msbuildArgs
38+
if($LASTEXITCODE -ne 0)
39+
{
40+
throw "Error running msbuild: $LASTEXITCODE"
41+
}
42+
}
43+
44+
function Normalize-Path([string]$path)
45+
{
46+
$path = [System.IO.Path]::GetFullPath($path)
47+
if( !$path.EndsWith([System.IO.Path]::DirectorySeparatorChar) )
48+
{
49+
$path += [System.IO.Path]::DirectorySeparatorChar
50+
}
51+
return $path
52+
}
53+
54+
function Get-BuildPaths( [string]$repoRoot)
55+
{
56+
$buildPaths = @{}
57+
$buildPaths.RepoRoot = $repoRoot
58+
$buildPaths.BuildOutputPath = Normalize-Path (Join-Path $repoRoot 'BuildOutput')
59+
$buildPaths.NugetRepositoryPath = Normalize-Path (Join-Path $buildPaths.BuildOutputPath 'packages')
60+
$buildPaths.NugetOutputPath = Normalize-Path (Join-Path $buildPaths.BuildOutputPath 'Nuget')
61+
$buildPaths.SrcRoot = Normalize-Path (Join-Path $repoRoot 'src')
62+
$buildPaths.LibLLVMSrcRoot = Normalize-Path (Join-Path $buildPaths.SrcRoot 'LibLLVM')
63+
$buildPaths.BuildTaskProjRoot = ([IO.Path]::Combine( $repoRoot, 'BuildExtensions', 'Llvm.NET.BuildTasks') )
64+
$buildPaths.BuildTaskProj = ([IO.Path]::Combine( $buildPaths.BuildTaskProjRoot, 'Llvm.NET.BuildTasks.csproj') )
65+
$buildPaths.BuildTaskBin = ([IO.Path]::Combine( $repoRoot, 'BuildOutput', 'bin', 'Release', 'net47', 'Llvm.NET.BuildTasks.dll') )
66+
return $buildPaths
67+
}
68+
69+
function Get-BuildInformation($buildPaths)
70+
{
71+
Write-Information "Computing Build information"
72+
# Run as distinct job to control 32 bit context and to unload the DLL on completion
73+
# this prevents it from remaining loaded in the current session, which would prevent
74+
# rebuild or deletes.
75+
Start-Job -RunAs32 -ScriptBlock {
76+
Write-Information "Computing Build information"
77+
$buildPaths = $args[0]
78+
79+
Add-Type -Path $buildPaths.BuildTaskBin
80+
$buildVersionData = [Llvm.NET.BuildTasks.BuildVersionData]::Load( (Join-Path $buildPaths.RepoRoot BuildVersion.xml ) )
81+
$semver = $buildVersionData.CreateSemVer(!!$env:APPVEYOR, !!$env:APPVEYOR_PULL_REQUEST_NUMBER, [DateTime]::UtcNow)
82+
83+
return @{
84+
FullBuildNumber = $semVer.ToString($true)
85+
PackageVersion = $semVer.ToString($false)
86+
FileVersionMajor = $semVer.FileVersion.Major
87+
FileVersionMinor = $semVer.FileVersion.Minor
88+
FileVersionBuild = $semVer.FileVersion.Build
89+
FileVersionRevision = $semver.FileVersion.Revision
90+
FileVersion= "$($semVer.FileVersion.Major).$($semVer.FileVersion.Minor).$($semVer.FileVersion.Build).$($semVer.FileVersion.Revision)"
91+
LlvmVersion = "$($buildVersionData.AdditionalProperties['LlvmVersionMajor']).$($buildVersionData.AdditionalProperties['LlvmVersionMinor']).$($buildVersionData.AdditionalProperties['LlvmVersionPatch'])"
92+
}
93+
} -ArgumentList @($buildPaths) | Receive-Job -Wait -AutoRemoveJob
94+
}
95+
96+
function ConvertTo-PropertyList([hashtable]$table)
97+
{
98+
(($table.GetEnumerator() | %{ "$($_.Key)=$($_.Value)" }) -join ';')
99+
}
100+
101+
# Main Script entry point -----------
102+
103+
pushd $PSScriptRoot
104+
try
105+
{
106+
# setup standard MSBuild logging for this build
107+
$msbuildLoggerArgs = @('/clp:Verbosity=Minimal')
108+
109+
if (Test-Path "C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll")
110+
{
111+
$msbuildLoggerArgs = $msbuildLoggerArgs + @("/logger:`"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll`"")
112+
}
113+
114+
$buildPaths = Get-BuildPaths $PSScriptRoot
115+
116+
Write-Information "Build Paths:"
117+
Write-Information ($buildPaths | Format-Table | Out-String)
118+
119+
if( Test-Path -PathType Container $buildPaths.BuildOutputPath )
120+
{
121+
Write-Information "Cleaning output folder from previous builds"
122+
rd -Recurse -Force -Path $buildPaths.BuildOutputPath
123+
}
124+
125+
md BuildOutput\NuGet\ | Out-Null
126+
127+
Write-Information "Restoring NUGET for internal build task"
128+
invoke-msbuild -Targets Restore -Project $buildPaths.BuildTaskProj -LoggerArgs $msbuildLoggerArgs
129+
130+
Write-Information "Building internal build task and NuGetPackage"
131+
Invoke-MSBuild -Targets Build -Properties @{Configuration='Release';} -Project $buildPaths.BuildTaskProj -LoggerArgs $msbuildLoggerArgs
132+
133+
$BuildInfo = Get-BuildInformation $buildPaths
134+
if($env:APPVEYOR)
135+
{
136+
Update-AppVeyorBuild -Version $BuildInfo.FullBuildNumber
137+
}
138+
139+
$packProperties = @{ version=$($BuildInfo.PackageVersion);
140+
llvmversion=$($BuildInfo.LlvmVersion);
141+
buildbinoutput=(normalize-path (Join-path $($buildPaths.BuildOutputPath) 'bin'));
142+
configuration='Release'
143+
}
144+
145+
$msBuildProperties = @{ Configuration = 'Release';
146+
FullBuildNumber = $BuildInfo.FullBuildNumber;
147+
PackageVersion = $BuildInfo.PackageVersion;
148+
FileVersionMajor = $BuildInfo.FileVersionMajor;
149+
FileVersionMinor = $BuildInfo.FileVersionMinor;
150+
FileVersionBuild = $BuildInfo.FileVersionBuild;
151+
FileVersionRevision = $BuildInfo.FileVersionRevision;
152+
FileVersion = $BuildInfo.FileVersion;
153+
LlvmVersion = $BuildInfo.LlvmVersion;
154+
}
155+
156+
Write-Information "Build Parameters:"
157+
Write-Information ($BuildInfo | Format-Table | Out-String)
158+
159+
# Need to invoke NuGet directly for restore of vcxproj as there is no /t:Restore target support
160+
Write-Information "Restoring Nuget Packages for LibLLVM.vcxproj"
161+
Invoke-NuGet restore src\LibLLVM\LibLLVM.vcxproj -PackagesDirectory $buildPaths.NuGetRepositoryPath
162+
163+
Write-Information "Building LibLLVM"
164+
Invoke-MSBuild -Targets Build -Project src\LibLLVM\MultiPlatformBuild.vcxproj -Properties $msBuildProperties -LoggerArgs $msbuildLoggerArgs
165+
166+
Write-Information "Restoring Nuget Packages for Llvm.NET"
167+
Invoke-MSBuild -Targets Restore -Project src\Llvm.NET\Llvm.NET.csproj -Properties $msBuildProperties -LoggerArgs $msbuildLoggerArgs
168+
169+
Write-Information "Building Llvm.NET"
170+
Invoke-MSBuild -Targets Build -Project src\Llvm.NET\Llvm.NET.csproj -Properties $msBuildProperties -LoggerArgs $msbuildLoggerArgs
171+
172+
Write-Information "Running Nuget Restore for Llvm.NET Tests"
173+
Invoke-MSBuild -Targets Restore -Project src\Llvm.NETTests\LLVM.NETTests.csproj -Properties $msBuildProperties -LoggerArgs $msbuildLoggerArgs
174+
175+
Write-Information "Building Llvm.NET Tests"
176+
Invoke-MSBuild -Targets Build -Project src\Llvm.NETTests\LLVM.NETTests.csproj -Properties $msBuildProperties -LoggerArgs $msbuildLoggerArgs
177+
}
178+
finally
179+
{
180+
popd
181+
}

BuildAll.slnproj

Lines changed: 0 additions & 34 deletions
This file was deleted.

BuildEnv.props

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)