Skip to content

Commit

Permalink
Merge pull request #110 from BUTR/dev
Browse files Browse the repository at this point in the history
v1.5.6
  • Loading branch information
Aragas authored May 2, 2024
2 parents 4c3bf47 + 592e3d5 commit e74dcbc
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 13 deletions.
102 changes: 90 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,39 +67,117 @@ jobs:
BANNERLORD_BUTR_COMPATIBILITY_SCORE_URL: ${{ secrets.BANNERLORD_BUTR_COMPATIBILITY_SCORE_URL }}
shell: pwsh

- name: Add GPU acceleration hint
- name: Upload Bannerlord folder
uses: actions/upload-artifact@v4
with:
name: bannerlord-tmp-${{matrix.project}}-${{matrix.configuration}}
path: ./bannerlord/

gpu-hint:
name: Add GPU Hints
needs: [build]
runs-on: windows-latest
steps:
- uses: actions/checkout@v4

- name: Setup
uses: butr/actions-common-setup@v2
with:
github-token: ${{secrets.GITHUB_TOKEN}}

- name: Download Bannerlord Temp artifact Pattern
uses: actions/download-artifact@v4
with:
pattern: bannerlord-tmp-*
merge-multiple: true
path: ./bannerlord
continue-on-error: true

- name: Add Dedicated GPU Hint
run: |
# dotnet tool install -g Topten.nvpatch;
# $env:DOTNET_ROLL_FORWARD="Major";
dotnet tool install -g dotnet-script;
echo "Downloading ILAsm";
Invoke-WebRequest https://globalcdn.nuget.org/packages/runtime.win-x64.microsoft.netcore.ilasm.8.0.0.nupkg -OutFile ilasm.nupkg;
Invoke-WebRequest https://globalcdn.nuget.org/packages/runtime.win-x64.microsoft.netcore.ildasm.8.0.0.nupkg -OutFile ildasm.nupkg;
echo "Extracting ILAsm";
Expand-Archive ilasm.nupkg -d tools/ilasm;
Expand-Archive ildasm.nupkg -d tools/ildasm;
#echo "chmod ILAsm";
#chmod +x tools/ilasm/runtimes/linux-x64/native/ilasm;
#chmod +x tools/ildasm/runtimes/linux-x64/native/ildasm;
# So what is happening here?
# We're not able to export global variables from C#
# But ILAsm is able to do it
# So we compile our .exe files from C#
# Then we decompile them with ILDasm
# Then we compile them back to .exe with ILAsm and with the .il file for exporting the global variable
# Then we set the icon back because ILAsm doesn't support setting the icon
$workingDir = "$PWD";
mkdir tmp;
cd build/set-icon;
yarn install;
cd $workingDir;
$fileNames = Get-ChildItem -Path "bannerlord/" -Recurse -Include *.exe;
foreach ($f in $fileNames) {
cd $workingDir/tmp;
echo $f.FullName;
# nvpatch --enable $f.FullName;
dotnet script build/gpu.csx -- --enable-gpu "$f";
$runtime = "";
If ($f.FullName.Contains("Win64_Shipping_Client")) {
$runtime = "Win64_Shipping_Client";
}
If ($f.FullName.Contains("Gaming.Desktop.x64_Shipping_Client")) {
$runtime = "Gaming.Desktop.x64_Shipping_Client";
}
$fileDirname = $f.DirectoryName;
$dirname = [System.IO.Path]::GetFileNameWithoutExtension($f.FullName);
New-Item -ItemType Directory -Path $dirname/$runtime -Force
cd $dirname/$runtime;
# Decompile to IL Code
& "$workingDir/tools/ildasm/runtimes/win-x64/native/ildasm.exe" "$f" /OUT=Code.il
#& "$workingDir/tools/ildasm/runtimes/linux-x64/native/ildasm" "$f" -OUT="Code.il"
Copy-Item -Path $workingDir/build/ForceDedicatedGraphicCard.il -Destination ForceDedicatedGraphicCard.il;
# Recompile to .exe
& "$workingDir/tools/ilasm/runtimes/win-x64/native/ilasm.exe" -QUIET -NOLOGO -OPTIMIZE -EXE /X64 -OUTPUT="$dirname.exe" Code.il ForceDedicatedGraphicCard.il
#& "$workingDir/tools/ilasm/runtimes/linux-x64/native/ilasm" -QUIET -NOLOGO -OPTIMIZE -EXE -X64 -OUTPUT="$dirname.exe" Code.il ForceDedicatedGraphicCard.il
# Set Icon
cd $workingDir/build/set-icon;
node index.js "$workingDir/tmp/$dirname/$runtime/$dirname.exe" "$workingDir/resources/BLSE_SMALL.ico";
Copy-Item -Path "$workingDir/tmp/$dirname/$runtime/$dirname.exe" -Destination "$fileDirname/$dirname.exe" -force
}
cd $workingDir;
rmdir tmp -Recurse -Force;
shell: pwsh

