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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CMakeList.txt : CMake project for OpenSHC

cmake_minimum_required (VERSION 3.20)
cmake_minimum_required (VERSION 3.21)

# NOTE: POST_BUILD does not run if the target is unchanged, so a config switch will not trigger them again, so clean + build if issues happen
function(target_file_copy_if_different TARGET FILE DEST)
Expand Down
36 changes: 32 additions & 4 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 19,
"minor": 21,
"patch": 0
},
"configurePresets": [
{
"name": "nmake-base",
"name": "configure-base",
"hidden": true,
"generator": "NMake Makefiles",
"binaryDir": "${sourceDir}/build-${presetName}",
Expand Down Expand Up @@ -41,19 +41,47 @@
},
{
"name": "Debug",
"inherits": "nmake-base",
"inherits": "configure-base",
"description": "VS2005 NMake (Debug) x86",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "${presetName}"
}
},
{
"name": "RelWithDebInfo",
"inherits": "nmake-base",
"inherits": "configure-base",
"description": "VS2005 NMake (RelWithDebInfo) x86",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "${presetName}"
}
}
],
"buildPresets": [
{
"name": "build-base",
"hidden": true,
"environment": {
"VSINSTALLDIR": "${sourceDir}/MSVC1400",
"VCINSTALLDIR": "${sourceDir}/MSVC1400/VC",
"FrameworkDir": "C:/WINDOWS/Microsoft.NET/Framework",
"FrameworkVersion": "v2.0.50727",
"FrameworkSDKDir": "${sourceDir}/MSVC1400/SDK/v2.0",
"DevEnvDir": "${sourceDir}/MSVC1400/Common7/IDE",
"PATH": "${sourceDir}/MSVC1400/Common7/IDE;${sourceDir}/MSVC1400/VC/bin;${sourceDir}/MSVC1400/Common7/Tools;${sourceDir}/MSVC1400/Common7/Tools/Bin;${sourceDir}/MSVC1400/VC/PlatformSDK/Bin;C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727",
"INCLUDE": "${sourceDir}/MSVC1400/VC/include;${sourceDir}/MSVC1400/VC/PlatformSDK/Include",
"LIB": "${sourceDir}/MSVC1400/VC/lib;${sourceDir}/MSVC1400/VC/PlatformSDK/Lib",
"LIBPATH": "C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727"
}
},
{
"name": "Debug",
"inherits": "build-base",
"configurePreset": "Debug"
},
{
"name": "RelWithDebInfo",
"inherits": "build-base",
"configurePreset": "RelWithDebInfo"
}
]
}
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,11 @@ Additionally, it configures format-on-save and a debug target for the UCP3.
If the scripts are preferred, the following triggers a build using the scripts:
1. Open a terminal. If the Visual Studio CMake version is used, it needs to be the CMD developer command prompt.
2. Navigate to this project folder
3. Invoke vsvars32-portable.bat from the MSVC1400 in the developer command prompt session. Check with `where cl.exe` to see if it was successful: cl.exe and link.exe are supposed to be executed from your MSVC1400 folder. `where cmake` should point to your CMake installation.
4. Execute build.bat:
3. Execute build.bat:
```sh
build.bat RelWithDebInfo
```
5. Compare a function byte by byte to check compilation:
4. Compare a function byte by byte to check compilation:
```sh
reccmp-reccmp --target STRONGHOLDCRUSADER --verbose 0x401000
```
Expand Down
121 changes: 31 additions & 90 deletions build.bat
Original file line number Diff line number Diff line change
@@ -1,70 +1,17 @@
@echo off
setlocal EnableDelayedExpansion

:: --- Validate task parameter (clean, build, rebuild) ---
:: --- Validate preset parameter (required) ---
if "%~1"=="" (
echo [ERROR] Task not specified.
echo Usage: %~nx0 [clean^|build^|rebuild] [BuildType]
echo [ERROR] Preset not specified.
echo Usage: %~nx0 ^<Preset^> [Target]
echo ^<Preset^> : Required. The CMake configure/build preset to use.
echo [Target] : Optional. The specific target to build. If omitted, the default target will be built.
exit /b 1
)

set "TASK=%~1"

if /I not "%TASK%"=="clean" if /I not "%TASK%"=="build" if /I not "%TASK%"=="rebuild" (
echo [ERROR] Invalid task: "%TASK%"
echo Valid tasks are: clean, build, rebuild
exit /b 1
)

:: --- Validate build type parameter (must be only letters) ---
if "%~2"=="" (
echo [ERROR] Build type not specified.
echo Usage: %~nx0 [clean^|build^|rebuild] [BuildType]
exit /b 1
)

