Skip to content

Updating to support .NET 5 and to use Open.snk #155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<EnableDefaultNoneItems>false</EnableDefaultNoneItems>
<NoWarn>CS0659;$(NoWarn)</NoWarn>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<SignAssembly>true</SignAssembly>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
Expand All @@ -38,20 +39,25 @@
<Authors>Microsoft and Contributors</Authors>
<BaseOutputPath>$(BaseArtifactsPath)bin/$(BaseArtifactsPathSuffix)/</BaseOutputPath>
<Company>Microsoft</Company>
<ContinuousIntegrationBuild Condition="'$(BUILD_BUILDNUMBER)' != ''">true</ContinuousIntegrationBuild>
<PackageOutputPath>$(BaseArtifactsPath)pkg/$(Configuration)/</PackageOutputPath>
<Product>LLVMSharp</Product>
<VersionPrefix>11.0.0</VersionPrefix>
<VersionSuffix>beta</VersionSuffix>
<VersionSuffix Condition="'$(BUILD_REASON)' == 'PullRequest'">pr</VersionSuffix>
</PropertyGroup>

<!-- Default settings that are otherwise undefined -->
<PropertyGroup>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)Open.snk</AssemblyOriginatorKeyFile>
<AssemblyOriginatorPublicKey>00240000048000009400000006020000002400005253413100040000010001004b86c4cb78549b34bab61a3b1800e23bfeb5b3ec390074041536a7e3cbd97f5f04cf0f857155a8928eaa29ebfd11cfbbad3ba70efea7bda3226c6a8d370a4cd303f714486b6ebc225985a638471e6ef571cc92a4613c00b8fa65d61ccee0cbe5f36330c9a01f4183559f1bef24cc2917c6d913e3a541333a1d05d9bed22b38cb</AssemblyOriginatorPublicKey>
<Copyright>Copyright © Microsoft and Contributors</Copyright>
<Description>LLVMSharp is a multi-platform .NET Standard library for accessing the LLVM infrastructure.</Description>
<Features>strict</Features>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<HighEntropyVA>true</HighEntropyVA>
<LangVersion>preview</LangVersion>
<LangVersion>latest</LangVersion>
<MinClientVersion>4.3</MinClientVersion>
<NeutralLanguage>en-US</NeutralLanguage>
<OverwriteReadOnlyFiles>true</OverwriteReadOnlyFiles>
<PackageLicenseExpression>NCSA</PackageLicenseExpression>
Expand All @@ -65,9 +71,4 @@
<UseSharedCompilation>true</UseSharedCompilation>
</PropertyGroup>

<!-- Package references which are consumed by all projects -->
<ItemGroup>
<PackageReference Include="Microsoft.Net.Compilers.Toolset" IsImplicitlyDefined="true" PrivateAssets="all" />
</ItemGroup>

</Project>
20 changes: 13 additions & 7 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,25 @@
<DefineConstants>$(DefineConstants);$(OS)</DefineConstants>
</PropertyGroup>

<!-- Settings that are only set for CI builds -->
<PropertyGroup Condition="'$(BUILD_BUILDNUMBER)' != ''">
<PackageVersion Condition="'$(EXCLUDE_BUILDNUMBER_FROM_PACKAGE)' == ''">$(Version)-$(BUILD_BUILDNUMBER)</PackageVersion>
</PropertyGroup>

<!-- Settings that allow testing to work by default -->
<PropertyGroup>
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == ''">$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
<PropertyGroup Condition="'$(RuntimeIdentifier)' == '' AND '$(Contin)' != 'true'">
<RuntimeIdentifier>$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
<RuntimeIdentifier Condition="'$(OVERRIDE_RUNTIME_IDENTIFIER)' != ''">$(OVERRIDE_RUNTIME_IDENTIFIER)</RuntimeIdentifier>
</PropertyGroup>

<!-- Package versions for package references across all projects -->
<ItemGroup>
<PackageReference Update="libLLVM" Version="11.0.0" />
<PackageReference Update="Microsoft.Bcl.HashCode" Version="1.1.0" />
<PackageReference Update="Microsoft.Net.Compilers.Toolset" Version="3.5.0" />
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Update="NUnit" Version="3.12.0" />
<PackageReference Update="NUnit3TestAdapter" Version="3.16.1" />
<PackageReference Update="Microsoft.Bcl.HashCode" Version="1.1.1" />
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0" />
<PackageReference Update="NUnit" Version="3.13.1" />
<PackageReference Update="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Update="System.Memory" Version="4.5.4" />
</ItemGroup>

