Skip to content

Commit

Permalink
Merge from master
Browse files Browse the repository at this point in the history
  • Loading branch information
sirjuddington committed May 24, 2024
2 parents d99859b + 306da18 commit bb8b2ec
Show file tree
Hide file tree
Showing 12 changed files with 403 additions and 88 deletions.
6 changes: 5 additions & 1 deletion cmake/win_msvc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,16 @@ if(NOT SLADE_EXE_NAME)
set(SLADE_EXE_NAME SLADE)
endif()

if(NOT SLADE_EXE_DIR)
set(SLADE_EXE_DIR dist)
endif()

# Properties
set_target_properties(slade
PROPERTIES
LINK_FLAGS "/subsystem:windows"
OUTPUT_NAME "${SLADE_EXE_NAME}"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/dist"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/${SLADE_EXE_DIR}"
)

# Precompiled Header
Expand Down
1 change: 1 addition & 0 deletions dist/res/config/archive_formats.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ archive_formats
{
name = "Terminal Velocity POD";
entry_format = "archive_pod";
supports_dirs = true;
extensions { pod = "Terminal Velocity POD"; }
}

Expand Down
46 changes: 25 additions & 21 deletions msvc/SLADE.rc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Microsoft Visual C++ generated resource script.
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"

Expand Down Expand Up @@ -51,10 +51,14 @@ END
// Version
//

#define SLADE_VERSION 3,2,5,0
#define SLADE_VERSION_STR "3.2.5"
#define SLADE_COPYRIGHT "Copyright (C) 2008-2024"

VS_VERSION_INFO VERSIONINFO
FILEVERSION 3, 3, 0
PRODUCTVERSION 3, 3, 0
FILEFLAGSMASK 0x3fL
FILEVERSION SLADE_VERSION
PRODUCTVERSION SLADE_VERSION
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
Expand All @@ -64,23 +68,23 @@ FILEOS 0x40004L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "0c0904b0"
BEGIN
VALUE "FileDescription", "SLADE"
VALUE "FileVersion", "3.3.0 alpha"
VALUE "InternalName", "SLADE.exe"
VALUE "LegalCopyright", "Copyright (C) 2023"
VALUE "OriginalFilename", "SLADE.exe"
VALUE "ProductName", "SLADE"
VALUE "ProductVersion", "3.3.0 alpha"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0xc09, 1200
END
BLOCK "StringFileInfo"
BEGIN
BLOCK "0c0904b0"
BEGIN
VALUE "FileDescription", "SLADE"
VALUE "FileVersion", SLADE_VERSION_STR
VALUE "InternalName", "SLADE.exe"
VALUE "LegalCopyright", SLADE_COPYRIGHT
VALUE "OriginalFilename", "SLADE.exe"
VALUE "ProductName", "SLADE"
VALUE "ProductVersion", SLADE_VERSION_STR
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0xc09, 1200
END
END


Expand Down
98 changes: 98 additions & 0 deletions msvc/buildall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Setup -----------------------------------------------------------------------

# Find MSVC base path (community or professional)
$msvcpath = "${env:ProgramFiles}\Microsoft Visual Studio\2022\Professional"
if (-not (Test-Path $msvcpath))
{
$msvcpath = "${env:ProgramFiles}\Microsoft Visual Studio\2022\Community"
}
if (-not (Test-Path $msvcpath))
{
Write-Host "`nCould not find Visual Studio 2022 path" -ForegroundColor Red
Exit-PSSession
}
Write-Host "`nFound VS2022 at ${msvcpath}" -foregroundcolor blue

# Cmake config line vars
$buildtype = "-DCMAKE_BUILD_TYPE:STRING=`"RelWithDebInfo`""
$toolchainfile = "-DCMAKE_TOOLCHAIN_FILE=`"H:/Dev/vcpkg/scripts/buildsystems/vcpkg.cmake`""


# 32bit build -----------------------------------------------------------------

