fxos: add a CMake option to post-process compiler logs

This commit is contained in:
Lephenixnoir 2023-09-03 19:11:44 +02:00
parent 6406f05eb2
commit 3e620280c0
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
2 changed files with 23 additions and 2 deletions

View File

@ -6,6 +6,24 @@ add_compile_options(
-Wall -Wextra -D_GNU_SOURCE -std=c++17 -O2
-fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}/=)
# Diagnostic options to clean up output a little bit
if(FXOS_CLEAN_LOGS)
add_compile_options(
-fdiagnostics-urls=never -fno-diagnostics-show-caret
-fdiagnostics-color=always -fno-diagnostics-show-labels -fno-show-column)
# Filter the compiler output through a filter script
file(WRITE "${PROJECT_BINARY_DIR}/compiler_filter.sh" "\
set -e \n\
set -o pipefail \n\
\"$@\" |& sed 's#${PROJECT_SOURCE_DIR}/##g' \n\
")
file(CHMOD "${PROJECT_BINARY_DIR}/compiler_filter.sh"
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE
"${PROJECT_BINARY_DIR}/compiler_filter.sh")
endif()
#---
# fxos core
#---

View File

@ -33,11 +33,14 @@ requirements.
* flex (2.6.4)
* CMake (3.15) and make (eg. 4.2.1)
The only real configure option is the install path. CMake's default is
There are two configure options:
* `-DCMAKE_INSTALL_PREFIX=<PATH>`: the install path. CMake's default is
`/usr/local`; a viable alternative is `$HOME/.local`.
* `-DFXOS_CLEAN_LOGS=1`: enables basic compiler output filtering to get error messages under control. Tested with GCC.
```sh
% cmake -B build # -DCMAKE_INSTALL_PREFIX=$HOME/.local
% cmake -B build # -DCMAKE_INSTALL_PREFIX=$HOME/.local -DFXOS_CLEAN_LOGS=1
% make -C build -j$(nproc) install
```