Expand Down
Binary file added Open.snk
Binary file not shown.
12 changes: 10 additions & 2 deletions scripts/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,29 @@ jobs:
configuration: Release
architecture: x64

- template: azure-windows.yml
parameters:
name: build_nuget
pool: windows-latest
configuration: Release
architecture: x64
EXCLUDE_BUILDNUMBER_FROM_PACKAGE: true

- template: azure-unix.yml
parameters:
name: ubuntu_debug_x64
pool: ubuntu-latest
configuration: Debug
architecture: x64
rid: ubuntu.18.04-x64
OVERRIDE_RUNTIME_IDENTIFIER: ubuntu.18.04-x64

- template: azure-unix.yml
parameters:
name: ubuntu_release_x64
pool: ubuntu-latest
configuration: Release
architecture: x64
rid: ubuntu.18.04-x64
OVERRIDE_RUNTIME_IDENTIFIER: ubuntu.18.04-x64

- template: azure-unix.yml
parameters:
Expand Down
3 changes: 2 additions & 1 deletion scripts/azure-unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ jobs:
ArtifactName: packages
publishLocation: Container
variables:
RuntimeIdentifier: ${{parameters.rid}}
EXCLUDE_BUILDNUMBER_FROM_PACKAGE: ${{parameters.EXCLUDE_BUILDNUMBER_FROM_PACKAGE}}
OVERRIDE_RUNTIME_IDENTIFIER: ${{parameters.OVERRIDE_RUNTIME_IDENTIFIER}}
3 changes: 3 additions & 0 deletions scripts/azure-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ jobs:
PathtoPublish: artifacts/pkg/${{parameters.configuration}}
ArtifactName: packages
publishLocation: Container
variables:
EXCLUDE_BUILDNUMBER_FROM_PACKAGE: ${{parameters.EXCLUDE_BUILDNUMBER_FROM_PACKAGE}}
OVERRIDE_RUNTIME_IDENTIFIER: ${{parameters.OVERRIDE_RUNTIME_IDENTIFIER}}
4 changes: 2 additions & 2 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ try {
$DotNetInstallDirectory = Join-Path -Path $ArtifactsDir -ChildPath "dotnet"
Create-Directory -Path $DotNetInstallDirectory

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

$env:PATH="$DotNetInstallDirectory;$env:PATH"
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ if [[ ! -z "$architecture" ]]; then
DotNetInstallDirectory="$ArtifactsDir/dotnet"
CreateDirectory "$DotNetInstallDirectory"

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

PATH="$DotNetInstallDirectory:$PATH:"
fi
Expand Down
7 changes: 6 additions & 1 deletion sources/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@
-->

<PropertyGroup>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileDirectory)..\Directory.Build.props</MSBuildAllProjects>
<LLVMSharpProjectCategory>sources</LLVMSharpProjectCategory>
</PropertyGroup>

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

<ItemGroup>
<InternalsVisibleTo Include="$(MSBuildProjectName).UnitTests" />
<InternalsVisibleTo Include="$(MSBuildProjectName).UnitTests" Key="$(AssemblyOriginatorPublicKey)" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" IsImplicitlyDefined="true" PrivateAssets="all" />
</ItemGroup>

</Project>
51 changes: 22 additions & 29 deletions sources/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,32 @@
<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.targets" />