Write-Host "`nProceed with 32bit build? (y/n) " -foregroundcolor cyan -nonewline
$build32 = Read-Host
if ($build32.ToLower() -eq "y")
{
# Clear existing build
if (Test-Path "../dist/build32")
{
Remove-Item -Recurse -Force "../dist/build32" | out-null
}

# Setup 32bit build environment variables
cmd.exe /c "call `"$msvcpath\VC\Auxiliary\Build\vcvars32.bat`" && set > %temp%\vcvars32.txt"
Get-Content "$env:temp\vcvars32.txt" | Foreach-Object {
if ($_ -match "^(.*?)=(.*)$")
{
Set-Content "env:\$($matches[1])" $matches[2]
}
}

# Set 32bit cmake vars
$targettriplet = "-DVCPKG_TARGET_TRIPLET:STRING=`"x86-windows-static`""
$outputdir = "-DSLADE_EXE_DIR=`"dist/build32`""

# Configure
Write-Host "`nConfiguring 32bit build..." -foregroundcolor blue
cmake -G Ninja $buildtype -DBUILD_PK3=OFF $targettriplet $toolchainfile $outputdir .. -B "build32"

# Build
Write-Host "`nBuilding 32bit executable..." -foregroundcolor blue
cmake --build "build32"

# Clean up
Remove-Item -Recurse -Force "build32"
Remove-Item -Force ${env::temp}\vcvars32.txt
}


# 64bit build -----------------------------------------------------------------

Write-Host "`nProceed with 64bit build? (y/n) " -foregroundcolor cyan -nonewline
$build64 = Read-Host
if ($build64.ToLower() -eq "y")
{
# Clear existing build
if (Test-Path "../dist/build64")
{
Remove-Item -Recurse -Force "../dist/build64" | out-null
}

# Setup 64bit build environment variables
cmd.exe /c "call `"$msvcpath\VC\Auxiliary\Build\vcvars64.bat`" && set > %temp%\vcvars64.txt"
Get-Content "$env:temp\vcvars64.txt" | Foreach-Object {
if ($_ -match "^(.*?)=(.*)$")
{
Set-Content "env:\$($matches[1])" $matches[2]
}
}

# Set 64bit cmake vars
$targettriplet = "-DVCPKG_TARGET_TRIPLET:STRING=`"x64-windows-static`""
$outputdir = "-DSLADE_EXE_DIR=`"dist/build64`""

# Configure
Write-Host "`nConfiguring 64bit build..." -foregroundcolor blue
cmake -G Ninja $buildtype -DBUILD_PK3=OFF $targettriplet $toolchainfile $outputdir .. -B "build64"

# Build
Write-Host "`nBuilding 64bit executable..." -foregroundcolor blue
cmake --build "build64"

# Clean up
Remove-Item -Recurse -Force "build64"
Remove-Item -Force ${env::temp}\vcvars64.txt
}

Write-Host "`nDone!" -foregroundcolor green
74 changes: 20 additions & 54 deletions dist/makebuild.ps1 → msvc/makerelease.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,86 +17,52 @@ if ($userev.ToLower() -eq "y")
$version = "${version}_$rev_short"
}

<# SLADE is now built on Windows via cmake, not sure how to do it here properly yet
so will just build manually in VS for now
# Prompt to build SLADE
Write-Host "`nRebuild SLADE? (y/n) " -foregroundcolor cyan -nonewline
$buildbinaries = Read-Host
# Build SLADE
if ($buildbinaries.ToLower() -eq "y")
{
# Find devenv path (community or professional)
$devenvpath = "${env:ProgramFiles}\Microsoft Visual Studio\2022\Professional\Common7\IDE\devenv.com"
if (-not (Test-Path $devenvpath))
{
$devenvpath = "${env:ProgramFiles}\Microsoft Visual Studio\2022\Community\Common7\IDE\devenv.com"
}
if (-not (Test-Path $devenvpath))
{
Write-Host "`nCould not find Visual Studio 2022 path" -ForegroundColor Red
Exit-PSSession
}
else
{
Write-Host "`nFound VS2022 at ${devenvpath}";
Write-Host "`nProceed with 64bit build? (y/n) " -foregroundcolor cyan -nonewline
$build64 = Read-Host
if ($build64.ToLower() -eq "y")
{
& $devenvpath (resolve-path ..\msvc\SLADE.sln).Path /rebuild "Release|x64" /project SLADE.vcxproj
}
Write-Host "`nProceed with 32bit build? (y/n) " -foregroundcolor cyan -nonewline
$build32 = Read-Host
if ($build32.ToLower() -eq "y")
{
& $devenvpath (resolve-path ..\msvc\SLADE.sln).Path /rebuild "Release|Win32" /project SLADE.vcxproj
}
}
& ./buildall.ps1
}
#>

# Determine release directory + platforms
$releasedir = "$PSScriptRoot\$version"
$releasedir = "..\dist\$version"
$releasedir32 = "$releasedir\win32"
$releasedir64 = "$releasedir\x64"

# Create release directory if needed
Write-Host "`nCreate directory $releasedir" -foregroundcolor yellow
Write-Host "`nCreate directory $releasedir" -foregroundcolor blue
New-Item -ItemType directory -Force -Path "$releasedir32" | out-null
New-Item -ItemType directory -Force -Path "$releasedir64" | out-null

