Skip to content

Commit fc6d743

Browse files
Updating to support .NET 5 and to use Open.snk (#155)
* Updating to support .NET 5 and to use Open.snk * Don't set RuntimeIdentifier at the solution level * Ensure pError is null initialized * Adding a job to build the release nuget packages
1 parent f5b61b9 commit fc6d743

21 files changed

+110
-91
lines changed

Directory.Build.props

+7-6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<EnableDefaultNoneItems>false</EnableDefaultNoneItems>
2626
<NoWarn>CS0659;$(NoWarn)</NoWarn>
2727
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
28+
<SignAssembly>true</SignAssembly>
2829
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
2930
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
3031
</PropertyGroup>
@@ -38,20 +39,25 @@
3839
<Authors>Microsoft and Contributors</Authors>
3940
<BaseOutputPath>$(BaseArtifactsPath)bin/$(BaseArtifactsPathSuffix)/</BaseOutputPath>
4041
<Company>Microsoft</Company>
42+
<ContinuousIntegrationBuild Condition="'$(BUILD_BUILDNUMBER)' != ''">true</ContinuousIntegrationBuild>
4143
<PackageOutputPath>$(BaseArtifactsPath)pkg/$(Configuration)/</PackageOutputPath>
4244
<Product>LLVMSharp</Product>
4345
<VersionPrefix>11.0.0</VersionPrefix>
4446
<VersionSuffix>beta</VersionSuffix>
47+
<VersionSuffix Condition="'$(BUILD_REASON)' == 'PullRequest'">pr</VersionSuffix>
4548
</PropertyGroup>
4649

4750
<!-- Default settings that are otherwise undefined -->
4851
<PropertyGroup>
52+
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)Open.snk</AssemblyOriginatorKeyFile>
53+
<AssemblyOriginatorPublicKey>00240000048000009400000006020000002400005253413100040000010001004b86c4cb78549b34bab61a3b1800e23bfeb5b3ec390074041536a7e3cbd97f5f04cf0f857155a8928eaa29ebfd11cfbbad3ba70efea7bda3226c6a8d370a4cd303f714486b6ebc225985a638471e6ef571cc92a4613c00b8fa65d61ccee0cbe5f36330c9a01f4183559f1bef24cc2917c6d913e3a541333a1d05d9bed22b38cb</AssemblyOriginatorPublicKey>
4954
<Copyright>Copyright © Microsoft and Contributors</Copyright>
5055
<Description>LLVMSharp is a multi-platform .NET Standard library for accessing the LLVM infrastructure.</Description>
5156
<Features>strict</Features>
5257
<GenerateDocumentationFile>false</GenerateDocumentationFile>
5358
<HighEntropyVA>true</HighEntropyVA>
54-
<LangVersion>preview</LangVersion>
59+
<LangVersion>latest</LangVersion>
60+
<MinClientVersion>4.3</MinClientVersion>
5561
<NeutralLanguage>en-US</NeutralLanguage>
5662
<OverwriteReadOnlyFiles>true</OverwriteReadOnlyFiles>
5763
<PackageLicenseExpression>NCSA</PackageLicenseExpression>
@@ -65,9 +71,4 @@
6571
<UseSharedCompilation>true</UseSharedCompilation>
6672
</PropertyGroup>
6773

68-
<!-- Package references which are consumed by all projects -->
69-
<ItemGroup>
70-
<PackageReference Include="Microsoft.Net.Compilers.Toolset" IsImplicitlyDefined="true" PrivateAssets="all" />
71-
</ItemGroup>
72-
7374
</Project>

Directory.Build.targets

+13-7
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,25 @@
1515
<DefineConstants>$(DefineConstants);$(OS)</DefineConstants>
1616
</PropertyGroup>
1717

18+
<!-- Settings that are only set for CI builds -->
19+
<PropertyGroup Condition="'$(BUILD_BUILDNUMBER)' != ''">
20+
<PackageVersion Condition="'$(EXCLUDE_BUILDNUMBER_FROM_PACKAGE)' == ''">$(Version)-$(BUILD_BUILDNUMBER)</PackageVersion>
21+
</PropertyGroup>
22+
1823
<!-- Settings that allow testing to work by default -->
19-
<PropertyGroup>
20-
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == ''">$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
24+
<PropertyGroup Condition="'$(RuntimeIdentifier)' == '' AND '$(Contin)' != 'true'">
25+
<RuntimeIdentifier>$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
26+
<RuntimeIdentifier Condition="'$(OVERRIDE_RUNTIME_IDENTIFIER)' != ''">$(OVERRIDE_RUNTIME_IDENTIFIER)</RuntimeIdentifier>
2127
</PropertyGroup>
2228