<PropertyGroup>
<GeneratedInternalsVisibleToFile Condition="'$(GeneratedInternalsVisibleToFile)' == ''">$(IntermediateOutputPath)$(MSBuildProjectName).InternalsVisibleTo$(DefaultLanguageSourceExtension)</GeneratedInternalsVisibleToFile>
<GeneratedSkipLocalsInitFile Condition="'$(GeneratedSkipLocalsInitFile)' == ''">$(IntermediateOutputPath)$(MSBuildProjectName).SkipLocalsInit$(DefaultLanguageSourceExtension)</GeneratedSkipLocalsInitFile>
<GeneratedSkipLocalsInitFileLines>
<![CDATA[//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
[module: System.Runtime.CompilerServices.SkipLocalsInitAttribute]
// Generated by the MSBuild WriteLinesToFile class.]]>
</GeneratedSkipLocalsInitFileLines>
</PropertyGroup>

<ItemDefinitionGroup>
<InternalsVisibleTo>
<Visible>false</Visible>
</InternalsVisibleTo>
</ItemDefinitionGroup>

<Target Name="GenerateInternalsVisibleTo"
BeforeTargets="CoreCompile"
DependsOnTargets="PrepareForBuild;CoreGenerateInternalsVisibleTo"
Condition="'@(InternalsVisibleTo)' != ''" />

<Target Name="CoreGenerateInternalsVisibleTo"
Condition="'$(Language)' == 'VB' or '$(Language)' == 'C#'"
<Target Name="GenerateSkipLocalsInit"
BeforeTargets="BeforeCompile;CoreCompile"
DependsOnTargets="PrepareForBuild"
Condition="'$(Language)' == 'C#' And '$(TargetFramework)' == 'net5.0'"
Inputs="$(MSBuildAllProjects)"
Outputs="$(GeneratedInternalsVisibleToFile)">
<CreateItem Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute" AdditionalMetadata="_Parameter1=%(InternalsVisibleTo.Identity)" Condition="'%(InternalsVisibleTo.PublicKey)' == ''">
<Output TaskParameter="Include" ItemName="InternalsVisibleToAttribute" />
</CreateItem>
<CreateItem Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute" AdditionalMetadata="_Parameter1=%(InternalsVisibleTo.Identity), PublicKey=%(InternalsVisibleTo.PublicKey)" Condition="'%(InternalsVisibleTo.PublicKey)' != ''">
<Output TaskParameter="Include" ItemName="InternalsVisibleToAttribute" />
</CreateItem>
Outputs="$(GeneratedSkipLocalsInitFile)">
<WriteLinesToFile Lines="$(GeneratedSkipLocalsInitFileLines)" Overwrite="true" WriteOnlyWhenDifferent="true" File="$(GeneratedSkipLocalsInitFile)" />

<WriteCodeFragment AssemblyAttributes="@(InternalsVisibleToAttribute)" Language="$(Language)" OutputFile="$(GeneratedInternalsVisibleToFile)">
<Output TaskParameter="OutputFile" ItemName="Compile" />
<Output TaskParameter="OutputFile" ItemName="FileWrites" />
</WriteCodeFragment>
<ItemGroup>
<Compile Include="$(GeneratedSkipLocalsInitFile)" />
</ItemGroup>
</Target>

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

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private static IntPtr OnDllImport(string libraryName, Assembly assembly, DllImpo

private static bool TryResolveLLVM(Assembly assembly, DllImportSearchPath? searchPath, out IntPtr nativeLibrary)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && NativeLibrary.TryLoad("libLLVM-10.so", assembly, searchPath, out nativeLibrary))
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && NativeLibrary.TryLoad("libLLVM-11.so", assembly, searchPath, out nativeLibrary))
{
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion sources/LLVMSharp/Interop.Extensions/LLVMBasicBlockRef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public string PrintToString()
{
var pStr = LLVM.PrintValueToString(this);

if (pStr is null)
if (pStr == null)
{
return string.Empty;
}
Expand Down
12 changes: 6 additions & 6 deletions sources/LLVMSharp/Interop.Extensions/LLVMContextRef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@ public bool TryGetBitcodeModule(LLVMMemoryBufferRef MemBuf, out LLVMModuleRef Ou
{
fixed (LLVMModuleRef* pOutM = &OutM)
{
sbyte* pMessage;
sbyte* pMessage = null;
var result = LLVM.GetBitcodeModuleInContext(this, MemBuf, (LLVMOpaqueModule**)pOutM, &pMessage);

if (pMessage is null)
if (pMessage == null)
{
OutMessage = string.Empty;
}
Expand All @@ -232,10 +232,10 @@ public bool TryParseBitcode(LLVMMemoryBufferRef MemBuf, out LLVMModuleRef OutMod
{
fixed (LLVMModuleRef* pOutModule = &OutModule)
{
sbyte* pMessage;
sbyte* pMessage = null;
var result = LLVM.ParseBitcodeInContext(this, MemBuf, (LLVMOpaqueModule**)pOutModule, &pMessage);

if (pMessage is null)
if (pMessage == null)
{
OutMessage = string.Empty;
}
Expand All @@ -253,10 +253,10 @@ public bool TryParseIR(LLVMMemoryBufferRef MemBuf, out LLVMModuleRef OutM, out s
{
fixed (LLVMModuleRef* pOutM = &OutM)
{
sbyte* pMessage;
sbyte* pMessage = null;
var result = LLVM.ParseIRInContext(this, MemBuf, (LLVMOpaqueModule**)pOutM, &pMessage);

if (pMessage is null)
if (pMessage == null)
{
OutMessage = string.Empty;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ public bool TryRemoveModule(LLVMModuleRef M, out LLVMModuleRef OutMod, out strin
{
fixed (LLVMModuleRef* pOutMod = &OutMod)
{
sbyte* pError;
sbyte* pError = null;
var result = LLVM.RemoveModule(this, M, (LLVMOpaqueModule**)pOutMod, &pError);

if (pError is null)
if (pError == null)
{
OutError = string.Empty;
}
Expand Down
25 changes: 12 additions & 13 deletions sources/LLVMSharp/Interop.Extensions/LLVMModuleRef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public string DataLayout

var pDataLayoutStr = LLVM.GetDataLayout(this);

if (pDataLayoutStr is null)
if (pDataLayoutStr == null)
{
return string.Empty;
}
Expand Down Expand Up @@ -62,7 +62,7 @@ public string Target

var pTriple = LLVM.GetTarget(this);

if (pTriple is null)
if (pTriple == null)
{
return string.Empty;
}
Expand Down Expand Up @@ -271,7 +271,7 @@ public string PrintToString()
{
var pStr = LLVM.PrintModuleToString(this);

if (pStr is null)
if (pStr == null)
{
return string.Empty;
}
Expand All @@ -296,10 +296,10 @@ public bool TryCreateExecutionEngine(out LLVMExecutionEngineRef OutEE, out strin
{
fixed (LLVMExecutionEngineRef* pOutEE = &OutEE)
{
sbyte* pError;
sbyte* pError = null;
var result = LLVM.CreateExecutionEngineForModule((LLVMOpaqueExecutionEngine**)pOutEE, this, &pError);

if (pError is null)
if (pError == null)
{
OutError = string.Empty;
}
Expand All @@ -317,10 +317,10 @@ public bool TryCreateInterpreter(out LLVMExecutionEngineRef OutInterp, out strin
{
fixed (LLVMExecutionEngineRef* pOutInterp = &OutInterp)
{
sbyte* pError;
sbyte* pError = null;
var result = LLVM.CreateInterpreterForModule((LLVMOpaqueExecutionEngine**)pOutInterp, this, &pError);

if (pError is null)
if (pError == null)
{
OutError = string.Empty;
}
Expand All @@ -345,10 +345,10 @@ public bool TryCreateMCJITCompiler(out LLVMExecutionEngineRef OutJIT, ref LLVMMC
fixed (LLVMExecutionEngineRef* pOutJIT = &OutJIT)
fixed (LLVMMCJITCompilerOptions* pOptions = &Options)
{
sbyte* pError;
sbyte* pError = null;
var result = LLVM.CreateMCJITCompilerForModule((LLVMOpaqueExecutionEngine**)pOutJIT, this, pOptions, (UIntPtr)Marshal.SizeOf<LLVMMCJITCompilerOptions>(), &pError);

if (pError is null)
if (pError == null)
{
OutError = string.Empty;
}
Expand Down Expand Up @@ -376,10 +376,9 @@ public bool TryPrintToFile(ReadOnlySpan<char> Filename, out string ErrorMessage)
}
catch (Exception)
{

}

if (pErrorMessage is null)
if (pErrorMessage == null)
{
ErrorMessage = string.Empty;
}
Expand All @@ -394,10 +393,10 @@ public bool TryPrintToFile(ReadOnlySpan<char> Filename, out string ErrorMessage)

public bool TryVerify(LLVMVerifierFailureAction Action, out string OutMessage)
{
sbyte* pMessage;
sbyte* pMessage = null;
var result = LLVM.VerifyModule(this, Action, &pMessage);

if (pMessage is null)
if (pMessage == null)
{
OutMessage = string.Empty;
}
Expand Down
Loading