Skip to content

Commit 96ed375

Browse files
committed
update premake + make its downloading a script
1 parent c0d16da commit 96ed375

File tree

7 files changed

+138
-4
lines changed

7 files changed

+138
-4
lines changed

.github/workflows/build.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
type: number
1111
jobs:
1212
build:
13-
runs-on: windows-2022
13+
runs-on: windows-2025
1414
name: "Build"
1515
env:
1616
BME_CHANNEL: ${{ github.event_name == 'workflow_dispatch' && 'release' || 'staging' }}
@@ -35,6 +35,9 @@ jobs:
3535
msbuild-architecture: x64
3636
vs-prerelease: true
3737

38+
- name: Install premake
39+
run: ./scripts/get-premake.ps1 5.0.0-beta4
40+
3841
- name: Generate project files (premake)
3942
run: premake/premake5 vs2022 --ci-build=${{ env.BME_CHANNEL }}
4043

@@ -101,7 +104,7 @@ jobs:
101104
- name: Create release
102105
if: github.event_name == 'workflow_dispatch'
103106
id: create_release
104-
uses: softprops/action-gh-release@v1
107+
uses: softprops/action-gh-release@v2
105108
with:
106109
tag_name: v${{ inputs.version }}
107110
name: Release v${{ inputs.version }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ installer/source/bin/x64_retail/launcher.dll
382382

383383
r1_modsrc/scripts/
384384
bmedll/FilesystemContents.h
385+
premake/premake5.exe
385386
premake/deps/include
386387

387-
!/premake/premake5.exe
388388
!/thirdparty/sentry/lib/*.lib

generate.bat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
:: This generates Visual Studio projects for building the C++ parts.
44

55
git submodule update --init
6-
premake\premake5 vs2022 %*
6+
powershell -ExecutionPolicy Bypass -Command "scripts\get-premake.ps1 5.0.0-beta4"
7+
premake\premake5 vs2022 %*

premake/premake5.exe

-1.21 MB
Binary file not shown.

premake/utils.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
os.chdir(_MAIN_SCRIPT_DIR)
22

3+
if _ACTION == nil then _ACTION = "" end -- workaround Premake bug, TODO: remove
34
require("vstudio")
5+
if _ACTION == "" then _ACTION = nil end -- workaround Premake bug, TODO: remove
46
premake.api.register {
57
name = "solutionitems",
68
scope = "workspace",

scripts/7zip.ps1

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
function Get-7zRegistry {
2+
$reg = [Microsoft.Win32.RegistryKey]::OpenBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, [Microsoft.Win32.RegistryView]::Registry64)
3+
4+
if ($null -eq $reg) {
5+
return $null
6+
}
7+
8+
$szKey = $reg.OpenSubKey("SOFTWARE")
9+
if ($null -eq $szKey) {
10+
return $null
11+
}
12+
13+
$szKey = $szKey.OpenSubKey("7-Zip")
14+
if ($null -eq $szKey) {
15+
return $null
16+
}
17+
18+
return $szKey.GetValue("Path") + "7z.exe"
19+
}
20+
21+
function Get-7zDefaultPaths {
22+
if (Get-Command "7z" -ErrorAction SilentlyContinue) {
23+
return (Get-Command "7z" -ErrorAction SilentlyContinue).Source
24+
}
25+
26+
if (Get-Command "7zz" -ErrorAction SilentlyContinue) {
27+
return (Get-Command "7zz" -ErrorAction SilentlyContinue).Source
28+
}
29+
30+
$path = "$env:ProgramFiles\7-Zip\7z.exe"
31+
if (Test-Path -Path $path -PathType Leaf) { return $path }
32+
33+
$path = "$env:ProgramW6432\7-Zip\7z.exe"
34+
if (Test-Path -Path $path -PathType Leaf) { return $path }
35+
36+
$path = "${env:ProgramFiles(x86)}\7-Zip\7z.exe"
37+
if (Test-Path -Path $path -PathType Leaf) { return $path }
38+
39+
$path = "$env:ProgramFiles\7-Zip-Zstandard\7z.exe"
40+
if (Test-Path -Path $path -PathType Leaf) { return $path }
41+
42+
$path = "$env:ProgramW6432\7-Zip-Zstandard\7z.exe"
43+
if (Test-Path -Path $path -PathType Leaf) { return $path }
44+
45+
return $null
46+
}
47+
48+
if ($IsWindows) {
49+
$7z = Get-7zRegistry
50+
}
51+
52+
if ($null -eq $7z) {
53+
$7z = Get-7zDefaultPaths
54+
}
55+
56+
if ($null -eq $7z) {
57+
Write-Error -Message "Could not locate 7-Zip. Make sure you have 7-Zip installed and try again."
58+
exit 1
59+
}

scripts/get-premake.ps1

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
if ($args.Count -lt 1) {
2+
Write-Output "Usage: <premake>"
3+
exit 1
4+
}
5+
6+
$premakeVersion = $args[0]
7+
8+
if ($PSVersionTable.PSVersion.Major -lt 6.0) {
9+
switch ($([System.Environment]::OSVersion.Platform)) {
10+
"Win32NT" {
11+
New-Variable -Option Constant -Name IsWindows -Value $True -ErrorAction SilentlyContinue
12+
New-Variable -Option Constant -Name IsLinux -Value $false -ErrorAction SilentlyContinue
13+
New-Variable -Option Constant -Name IsMacOs -Value $false -ErrorAction SilentlyContinue
14+
}
15+
}
16+
}
17+
18+
$destination = "premake.zip"
19+
$premakeBinPath = "premake/premake5.exe"
20+
$premakePath = "premake"
21+
22+
$currentPremakeVersion = ""
23+
if (Test-Path $premakeBinPath) {
24+
$currentPremakeVersion = ((& $premakeBinPath --version) -join "`n").Replace("premake5 (Premake Build Script Generator) ", "").Trim()
25+
if ($premakeVersionOutput -eq $premakeVersion) {
26+
exit
27+
}
28+
Write-Output "Premake dependency outdated: $currentPremakeVersion, expected: $premakeVersion"
29+
30+
#-------------------------------------------------
31+
Write-Output "Deleting old Premake binary..."
32+
#-------------------------------------------------
33+
34+
Remove-Item $premakeBinPath -ErrorAction Ignore
35+
}
36+
37+
#-------------------------------------------------
38+
Write-Output "Locating 7-Zip"
39+
#-------------------------------------------------
40+
41+
. $PSScriptRoot\7zip.ps1
42+
43+
#-------------------------------------------------
44+
Write-Output "Downloading Premake..."
45+
#-------------------------------------------------
46+
47+
Add-Type -AssemblyName System.Web
48+
$premakeURLVersion = [uri]::EscapeUriString($premakeVersion)
49+
50+
$source = "https://github.com/premake/premake-core/releases/download/v$premakeURLVersion/premake-$premakeURLVersion-windows.zip"
51+
52+
# Net.WebClient is much faster than Invoke-WebRequest/Invoke-RestMethod
53+
(New-Object Net.WebClient).DownloadFile($source, $destination)
54+
55+
#-------------------------------------------------
56+
Write-Output "Unpacking Premake..."
57+
#-------------------------------------------------
58+
59+
# Only unpack the files we need
60+
& "$7z" x $destination premake5.exe -aoa -o"$premakePath"
61+
62+
#-------------------------------------------------
63+
Write-Output "Doing cleanup..."
64+
#-------------------------------------------------
65+
66+
Remove-Item $destination
67+
68+
#-------------------------------------------------
69+
Write-Output "Premake download done!"

0 commit comments

Comments
 (0)