# Remove existing pk3 if it exists
$pk3path = ".\slade.pk3"
$pk3path = "..\dist\slade.pk3"
if (Test-Path "$pk3path")
{
Write-Host "`nRemoving existing slade.pk3" -foregroundcolor yellow
Write-Host "`nRemoving existing slade.pk3" -foregroundcolor blue
Remove-Item "$pk3path"
}

# Clean out Thumbs.db files from res folder
Write-Host "`nRemoving Thumbs.db files..." -foregroundcolor yellow
$resdir = (resolve-path ".\res").path
Get-ChildItem -Path . -Include Thumbs.db -Recurse -Name -Force | Remove-Item -Force
Write-Host "`nRemoving Thumbs.db files..." -foregroundcolor blue
$resdir = (resolve-path "..\dist\res").path
Get-ChildItem -Path ..\dist -Include Thumbs.db -Recurse -Name -Force | Remove-Item -Force

# Build pk3
Write-Host "`nBuilding slade.pk3..." -foregroundcolor yellow
Write-Host "`nBuilding slade.pk3..." -foregroundcolor blue
& $7zpath a -tzip $pk3path "$resdir\*" | out-null
Write-Host "Done" -foregroundcolor green

# Copy Files
Write-Host "`nCopying SLADE files..." -foregroundcolor yellow
Write-Host "`nCopying SLADE files..." -foregroundcolor blue
# Common
Copy-Item (resolve-path ".\slade.pk3") "$releasedir" -Force
Copy-Item (resolve-path "..\dist\slade.pk3") "$releasedir" -Force
# Win32
Copy-Item (resolve-path ".\SLADE.exe") "$releasedir32" -Force
Copy-Item (resolve-path ".\SLADE.pdb") "$releasedir32" -Force
Copy-Item (resolve-path "..\dist\build32\SLADE.exe") "$releasedir32" -Force
Copy-Item (resolve-path "..\dist\build32\SLADE.pdb") "$releasedir32" -Force
# x64
Copy-Item (resolve-path ".\SLADE-x64.exe") "$releasedir64\SLADE.exe" -Force
Copy-Item (resolve-path ".\SLADE-x64.pdb") "$releasedir64" -Force
Copy-Item (resolve-path "..\dist\build64\SLADE.exe") "$releasedir64" -Force
Copy-Item (resolve-path "..\dist\build64\SLADE.pdb") "$releasedir64" -Force
Write-Host "Done" -foregroundcolor green

# Prompt to build binaries 7z
Expand All @@ -115,17 +81,17 @@ if ($buildbinaries.ToLower() -eq "y")
$timestamp = ""
}

Write-Host "`nBuiling win32 binaries 7z..." -foregroundcolor yellow
Write-Host "`nBuiling win32 binaries 7z..." -foregroundcolor blue
& $7zpath a -t7z "$releasedir\slade_${version}${timestamp}.7z" `
"$releasedir32\SLADE.exe" `
"$releasedir32\SLADE.pdb" `
"$releasedir\slade.pk3"
Write-Host "Done" -foregroundcolor green

Write-Host "`nBuiling x64 binaries 7z..." -foregroundcolor yellow
Write-Host "`nBuiling x64 binaries 7z..." -foregroundcolor blue
& $7zpath a -t7z "$releasedir\slade_${version}_x64${timestamp}.7z" `
"$releasedir64\SLADE.exe" `
"$releasedir64\SLADE-x64.pdb" `
"$releasedir64\SLADE.pdb" `
"$releasedir\slade.pk3"
Write-Host "Done" -foregroundcolor green
}
Expand All @@ -144,11 +110,11 @@ if ($buildinstaller.ToLower() -eq "y")
}
if (Test-Path $innocompiler)
{
Write-Host "`nBuiling x86 installer..." -foregroundcolor yellow
Write-Host "`nBuiling x86 installer..." -foregroundcolor blue
& $innocompiler "/O+" "/O$releasedir" (resolve-path "..\win_installer\SLADE-x86.iss").Path
Write-Host "Done" -foregroundcolor green

Write-Host "`nBuiling x64 installer..." -foregroundcolor yellow
Write-Host "`nBuiling x64 installer..." -foregroundcolor blue
& $innocompiler "/O+" "/O$releasedir" (resolve-path "..\win_installer\SLADE-x64.iss").Path
Write-Host "Done" -foregroundcolor green
}
Expand Down
Loading

0 comments on commit bb8b2ec

Please sign in to comment.