Skip to content

Commit

Permalink
setup Nuke build
Browse files Browse the repository at this point in the history
  • Loading branch information
bezo97 committed Mar 7, 2021
1 parent 3087ea2 commit 4db6c80
Show file tree
Hide file tree
Showing 13 changed files with 451 additions and 39 deletions.
1 change: 1 addition & 0 deletions .nuke
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
OpenTK.WinForms.sln
4 changes: 4 additions & 0 deletions OpenTK.WinForms.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK.WinForms.MultiContro
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTK.WinForms.InputTest", "OpenTK.WinForms.InputTest\OpenTK.WinForms.InputTest.csproj", "{65839490-2DE7-4823-AC53-C210A805A982}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\_build.csproj", "{7F8678E7-2F0E-44B1-903D-80FBA892D6A0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7F8678E7-2F0E-44B1-903D-80FBA892D6A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7F8678E7-2F0E-44B1-903D-80FBA892D6A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{95E422AB-9DC7-4E2A-B13F-A26A52EF1BBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{95E422AB-9DC7-4E2A-B13F-A26A52EF1BBA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{95E422AB-9DC7-4E2A-B13F-A26A52EF1BBA}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
12 changes: 12 additions & 0 deletions OpenTK.WinForms/OpenTK.WinForms.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>8.0</LangVersion>
<!--Version info is filled by Nuke build-->
<Authors>Team OpenTK</Authors>
<Description>A WinForms control designed to wrap the OpenTK 4.x APIs.</Description>
<Copyright>Copyright (c) 2021 Team OpenTK</Copyright>
<Company>Team OpenTK</Company>
<PackageProjectUrl>https://github.com/opentk/GLControl</PackageProjectUrl>
<RepositoryUrl>https://github.com/opentk/GLControl</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageTags>OpenTK, GLControl</PackageTags>
</PropertyGroup>

<ItemGroup>
Expand Down
71 changes: 32 additions & 39 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,33 @@

### 4.0.0-pre.6

_March 4, 2021_

* Add `Context` property for better backward compatibility with GLControl 3.x.

### 4.0.0-pre.5

_February 18, 2021_

* Fix `Control.Site` null-reference bug.
* Add `Load` event for better backward compatibility with GLControl 3.x.
* Update simple test to demonstrate `Load` event.

### 4.0.0-pre.3

_December 28, 2020_

* Fix design-mode bugs.

### 4.0.0-pre.2

_December 22, 2020_

* Add more example projects to show usage: Simple example, multi-control example, and raw-input example.
* Fix more bugs.

### 4.0.0-pre.1

_December 21, 2020_

* All-new WebForms.GLControl, rewritten from the ground up for OpenTK 4.x and .NET Core 3.x+.
* Support both WinForms input events and "native device" input events.
* API is mostly backward compatible with the old GLControl.
* Full support for the new WinForms Designer (VS2019).
* All methods and properties fully XML-documented.
* Example project to show its usage.
* Readme that includes detailed usage and documentation.
# Release notes

All notable changes are documented in this file.

## 4.0.0-pre.5
- _March 4, 2021_
- Add `Context` property for better backward compatibility with GLControl 3.x.

## 4.0.0-pre.4
- _February 18, 2021_
- Fix `Control.Site` null-reference bug.
- Add `Load` event for better backward compatibility with GLControl 3.x.
- Update simple test to demonstrate `Load` event.

## 4.0.0-pre.3
- _December 28, 2020_
- Fix design-mode bugs.

## 4.0.0-pre.2
- _December 22, 2020_
- Add more example projects to show usage: Simple example, multi-control example, and raw-input example.
- Fix more bugs.

## 4.0.0-pre.1
- _December 21, 2020_
- All-new WebForms.GLControl, rewritten from the ground up for OpenTK 4.x and .NET Core 3.x+.
- Support both WinForms input events and "native device" input events.
- API is mostly backward compatible with the old GLControl.
- Full support for the new WinForms Designer (VS2019).
- All methods and properties fully XML-documented.
- Example project to show its usage.
- Readme that includes detailed usage and documentation.

7 changes: 7 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
:; set -eo pipefail
:; SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
:; ${SCRIPT_DIR}/build.sh "$@"
:; exit $?

@ECHO OFF
powershell -ExecutionPolicy ByPass -NoProfile "%~dp0build.ps1" %*
69 changes: 69 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[CmdletBinding()]
Param(
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]]$BuildArguments
)

Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)"

Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { Write-Error $_ -ErrorAction Continue; exit 1 }
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent

###########################################################################
# CONFIGURATION
###########################################################################

$BuildProjectFile = "$PSScriptRoot\build\_build.csproj"
$TempDirectory = "$PSScriptRoot\\.tmp"

$DotNetGlobalFile = "$PSScriptRoot\\global.json"
$DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1"
$DotNetChannel = "Current"

$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1
$env:DOTNET_MULTILEVEL_LOOKUP = 0

###########################################################################
# EXECUTION
###########################################################################

function ExecSafe([scriptblock] $cmd) {
& $cmd
if ($LASTEXITCODE) { exit $LASTEXITCODE }
}

# If dotnet CLI is installed globally and it matches requested version, use for execution
if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and `
$(dotnet --version) -and $LASTEXITCODE -eq 0) {
$env:DOTNET_EXE = (Get-Command "dotnet").Path
}
else {
# Download install script
$DotNetInstallFile = "$TempDirectory\dotnet-install.ps1"
New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile)

# If global.json exists, load expected version
if (Test-Path $DotNetGlobalFile) {
$DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json)
if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) {
$DotNetVersion = $DotNetGlobal.sdk.version
}
}

# Install by channel or version
$DotNetDirectory = "$TempDirectory\dotnet-win"
if (!(Test-Path variable:DotNetVersion)) {
ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath }
} else {
ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath }
}
$env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe"
}

Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)"

ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet }
ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments }
62 changes: 62 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash

bash --version 2>&1 | head -n 1

set -eo pipefail
SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)

###########################################################################
# CONFIGURATION
###########################################################################

BUILD_PROJECT_FILE="$SCRIPT_DIR/build/_build.csproj"
TEMP_DIRECTORY="$SCRIPT_DIR//.tmp"

DOTNET_GLOBAL_FILE="$SCRIPT_DIR//global.json"
DOTNET_INSTALL_URL="https://dot.net/v1/dotnet-install.sh"
DOTNET_CHANNEL="Current"

export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
export DOTNET_MULTILEVEL_LOOKUP=0

###########################################################################
# EXECUTION
###########################################################################

function FirstJsonValue {
perl -nle 'print $1 if m{"'"$1"'": "([^"]+)",?}' <<< "${@:2}"
}

# If dotnet CLI is installed globally and it matches requested version, use for execution
if [ -x "$(command -v dotnet)" ] && dotnet --version &>/dev/null; then
export DOTNET_EXE="$(command -v dotnet)"
else
# Download install script
DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh"
mkdir -p "$TEMP_DIRECTORY"
curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL"
chmod +x "$DOTNET_INSTALL_FILE"

# If global.json exists, load expected version
if [[ -f "$DOTNET_GLOBAL_FILE" ]]; then
DOTNET_VERSION=$(FirstJsonValue "version" "$(cat "$DOTNET_GLOBAL_FILE")")
if [[ "$DOTNET_VERSION" == "" ]]; then
unset DOTNET_VERSION
fi
fi

# Install by channel or version
DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix"
if [[ -z ${DOTNET_VERSION+x} ]]; then
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel "$DOTNET_CHANNEL" --no-path
else
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path
fi
export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet"
fi

echo "Microsoft (R) .NET Core SDK version $("$DOTNET_EXE" --version)"

"$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet
"$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@"
11 changes: 11 additions & 0 deletions build/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[*.cs]
dotnet_style_qualification_for_field = false:warning
dotnet_style_qualification_for_property = false:warning
dotnet_style_qualification_for_method = false:warning
dotnet_style_qualification_for_event = false:warning
dotnet_style_require_accessibility_modifiers = never:warning

csharp_style_expression_bodied_methods = true:silent
csharp_style_expression_bodied_properties = true:warning
csharp_style_expression_bodied_indexers = true:warning
csharp_style_expression_bodied_accessors = true:warning
Loading

0 comments on commit 4db6c80

Please sign in to comment.