2329
<!-- Package versions for package references across all projects -->
2430
<ItemGroup>
2531
<PackageReference Update="libLLVM" Version="11.0.0" />
26-
<PackageReference Update="Microsoft.Bcl.HashCode" Version="1.1.0" />
27-
<PackageReference Update="Microsoft.Net.Compilers.Toolset" Version="3.5.0" />
28-
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="16.5.0" />
29-
<PackageReference Update="NUnit" Version="3.12.0" />
30-
<PackageReference Update="NUnit3TestAdapter" Version="3.16.1" />
32+
<PackageReference Update="Microsoft.Bcl.HashCode" Version="1.1.1" />
33+
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="16.8.3" />
34+
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0" />
35+
<PackageReference Update="NUnit" Version="3.13.1" />
36+
<PackageReference Update="NUnit3TestAdapter" Version="3.17.0" />
3137
<PackageReference Update="System.Memory" Version="4.5.4" />
3238
</ItemGroup>
3339

Open.snk

596 Bytes
Binary file not shown.

scripts/azure-pipelines.yml

+10-2
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,29 @@ jobs:
3333
configuration: Release
3434
architecture: x64
3535

36+
- template: azure-windows.yml
37+
parameters:
38+
name: build_nuget
39+
pool: windows-latest
40+
configuration: Release
41+
architecture: x64
42+
EXCLUDE_BUILDNUMBER_FROM_PACKAGE: true
43+
3644
- template: azure-unix.yml
3745
parameters:
3846
name: ubuntu_debug_x64
3947
pool: ubuntu-latest
4048
configuration: Debug
4149
architecture: x64
42-
rid: ubuntu.18.04-x64
50+
OVERRIDE_RUNTIME_IDENTIFIER: ubuntu.18.04-x64
4351

4452
- template: azure-unix.yml
4553
parameters:
4654
name: ubuntu_release_x64
4755
pool: ubuntu-latest
4856
configuration: Release
4957
architecture: x64
50-
rid: ubuntu.18.04-x64
58+
OVERRIDE_RUNTIME_IDENTIFIER: ubuntu.18.04-x64
5159

5260
- template: azure-unix.yml
5361
parameters:

scripts/azure-unix.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ jobs:
2626
ArtifactName: packages
2727
publishLocation: Container
2828
variables:
29-
RuntimeIdentifier: ${{parameters.rid}}
29+
EXCLUDE_BUILDNUMBER_FROM_PACKAGE: ${{parameters.EXCLUDE_BUILDNUMBER_FROM_PACKAGE}}
30+
OVERRIDE_RUNTIME_IDENTIFIER: ${{parameters.OVERRIDE_RUNTIME_IDENTIFIER}}

scripts/azure-windows.yml

+3
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ jobs:
2424
PathtoPublish: artifacts/pkg/${{parameters.configuration}}
2525
ArtifactName: packages
2626
publishLocation: Container
27+
variables:
28+
EXCLUDE_BUILDNUMBER_FROM_PACKAGE: ${{parameters.EXCLUDE_BUILDNUMBER_FROM_PACKAGE}}
29+
OVERRIDE_RUNTIME_IDENTIFIER: ${{parameters.OVERRIDE_RUNTIME_IDENTIFIER}}

scripts/build.ps1

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ try {
120120
$DotNetInstallDirectory = Join-Path -Path $ArtifactsDir -ChildPath "dotnet"
121121
Create-Directory -Path $DotNetInstallDirectory
122122

123-
& $DotNetInstallScript -Channel 3.1 -Version latest -InstallDir $DotNetInstallDirectory -Architecture $architecture
124-
& $DotNetInstallScript -Channel 2.1 -Version latest -InstallDir $DotNetInstallDirectory -Architecture $architecture -Runtime dotnet
123+
& $DotNetInstallScript -Channel 5.0 -Version latest -InstallDir $DotNetInstallDirectory -Architecture $architecture
124+
& $DotNetInstallScript -Channel 3.1 -Version latest -InstallDir $DotNetInstallDirectory -Architecture $architecture -Runtime dotnet
125125

126126
$env:PATH="$DotNetInstallDirectory;$env:PATH"
127127
}

