my gitlab build stage gets exited during make-phase with errorcode 1 because inaktive code (which is grayed out in the IDE but not in the .c/.h files uploaded to the repository).
As an example i want to point out the following errormessage:
Example errormessage
../gecko_sdk_4.2.2/platform/radio/rail_lib/chip/efr32/efr32xg2x/rail_chip_specific.h:610:2: error: #error "This config is not valid, RAIL_RF_PATHS has to be either 1 or 2"
610 | #error "This config is not valid, RAIL_RF_PATHS has to be either 1 or 2"
| ^~~~~
In my IDE this specific segment of code is grayed out, which means it should be ignored. In IDE
How to fix all the issues, where do i have to make changes to my configuration.
My buildprocess errorlog:
$ build-wrapper/build-wrapper-linux-x86-64 --out-dir "${BUILD_WRAPPER_OUT_DIR}" make clean all
Making clean in ownSources
make[1]: Entering directory '/builds/root/honeyhtx02/ownSources'
test -z "sonar_scanner_example" || rm -f sonar_scanner_example
rm -f *.o
make[1]: Leaving directory '/builds/root/honeyhtx02/ownSources'
make[1]: Entering directory '/builds/root/honeyhtx02'
make[1]: Nothing to be done for 'clean-am'.
make[1]: Leaving directory '/builds/root/honeyhtx02'
Making all in ownSources
make[1]: Entering directory '/builds/root/honeyhtx02/ownSources'
gcc -DPACKAGE_NAME=\"sonar_scanner_example\" -DPACKAGE_TARNAME=\"sonar_scanner_example\" -DPACKAGE_VERSION=\"1.0\" -DPACKAGE_STRING=\"sonar_scanner_example\ 1.0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"sonar_scanner_example\" -DVERSION=\"1.0\" -I. -I../ownHeaders -I../gecko_sdk_4.2.2/platform/Device/SiliconLabs/EFR32ZG28/Include -I../gecko_sdk_4.2.2/platform/common/inc -I../gecko_sdk_4.2.2/platform/CMSIS/Core/Include -I../gecko_sdk_4.2.2/platform/service/device_init/inc -I../gecko_sdk_4.2.2/platform/emlib/inc -I../gecko_sdk_4.2.2/platform/service/hfxo_manager/inc -I../gecko_sdk_4.2.2/platform/security/sl_component/sl_mbedtls_support/config -I../gecko_sdk_4.2.2/platform/security/sl_component/sl_mbedtls_support/inc -I../gecko_sdk_4.2.2/util/third_party/mbedtls/include -I../gecko_sdk_4.2.2/util/third_party/mbedtls/library -I../gecko_sdk_4.2.2/platform/service/mpu/inc -I../gecko_sdk_4.2.2/platform/peripheral/inc -I../gecko_sdk_4.2.2/platform/service/power_manager/inc -I../gecko_sdk_4.2.2/platform/security/sl_component/sl_psa_driver/inc/public -I../gecko_sdk_4.2.2/platform/security/sl_component/sl_psa_driver/inc -I../gecko_sdk_4.2.2/platform/radio/rail_lib/common -I../gecko_sdk_4.2.2/platform/radio/rail_lib/protocol/ble -I../gecko_sdk_4.2.2/platform/radio/rail_lib/protocol/ieee802154 -I../gecko_sdk_4.2.2/platform/radio/rail_lib/protocol/zwave -I../gecko_sdk_4.2.2/platform/radio/rail_lib/chip/efr32/efr32xg2x -I../gecko_sdk_4.2.2/platform/radio/rail_lib/plugin/rail_util_callbacks -I../gecko_sdk_4.2.2/platform/radio/rail_lib/plugin/rail_util_protocol -I../gecko_sdk_4.2.2/platform/security/sl_component/se_manager/inc -I../gecko_sdk_4.2.2/platform/security/sl_component/se_manager/src -I../gecko_sdk_4.2.2/util/silicon_labs/silabs_core/memory_manager -I../gecko_sdk_4.2.2/app/flex/component/rail/sl_flex_rail_sleep -I../gecko_sdk_4.2.2/platform/common/toolchain/inc -I../gecko_sdk_4.2.2/platform/service/system/inc -I../gecko_sdk_4.2.2/platform/service/sleeptimer/inc -I../config -I../config/rail -I../autogen -I../ownTempo -I../ownSources -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
In file included from ../gecko_sdk_4.2.2/platform/service/power_manager/inc/sl_power_manager.h:37,
from main.c:37:
../gecko_sdk_4.2.2/platform/Device/SiliconLabs/EFR32ZG28/Include/em_device.h:93:2: error: #error "em_device.h: PART NUMBER undefined"
93 | #error "em_device.h: PART NUMBER undefined"
| ^~~~~
In file included from ../gecko_sdk_4.2.2/platform/service/power_manager/inc/sl_power_manager.h:38:
../gecko_sdk_4.2.2/platform/emlib/inc/em_core.h:74:33: error: 'EXT_IRQ_COUNT' undeclared here (not in a function)
74 | #define CORE_NVIC_REG_WORDS ((EXT_IRQ_COUNT + 31) / 32)
| ^~~~~~~~~~~~~
../gecko_sdk_4.2.2/platform/emlib/inc/em_core.h:298:14: note: in expansion of macro 'CORE_NVIC_REG_WORDS'
298 | uint32_t a[CORE_NVIC_REG_WORDS]; /*!< Array of NVIC mask words. */
| ^~~~~~~~~~~~~~~~~~~
../gecko_sdk_4.2.2/platform/emlib/inc/em_core.h:318:25: error: unknown type name 'IRQn_Type'
318 | bool CORE_IrqIsBlocked(IRQn_Type irqN);
| ^~~~~~~~~
../gecko_sdk_4.2.2/platform/emlib/inc/em_core.h:329:27: error: unknown type name 'IRQn_Type'
329 | void CORE_NvicMaskSetIRQ(IRQn_Type irqN, CORE_nvicMask_t *mask);
| ^~~~~~~~~
../gecko_sdk_4.2.2/platform/emlib/inc/em_core.h:330:29: error: unknown type name 'IRQn_Type'
330 | void CORE_NvicMaskClearIRQ(IRQn_Type irqN, CORE_nvicMask_t *mask);
| ^~~~~~~~~
../gecko_sdk_4.2.2/platform/emlib/inc/em_core.h:331:28: error: unknown type name 'IRQn_Type'
331 | bool CORE_NvicIRQDisabled(IRQn_Type irqN);
| ^~~~~~~~~
../gecko_sdk_4.2.2/platform/emlib/inc/em_core.h:333:35: error: unknown type name 'IRQn_Type'
333 | void *CORE_GetNvicRamTableHandler(IRQn_Type irqN);
| ^~~~~~~~~
../gecko_sdk_4.2.2/platform/emlib/inc/em_core.h:334:35: error: unknown type name 'IRQn_Type'
334 | void CORE_SetNvicRamTableHandler(IRQn_Type irqN, void *handler);
| ^~~~~~~~~
In file included from ../gecko_sdk_4.2.2/platform/radio/rail_lib/common/rail_types.h:4736,
from ../gecko_sdk_4.2.2/platform/radio/rail_lib/common/rail.h:38,
from ../ownHeaders/app_init.h:36,
from main.c:39:
../gecko_sdk_4.2.2/platform/radio/rail_lib/chip/efr32/efr32xg2x/rail_chip_specific.h:153:2: error: #error "Unsupported platform!"
153 | #error "Unsupported platform!"
| ^~~~~
../gecko_sdk_4.2.2/platform/radio/rail_lib/chip/efr32/efr32xg2x/rail_chip_specific.h:610:2: error: #error "This config is not valid, RAIL_RF_PATHS has to be either 1 or 2"
610 | #error "This config is not valid, RAIL_RF_PATHS has to be either 1 or 2"
| ^~~~~
In file included from main.c:65:
../ownHeaders/tlcd_gd3632_v4.h:186:24: warning: backslash and newline separated by space
186 | true,true,true,true, \
|
../ownHeaders/tlcd_gd3632_v4.h:516:16: error: expected ';' before 'void'
516 | static __INLINE void HLCD_Blink(bool b_blink)
| ^ ~~~~
| ;
../ownHeaders/tlcd_gd3632_v4.h: In function 'HLCD_Blink':
../ownHeaders/tlcd_gd3632_v4.h:518:3: warning: implicit declaration of function 'LCD_BlinkEnable' [-Wimplicit-function-declaration]
518 | LCD_BlinkEnable(b_blink);
| ^~~~~~~~~~~~~~~
make[1]: Leaving directory '/builds/root/honeyhtx02/ownSources'
make[1]: *** [Makefile:375: main.o] Error 1
make: *** [Makefile:331: all-recursive] Error 1
ERROR: Job failed: exit code 1
My .gitlab-ci.yml
image: gcc
variables:
SONAR_SERVER_URL: ${SonarQube_URL} # Replace with your SonarQube server URL
SONAR_SCANNER_VERSION: 5.0.1.3006 # Find the latest version in the "Linux" link on this page:
# https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/
BUILD_WRAPPER_OUT_DIR: build-wrapper-out/ # Directory where build-wrapper output will be placed
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
# note that SONAR_TOKEN is transmitted to the environment through Gitlab CI
get-sonar-binaries:
# this job download and unpacks the build-wrapper and the sonar-scanner
# in this example it is done for every build.
# This can be optimized by caching the files or better, by including them, in the build docker image.
stage: .pre
script:
# Download sonar-scanner
- curl -sSLo sonar-scanner.zip "https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_VERSION}-linux.zip"
- unzip -o sonar-scanner.zip
- mv sonar-scanner-${SONAR_SCANNER_VERSION}-linux sonar-scanner
# Download build-wrapper
- curl -sSLo build-wrapper.zip "${SONAR_SERVER_URL}/static/cpp/build-wrapper-linux-x86.zip"
- unzip -o build-wrapper.zip
- mv build-wrapper-linux-x86 build-wrapper
cache:
policy: push
key: "${CI_COMMIT_SHORT_SHA}"
paths:
- build-wrapper/ # to share the build-wrapper between jobs
- sonar-scanner/ # to share the sonar-scanner between jobs
build:
stage: build
# install the necessary build tools when needed
before_script:
- apt update && apt -y install autotools-dev
script:
# prepare the build tree
- autoreconf --install
- ./configure
# run the build inside the build wrapper
- build-wrapper/build-wrapper-linux-x86-64 --out-dir "${BUILD_WRAPPER_OUT_DIR}" make clean all
artifacts:
paths:
- sonar_scanner_example
cache:
policy: pull-push
key: "${CI_COMMIT_SHORT_SHA}"
paths:
- build-wrapper/
- sonar-scanner/
- "${BUILD_WRAPPER_OUT_DIR}"
sonarqube-check:
stage: .post
cache:
policy: pull
key: "${CI_COMMIT_SHORT_SHA}"
paths:
- sonar-scanner/
- "${BUILD_WRAPPER_OUT_DIR}"
script:
- sonar-scanner/bin/sonar-scanner --define sonar.host.url="${SONAR_SERVER_URL}" --define sonar.cfamily.build-wrapper-output="${BUILD_WRAPPER_OUT_DIR}"
only:
- merge_requests
- main
- develop
My Makefile.am
bin_PROGRAMS = sonar_scanner_example
sonar_scanner_example_SOURCES = main.c
AM_CPPFLAGS = -I../ownHeaders
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/platform/Device/SiliconLabs/EFR32ZG28/Include
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/platform/common/inc
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/platform/CMSIS/Core/Include
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/platform/service/device_init/inc
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/platform/emlib/inc
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/platform/service/hfxo_manager/inc
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/platform/security/sl_component/sl_mbedtls_support/config
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/platform/security/sl_component/sl_mbedtls_support/inc
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/util/third_party/mbedtls/include
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/util/third_party/mbedtls/library
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/platform/service/mpu/inc
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/platform/peripheral/inc
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/platform/service/power_manager/inc
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/platform/security/sl_component/sl_psa_driver/inc/public
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/platform/security/sl_component/sl_psa_driver/inc
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/platform/radio/rail_lib/common
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/platform/radio/rail_lib/protocol/ble
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/platform/radio/rail_lib/protocol/ieee802154
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/platform/radio/rail_lib/protocol/zwave
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/platform/radio/rail_lib/chip/efr32/efr32xg2x
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/platform/radio/rail_lib/plugin/rail_util_callbacks
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/platform/radio/rail_lib/plugin/rail_util_protocol
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/platform/security/sl_component/se_manager/inc
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/platform/security/sl_component/se_manager/src
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/util/silicon_labs/silabs_core/memory_manager
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/app/flex/component/rail/sl_flex_rail_sleep
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/platform/common/toolchain/inc
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/platform/service/system/inc
AM_CPPFLAGS += -I../gecko_sdk_4.2.2/platform/service/sleeptimer/inc
AM_CPPFLAGS += -I../config
AM_CPPFLAGS += -I../config/rail
AM_CPPFLAGS += -I../autogen
AM_CPPFLAGS += -I../ownTempo
AM_CPPFLAGS += -I../ownSources
My configure.ac
AC_INIT([sonar_scanner_example], [1.0])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_PROG_CC
AC_CONFIG_FILES([
Makefile
ownSources/Makefile
])
AC_OUTPUT
Code analysis with sonarqube in gitlab via CI-Pipeline
Expectation: Successful build stage. Reality: Total confusion.
I added the required define for the board i use (EFR32ZG...) in my configure.ac .
and as a result the issue was solved but the next appeared.
Besides the warnings, it seems like some function in my main.c can't be referenced. In my makefile.am paths to all required headers are listed. Some functions aren't referenced even though the paths to the source files are listed in the makefile.am as well.