Skip to content

Commit 66eae92

Browse files
author
Zsolt Borbély
committed
Test the build options
Add new build target: test-buildoptions Now every build option is tested on the proper targets. These are the native and the MCU targets in release mode and unittests. Therefore the USE_COMPILER_DEFAULT_LIBC build option is refactored. This check is integrated into the precommit process. JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély [email protected]
1 parent d4650bc commit 66eae92

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ project (Jerry C ASM)
113113
set(MCU_SCRIPT_GENERATED_HEADER ${CMAKE_BINARY_DIR}/generated.h)
114114

115115
# Should we use external libc?
116-
if(DEFINED USE_COMPILER_DEFAULT_LIBC AND USE_COMPILER_DEFAULT_LIBC STREQUAL "YES")
116+
if(DEFINED COMPILER_DEFAULT_LIBC AND COMPILER_DEFAULT_LIBC STREQUAL "ON")
117117
if(DEFINED EXTERNAL_LIBC_INTERFACE AND NOT EXTERNAL_LIBC_INTERFACE STREQUAL "UNDEFINED")
118-
message(FATAL_ERROR "EXTERNAL_LIBC_INTERFACE='${EXTERNAL_LIBC_INTERFACE}' should not be set in case compiler's default libc is used (USE_COMPILER_DEFAULT_LIBC=YES)")
118+
message(FATAL_ERROR "EXTERNAL_LIBC_INTERFACE='${EXTERNAL_LIBC_INTERFACE}' should not be set in case compiler's default libc is used (COMPILER_DEFAULT_LIBC=ON)")
119119
endif()
120120

121121
set(USE_JERRY_LIBC FALSE)

Makefile

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,20 @@ BUILD_NAME:=
8181
BUILD_NAME:=$(BUILD_NAME)-ALL_IN_ONE-$(ALL_IN_ONE)
8282
endif
8383

84-
# Flag, indicating whether to use compiler's default libc (YES / NO)
85-
ifneq ($(USE_COMPILER_DEFAULT_LIBC),)
86-
CMAKE_DEFINES:=$(CMAKE_DEFINES) -DUSE_COMPILER_DEFAULT_LIBC=$(USE_COMPILER_DEFAULT_LIBC)
84+
# Flag, indicating whether to use compiler's default libc (ON / OFF)
85+
ifneq ($(COMPILER_DEFAULT_LIBC),)
86+
CMAKE_DEFINES:=$(CMAKE_DEFINES) -DCOMPILER_DEFAULT_LIBC=$(COMPILER_DEFAULT_LIBC)
8787
endif
8888

8989
# Apply strip to release binaries
9090
ifneq ($(STRIP_RELEASE_BINARY),)
9191
CMAKE_DEFINES:=$(CMAKE_DEFINES) -DSTRIP_RELEASE_BINARY=$(STRIP_RELEASE_BINARY)
9292
endif
9393

94+
# For testing build-options
95+
export BUILD_OPTIONS_TEST_MCU := LTO ALL_IN_ONE
96+
export BUILD_OPTIONS_TEST_NATIVE := $(BUILD_OPTIONS_TEST_MCU) VALGRIND VALGRIND_FREYA COMPILER_DEFAULT_LIBC
97+
9498
# Directories
9599
export ROOT_DIR := $(shell pwd)
96100
export BUILD_DIR_PREFIX := $(ROOT_DIR)/build/obj
@@ -128,6 +132,15 @@ export JERRY_TEST_TARGETS_CP := \
128132
$(foreach __MODE,$(DEBUG_MODES) $(RELEASE_MODES), \
129133
$(__MODE).$(NATIVE_SYSTEM)-cp)
130134

135+
# Build-options test targets
136+
export JERRY_BUILD_OPTIONS_TEST_TARGETS := \
137+
$(foreach __MODE,$(RELEASE_MODES), \
138+
$(__MODE).$(NATIVE_SYSTEM) \
139+
$(foreach __SYSTEM,$(MCU_SYSTEMS), \
140+
$(__MODE).mcu_$(__SYSTEM)))
141+
142+
JERRY_BUILD_OPTIONS_TEST_TARGETS += unittests
143+
131144
# JS test suites (in the format of id:path)
132145
export JERRY_TEST_SUITE_J := j:$(ROOT_DIR)/tests/jerry
133146
export JERRY_TEST_SUITE_JTS := jts:$(ROOT_DIR)/tests/jerry-test-suite
@@ -311,6 +324,19 @@ check-vera:
311324
check-cppcheck:
312325
$(Q) $(call SHLOG,./tools/check-cppcheck.sh,$(OUT_DIR)/cppcheck.log,Cppcheck)
313326

327+
.PHONY: test-buildoptions
328+
test-buildoptions:
329+
$(Q) for target in $(JERRY_BUILD_OPTIONS_TEST_TARGETS); do \
330+
if [[ $$target =~ "mcu" ]]; then \
331+
current_options=$$BUILD_OPTIONS_TEST_MCU; \
332+
else \
333+
current_options=$$BUILD_OPTIONS_TEST_NATIVE; \
334+
fi; \
335+
for option in $$current_options; do \
336+
$(MAKE) $$option=ON $$target || exit 1; \
337+
done \
338+
done
339+
314340
.PHONY: build
315341
build: build.$(NATIVE_SYSTEM) $(foreach __SYSTEM,$(MCU_SYSTEMS),build.mcu_$(__SYSTEM))
316342

@@ -339,6 +365,8 @@ precommit: prerequisites
339365
$(Q)+$(MAKE) --no-print-directory clean
340366
$(Q) echo "Running checks..."
341367
$(Q)+$(MAKE) --no-print-directory check-signed-off check-vera check-cppcheck
368+
$(Q) echo "...testing build-options..."
369+
$(Q)+$(MAKE) --no-print-directory test-buildoptions
342370
$(Q) echo "...building engine..."
343371
$(Q)+$(MAKE) --no-print-directory build
344372
$(Q) echo "...building and running unit tests..."

targets/mbedk64f/Makefile.mbedk64f

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jerry:
4141
-DENABLE_LTO=OFF \
4242
-DENABLE_VALGRIND=OFF \
4343
-DCMAKE_TOOLCHAIN_FILE=build/configs/toolchain_external.cmake \
44-
-DUSE_COMPILER_DEFAULT_LIBC=YES \
44+
-DCOMPILER_DEFAULT_LIBC=ON \
4545
-DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=arm7-m \
4646
-DEXTERNAL_CMAKE_C_COMPILER=arm-none-eabi-gcc \
4747
-DEXTERNAL_COMPILE_FLAGS="$(EXT_CFLAGS)" \

0 commit comments

Comments
 (0)