scripts/build.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ if [[ ! -z "$architecture" ]]; then
204204
DotNetInstallDirectory="$ArtifactsDir/dotnet"
205205
CreateDirectory "$DotNetInstallDirectory"
206206

207-
. "$DotNetInstallScript" --channel 3.1 --version latest --install-dir "$DotNetInstallDirectory" --architecture "$architecture"
208-
. "$DotNetInstallScript" --channel 2.1 --version latest --install-dir "$DotNetInstallDirectory" --architecture "$architecture" --runtime dotnet
207+
. "$DotNetInstallScript" --channel 5.0 --version latest --install-dir "$DotNetInstallDirectory" --architecture "$architecture"
208+
. "$DotNetInstallScript" --channel 3.1 --version latest --install-dir "$DotNetInstallDirectory" --architecture "$architecture" --runtime dotnet
209209

210210
PATH="$DotNetInstallDirectory:$PATH:"
211211
fi

sources/Directory.Build.props

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,19 @@
1111
-->
1212

1313
<PropertyGroup>
14+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
1415
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileDirectory)..\Directory.Build.props</MSBuildAllProjects>
1516
<LLVMSharpProjectCategory>sources</LLVMSharpProjectCategory>
1617
</PropertyGroup>
1718

1819
<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.props" />
1920

2021
<ItemGroup>
21-
<InternalsVisibleTo Include="$(MSBuildProjectName).UnitTests" />
22+
<InternalsVisibleTo Include="$(MSBuildProjectName).UnitTests" Key="$(AssemblyOriginatorPublicKey)" />
23+
</ItemGroup>
24+
25+
<ItemGroup>
26+
<PackageReference Include="Microsoft.SourceLink.GitHub" IsImplicitlyDefined="true" PrivateAssets="all" />
2227
</ItemGroup>
2328

2429
</Project>

sources/Directory.Build.targets

+22-29
Original file line numberDiff line numberDiff line change
@@ -17,39 +17,32 @@
1717
<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.targets" />
1818

