Skip to content
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
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,8 @@ dotnet_diagnostic.IDE0022WithoutSuggestion.severity = none

dotnet_diagnostic.IDE0034.severity = warning

dotnet_diagnostic.IDE0046.severity = suggestion

dotnet_diagnostic.IDE0058.severity = none

dotnet_diagnostic.IDE0067.severity = none
Expand Down
20 changes: 13 additions & 7 deletions Build-Docs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Param(
[switch]$NoClone
)

pushd $PSScriptRoot
Push-Location $PSScriptRoot
$oldPath = $env:Path
try
{
Expand All @@ -34,6 +34,7 @@ try
$msBuildProperties = @{ Configuration = $Configuration
LlvmVersion = $buildInfo['LlvmVersion']
}
$msBuildPropertyList = ConvertTo-PropertyList $msBuildProperties

$docsOutputPath = $buildInfo['DocsOutputPath']

Expand All @@ -43,7 +44,7 @@ try
{
if(Test-Path -PathType Container $docsOutputPath)
{
del -Path $docsOutputPath -Recurse -Force
Remove-Item -Path $docsOutputPath -Recurse -Force
}

Write-Information "Cloning Docs repository"
Expand All @@ -58,16 +59,21 @@ try
$currentVersionDocsPath = Join-Path $docsOutputPath 'current'
if(Test-Path -PathType Container $currentVersionDocsPath)
{
del -Path $currentVersionDocsPath -Recurse -Force
Remove-Item -Path $currentVersionDocsPath -Recurse -Force
}

$docfxRestoreBinLogPath = Join-Path $buildInfo['BinLogsPath'] Ubiquity.NET.Llvm-docfx-Restore.binlog
$docfxBuildBinLogPath = Join-Path $buildInfo['BinLogsPath'] Ubiquity.NET.Llvm-docfx-Build.binlog

Write-Information "Building Docs Solution"
Write-Information "Building top level docs index"
dotnet build 'docfx\index\Ubiquity.NET.Llvm.Docfx.Index.csproj' -p:$msBuildPropertyList

Write-Information "Building current version library docs"
dotnet build 'docfx\current\Ubiquity.NET.Llvm.Docfx.API.csproj' -p:$msBuildPropertyList

# NOTE: Current state of DocFX requires a distinct restore pass.
Invoke-MSBuild -Targets 'Restore' -Project docfx\Ubiquity.NET.Llvm.DocFX.sln -Properties $msBuildProperties -LoggerArgs ($buildInfo['MsBuildLoggerArgs'] + @("/bl:$docfxRestoreBinLogPath") )
Invoke-MSBuild -Targets 'Build' -Project docfx\Ubiquity.NET.Llvm.DocFX.sln -Properties $msBuildProperties -LoggerArgs ($buildInfo['MsBuildLoggerArgs'] + @("/bl:$docfxBuildBinLogPath") )
#Invoke-MSBuild -Targets 'Restore' -Project docfx\Ubiquity.NET.Llvm.DocFX.sln -Properties $msBuildProperties -LoggerArgs ($buildInfo['MsBuildLoggerArgs'] + @("/bl:$docfxRestoreBinLogPath") )
#Invoke-MSBuild -Targets 'Build' -Project docfx\Ubiquity.NET.Llvm.DocFX.sln -Properties $msBuildProperties -LoggerArgs ($buildInfo['MsBuildLoggerArgs'] + @("/bl:$docfxBuildBinLogPath") )
}
catch
{
Expand All @@ -80,6 +86,6 @@ catch
}
finally
{
popd
Push-Location
$env:Path = $oldPath
}
55 changes: 11 additions & 44 deletions Build-Interop.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,50 +44,19 @@ This script is unfortunately necessary due to several factors:
native assemblies to place the binaries in the correct "native" "runtimes" folder for NuGet
to handle them.
#>

Param(
[string]$Configuration="Release",
[switch]$AllowVsPreReleases,
[switch]$FullInit
)

pushd $PSScriptRoot
Push-location $PSScriptRoot
$oldPath = $env:Path
try
{
. .\repo-buildutils.ps1
$buildInfo = Initialize-BuildEnvironment -FullInit:$FullInit -AllowVsPreReleases:$AllowVsPreReleases

# <HACK>
# for details of why this is needed, see src\PatchVsForLibClang\readme.md
# min version with fix (VS 2019 16.9 preview 2)
$minOfficialVersion = [System.Version]('16.9.30803.129')

Write-Information "Building PatchVsForLibClang.exe"
$msBuildProperties = @{ Configuration = 'Release'}
$buildLogPath = Join-Path $buildInfo['BinLogsPath'] PatchVsForLibClang.binlog
Invoke-MSBuild -Targets 'Restore;Build' -Project src\PatchVsForLibClang\PatchVsForLibClang.sln -Properties $msBuildProperties -LoggerArgs ($buildInfo['MsBuildLoggerArgs'] + @("/bl:$buildLogPath") )

$vs = Find-VSInstance -AllowVsPreReleases:$AllowVsPreReleases
if($vs.InstallationVersion -lt $minOfficialVersion)
{
pushd (Join-Path $buildInfo.BuildOutputPath 'bin\PatchVsForLibClang\Release\netcoreapp3.1')
try
{
Write-Information "Patching VS CRT for parsing with LibClang..."
.\PatchVsForLibClang.exe $vs.InstallationPath
}
finally
{
popd
}
}
else
{
Write-Information "$($vs.DisplayName) ($($vs.InstallationVersion)) already includes the official patch - skipping manual patch"
}
#</HACK>

# Download and unpack the LLVM libs if not already present, this doesn't use NuGet as the NuGet compression
# is insufficient to keep the size reasonable enough to support posting to public galleries. Additionally, the
# support for native lib projects in NuGet is tenuous at best. Due to various compiler version dependencies
Expand All @@ -99,28 +68,27 @@ try
$msBuildProperties = @{ Configuration = $Configuration
LlvmVersion = $buildInfo['LlvmVersion']
}
$msbuildPropertyList = ConvertTo-PropertyList $msBuildProperties

Write-Information "Building LllvmBindingsGenerator"
$generatorRestoreBuildLogPath = Join-Path $buildInfo['BinLogsPath'] LlvmBindingsGeneratorRestore.binlog
$generatorBuildLogPath = Join-Path $buildInfo['BinLogsPath'] LlvmBindingsGenerator.binlog

# manual restore needed so that the CppSharp libraries are available during the build phase
Invoke-MSBuild -Targets 'Restore' -Project 'src\Interop\LlvmBindingsGenerator\LlvmBindingsGenerator.csproj' -Properties $msBuildProperties -LoggerArgs ($buildInfo['MsBuildLoggerArgs'] + @("/bl:$generatorRestoreBuildLogPath"))
Invoke-MSBuild -Targets 'Build' -Project 'src\Interop\LlvmBindingsGenerator\LlvmBindingsGenerator.csproj' -Properties $msBuildProperties -LoggerArgs ($buildInfo['MsBuildLoggerArgs'] + @("/bl:$generatorBuildLogPath"))
dotnet build 'src\Interop\LlvmBindingsGenerator\LlvmBindingsGenerator.csproj' -p:$msbuildPropertyList

# At present CppSharp only supports the "desktop" framework, so limiting this to net47 for now
# Hopefully they will support .NET Core soon, if not, the generation stage may need to move out
# to a manual step with the results checked in.
Write-Information "Generating P/Invoke Bindings"
Write-Information "LlvmBindingsGenerator.exe $($buildInfo['LlvmLibsRoot']) $(Join-Path $buildInfo['SrcRootPath'] 'Interop\LibLLVM') $(Join-Path $buildInfo['SrcRootPath'] 'Interop\Ubiquity.NET.Llvm.Interop')"

& "$($buildInfo['BuildOutputPath'])\bin\LlvmBindingsGenerator\Release\net5.0-windows\LlvmBindingsGenerator.exe" $buildInfo['LlvmLibsRoot'] (Join-Path $buildInfo['SrcRootPath'] 'Interop\LibLLVM') (Join-Path $buildInfo['SrcRootPath'] 'Interop\Ubiquity.NET.Llvm.Interop')
dotnet "$($buildInfo['BuildOutputPath'])\bin\LlvmBindingsGenerator\$Configuration\net5.0\LlvmBindingsGenerator.dll" $buildInfo['LlvmLibsRoot'] (Join-Path $buildInfo['SrcRootPath'] 'Interop\LibLLVM') (Join-Path $buildInfo['SrcRootPath'] 'Interop\Ubiquity.NET.Llvm.Interop')
if($LASTEXITCODE -eq 0)
{
# now build the projects that consume generated output for the bindings

# Need to invoke NuGet directly for restore of vcxproj as /t:Restore target doesn't support packages.config
# and PackageReference isn't supported for native projects... [Sigh...]

# TODO: Convert C++ code to CMAKE, this means leveraging CSmeVer build task as a standalone tool so that the version Information
# is available to the scripts to provide to the build. Also means dealing with PDBgit in some fashion to establish symbols
# correctly to the source, For now leave it on the legacy direct calls to MSBUILD as dotnet msbuild can't find any of the
# C++ support - Seems it's using a different set of msbuild props/targets files...
Write-Information "Restoring LibLLVM"
Invoke-NuGet restore 'src\Interop\LibLLVM\LibLLVM.vcxproj'

Expand All @@ -129,8 +97,7 @@ try
Invoke-MSBuild -Targets 'Build' -Project 'src\Interop\LibLLVM\LibLLVM.vcxproj' -Properties $msBuildProperties -LoggerArgs ($buildInfo['MsBuildLoggerArgs'] + @("/bl:$libLLVMBinLogPath") )

Write-Information "Building Ubiquity.NET.Llvm.Interop"
$interopSlnBinLog = Join-Path $buildInfo['BinLogsPath'] Interop.sln.binlog
Invoke-MSBuild -Targets 'Restore;Build' -Project 'src\Interop\Interop.sln' -Properties $msBuildProperties -LoggerArgs ($buildInfo['MsBuildLoggerArgs'] + @("/bl:$interopSlnBinLog") )
dotnet build 'src\Interop\Interop.sln' -p:$msbuildPropertyList
}
else
{
Expand All @@ -148,6 +115,6 @@ catch
}
finally
{
popd
Pop-Location
$env:Path = $oldPath
}
19 changes: 4 additions & 15 deletions Build-Source.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Param(
[switch]$FullInit
)

pushd $PSScriptRoot
Push-Location $PSScriptRoot
$oldPath = $env:Path
try
{
Expand All @@ -29,24 +29,13 @@ try
. .\repo-buildutils.ps1
$buildInfo = Initialize-BuildEnvironment -FullInit:$FullInit -AllowVsPreReleases:$AllowVsPreReleases

$packProperties = @{ version=$($buildInfo['PackageVersion'])
llvmversion=$($buildInfo['LlvmVersion'])
buildbinoutput=(Join-path $($buildInfo['BuildOutputPath']) 'bin')
configuration=$Configuration
}

$msBuildProperties = @{ Configuration = $Configuration
LlvmVersion = $buildInfo['LlvmVersion']
}

# build the interop layer first using the script to manage the complexities of generated marshaling Interop
# and dependencies between C# and C++ projects.
.\Build-Interop.ps1 -AllowVsPreReleases:$AllowVsPreReleases

# build the Managed code OO Wrapper layer
$buildLogPath = Join-Path $buildInfo['BinLogsPath'] Ubiquity.NET.Llvm.binlog
Write-Information "Building Ubiquity.NET.Llvm"
Invoke-MSBuild -Targets 'Restore;Build' -Project src\Ubiquity.NET.Llvm.sln -Properties $msBuildProperties -LoggerArgs ($buildInfo['MsBuildLoggerArgs'] + @("/bl:$buildLogPath") )
Write-Information "dotnet build 'src\Ubiquity.NET.Llvm.sln' -c $Configuration -p:`"LlvmVersion=$($buildInfo['LlvmVersion'])`""
dotnet build 'src\Ubiquity.NET.Llvm.sln' -c $Configuration -p:"LlvmVersion=$($buildInfo['LlvmVersion'])"

# Create a ZIP file of all the nuget packages
pushd $buildInfo['NuGetOutputPath']
Expand All @@ -63,6 +52,6 @@ catch
}
finally
{
popd
Pop-Location
$env:Path = $oldPath
}
3 changes: 2 additions & 1 deletion BuildVersion.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<BuildVersionData
BuildMajor = "10"
BuildMajor = "11"
BuildMinor = "0"
BuildPatch = "0"
PreReleaseName = "alpha"
/>
4 changes: 2 additions & 2 deletions Invoke-UnitTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ try
$testsFailed = $testsFailed -or (Invoke-DotNetTest $buildInfo 'Samples\Kaleidoscope\Kaleidoscope.Tests\Kaleidoscope.Tests.csproj')

Write-Information 'Running sample app for .NET Core'
pushd (Join-path $buildInfo['BuildOutputPath'] bin\CodeGenWithDebugInfo\Release\netcoreapp3.1)
Push-Location (Join-path $buildInfo['BuildOutputPath'] 'bin\CodeGenWithDebugInfo\Release\net5.0')
try
{
dotnet CodeGenWithDebugInfo.dll M3 'Support Files\test.c' $buildInfo['TestResultsPath']
$testsFailed = $testsFailed -or ($LASTEXITCODE -ne 0)
}
finally
{
popd
Pop-Location
}

if($testsFailed)
Expand Down
32 changes: 0 additions & 32 deletions OneFlow/Finish-Feature.ps1

This file was deleted.

85 changes: 34 additions & 51 deletions OneFlow/Publish-Release.ps1
Original file line number Diff line number Diff line change
@@ -1,65 +1,48 @@
<#
.SYNOPSIS
Publishes the current branch state as an official release tag
Publishes the current release as a new branch to the upstream repository

.DESCRIPTION
This function ensures that no changes exist in the local repository so that only the tag is pushed.
Pushing a release tag should trigger GitHub actions that starts the official build via a GitHub action
Generally, this function will finalize the changes for the release and create a new "merge-back"
branch to manage any conflicts to prevent commits "AFTER" the tag is applied to the origin repository.
After this completes it is still required to create a PR for the resulting branch to the origin's "develop"
branch to merge any changes in this branch - including the release tag.

Completing the PR with a release tag should trigger the start the official build via a GitHub action
or other such automated build processes. These, normally, also include publication of the resulting
binaries as appropriate. This function only pushes the tag, the rest is up to the back-end configuration
of the repository.

.NOTE
For the gory details of this process see: https://www.endoflineblog.com/implementing-oneflow-on-github-bitbucket-and-gitlab
#>

. .\repo-buildutils.ps1
Param([switch]$TagOnly)
$repoRoot = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($PSScriptRoot, ".."))
. (join-path $repoRoot repo-buildutils.ps1)
$buildInfo = Initialize-BuildEnvironment

# Release tags must only be pushed from a repository with the official GitHub repository as the origin remote.
# This ensures that the links to source in the generated docs will have the correct URLs
# (e.g. docs pushed to the official repository MUST not have links to source in some private fork)
$remoteUrl = git ls-remote --get-url

Write-Information "Remote URL: $remoteUrl"

if($remoteUrl -ine "https://github.com/UbiquityDotNET/Llvm.NET.git")
{
throw "Publishing a release tag is only allowed when the origin remote is the official source release current remote is '$remoteUrl'"
}
# create script scoped alias for git that throws a PowerShell exception if the command fails
Set-Alias git Invoke-git -scope Script -option Private

# pushing the tag to GitHub triggers the official build and release of the Nuget Packages
# merging the tag to develop branch on the official repository triggers the official build and release of the Nuget Packages
$tagName = Get-BuildVersionTag $buildInfo
$releaseBranch = "release/$tagName"
$currentBranch = git rev-parse --abbrev-ref HEAD
if( $releaseBranch -ne $currentBranch )
{
throw "Current branch '$currentBranch' doesn't match the expected release branch from BuildVersion.xml, expected '$releaseBranch'"
}

$localCommitSha = git rev-parse --verify $releaseBranch
$remoteCommitSha = git rev-parse --verify "origin/$releaseBranch"
if( $localCommitSha -ne $remoteCommitSha )
{
throw "Local HEAD is not the same as origin, these must be in sync so that only the tag itself is pushed"
}

Write-Information "tagging $tagname on $releasebranch"

git tag -a $tagname -m "Official release: $tagname"
if(!$?) {throw 'GIT tag command failed'}
git checkout develop
if(!$?) {throw 'GIT co develop command failed'}
git merge $releaseBranch
if(!$?) {throw 'GIT merge command failed'}
git push --tags origin develop
if(!$?) {throw 'GIT push --tags origin develop command failed'}
git branch -d $releaseBranch
if(!$?) {throw 'GIT delete local release branch command failed'}
git push origin --delete $releaseBranch
if(!$?) {throw 'GIT delete remote release branch command failed'}

# update master branch to point to the latest release for full releases
git checkout master
if(!$?) {throw 'GIT checkout master command failed'}
git merge --ff-only $tagName
if(!$?) {throw 'GIT merge --ff-only command failed'}
git push
if(!$?) {throw 'GIT push (master update) command failed'}
$mergeBackBranchName = "merge-back-$tagName"

# check out and tag the release branch
git checkout $releasebranch
git tag $tagname -m "Official release: $tagname"
git push --tags

# create a "merge-back" child branch to handle any updates/conflict resolutions
# the tag from the parent will flow through to the final commit of the PR For
# the merge. Otherwise, the tag is locked to the commit on the release branch
# and any conflict resolution commits are "AFTER" the tag (and thus, not included
# in the tagged commit)
# This PR **MUST** be merged to origin with the --no-ff strategy
git checkout -b $mergeBackBranchName $releasebranch
git push $mergeBackBranchName

Write-Output "Created and published $mergeBackBranchName to your forked repository, you must create a PR for this change to the Official repository"
Write-Output "Additionally, these changes **MUST** be merged back without squashing"
3 changes: 1 addition & 2 deletions OneFlow/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ model and workflow. With one active long term branch 'develop'. The master
branch is present and long term but is not active, it only points to the latest
official release (including preview releases) of the project. This is a convenience
to allow getting the latests released source quickly. Generally the scripts used here
are only for release managers with direct push permissions to the repository and are
not required (or even an option) for most contributors.
are only for release managers and are not required (or even an option) for most contributors.
Loading