- name: Upload Bannerlord folder
uses: actions/upload-artifact@v4
with:
name: bannerlord-${{matrix.project}}-${{matrix.configuration}}
name: bannerlord
path: ./bannerlord/

###########################
# NEXUSMODS #
###########################
publish-on-nexusmods:
if: github.ref == 'refs/heads/master'
needs: [get-changelog, build]
needs: [get-changelog, build, gpu-hint]
uses: BUTR/workflows/.github/workflows/release-nexusmods.yml@master
with:
nexusmods_game_id: mountandblade2bannerlord
nexusmods_mod_id: 1
mod_filename: 'Bannerlord Software Extender (BLSE)'
mod_version: ${{ needs.get-changelog.outputs.mod_version }}
mod_description: ${{ needs.build.outputs.mod_description }}
mod_description: ${{ needs.get-changelog.outputs.mod_description }}
artifact_name: bannerlord
secrets:
NEXUSMODS_APIKEY: ${{ secrets.ARAGAS_NEXUSMODS_API_KEY }}
Expand All @@ -110,20 +188,20 @@ jobs:
###########################
publish-on-github:
if: github.ref == 'refs/heads/master'
needs: [get-changelog, build]
needs: [get-changelog, build, gpu-hint]
uses: BUTR/workflows/.github/workflows/release-github.yml@master
with:
mod_id: Bannerlord.BLSE
mod_version: ${{ needs.get-changelog.outputs.mod_version }}
mod_description: ${{ needs.build.outputs.mod_description }}
mod_description: ${{ needs.get-changelog.outputs.mod_description }}
artifact_name: bannerlord

###########################
# STEAM #
###########################
publish-on-steam:
if: false && github.ref == 'refs/heads/master'
needs: [get-changelog, build]
needs: [get-changelog, build, gpu-hint]
runs-on: ubuntu-latest
steps:
- name: Download Module artifact
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,5 @@ MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
/src/.idea/*
/tmp/*
/tools/*
15 changes: 15 additions & 0 deletions build/ForceDedicatedGraphicCard.il
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.class public Bannerlord.BLSE.ForceDedicatedGraphicCard
{
.method public static int32 NvOptimusEnablement() cil managed
{
.export [1]
ldc.i4.1
ret
}
.method public static uint32 AmdPowerXpressRequestHighPerformance() cil managed
{
.export [2]
ldc.i4.1
ret
}
}
2 changes: 1 addition & 1 deletion build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<!--Development Variables-->
<PropertyGroup>
<Version>1.5.5</Version>
<Version>1.5.6</Version>
<HarmonyVersion>2.2.2</HarmonyVersion>
<BUTRSharedVersion>3.0.0.139</BUTRSharedVersion>
<BUTRModuleManagerVersion>5.0.222</BUTRModuleManagerVersion>
Expand Down
7 changes: 7 additions & 0 deletions build/set-icon/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const changeExe = require('changeexe');

const args = process.argv;

(async () => {
await changeExe.icon(args[2], args[3]);
})();
5 changes: 5 additions & 0 deletions build/set-icon/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"changeexe": "^1.0.3"
}
}
15 changes: 15 additions & 0 deletions build/set-icon/yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


adm-zip@^0.5.10:
version "0.5.12"
resolved "https://registry.yarnpkg.com/adm-zip/-/adm-zip-0.5.12.tgz#87786328e91d54b37358d8a50f954c4cd73ba60b"
integrity sha512-6TVU49mK6KZb4qG6xWaaM4C7sA/sgUMLy/JYMOzkcp3BvVLpW0fXDFQiIzAuxFCt/2+xD7fNIiPFAoLZPhVNLQ==

changeexe@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/changeexe/-/changeexe-1.0.3.tgz#e9ccc889aa78179edce7128bb09bf0ff379c65ac"
integrity sha512-UpX2cVZW7smLML+fmdvBw12Nhz1PxODswpOx+9kYDOY+IWSntuFVaC3nFVIJ6+3dmZNFbwR2DDrkBrV861KRCA==
dependencies:
adm-zip "^0.5.10"
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
---------------------------------------------------------------------------------------------------
Version: 1.5.6
Game Versions: v1.0.0,v1.0.1,v1.0.2,v1.0.3,v1.1.0,v1.1.1,v1.1.2,v1.1.3,v1.1.4,v1.1.5,v1.1.6,v1.2.x
* BETA Release!
* Added back support for GPU Acceleration Hints
---------------------------------------------------------------------------------------------------
Version: 1.5.5
Game Versions: v1.0.0,v1.0.1,v1.0.2,v1.0.3,v1.1.0,v1.1.1,v1.1.2,v1.1.3,v1.1.4,v1.1.5,v1.1.6,v1.2.x
* BETA Release!
Expand Down

0 comments on commit e74dcbc

Please sign in to comment.