Skip to content

Commit 079fb00

Browse files
committed
Minor docs update, code review changes, script modifications.
1 parent 4474cf8 commit 079fb00

File tree

5 files changed

+143
-24
lines changed

5 files changed

+143
-24
lines changed

CMakeLists.txt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@
3333

3434
message(STATUS "Begin [WOLFBOOT_ROOT]/CmakeLists.txt")
3535

36+
#---------------------------------------------------------------------------------------------
37+
# First, ensure no in-source build occurs.
38+
#---------------------------------------------------------------------------------------------
39+
if(NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
40+
message(FATAL_ERROR
41+
"In-source builds are not allowed for wolfBoot.\
42+
Run cmake from a separate directory from where CMakeLists.txt lives.\
43+
Clean up any stray cache or build directories and try again. \
44+
See [WOLFBOOT_ROOT]/docs/CMake.md for additional details.")
45+
endif()
46+
3647
message(STATUS "wolfBoot target: ${WOLFBOOT_TARGET}")
3748
message(STATUS "CMake version: ${CMAKE_VERSION}")
3849
message(STATUS "Generator: ${CMAKE_GENERATOR}")
@@ -46,14 +57,6 @@ include(cmake/config_defaults.cmake)
4657
#---------------------------------------------------------------------------------------------
4758
# Initial environment checks
4859
#---------------------------------------------------------------------------------------------
49-
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
50-
message(
51-
FATAL_ERROR
52-
"In-source builds are not allowed for wolfBoot.\
53-
Run cmake from a separate directory from where CMakeLists.txt lives.\
54-
NOTE: cmake will now create CMakeCache.txt and CMakeFiles/*.\
55-
You must delete them, or cmake will refuse to work.")
56-
endif()
5760

5861
# This must appear before project(wolfBoot)
5962
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
@@ -66,6 +69,7 @@ if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
6669
endif()
6770
endif()
6871

72+
6973
if(NOT DEFINED PREFERRED_HOST_CC_NAME_LIST OR PREFERRED_HOST_CC_NAME_LIST STREQUAL "")
7074
# set(PREFERRED_HOST_CC_NAME_LIST gcc clang cl)
7175
if(CMAKE_HOST_WIN32)

docs/CMake.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
See the [`WOLFBOOT_ROOT`/cmake/README.md](../cmake/README.md) file.
44

5+
## Important: No in-source builds.
6+
7+
One of the first checks in the `[WOLFBOOT_ROOT]/CMakeLists.txt` is whether `CMAKE_SOURCE_DIR` == `CMAKE_BINARY_DIR`.
8+
In-source builds are not supported. The provided wolfSSL presets will typically prevent this.
9+
Beware when integrating with existing projects or creating custom presets.
10+
511
### CMake - Presets
612

713
This section explains how to build wolfBoot using CMake Presets.
@@ -181,14 +187,14 @@ C:\Users\%USERNAME%\AppData\Local\CMakeTools
181187

182188
#### Tips & Gotchas
183189

184-
Out-of-source enforced: wolfBoots CMakeLists.txt blocks in-source builds;
190+
Out-of-source enforced: wolfBoot's CMakeLists.txt blocks in-source builds;
185191
presets default to `build-${presetName}` anyway.
186192

187193
Toolchain auto-select: If `WOLFBOOT_TARGET` is not x86_64_efi or sim,
188194
CMAKE_TOOLCHAIN_FILE defaults to `cmake/toolchain_arm-none-eabi.cmake`.
189195

190196
Windows host tools: When HOST_CC is `cl.exe`, CMakeLists.txt creates a
191-
lightweight `unistd.h` shim and adjusts flagsno manual changes needed.
197+
lightweight `unistd.h` shim and adjusts flags-no manual changes needed.
192198

193199
`$penv` vs `$env`: Use `$penv{VAR}` in environment to append to the existing
194200
process environment (keeps your PATH). `$env{VAR}` replaces it.

tools/keytools/README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ make wolfboot_signing_private_key.der SIGN=ED25519
3939
./tools/keytools/keygen --ed25519 -g wolfboot_signing_private_key.der
4040
```
4141

42+
Note the above example is a basic case where a single key is generated.
43+
The tool supports multiple keys both with `[-g privkey]` and `[-i pubkey]` parameters.
44+
45+
See the local docs [docs/keystore.md](../../docs/keystore.md)
46+
and the [wolfBoot Keystore section of the manual](https://www.wolfssl.com/documentation/manuals/wolfboot/appendix04.html)
47+
for additional details.
48+
4249
## Debugging and Development
4350

4451
### `DEBUG_SIGNTOOL`
@@ -48,12 +55,3 @@ Enables additional diagnostic messages that may be useful during development and
4855
### `WOLFBOOT_SHOW_INCLUDE`
4956

5057
Enables compile-time verbosity to indicate which `user_settings.h` file is being used.
51-
52-
Unless otherwise specified the `keygen` app will create:
53-
54-
1. `./wolfboot_signing_private_key.der` - the private key used for signing.
55-
2. `./keystore.der` - the public key.
56-
3. `src/keystore.c` - the public key, converted to c array.
57-
58-
Common pitfalls: mismatched keystore files in different directories. There should be exactly one
59-
instance of each of the above files in the build tree.

tools/scripts/cmake_test.bat

Lines changed: 103 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,104 @@
66
:: This test manually sets paths to cmake and include files (also assumes VS 2022 is installed, but can be any suitable path)
77
cls
88

9-
set "Path=C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\bin\HostX86\x86;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\VC\VCPackages;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\bin\Roslyn;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\;C:\Program Files (x86)\HTML Help Workshop;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\FSharp\Tools;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Team Tools\DiagnosticsHub\Collector;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\Extensions\Microsoft\CodeCoverage.Console;C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\\x86;C:\Program Files (x86)\Windows Kits\10\bin\\x86;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\\MSBuild\Current\Bin\amd64;C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\;C:\Program Files (x86)\VMware\VMware Workstation\bin\;C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Git\cmd;C:\SysGCC\esp32-master\tools\riscv32-esp-elf\esp-15.2.0_20250920\riscv32-esp-elf\bin;C:\SysGCC\esp32-master\tools\xtensa-esp-elf\esp-15.2.0_20250920\xtensa-esp-elf\bin;C:\Program Files (x86)\VMware\VMware Workstation\bin\;C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\Git\cmd;C:\Users\gojimmypi\AppData\Local\Microsoft\WindowsApps;C:\Users\gojimmypi\AppData\Local\Programs\Microsoft VS Code\bin;C:\ST\STM32CubeIDE_1.14.1\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_2.1.100.202311100844\tools\bin;C:\Program Files\Git\usr\bin\;C:\Users\gojimmypi\.dotnet\tools;C:\SysGCC\esp32-master\tools\riscv32-esp-elf\esp-13.2.0_20240530\riscv32-esp-elf\bin;C:\Users\gojimmypi\AppData\Local\Microsoft\WinGet\Packages\Ninja-build.Ninja_Microsoft.Winget.Source_8wekyb3d8bbwe;;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\VC\Linux\bin\ConnectionManagerExe"
10-
set "INCLUDE=C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\include;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\ATLMFC\include;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\VS\include;C:\Program Files (x86)\Windows Kits\10\include\10.0.26100.0\ucrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\um;C:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\shared;C:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\winrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\cppwinrt;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um"
11-
set "LIB=C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\ATLMFC\lib\x86;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\lib\x86;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x86;C:\Program Files (x86)\Windows Kits\10\lib\10.0.26100.0\ucrt\x86;C:\Program Files (x86)\Windows Kits\10\\lib\10.0.26100.0\\um\x86"
9+
:: Optionally hard code your paths like this:
10+
:: set "Path=C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\bin\HostX86\x86;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\VC\VCPackages;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\bin\Roslyn;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\;C:\Program Files (x86)\HTML Help Workshop;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\FSharp\Tools;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Team Tools\DiagnosticsHub\Collector;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\Extensions\Microsoft\CodeCoverage.Console;C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\\x86;C:\Program Files (x86)\Windows Kits\10\bin\\x86;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\\MSBuild\Current\Bin\amd64;C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\;C:\Program Files (x86)\VMware\VMware Workstation\bin\;C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Git\cmd;C:\SysGCC\esp32-master\tools\riscv32-esp-elf\esp-15.2.0_20250920\riscv32-esp-elf\bin;C:\SysGCC\esp32-master\tools\xtensa-esp-elf\esp-15.2.0_20250920\xtensa-esp-elf\bin;C:\Program Files (x86)\VMware\VMware Workstation\bin\;C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\Git\cmd;C:\Users\gojimmypi\AppData\Local\Microsoft\WindowsApps;C:\Users\gojimmypi\AppData\Local\Programs\Microsoft VS Code\bin;C:\ST\STM32CubeIDE_1.14.1\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_2.1.100.202311100844\tools\bin;C:\Program Files\Git\usr\bin\;C:\Users\gojimmypi\.dotnet\tools;C:\SysGCC\esp32-master\tools\riscv32-esp-elf\esp-13.2.0_20240530\riscv32-esp-elf\bin;C:\Users\gojimmypi\AppData\Local\Microsoft\WinGet\Packages\Ninja-build.Ninja_Microsoft.Winget.Source_8wekyb3d8bbwe;;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\VC\Linux\bin\ConnectionManagerExe"
11+
:: set "INCLUDE=C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\include;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\ATLMFC\include;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\VS\include;C:\Program Files (x86)\Windows Kits\10\include\10.0.26100.0\ucrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\um;C:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\shared;C:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\winrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\cppwinrt;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um"
12+
:: set "LIB=C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\ATLMFC\lib\x86;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\lib\x86;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x86;C:\Program Files (x86)\Windows Kits\10\lib\10.0.26100.0\ucrt\x86;C:\Program Files (x86)\Windows Kits\10\\lib\10.0.26100.0\\um\x86"
13+
14+
@echo off
15+
setlocal
16+
17+
echo [INFO] Checking Visual Studio / MSVC environment...
18+
19+
REM -------------------------------------------------------------------
20+
REM 1) Check whether Visual Studio is already on PATH
21+
REM -------------------------------------------------------------------
22+
echo %PATH% | findstr /I "Microsoft Visual Studio" >nul
23+
if errorlevel 1 (
24+
echo [WARN] Visual Studio not obviously found in PATH.
25+
echo [WARN] This test is expected to run from a Visual Studio Developer Command Prompt.
26+
) else (
27+
echo [INFO] Visual Studio paths detected in PATH.
28+
)
29+
30+
REM -------------------------------------------------------------------
31+
REM 2) Check VCToolsInstallDir
32+
REM -------------------------------------------------------------------
33+
if "%VCToolsInstallDir%"=="" (
34+
echo [WARN] VCToolsInstallDir is not defined.
35+
echo [WARN] You may not be running from a proper Developer Command Prompt.
36+
) else (
37+
echo [INFO] VCToolsInstallDir = "%VCToolsInstallDir%"
38+
)
39+
40+
REM -------------------------------------------------------------------
41+
REM 3) Check INCLUDE
42+
REM -------------------------------------------------------------------
43+
if "%INCLUDE%"=="" goto NO_INCLUDE
44+
45+
echo %INCLUDE% | findstr /I "VC\\Tools\\MSVC\\" >nul
46+
if errorlevel 1 goto INCLUDE_WARN
47+
48+
echo [INFO] INCLUDE contains VC\Tools\MSVC\ (looks OK).
49+
goto AFTER_INCLUDE
50+
51+
:NO_INCLUDE
52+
echo [ERROR] INCLUDE is not defined.
53+
echo [ERROR] Please run this test from a Visual Studio Developer Command Prompt.
54+
set VS_ENV_ERROR=1
55+
goto AFTER_INCLUDE
56+
57+
:INCLUDE_WARN
58+
echo [WARN] INCLUDE does not contain "VC\Tools\MSVC\".
59+
echo [WARN] Current INCLUDE is:
60+
echo %INCLUDE%
61+
set VS_ENV_WARN=1
62+
63+
:AFTER_INCLUDE
64+
65+
REM -------------------------------------------------------------------
66+
REM 4) Check LIB
67+
REM -------------------------------------------------------------------
68+
if "%LIB%"=="" goto NO_LIB
69+
70+
echo %LIB% | findstr /I "VC\\Tools\\MSVC\\" >nul
71+
if errorlevel 1 goto LIB_WARN
72+
73+
echo [INFO] LIB contains VC\Tools\MSVC\ (looks OK).
74+
goto AFTER_LIB
75+
76+
:NO_LIB
77+
echo [ERROR] LIB is not defined.
78+
echo [ERROR] Please run this test from a Visual Studio Developer Command Prompt.
79+
set VS_ENV_ERROR=1
80+
goto AFTER_LIB
81+
82+
:LIB_WARN
83+
echo [WARN] LIB does not contain "VC\Tools\MSVC\".
84+
echo [WARN] Current LIB is:
85+
echo %LIB%
86+
set VS_ENV_WARN=1
87+
88+
:AFTER_LIB
89+
90+
REM -------------------------------------------------------------------
91+
REM 5) Decide exit code (for CTest)
92+
REM -------------------------------------------------------------------
93+
if defined VS_ENV_ERROR (
94+
echo [ERROR] Visual Studio environment is incomplete. Failing test.
95+
endlocal & exit /b 1
96+
)
97+
98+
if defined VS_ENV_WARN (
99+
echo [WARN] Visual Studio environment has potential issues, but continuing.
100+
endlocal
101+
)
102+
103+
echo [INFO] Visual Studio environment looks good.
104+
endlocal
105+
106+
exit /b 0
12107

13108
:: We start in /tools/scripts, but build two directories up: from wolfBoot root
14109

@@ -49,6 +144,10 @@ echo Starting %~nx0 from %CD%
49144
:: End common start directory detection
50145

51146

147+
::------------------------------------------------------------------------------------
148+
:: CMake test
149+
::------------------------------------------------------------------------------------
150+
52151
:: Is CMake installed?
53152
where cmake >nul 2>&1
54153
if errorlevel 1 (
@@ -58,12 +157,11 @@ if errorlevel 1 (
58157
)
59158

60159

61-
62160
rmdir /s /q build-stm32l4
63161

64162
cmake --preset stm32l4
65163

66-
164+
:: Optional parallel build specification:
67165
:: cmake --build --preset stm32l4 --parallel 4 -v
68166

69167
cmake --build --preset stm32l4

tools/scripts/config2presets.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,19 @@ def run_cmake_and_report_unused(preset_name: str, repo_root: Path):
396396
combined += "\n"
397397
combined += proc.stderr
398398

399+
# If CMake failed, show the full output first so the error is visible.
400+
if proc.returncode != 0:
401+
print("")
402+
print("CMake configure for preset '{}' failed with exit code {}.".format(
403+
preset_name, proc.returncode
404+
))
405+
print("Full CMake output follows:")
406+
print("==============================================")
407+
print("============= BEGIN CMAKE OUTPUT =============")
408+
print(combined)
409+
print("============= END CMAKE OUTPUT =============")
410+
print("==============================================")
411+
399412
unused = extract_unused_vars(combined)
400413

401414
if unused:

0 commit comments

Comments
 (0)