:: --- Validate that is is at least all letters, also need to use "." hack due to piping issue with *$ in findstr (. consumes \r) ---
echo %~2 | findstr /R "^[a-zA-Z][a-zA-Z]*.$" >nul
if errorlevel 1 (
echo [ERROR] Invalid build type: "%~2"
echo It must only contain letters ^(e.g., Debug, Release^).
exit /b 1
)

:: --- Set build directory ---
set "BUILD_DIR=build-%~2"

:: --- Clean build directory if task is clean or rebuild ---
if /I not "%TASK%"=="build" (
if exist "%BUILD_DIR%" (
echo Cleaning build directory "%BUILD_DIR%"...
rmdir /S /Q "%BUILD_DIR%"
if errorlevel 1 (
echo [ERROR] Failed to clean build directory "%BUILD_DIR%".
exit /b 1
)
echo Clean completed successfully.
) else (
echo Build directory "%BUILD_DIR%" does not exist. Nothing to clean.
)
)

:: --- If task is clean only, exit after cleaning ---
if /I "%TASK%"=="clean" (
exit /b 0
)

:: --- Check and load old environment into context ---
set "VSVARS=MSVC1400\vsvars32-portable.bat"
if not exist "%VSVARS%" (
echo [ERROR] Could not find environment setup script: %VSVARS%
exit /b 1
)
call "%VSVARS%"
if errorlevel 1 (
echo [ERROR] Failed to execute: %VSVARS%
exit /b 2
)
set "PRESET=%~1"
set "TARGET=%~2"

:: --- Check for cmake ---
where cmake >nul 2>nul
Expand All @@ -74,7 +21,9 @@ if errorlevel 1 (
echo [ERROR] 'vswhere' not found, cannot locate 'cmake'.
exit /b 1
)
FOR /F "tokens=* USEBACKQ" %%g IN (`"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath -requires Microsoft.VisualStudio.Component.VC.CMake.Project`) do (SET "CMAKE=%%g\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin")
FOR /F "tokens=* USEBACKQ" %%g IN (`"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath -requires Microsoft.VisualStudio.Component.VC.CMake.Project`) do (
SET "CMAKE=%%g\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin"
)
echo [INFO] Detected: "!CMAKE!"
if not exist "!CMAKE!" (
echo [ERROR] 'cmake' is not found in PATH and not found using vswhere.
Expand All @@ -83,47 +32,39 @@ if errorlevel 1 (
set "PATH=!CMAKE!;%PATH%"
)

:: --- Check for nmake ---
where nmake >nul 2>nul
if errorlevel 1 (
echo [ERROR] 'nmake' is not found in PATH.
exit /b 1
)

:: --- Kill mspdbsrv.exe if it's running ---
tasklist | find /I "mspdbsrv.exe" >nul
if not errorlevel 1 (
echo Stopping mspdbsrv.exe...
taskkill /f /t /im mspdbsrv.exe >nul
if errorlevel 1 (
echo [WARNING] Failed to stop mspdbsrv.exe, continuing...
)
)

:: --- Create build directory ---
if not exist "%BUILD_DIR%" (
mkdir "%BUILD_DIR%" >nul 2>&1
if errorlevel 1 (
echo [ERROR] Failed to create build directory "%BUILD_DIR%".
exit /b 1
)
)

:: --- Run cmake and nmake ---
pushd "%BUILD_DIR%"
cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=%~2
:: --- Run cmake configure using preset ---
echo [INFO] Configuring with preset "%PRESET%"...
cmake --preset "%PRESET%"
if errorlevel 1 (
echo [ERROR] cmake failed.
popd
echo [ERROR] CMake configure failed for preset "%PRESET%".
exit /b 1
)

nmake
if errorlevel 1 (
echo [ERROR] nmake build failed.
popd
exit /b 1
:: --- Run cmake build using preset ---
if "%TARGET%"=="" (
echo [INFO] Building preset "%PRESET%" with default target...
cmake --build --preset "%PRESET%"
if errorlevel 1 (
echo [ERROR] CMake build failed for preset "%PRESET%".
exit /b 1
)
echo Build completed successfully for preset "%PRESET%".
) else (
echo [INFO] Building preset "%PRESET%" with target "%TARGET%"...
cmake --build --preset "%PRESET%" --target "%TARGET%"
if errorlevel 1 (
echo [ERROR] CMake build failed for preset "%PRESET%" target "%TARGET%".
exit /b 1
)
echo Build completed successfully for preset "%PRESET%" target "%TARGET%".
)

popd
echo Build completed successfully for "%~2" configuration.
2 changes: 1 addition & 1 deletion create-include-lists.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Usage: cmake -P generate_file_list.cmake
# ======================================================================

cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.21)

function(generate_file_list SOURCE_ROOT PATTERNS_LIST OUTPUT_FILE)
set(ALL_ENTRIES "")
Expand Down