Skip to content

Commit 502630d

Browse files
author
sourcehold
committed
Merge branch 'main' of https://github.com/sourcehold/openshc into conversions/style3
2 parents 5d23be8 + ce4638d commit 502630d

5 files changed

Lines changed: 73 additions & 100 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# CMakeList.txt : CMake project for OpenSHC
22

3-
cmake_minimum_required (VERSION 3.20)
3+
cmake_minimum_required (VERSION 3.21)
44

55
# 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
66
function(target_file_copy_if_different TARGET FILE DEST)

CMakePresets.json

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
"version": 3,
33
"cmakeMinimumRequired": {
44
"major": 3,
5-
"minor": 19,
5+
"minor": 21,
66
"patch": 0
77
},
88
"configurePresets": [
99
{
10-
"name": "nmake-base",
10+
"name": "configure-base",
1111
"hidden": true,
1212
"generator": "NMake Makefiles",
1313
"binaryDir": "${sourceDir}/build-${presetName}",
@@ -41,19 +41,47 @@
4141
},
4242
{
4343
"name": "Debug",
44-
"inherits": "nmake-base",
44+
"inherits": "configure-base",
4545
"description": "VS2005 NMake (Debug) x86",
4646
"cacheVariables": {
4747
"CMAKE_BUILD_TYPE": "${presetName}"
4848
}
4949
},
5050
{
5151
"name": "RelWithDebInfo",
52-
"inherits": "nmake-base",
52+
"inherits": "configure-base",
5353
"description": "VS2005 NMake (RelWithDebInfo) x86",
5454
"cacheVariables": {
5555
"CMAKE_BUILD_TYPE": "${presetName}"
5656
}
5757
}
58+
],
59+
"buildPresets": [
60+
{
61+
"name": "build-base",
62+
"hidden": true,
63+
"environment": {
64+
"VSINSTALLDIR": "${sourceDir}/MSVC1400",
65+
"VCINSTALLDIR": "${sourceDir}/MSVC1400/VC",
66+
"FrameworkDir": "C:/WINDOWS/Microsoft.NET/Framework",
67+
"FrameworkVersion": "v2.0.50727",
68+
"FrameworkSDKDir": "${sourceDir}/MSVC1400/SDK/v2.0",
69+
"DevEnvDir": "${sourceDir}/MSVC1400/Common7/IDE",
70+
"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",
71+
"INCLUDE": "${sourceDir}/MSVC1400/VC/include;${sourceDir}/MSVC1400/VC/PlatformSDK/Include",
72+
"LIB": "${sourceDir}/MSVC1400/VC/lib;${sourceDir}/MSVC1400/VC/PlatformSDK/Lib",
73+
"LIBPATH": "C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727"
74+
}
75+
},
76+
{
77+
"name": "Debug",
78+
"inherits": "build-base",
79+
"configurePreset": "Debug"
80+
},
81+
{
82+
"name": "RelWithDebInfo",
83+
"inherits": "build-base",
84+
"configurePreset": "RelWithDebInfo"
85+
}
5886
]
5987
}

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,11 @@ Additionally, it configures format-on-save and a debug target for the UCP3.
5959
If the scripts are preferred, the following triggers a build using the scripts:
6060
1. Open a terminal. If the Visual Studio CMake version is used, it needs to be the CMD developer command prompt.
6161
2. Navigate to this project folder
62-
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.
63-
4. Execute build.bat:
62+
3. Execute build.bat:
6463
```sh
6564
build.bat RelWithDebInfo
6665
```
67-
5. Compare a function byte by byte to check compilation:
66+
4. Compare a function byte by byte to check compilation:
6867
```sh
6968
reccmp/run reccmp-reccmp --target STRONGHOLDCRUSADER --verbose 0x401000
7069
```

build.bat

Lines changed: 37 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,17 @@
11
@echo off
22
setlocal EnableDelayedExpansion
33

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

11-
set "TASK=%~1"
12-
13-
if /I not "%TASK%"=="clean" if /I not "%TASK%"=="build" if /I not "%TASK%"=="rebuild" (
14-
echo [ERROR] Invalid task: "%TASK%"
15-
echo Valid tasks are: clean, build, rebuild
16-
exit /b 1
17-
)
18-
19-
:: --- Validate build type parameter (must be only letters) ---
20-
if "%~2"=="" (
21-
echo [ERROR] Build type not specified.
22-
echo Usage: %~nx0 [clean^|build^|rebuild] [BuildType]
23-
exit /b 1
24-
)
25-
26-
:: --- Validate that is is at least all letters, also need to use "." hack due to piping issue with *$ in findstr (. consumes \r) ---
27-
echo %~2 | findstr /R "^[a-zA-Z][a-zA-Z]*.$" >nul
28-
if errorlevel 1 (
29-
echo [ERROR] Invalid build type: "%~2"
30-
echo It must only contain letters ^(e.g., Debug, Release^).
31-
exit /b 1
32-
)
33-
34-
:: --- Set build directory ---
35-
set "BUILD_DIR=build-%~2"
36-
37-
:: --- Clean build directory if task is clean or rebuild ---
38-
if /I not "%TASK%"=="build" (
39-
if exist "%BUILD_DIR%" (
40-
echo Cleaning build directory "%BUILD_DIR%"...
41-
rmdir /S /Q "%BUILD_DIR%"
42-
if errorlevel 1 (
43-
echo [ERROR] Failed to clean build directory "%BUILD_DIR%".
44-
exit /b 1
45-
)
46-
echo Clean completed successfully.
47-
) else (
48-
echo Build directory "%BUILD_DIR%" does not exist. Nothing to clean.
49-
)
50-
)
51-
52-
:: --- If task is clean only, exit after cleaning ---
53-
if /I "%TASK%"=="clean" (
54-
exit /b 0
55-
)
56-
57-
:: --- Check and load old environment into context ---
58-
set "VSVARS=MSVC1400\vsvars32-portable.bat"
59-
if not exist "%VSVARS%" (
60-
echo [ERROR] Could not find environment setup script: %VSVARS%
61-
exit /b 1
62-
)
63-
call "%VSVARS%"
64-
if errorlevel 1 (
65-
echo [ERROR] Failed to execute: %VSVARS%
66-
exit /b 2
67-
)
13+
set "PRESET=%~1"
14+
set "TARGET=%~2"
6815

