Skip to content

Commit cd8a7b4

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 86cdc4b commit cd8a7b4

File tree

4 files changed

+65
-6
lines changed

4 files changed

+65
-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: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,15 @@ 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

89+
# For testing build-options
90+
export BUILD_OPTIONS_TEST_MCU := LTO ALL_IN_ONE
91+
export BUILD_OPTIONS_TEST_NATIVE := $(BUILD_OPTIONS_TEST_MCU) VALGRIND VALGRIND_FREYA COMPILER_DEFAULT_LIBC
92+
8993
# Directories
9094
export ROOT_DIR := $(shell pwd)
9195
export BUILD_DIR_PREFIX := $(ROOT_DIR)/build/obj
@@ -121,6 +125,15 @@ export JERRY_TEST_TARGETS_CP := \
121125
$(foreach __MODE,$(DEBUG_MODES) $(RELEASE_MODES), \
122126
$(__MODE).$(NATIVE_SYSTEM)-cp)
123127

128+
# Build-options test targets
129+
export JERRY_BUILD_OPTIONS_TEST_TARGETS := \
130+
$(foreach __MODE,$(RELEASE_MODES), \
131+
$(__MODE).$(NATIVE_SYSTEM) \
132+
$(foreach __SYSTEM,$(MCU_SYSTEMS), \
133+
$(__MODE).mcu_$(__SYSTEM)-$(firstword $(MCU_MODS))))
134+
135+
JERRY_BUILD_OPTIONS_TEST_TARGETS += unittests
136+
124137
# JS test suites (in the format of id:path)
125138
export JERRY_TEST_SUITE_J := j:$(ROOT_DIR)/tests/jerry
126139
export JERRY_TEST_SUITE_JTS := jts:$(ROOT_DIR)/tests/jerry-test-suite
@@ -304,6 +317,10 @@ check-vera:
304317
check-cppcheck:
305318
$(Q) $(call SHLOG,./tools/check-cppcheck.sh,$(OUT_DIR)/cppcheck.log,Cppcheck)
306319

320+
.PHONY: test-buildoptions
321+
test-buildoptions:
322+
$(Q) $(call SHLOG,./tools/test-buildoptions.sh "$(JERRY_BUILD_OPTIONS_TEST_TARGETS)" "$(BUILD_OPTIONS_TEST_NATIVE)" "$(BUILD_OPTIONS_TEST_MCU)",$(OUT_DIR)/test-buildoptions.log,Buildoptions test)
323+
307324
.PHONY: build
308325
build: build.$(NATIVE_SYSTEM) $(foreach __SYSTEM,$(MCU_SYSTEMS),build.mcu_$(__SYSTEM))
309326

@@ -332,6 +349,8 @@ precommit: prerequisites
332349
$(Q)+$(MAKE) --no-print-directory clean
333350
$(Q) echo "Running checks..."
334351
$(Q)+$(MAKE) --no-print-directory check-signed-off check-vera check-cppcheck
352+
$(Q) echo "...testing build-options..."
353+
$(Q)+$(MAKE) --no-print-directory test-buildoptions
335354
$(Q) echo "...building engine..."
336355
$(Q)+$(MAKE) --no-print-directory build
337356
$(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)" \

tools/test-buildoptions.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
# Copyright 2016 Samsung Electronics Co., Ltd.
4+
# Copyright 2016 University of Szeged
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
TARGETS=$1
19+
shift
20+
21+
BUILD_OPTIONS_NATIVE=$1
22+
shift
23+
24+
BUILD_OPTIONS_MCU=$1
25+
shift
26+
27+
for target in $TARGETS
28+
do
29+
if [[ "$target" =~ "mcu" ]]
30+
then
31+
current_options=$BUILD_OPTIONS_MCU
32+
else
33+
current_options=$BUILD_OPTIONS_NATIVE
34+
fi
35+
36+
for option in $current_options
37+
do
38+
make $option=ON $target || exit 1
39+
done
40+
done

0 commit comments

Comments
 (0)