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
87 changes: 43 additions & 44 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: MBINCompiler
permissions:
contents: read

on:
# Run on all branches except for the gh-pages branch
Expand Down Expand Up @@ -28,58 +30,52 @@ jobs:
- {name: 'Ubuntu', runtime: 'linux-x64', bin: 'MBINCompiler'}
- {name: 'Windows', runtime: 'win-x64', bin: 'MBINCompiler.exe'}
- {name: 'macOS', runtime: 'osx-arm64', bin: 'MBINCompiler'}
dotnet: [{framework: 'net6.0', version: '6.0.0'}, {framework: 'net8.0', version: '8.0.0'}]
dotnet: [{framework: 'net10.0', version: '10.0.0'}, {framework: 'net8.0', version: '8.0.0'}]
# We only ship a .NET 8 build for macOS.
exclude:
- os: {name: 'macOS', runtime: 'osx-arm64', bin: 'MBINCompiler'}
dotnet: {framework: 'net6.0', version: '6.0.0'}
dotnet: {framework: 'net10.0', version: '10.0.0'}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- uses: actions/setup-dotnet@v5
with:
# Install both sdk versions.
dotnet-version: |
6.0.100
8.0.100
10.0.100
- name: Build ${{ matrix.os.name }}-dotnet ${{ matrix.dotnet.framework }} binaries
# Pin the runtime patch version via an MSBuild property rather than
# editing the csproj with `sed`. This avoids GNU-vs-BSD `sed -i`
# incompatibilities (the macOS runner ships BSD sed) and is equivalent.
run: |
dotnet publish libMBIN-DLL --no-self-contained -c Release -f ${{ matrix.dotnet.framework }} -r ${{ matrix.os.runtime }} -p:RuntimeFrameworkVersion=${{ matrix.dotnet.version }} /nowarn:cs0618 /nowarn:cs0169 /nowarn:cs0414
dotnet publish MBINCompiler --no-self-contained -c Release -f ${{ matrix.dotnet.framework }} -r ${{ matrix.os.runtime }} -p:RuntimeFrameworkVersion=${{ matrix.dotnet.version }} /nowarn:cs0618 /nowarn:cs0169 /nowarn:cs0414
dotnet publish libMBIN-DLL --no-self-contained -c Release -f ${{ matrix.dotnet.framework }} -r ${{ matrix.os.runtime }} -p:RuntimeFrameworkVersion=${{ matrix.dotnet.version }}
dotnet publish MBINCompiler --no-self-contained -c Release -f ${{ matrix.dotnet.framework }} -r ${{ matrix.os.runtime }} -p:RuntimeFrameworkVersion=${{ matrix.dotnet.version }}
- name: Move the binary so the tests can find it
shell: bash
run: |
cp "Build/Release/${{ matrix.dotnet.framework }}/${{ matrix.os.runtime }}/publish/${{ matrix.os.bin }}" "${{ matrix.os.bin }}"
cp "Build/Release/${{ matrix.dotnet.framework }}/${{ matrix.os.runtime }}/publish/libMBIN.dll" libMBIN.dll
chmod +x "${{ matrix.os.bin }}"
- name: Set up Python 3.9
uses: actions/setup-python@v5
mkdir -p binaries
cp "Build/Release/${{ matrix.dotnet.framework }}/${{ matrix.os.runtime }}/publish/${{ matrix.os.bin }}" "binaries/${{ matrix.os.bin }}"
cp "Build/Release/${{ matrix.dotnet.framework }}/${{ matrix.os.runtime }}/publish/libMBIN.dll" binaries/libMBIN.dll
chmod +x "binaries/${{ matrix.os.bin }}"
- name: Set up Python 3.10
uses: actions/setup-python@v6
with:
python-version: "3.9"
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip uv
uv sync
- name: Run tests
run: uv run python -m pytest --mbincompiler_path="./${{ matrix.os.bin }}" --tb=no --report
- name: Upload Windows binaries
uses: actions/upload-artifact@v4
run: uv run python -m pytest --mbincompiler_path="./binaries/${{ matrix.os.bin }}" --tb=no --report
- name: Upload ${{ matrix.os.name }} binaries
uses: actions/upload-artifact@v7
with:
name: MBINCompiler-${{ matrix.os.name }}-${{ matrix.dotnet.framework }}
if-no-files-found: error
path: |
MBINCompiler.exe
libMBIN.dll
if: ${{matrix.os.name == 'Windows' }}
- name: Upload Linux binaries
uses: actions/upload-artifact@v4
with:
name: MBINCompiler-${{ matrix.os.name }}-${{ matrix.dotnet.framework }}
path: |
MBINCompiler
libMBIN.dll
if: ${{matrix.os.name == 'Ubuntu' }}
Build/Release/${{ matrix.dotnet.framework }}/${{ matrix.os.runtime }}/publish/${{ matrix.os.bin }}
Build/Release/${{ matrix.dotnet.framework }}/${{ matrix.os.runtime }}/publish/libMBIN.dll
if: ${{ matrix.os.name != 'macOS' }}
- name: Package macOS archive (CLI + droplet + Quick Action)
# Assemble on macOS so `ditto` preserves the droplet .app bundle (its exec
# bits / signature would be lost if zipped by the Windows release job or by
Expand All @@ -98,33 +94,36 @@ jobs:
ditto -c -k --keepParent "$STAGE" MBINCompiler-macOS.zip
if: ${{matrix.os.name == 'macOS' }}
- name: Upload macOS archive
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: MBINCompiler-${{ matrix.os.name }}-${{ matrix.dotnet.framework }}
if-no-files-found: error
path: |
MBINCompiler-macOS.zip
libMBIN.dll
if: ${{matrix.os.name == 'macOS' }}
Build/Release/${{ matrix.dotnet.framework }}/${{ matrix.os.runtime }}/publish/libMBIN.dll
if: ${{ matrix.os.name == 'macOS' }}
- name: Upload report
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: MBINCompiler-report
if-no-files-found: error
path: report.json
if: ${{matrix.os.name == 'Windows' && matrix.dotnet.framework == 'net6.0'}}
if: ${{matrix.os.name == 'Windows' && matrix.dotnet.framework == 'net8.0'}}
save_mapping:
name: Build save file mapping and generate mapping
runs-on: Windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: Build SaveFileMapping binary
run: dotnet publish SaveFileMapping -c Release -f net8.0 -r win-x64 -o Build/Release/net8/ /nowarn:cs0618 /nowarn:cs0169 /nowarn:cs0414
run: dotnet publish SaveFileMapping -c Release -f net8.0 -r win-x64 -o Build/Release/net8/
- name: Generate save data mapping
run : Build/Release/net8/SaveFileMapping.exe
shell: bash
- name: Upload report
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: savedata-mapping
if-no-files-found: error
path: mapping.json
release:
name: Release MBINCompiler binaries and other data
Expand All @@ -134,19 +133,19 @@ jobs:
needs: [build_test, save_mapping]
steps:
- name: Download files for release
uses: actions/download-artifact@v4
uses: actions/download-artifact@v8
- name: Rename files for release
run: |
mv MBINCompiler-Windows-net6.0/MBINCompiler.exe MBINCompiler-dotnet6.exe
mv MBINCompiler-Windows-net6.0/libMBIN.dll libMBIN-dotnet6.dll
mv MBINCompiler-Windows-net10.0/MBINCompiler.exe MBINCompiler-dotnet10.exe
mv MBINCompiler-Windows-net10.0/libMBIN.dll libMBIN-dotnet10.dll
mv MBINCompiler-Windows-net8.0/MBINCompiler.exe MBINCompiler.exe
mv MBINCompiler-Windows-net8.0/libMBIN.dll libMBIN.dll
mv MBINCompiler-Ubuntu-net6.0/MBINCompiler MBINCompiler-linux-dotnet6
mv MBINCompiler-Ubuntu-net6.0/libMBIN.dll libMBIN-linux-dotnet6.so
mv MBINCompiler-Ubuntu-net10.0/MBINCompiler MBINCompiler-linux-dotnet10
mv MBINCompiler-Ubuntu-net10.0/libMBIN.dll libMBIN-linux-dotnet10.so
mv MBINCompiler-Ubuntu-net8.0/MBINCompiler MBINCompiler-linux
mv MBINCompiler-Ubuntu-net8.0/libMBIN.dll libMBIN-linux.so
mv MBINCompiler-macOS-net8.0/MBINCompiler-macOS.zip MBINCompiler-macOS.zip
mv MBINCompiler-macOS-net8.0/libMBIN.dll libMBIN-mac.dll
mv MBINCompiler-macOS-net8.0/Build/Release/net8.0/osx-arm64/publish/libMBIN.dll libMBIN-mac.dll
mv savedata-mapping/mapping.json mapping.json
mv MBINCompiler-report/report.json report.json
- name: Get MBINCompiler tag version
Expand All @@ -164,12 +163,12 @@ jobs:
files: |
MBINCompiler.exe
libMBIN.dll
MBINCompiler-dotnet6.exe
libMBIN-dotnet6.dll
MBINCompiler-dotnet10.exe
libMBIN-dotnet10.dll
MBINCompiler-linux
libMBIN-linux.so
MBINCompiler-linux-dotnet6
libMBIN-linux-dotnet6.so
MBINCompiler-linux-dotnet10
libMBIN-linux-dotnet10.so
MBINCompiler-macOS.zip
libMBIN-mac.dll
report.json
Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/Build/Debug/net6.0/MBINCompiler.dll",
"program": "${workspaceFolder}/Build/Debug/net8.0/MBINCompiler.dll",
"args": [],
"cwd": "${workspaceFolder}/MBINCompiler",
"console": "internalConsole",
Expand Down
5 changes: 5 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>
<PropertyGroup>
<NoWarn>$(NoWarn);CS0618;CS0169;CS0414;CS0649</NoWarn>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion MBINCompiler/MBINCompiler.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</ItemGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
Expand Down
2 changes: 1 addition & 1 deletion MBINCompilerDocs/MBINCompilerDocs.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ _**For Developers:** You can download a precompiled DLL or get the libMBIN sourc
[DOWNLOAD LATEST RELEASE](../../releases)

