Skip to content

Commit

Permalink
Upgrade to .NET 8 (#159)
Browse files Browse the repository at this point in the history
* Upgrade to .NET 8

* Upgrade to .NET 8

* Upgrade to use CAstFfi v2023.11.21

* Fix issues with using .NET 8 and latest version of CAstFfi

* Update test c library build script

* Update

* Disable generating files

* Fix failing unit tests

* Fix test data

* Fix test data

* Fix test data

* Don't include 64 bit enums in tests

* Don't include 64 bit enums
  • Loading branch information
lithiumtoast authored Nov 22, 2023
1 parent f3b5c20 commit d6033bb
Show file tree
Hide file tree
Showing 73 changed files with 292 additions and 1,693 deletions.
75 changes: 6 additions & 69 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,75 +1,12 @@
name: "main"
name: "Main"

on:
push:
branches:
- main
tags:
- v*
paths-ignore:
- '**.md'
workflow_dispatch:
pull_request:
branches:
- main
paths-ignore:
- '**.md'
types: [assigned, opened, synchronize, reopened]

jobs:
dotnet-job:
name: ".NET"
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: false
matrix:
platform:
- { name: Windows x64, os: windows-latest, shell: bash }
- { name: Linux x64, os: ubuntu-latest, shell: bash }
- { name: macOS x64, os: macos-latest, shell: bash }
defaults:
run:
shell: ${{ matrix.platform.shell }}
steps:

- name: "Clone Git repository"
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: "Install Clang: Windows"
if: matrix.platform.os == 'windows-latest'
run: |
source "${{ github.workspace }}\.github\scripts\install-clang-x64-windows.sh"
- name: "Install Clang: Linux"
if: matrix.platform.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install gcc-aarch64-linux-gnu llvm-14 clang-14
- name: "Install .NET"
uses: actions/setup-dotnet@v1
with:
dotnet-version: '7.0.x'
include-prerelease: true

- name: "Install CAstFfi"
shell: bash
run: dotnet tool install --global bottlenoselabs.CAstFfi.Tool

- name: ".NET"
uses: bottlenoselabs/github-actions-dotnet@v3
with:
dotnet-sdk-version: "7.0.x"
solution-or-project: "${{ github.workspace }}/src/cs/C2CS.sln"
is-enabled-upload-myget: "${{ matrix.platform.os == 'ubuntu-latest' && ( github.event_name == 'push' || startsWith(github.ref, 'refs/tags/v') ) }}"
is-enabled-upload-nuget: "${{ matrix.platform.os == 'ubuntu-latest' && startsWith(github.ref, 'refs/tags/v') }}"
myget-access-token: "${{ secrets.MYGET_ACCESS_TOKEN }}"
nuget-access-token: "${{ secrets.NUGET_ACCESS_TOKEN }}"

# - name: "Snipe test files"
# uses: actions/upload-artifact@v3
# with:
# name: "Test Data ${{ matrix.platform.name }}"
# path: |
# ${{ github.workspace }}/src/cs/tests/*Tests*/**/*.json

test-job:
name: "Test"
uses: "./.github/workflows/test.yml"
70 changes: 70 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: "Release"
on:
workflow_dispatch:
inputs:
pre-release:
description: 'Is pre-release? (NOTE: Pre-releases are uploaded to MyGet.org instead of NuGet.org.)'
required: true
default: 'true'
version:
description: 'Version (NOTE: If left blank, the current date is used as the version.)'
required: false
default: ''

jobs:

test-job:
name: "Test .NET solution"
uses: "./.github/workflows/test.yml"

release-job:
name: "Release"
needs: [test-job]
runs-on: ubuntu-latest
permissions:
contents: write
steps:

- name: "Clone Git repository"
uses: actions/checkout@v3

- name: "Set version"
id: set-version
shell: bash
run: |
VERSION="${{ github.event.inputs.version }}"
if [[ -z "$VERSION" ]]; then
IS_PRERELEASE="${{ github.event.inputs.pre-release }}"
if [[ "$IS_PRERELEASE" = "true" ]]; then
VERSION="$(date +'%Y.%m.%d')-rc"
else
VERSION="$(date +'%Y.%m.%d')"
fi
fi
echo "VERSION=$VERSION"
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
- name: ".NET pack"
run: dotnet pack "./src/cs" --nologo --verbosity minimal --configuration Release -p:PackageVersion="${{ steps.set-version.outputs.VERSION }}" -p:RepositoryBranch="${{ github.head_ref || github.ref_name }}" -p:RepositoryCommit="${{ github.sha }}"

- name: "Upload packages to MyGet"
if: github.event_name == 'workflow_dispatch' && github.event.inputs.pre-release == 'true'
env:
MYGET_ACCESS_TOKEN: ${{ secrets.MYGET_ACCESS_TOKEN }}
run: dotnet nuget push "./nupkg/**/*.nupkg" --source https://www.myget.org/F/bottlenoselabs/api/v3/index.json --skip-duplicate --api-key $MYGET_ACCESS_TOKEN

- name: "Upload packages to NuGet"
if: github.event_name == 'schedule' || github.event.inputs.pre-release == 'false'
env:
NUGET_ACCESS_TOKEN: ${{ secrets.NUGET_ACCESS_TOKEN }}
run: dotnet nuget push "./nupkg/**/*.nupkg" --source https://api.nuget.org/v3/index.json --skip-duplicate --api-key $NUGET_ACCESS_TOKEN

- name: "Create tag and GitHub release"
uses: softprops/action-gh-release@v1
if: github.event_name == 'schedule' || github.event.inputs.pre-release == 'false'
with:
generate_release_notes: true
prerelease: "{{ github.event.inputs.pre-release == 'true' }}"
tag_name: "v${{ steps.set-version.outputs.VERSION }}"

56 changes: 56 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: "Test .NET solution"

on:
workflow_call:

jobs:

test-dotnet-job:
name: "Test .NET solution: ${{ matrix.platform.name }}"
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: false
matrix:
platform:
- { name: Windows, os: windows-latest }
- { name: Linux, os: ubuntu-latest }
- { name: macOS, os: macos-latest }
defaults:
run:
shell: bash
steps:

- name: "Clone Git repository"
uses: actions/checkout@v3

- name: "Install Clang: Windows"
if: matrix.platform.os == 'windows-latest'
run: |
source "${{ github.workspace }}\.github\scripts\install-clang-x64-windows.sh"
- name: "Install Clang: Linux"
if: matrix.platform.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install gcc-i686-linux-gnu gcc-x86-64-linux-gnu gcc-aarch64-linux-gnu llvm-14 clang-14
- name: "Setup .NET"
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.x'

- name: "Install CAstFfi"
shell: bash
run: dotnet tool install --global bottlenoselabs.CAstFfi.Tool

- name: "Test .NET solution"
run: |
dotnet test '${{ github.workspace }}/src/cs' --nologo --verbosity minimal --configuration Release
- name: "Collect generated test files"
uses: actions/upload-artifact@v3
if: github.event_name == 'pull_request'
with:
name: "Test Data ${{ matrix.platform.name }}"
path: |
${{ github.workspace }}/src/cs/tests/*.Tests/Data/Values/**/*.json
14 changes: 0 additions & 14 deletions GitVersion.yml

This file was deleted.

4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ See [LESSONS-LEARNED.md](./LESSONS-LEARNED.md).

## Installing `C2CS`

`C2CS` is distributed as a NuGet tool. To get started, the .NET 7 software development kit (SDK) is required.
`C2CS` is distributed as a NuGet tool. To get started, the .NET 8 software development kit (SDK) is required.

### Latest release of `C2CS`

Expand Down Expand Up @@ -75,7 +75,7 @@ The `C2CS.Runtime` C# code is directly added to the bottom of the generated bind

### Prerequisites

1. Install [.NET 7 SDK](https://dotnet.microsoft.com/download).
1. Install [.NET 8 SDK](https://dotnet.microsoft.com/download).
2. Install build tools for C/C++.
- Windows:
1. Install Git Bash. (Usually installed with Git for Windows: https://git-scm.com/downloads.)
Expand Down
1 change: 0 additions & 1 deletion nuget.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
<clear />
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
<add key="bottlenoselabs" value="https://www.myget.org/F/bottlenoselabs/api/v3/index.json" />
<add key="dotnet-experimental" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json" />
</packageSources>
</configuration>
7 changes: 4 additions & 3 deletions src/c/tests/_container_library/build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash
DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
OUPUT_DIRECTORY=$DIRECTORY/bin

rm -rf ./cmake-build-release
cmake -S . -B cmake-build-release -DCMAKE_BUILD_TYPE=Release -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=/Users/lstranks/Programming/bottlenoselabs/c2cs/bin/C2CS.Tests/Debug/net7.0/c/tests/_container_library/bin -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/Users/lstranks/Programming/bottlenoselabs/c2cs/bin/C2CS.Tests/Debug/net7.0/c/tests/_container_library/bin -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/Users/lstranks/Programming/bottlenoselabs/c2cs/bin/C2CS.Tests/Debug/net7.0/c/tests/_container_library/bin -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=/Users/lstranks/Programming/bottlenoselabs/c2cs/bin/C2CS.Tests/Debug/net7.0/c/tests/_container_library/bin
rm -rf $DIRECTORY/cmake-build-release
cmake -S $DIRECTORY -B cmake-build-release -DCMAKE_BUILD_TYPE=Release -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=$OUPUT_DIRECTORY -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=$OUPUT_DIRECTORY -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=$OUPUT_DIRECTORY
cmake --build cmake-build-release --config Release
rm -rf ./cmake-build-release
rm -rf $DIRECTORY/cmake-build-release
2 changes: 1 addition & 1 deletion src/c/tests/enums/EnumForceSInt32.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ typedef enum EnumForceSInt32 {
ENUM_FORCE_SINT32_DAY_WEDNESDAY,
ENUM_FORCE_SINT32_DAY_THURSDAY,
ENUM_FORCE_SINT32_DAY_FRIDAY,
_ENUM_FORCE_SINT32 = 0x7FFFFF
_ENUM_FORCE_SINT32 = 0x7FFFFFFFUL
} EnumForceSInt32;

FFI_API_DECL void EnumForceSInt32__print_EnumForceSInt32(const EnumForceSInt32 e)
Expand Down
21 changes: 0 additions & 21 deletions src/c/tests/enums/EnumForceSInt64.h

This file was deleted.

2 changes: 1 addition & 1 deletion src/c/tests/enums/EnumForceUInt32.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ typedef enum EnumForceUInt32 {
ENUM_FORCE_UINT32_DAY_WEDNESDAY,
ENUM_FORCE_UINT32_DAY_THURSDAY,
ENUM_FORCE_UINT32_DAY_FRIDAY,
_ENUM_FORCE_UINT32 = 0xffffffffffffffffL
_ENUM_FORCE_UINT32 = 0xFFFFFFFFUL
} EnumForceUInt32;

FFI_API_DECL void EnumForceUInt32__print_EnumForceUInt32(const EnumForceUInt32 e)
Expand Down
21 changes: 0 additions & 21 deletions src/c/tests/enums/EnumForceUInt64.h

This file was deleted.

5 changes: 1 addition & 4 deletions src/c/tests/enums/_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
#include "EnumForceSInt8.h"
#include "EnumForceSInt16.h"
#include "EnumForceSInt32.h"
#include "EnumForceSInt64.h"

#include "EnumForceUInt8.h"
#include "EnumForceUInt16.h"
#include "EnumForceUInt32.h"
#include "EnumForceUInt64.h"
#include "EnumForceUInt32.h"
3 changes: 0 additions & 3 deletions src/cs/TODO.md

This file was deleted.

Loading

0 comments on commit d6033bb

Please sign in to comment.