diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 923be1c..edfaf17 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -14,6 +14,7 @@ on: - '*.md' - LICENSE - '.nuget/*' + - build/*.ps1 - build/*.yml schedule: - cron: '34 18 * * 6' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9265d47..cd15157 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,6 +14,7 @@ on: - '*.md' - LICENSE - '.nuget/*' + - build/*.ps1 - build/*.yml jobs: diff --git a/.github/workflows/msvc.yml b/.github/workflows/msvc.yml index 418a92e..7f62ef0 100644 --- a/.github/workflows/msvc.yml +++ b/.github/workflows/msvc.yml @@ -14,7 +14,9 @@ on: - '*.md' - LICENSE - '.nuget/*' + - build/*.ps1 - build/*.yml + schedule: - cron: '34 20 * * 6' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2be320b..f6971aa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,6 +14,7 @@ on: - '*.md' - LICENSE - '.nuget/*' + - build/*.ps1 - build/*.yml jobs: diff --git a/.github/workflows/wsl.yml b/.github/workflows/wsl.yml new file mode 100644 index 0000000..89b077e --- /dev/null +++ b/.github/workflows/wsl.yml @@ -0,0 +1,53 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# +# http://go.microsoft.com/fwlink/?LinkID=615560 + +name: 'CMake (WSL)' + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + paths-ignore: + - '*.md' + - LICENSE + - '.nuget/*' + - build/*.ps1 + - build/*.yml + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + + matrix: + build_type: [x64-Debug-Linux, x64-Release-Linux] + gcc: [10, 11, 12] + # x64-Debug-NI-Linux, x64-Release-NI-Linux trigger issue with GCC + + steps: + - uses: actions/checkout@v4 + + - name: Clone test repository + uses: actions/checkout@v4 + with: + repository: walbourn/directxmathtest + path: Tests + ref: main + + - uses: seanmiddleditch/gha-setup-ninja@v5 + + - name: 'Configure CMake' + working-directory: ${{ github.workspace }}/Tests + run: cmake --preset=${{ matrix.build_type }} + env: + CC: gcc-${{ matrix.gcc }} + CXX: g++-${{ matrix.gcc }} + + - name: 'Build' + working-directory: ${{ github.workspace }}/Tests + run: cmake --build out/build/${{ matrix.build_type }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 216bf06..16a407c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required (VERSION 3.20) -set(DIRECTXMATH_VERSION 3.1.9) +set(DIRECTXMATH_VERSION 3.19) project(DirectXMath VERSION ${DIRECTXMATH_VERSION} @@ -110,8 +110,10 @@ elseif(NOT (DEFINED DXMATH_ARCHITECTURE)) endif() #--- Test suite -include(CTest) -if(BUILD_TESTING AND WIN32 AND (NOT WINDOWS_STORE) AND (EXISTS "${CMAKE_CURRENT_LIST_DIR}/Tests/CMakeLists.txt")) - enable_testing() - add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/Tests) +if(NOT WINDOWS_STORE) + include(CTest) + if(BUILD_TESTING AND WIN32 AND (NOT WINDOWS_STORE) AND (EXISTS "${CMAKE_CURRENT_LIST_DIR}/Tests/CMakeLists.txt")) + enable_testing() + add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/Tests) + endif() endif() diff --git a/build/DirectXMath-GitHub-CMake.yml b/build/DirectXMath-GitHub-CMake.yml index 385fa73..6a263c3 100644 --- a/build/DirectXMath-GitHub-CMake.yml +++ b/build/DirectXMath-GitHub-CMake.yml @@ -22,6 +22,7 @@ trigger: - LICENSE - '.github/*' - '.nuget/*' + - build/*.ps1 pr: branches: diff --git a/build/DirectXMath-GitHub-MinGW.yml b/build/DirectXMath-GitHub-MinGW.yml index 406314e..e777228 100644 --- a/build/DirectXMath-GitHub-MinGW.yml +++ b/build/DirectXMath-GitHub-MinGW.yml @@ -22,6 +22,7 @@ trigger: - LICENSE - '.github/*' - '.nuget/*' + - build/*.ps1 pr: branches: diff --git a/build/DirectXMath-GitHub-WSL.yml b/build/DirectXMath-GitHub-WSL.yml index 9372484..5935475 100644 --- a/build/DirectXMath-GitHub-WSL.yml +++ b/build/DirectXMath-GitHub-WSL.yml @@ -22,6 +22,7 @@ trigger: - LICENSE - '.github/*' - '.nuget/*' + - build/*.ps1 pr: branches: diff --git a/build/preparerelease.ps1 b/build/preparerelease.ps1 new file mode 100644 index 0000000..7af3e74 --- /dev/null +++ b/build/preparerelease.ps1 @@ -0,0 +1,126 @@ +<# + +.NOTES +Copyright (c) Microsoft Corporation. +Licensed under the MIT License. + +.SYNOPSIS +Prepares a PR for release + +.DESCRIPTION +This script is used to do the edits required for preparing a release PR. + +.PARAMETER BaseBranch +This the branch to use as the base of the release. Defaults to 'main'. + +.PARAMETER TargetBranch +This is the name of the newly created branch for the release PR. Defaults to 'release'. If set to 'none', then no branch is created. + +.PARAMETER UpdateVersion +This is a $true or $false value that indicates if the library version number should be incremented. Defaults to $true. + +.LINK +https://github.com/microsoft/DirectXMath/wiki + +#> + +param( + [string]$BaseBranch = "main", + [string]$TargetBranch = $null, + [bool]$UpdateVersion = $true +) + +$reporoot = Split-Path -Path $PSScriptRoot -Parent +$cmake = $reporoot + "\CMakeLists.txt" +$header = $reporoot + "\Inc\DirectXMath.h" +$readme = $reporoot + "\README.md" +$history = $reporoot + "\CHANGELOG.md" + +if ((-Not (Test-Path $cmake)) -Or (-Not (Test-Path $header)) -Or (-Not (Test-Path $readme)) -Or (-Not (Test-Path $history))) { + Write-Error "ERROR: Unexpected location of script file!" -ErrorAction Stop +} + +$branch = git branch --show-current +if ($branch -ne $BaseBranch) { + Write-Error "ERROR: Must be in the $BaseBranch branch!" -ErrorAction Stop +} + +git pull -q +if ($LastExitCode -ne 0) { + Write-Error "ERROR: Failed to sync branch!" -ErrorAction Stop +} + +$version = Get-Content ($cmake) | Select-String -Pattern "set\(DIRECTXMATH_VERSION" -CaseSensitive +if (-Not ($version -match "([0-9]?\.[0-9]+)")) { + Write-Error "ERROR: Failed to current version!" -ErrorAction Stop +} +$version = $Matches.0 +$rawversion = $version.replace('.','') + +$newreleasedate = Get-Date -Format "MMMM yyyy" +$newreleasetag = (Get-Date -Format "MMMyyyy").ToLower() + +if($UpdateVersion) { + [string]$newrawversion = ([int]$rawversion + 1) +} +else { + $newrawversion = $rawversion +} + +$newversion = $newrawversion[0] + "." + $newrawversion[1] + $newrawversion[2] + +$rawreleasedate = $(Get-Content $readme) | Select-String -Pattern "\*\*[A-Z][a-z]+\S.?\S.\d\d\d\d\*\*" +if ([string]::IsNullOrEmpty($rawreleasedate)) { + Write-Error "ERROR: Failed to current release date!" -ErrorAction Stop +} +$releasedate = $rawreleasedate -replace '\*','' + +if($releasedate -eq $newreleasedate) { + Write-Error ("ERROR: Release "+$releasedate+" already exists!") -ErrorAction Stop +} + +if ($TargetBranch -ne 'none') { + if ([string]::IsNullOrEmpty($TargetBranch)) { + $TargetBranch = $newreleasetag + "release" + } + + git checkout -b $TargetBranch + if ($LastExitCode -ne 0) { + Write-Error "ERROR: Failed to create new topic branch!" -ErrorAction Stop + } +} + +Write-Host " Old Version: " $version +Write-Host "Old Release Date: " $releasedate +Write-Host "->" +Write-Host " Release Date: " $newreleasedate +Write-Host " Release Tag: " $newreleasetag +Write-Host " Release Version: " $newversion + +if($UpdateVersion) { + (Get-Content $cmake).Replace("set(DIRECTXMATH_VERSION $version)","set(DIRECTXMATH_VERSION $newversion)") | Set-Content $cmake + (Get-Content $header).Replace("#define DIRECTX_MATH_VERSION $rawversion","#define DIRECTX_MATH_VERSION $newrawversion") | Set-Content $header +} + +(Get-Content $readme).Replace("$rawreleasedate", "**$newreleasedate**") | Set-Content $readme + +Get-ChildItem -Path ($reporoot + "\.nuget") -Filter *.nuspec | Foreach-Object { + (Get-Content -Path $_.Fullname).Replace("$releasedate", "$newreleasedate") | Set-Content -Path $_.Fullname -Encoding utf8 + } + +[System.Collections.ArrayList]$file = Get-Content $history +$inserthere = @() + +for ($i=0; $i -lt $file.count; $i++) { + if ($file[$i] -match "## Release History") { + $inserthere += $i + 1 + } +} + +$file.insert($inserthere[0], "`n### $newreleasedate`n* change history here") +Set-Content -Path $history -Value $file + +code $history $readme +if ($LastExitCode -ne 0) { + Write-Error "ERROR: Failed to launch VS Code!" -ErrorAction Stop +}