**PLEASE NOTE:** MBINCompiler requires .NET 8 to run. If you do not have this you can download is [here](https://dotnet.microsoft.com/download/dotnet/8.0/runtime)
Select an appropriate download under the the "Run desktop apps" set of downloads
Select an appropriate download under the the "Run desktop apps" set of downloads.
We also provide .NET 10 binaries for Windows and Linux. To see what is the primary and what is the secondary supported .NET version, see [this](https://github.com/monkeyman192/MBINCompiler/issues/669) issue.

**ALSO NOTE:** As of the Worlds part 2 update, MBINCompiler will no longer generate or handle EXML files, and will instead handle MXML files. This is to (finally) get MBINCompiler producing files in the same format as NMS expects. For modding puposes the MXML are not the actual files you need to place in a mod directory. To do this, you can rename the MXML file to EXML.

Expand Down Expand Up @@ -147,15 +148,15 @@ While this library targets multiple frameworks, building MBINCompiler and libMBI
The full command to build all the libraries under the .NET framework looks like:

```sh
dotnet publish -c Release -f net8.0 -r win-x64 /nowarn:cs0618 /nowarn:cs0169 /nowarn:cs0414
dotnet publish -c Release -f net8.0 -r win-x64
```

Change the `-r` runtime identifier to target a different platform, eg. `linux-x64` or `osx-arm64` (Apple Silicon macOS).

For convenience we have included a number of scripts which build the entire project:

- `build-net6.bat` / `build-net6.sh`: the .NET 6 framework (Windows / linux).
- `build-net8.bat` / `build-net8.sh`: the .NET 8 framework (Windows / linux).
- `build-net10.bat` / `build-net10.sh`: the .NET 10 framework (Windows / linux).
- `build-net8-mac.sh`: the .NET 8 framework for Apple Silicon macOS (`osx-arm64`).

## Installing python dependencies
Expand All @@ -171,7 +172,7 @@ For anyone helping to develop MBINCompiler, if you are contributing new structs
### Requirements

Before running the tests, you need to have built a `Release` version of MBINCompiler locally.
You can do this by running `dotnet publish --no-self-contained -c Release -f net8.0 -r win-x64 /nowarn:cs0618 /nowarn:cs0169 /nowarn:cs0414` (change dotnet and framework version as required).
You can do this by running `dotnet publish --no-self-contained -c Release -f net8.0 -r win-x64` (change dotnet and framework version as required).
See section above about building for more details.

On macOS (Apple Silicon) build with `./build-net8-mac.sh` and then run the tests with the matching platform, eg. `uv run pytest --platform osx-arm64`. If the built binary lives somewhere other than the default `Build/Release/net8.0/<platform>/publish/` location you can point the tests at it directly with `--mbincompiler_path`.
Expand Down
2 changes: 1 addition & 1 deletion SaveFileMapping/SaveFileMapping.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
Expand Down
2 changes: 1 addition & 1 deletion build-net6.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
dotnet publish --no-self-contained -c Release -f net6.0 -r win-x64 /nowarn:cs0618 /nowarn:cs0169 /nowarn:cs0414
dotnet publish --no-self-contained -c Release -f net10.0 -r win-x64
pause
2 changes: 1 addition & 1 deletion build-net6.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dotnet publish --no-self-contained -c Release -f net6.0 -r linux-x64 /nowarn:cs0618 /nowarn:cs0169 /nowarn:cs0414
dotnet publish --no-self-contained -c Release -f net10.0 -r linux-x64
2 changes: 1 addition & 1 deletion build-net8-mac.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dotnet publish --no-self-contained -c Release -f net8.0 -r osx-arm64 /nowarn:cs0618 /nowarn:cs0169 /nowarn:cs0414
dotnet publish --no-self-contained -c Release -f net8.0 -r osx-arm64
2 changes: 1 addition & 1 deletion build-net8.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
dotnet publish --no-self-contained -c Release -f net8.0 -r win-x64 /nowarn:cs0618 /nowarn:cs0169 /nowarn:cs0414
dotnet publish --no-self-contained -c Release -f net8.0 -r win-x64
pause
2 changes: 1 addition & 1 deletion build-net8.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dotnet publish --no-self-contained -c Release -f net8.0 -r linux-x64 /nowarn:cs0618 /nowarn:cs0169 /nowarn:cs0414
dotnet publish --no-self-contained -c Release -f net8.0 -r linux-x64
12 changes: 9 additions & 3 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ def pytest_terminal_summary(terminalreporter):


@pytest.hookimpl(trylast=True)
def pytest_sessionfinish(session, exitstatus):
# Override the default behaviour and cause pytest to always pass
session.exitstatus = 0
def pytest_sessionfinish(session: pytest.Session, exitstatus):
# Override the default behaviour and cause pytest to always pass unless every single test failed.
total_tests = session.testscollected
failed_tests = session.testsfailed

if total_tests > 0 and total_tests == failed_tests:
session.exitstatus = 1
else:
session.exitstatus = 0
2 changes: 1 addition & 1 deletion libMBIN-DLL/libMBIN-DLL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<RootNamespace>libMBIN</RootNamespace>
<AssemblyName>libMBIN</AssemblyName>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<Configurations>Release;Debug;Release-XML</Configurations>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "mbincompiler"
version = "1.0.0"
description = "Unit test and extraction tools for MBINCompiler"
readme = "README.md"
requires-python = ">=3.9"
requires-python = ">=3.10"
dependencies = [
"pytest",
"requests",
Expand Down
Loading
Loading