1919
<PropertyGroup>
20-
<GeneratedInternalsVisibleToFile Condition="'$(GeneratedInternalsVisibleToFile)' == ''">$(IntermediateOutputPath)$(MSBuildProjectName).InternalsVisibleTo$(DefaultLanguageSourceExtension)</GeneratedInternalsVisibleToFile>
20+
<GeneratedSkipLocalsInitFile Condition="'$(GeneratedSkipLocalsInitFile)' == ''">$(IntermediateOutputPath)$(MSBuildProjectName).SkipLocalsInit$(DefaultLanguageSourceExtension)</GeneratedSkipLocalsInitFile>
21+
<GeneratedSkipLocalsInitFileLines>
22+
<![CDATA[//------------------------------------------------------------------------------
23+
// <auto-generated>
24+
// This code was generated by a tool.
25+
//
26+
// Changes to this file may cause incorrect behavior and will be lost if
27+
// the code is regenerated.
28+
// </auto-generated>
29+
//------------------------------------------------------------------------------
30+
[module: System.Runtime.CompilerServices.SkipLocalsInitAttribute]
31+
// Generated by the MSBuild WriteLinesToFile class.]]>
32+
</GeneratedSkipLocalsInitFileLines>
2133
</PropertyGroup>
2234

23-
<ItemDefinitionGroup>
24-
<InternalsVisibleTo>
25-
<Visible>false</Visible>
26-
</InternalsVisibleTo>
27-
</ItemDefinitionGroup>
28-
29-
<Target Name="GenerateInternalsVisibleTo"
30-
BeforeTargets="CoreCompile"
31-
DependsOnTargets="PrepareForBuild;CoreGenerateInternalsVisibleTo"
32-
Condition="'@(InternalsVisibleTo)' != ''" />
33-
34-
<Target Name="CoreGenerateInternalsVisibleTo"
35-
Condition="'$(Language)' == 'VB' or '$(Language)' == 'C#'"
35+
<Target Name="GenerateSkipLocalsInit"
36+
BeforeTargets="BeforeCompile;CoreCompile"
37+
DependsOnTargets="PrepareForBuild"
38+
Condition="'$(Language)' == 'C#' And '$(TargetFramework)' == 'net5.0'"
3639
Inputs="$(MSBuildAllProjects)"
37-
Outputs="$(GeneratedInternalsVisibleToFile)">
38-
<CreateItem Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute" AdditionalMetadata="_Parameter1=%(InternalsVisibleTo.Identity)" Condition="'%(InternalsVisibleTo.PublicKey)' == ''">
39-
<Output TaskParameter="Include" ItemName="InternalsVisibleToAttribute" />
40-
</CreateItem>
41-
<CreateItem Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute" AdditionalMetadata="_Parameter1=%(InternalsVisibleTo.Identity), PublicKey=%(InternalsVisibleTo.PublicKey)" Condition="'%(InternalsVisibleTo.PublicKey)' != ''">
42-
<Output TaskParameter="Include" ItemName="InternalsVisibleToAttribute" />
43-
</CreateItem>
40+
Outputs="$(GeneratedSkipLocalsInitFile)">
41+
<WriteLinesToFile Lines="$(GeneratedSkipLocalsInitFileLines)" Overwrite="true" WriteOnlyWhenDifferent="true" File="$(GeneratedSkipLocalsInitFile)" />
4442

45-
<WriteCodeFragment AssemblyAttributes="@(InternalsVisibleToAttribute)" Language="$(Language)" OutputFile="$(GeneratedInternalsVisibleToFile)">
46-
<Output TaskParameter="OutputFile" ItemName="Compile" />
47-
<Output TaskParameter="OutputFile" ItemName="FileWrites" />
48-
</WriteCodeFragment>
43+
<ItemGroup>
44+
<Compile Include="$(GeneratedSkipLocalsInitFile)" />
45+
</ItemGroup>
4946
</Target>
5047

51-
<!-- Empty target so that `dotnet test` will work on the solution -->
52-
<!-- https://github.com/Microsoft/vstest/issues/411 -->
53-
<Target Name="VSTest" />
54-
5548
</Project>

sources/LLVMSharp/Interop.Extensions/LLVM.ResolveLibrary.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ private static IntPtr OnDllImport(string libraryName, Assembly assembly, DllImpo
3434

3535
private static bool TryResolveLLVM(Assembly assembly, DllImportSearchPath? searchPath, out IntPtr nativeLibrary)
3636
{
37-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && NativeLibrary.TryLoad("libLLVM-10.so", assembly, searchPath, out nativeLibrary))
37+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && NativeLibrary.TryLoad("libLLVM-11.so", assembly, searchPath, out nativeLibrary))
3838
{
3939
return true;
4040
}

sources/LLVMSharp/Interop.Extensions/LLVMBasicBlockRef.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public string PrintToString()
8989
{
9090
var pStr = LLVM.PrintValueToString(this);
9191

92-
if (pStr is null)
92+
if (pStr == null)
9393
{
9494
return string.Empty;
9595
}

sources/LLVMSharp/Interop.Extensions/LLVMContextRef.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ public bool TryGetBitcodeModule(LLVMMemoryBufferRef MemBuf, out LLVMModuleRef Ou
211211
{
212212
fixed (LLVMModuleRef* pOutM = &OutM)
213213
{
214-
sbyte* pMessage;
214+
sbyte* pMessage = null;
215215
var result = LLVM.GetBitcodeModuleInContext(this, MemBuf, (LLVMOpaqueModule**)pOutM, &pMessage);
216216

217-
if (pMessage is null)
217+
if (pMessage == null)
218218
{
219219
OutMessage = string.Empty;
220220
}
@@ -232,10 +232,10 @@ public bool TryParseBitcode(LLVMMemoryBufferRef MemBuf, out LLVMModuleRef OutMod
232232
{
233233
fixed (LLVMModuleRef* pOutModule = &OutModule)
234234
{
235-
sbyte* pMessage;
235+
sbyte* pMessage = null;
236236
var result = LLVM.ParseBitcodeInContext(this, MemBuf, (LLVMOpaqueModule**)pOutModule, &pMessage);
237237

238-
if (pMessage is null)
238+
if (pMessage == null)
239239
{
240240
OutMessage = string.Empty;
241241
}
@@ -253,10 +253,10 @@ public bool TryParseIR(LLVMMemoryBufferRef MemBuf, out LLVMModuleRef OutM, out s
253253
{
254254
fixed (LLVMModuleRef* pOutM = &OutM)
255255
{
256-
sbyte* pMessage;
256+
sbyte* pMessage = null;
257257
var result = LLVM.ParseIRInContext(this, MemBuf, (LLVMOpaqueModule**)pOutM, &pMessage);
258258

259-
if (pMessage is null)
259+
if (pMessage == null)
260260
{
261261
OutMessage = string.Empty;
262262
}

sources/LLVMSharp/Interop.Extensions/LLVMExecutionEngineRef.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,10 @@ public bool TryRemoveModule(LLVMModuleRef M, out LLVMModuleRef OutMod, out strin
142142
{
143143
fixed (LLVMModuleRef* pOutMod = &OutMod)
144144
{
145-
sbyte* pError;
145+
sbyte* pError = null;
146146
var result = LLVM.RemoveModule(this, M, (LLVMOpaqueModule**)pOutMod, &pError);
147147

148-
if (pError is null)
148+
if (pError == null)
149149
{
150150
OutError = string.Empty;
151151
}

sources/LLVMSharp/Interop.Extensions/LLVMModuleRef.cs

+12-13
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public string DataLayout
2727

2828
var pDataLayoutStr = LLVM.GetDataLayout(this);
2929

30-
if (pDataLayoutStr is null)
30+
if (pDataLayoutStr == null)
3131
{
3232
return string.Empty;
3333
}
@@ -62,7 +62,7 @@ public string Target
6262

6363
var pTriple = LLVM.GetTarget(this);
6464

65-
if (pTriple is null)
65+
if (pTriple == null)
6666
{
6767
return string.Empty;
6868
}
@@ -271,7 +271,7 @@ public string PrintToString()
271271
{
272272
var pStr = LLVM.PrintModuleToString(this);
273273

274-
if (pStr is null)
274+
if (pStr == null)
275275
{
276276
return string.Empty;
277277
}
@@ -296,10 +296,10 @@ public bool TryCreateExecutionEngine(out LLVMExecutionEngineRef OutEE, out strin
296296
{
297297
fixed (LLVMExecutionEngineRef* pOutEE = &OutEE)
298298
{
299-
sbyte* pError;
299+
sbyte* pError = null;
300300
var result = LLVM.CreateExecutionEngineForModule((LLVMOpaqueExecutionEngine**)pOutEE, this, &pError);
301301

302-
if (pError is null)
302+
if (pError == null)
303303
{
304304
OutError = string.Empty;
305305
}
@@ -317,10 +317,10 @@ public bool TryCreateInterpreter(out LLVMExecutionEngineRef OutInterp, out strin
317317
{
318318
fixed (LLVMExecutionEngineRef* pOutInterp = &OutInterp)
319319
{
320-
sbyte* pError;
320+
sbyte* pError = null;
321321
var result = LLVM.CreateInterpreterForModule((LLVMOpaqueExecutionEngine**)pOutInterp, this, &pError);
322322

323-
if (pError is null)
323+
if (pError == null)
324324
{
325325
OutError = string.Empty;
326326
}
@@ -345,10 +345,10 @@ public bool TryCreateMCJITCompiler(out LLVMExecutionEngineRef OutJIT, ref LLVMMC
345345
fixed (LLVMExecutionEngineRef* pOutJIT = &OutJIT)
346346
fixed (LLVMMCJITCompilerOptions* pOptions = &Options)
347347
{
348-
sbyte* pError;
348+
sbyte* pError = null;
349349
var result = LLVM.CreateMCJITCompilerForModule((LLVMOpaqueExecutionEngine**)pOutJIT, this, pOptions, (UIntPtr)Marshal.SizeOf<LLVMMCJITCompilerOptions>(), &pError);
350350

351-
if (pError is null)
351+
if (pError == null)
352352
{
353353
OutError = string.Empty;
354354
}
@@ -376,10 +376,9 @@ public bool TryPrintToFile(ReadOnlySpan<char> Filename, out string ErrorMessage)
376376
}
377377
catch (Exception)
378378
{
379-
380379
}
381380

382-
if (pErrorMessage is null)
381+
if (pErrorMessage == null)
383382
{
384383
ErrorMessage = string.Empty;
385384
}
@@ -394,10 +393,10 @@ public bool TryPrintToFile(ReadOnlySpan<char> Filename, out string ErrorMessage)
394393

395394
public bool TryVerify(LLVMVerifierFailureAction Action, out string OutMessage)
396395
{
397-
sbyte* pMessage;
396+
sbyte* pMessage = null;
398397
var result = LLVM.VerifyModule(this, Action, &pMessage);
399398

400-
if (pMessage is null)
399+
if (pMessage == null)
401400
{
402401
OutMessage = string.Empty;
403402
}

0 commit comments

Comments
 (0)