6916
:: --- Check for cmake ---
7017
where cmake >nul 2>nul
@@ -74,56 +21,55 @@ if errorlevel 1 (
7421
echo [ERROR] 'vswhere' not found, cannot locate 'cmake'.
7522
exit /b 1
7623
)
77-
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")
78-
echo [INFO] Detected: "!CMAKE!"
24+
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 (
25+
SET "CMAKE=%%g\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin"
26+
)
27+
if not exist "!CMAKE!" (
28+
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 -products Microsoft.VisualStudio.Product.BuildTools` ) do (
29+
SET "CMAKE=%%g\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin"
30+
)
31+
)
7932
if not exist "!CMAKE!" (
8033
echo [ERROR] 'cmake' is not found in PATH and not found using vswhere.
8134
exit /b 1
8235
)
36+
echo [INFO] Detected: "!CMAKE!"
8337
set "PATH=!CMAKE!;%PATH%"
8438
)
8539

86-
:: --- Check for nmake ---
87-
where nmake >nul 2>nul
88-
if errorlevel 1 (
89-
echo [ERROR] 'nmake' is not found in PATH.
90-
exit /b 1
91-
)
92-
9340
:: --- Kill mspdbsrv.exe if it's running ---
9441
tasklist | find /I "mspdbsrv.exe" >nul
9542
if not errorlevel 1 (
9643
echo Stopping mspdbsrv.exe...
9744
taskkill /f /t /im mspdbsrv.exe >nul
9845
if errorlevel 1 (
9946
echo [WARNING] Failed to stop mspdbsrv.exe, continuing...
100-
)
101-
)
102-
103-
:: --- Create build directory ---
104-
if not exist "%BUILD_DIR%" (
105-
mkdir "%BUILD_DIR%" >nul 2>&1
106-
if errorlevel 1 (
107-
echo [ERROR] Failed to create build directory "%BUILD_DIR%".
108-
exit /b 1
10947
)
11048
)
11149

112-
:: --- Run cmake and nmake ---
113-
pushd "%BUILD_DIR%"
114-
cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=%~2
50+
:: --- Run cmake configure using preset ---
51+
echo [INFO] Configuring with preset "%PRESET%"...
52+
cmake --preset "%PRESET%"
11553
if errorlevel 1 (
116-
echo [ERROR] cmake failed.
117-
popd
54+
echo [ERROR] CMake configure failed for preset "%PRESET%".
11855
exit /b 1
11956
)
12057

121-
nmake
122-
if errorlevel 1 (
123-
echo [ERROR] nmake build failed.
124-
popd
125-
exit /b 1
58+
:: --- Run cmake build using preset ---
59+
if "%TARGET%"=="" (
60+
echo [INFO] Building preset "%PRESET%" with default target...
61+
cmake --build --preset "%PRESET%"
62+
if errorlevel 1 (
63+
echo [ERROR] CMake build failed for preset "%PRESET%".
64+
exit /b 1
65+
)
66+
echo Build completed successfully for preset "%PRESET%".
67+
) else (
68+
echo [INFO] Building preset "%PRESET%" with target "%TARGET%"...
69+
cmake --build --preset "%PRESET%" --target "%TARGET%"
70+
if errorlevel 1 (
71+
echo [ERROR] CMake build failed for preset "%PRESET%" target "%TARGET%".
72+
exit /b 1
73+
)
74+
echo Build completed successfully for preset "%PRESET%" target "%TARGET%".
12675
)
127-
128-
popd
129-
echo Build completed successfully for "%~2" configuration.

create-include-lists.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Usage: cmake -P generate_file_list.cmake
66
# ======================================================================
77

8-
cmake_minimum_required(VERSION 3.20)
8+
cmake_minimum_required(VERSION 3.21)
99

1010
function(generate_file_list SOURCE_ROOT PATTERNS_LIST OUTPUT_FILE)
1111
set(ALL_ENTRIES "")

0 commit comments

Comments
 (0)