Skip to content

Commit 34edee7

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. JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély [email protected]
1 parent af24694 commit 34edee7

File tree

3 files changed

+60
-9
lines changed

3 files changed

+60
-9
lines changed

CMakeLists.txt

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

116116
# Should we use external libc?
117-
if(DEFINED USE_COMPILER_DEFAULT_LIBC AND USE_COMPILER_DEFAULT_LIBC STREQUAL "YES")
117+
if(DEFINED COMPILER_DEFAULT_LIBC AND COMPILER_DEFAULT_LIBC STREQUAL "ON")
118118
if(DEFINED EXTERNAL_LIBC_INTERFACE AND NOT EXTERNAL_LIBC_INTERFACE STREQUAL "UNDEFINED")
119-
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)")
119+
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)")
120120
endif()
121121

122122
set(USE_JERRY_LIBC FALSE)

Makefile

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,19 @@ BUILD_NAME:=
7373
# LOG
7474
ifneq ($(LOG),)
7575
CMAKE_DEFINES:=$(CMAKE_DEFINES) -DENABLE_LOG=$(LOG)
76+
BUILD_NAME:=$(BUILD_NAME)-LOG-$(LOG)
7677
endif
7778

7879
# Date system calls
7980
ifneq ($(DATE_SYS_CALLS),)
8081
CMAKE_DEFINES:=$(CMAKE_DEFINES) -DENABLE_DATE_SYS_CALLS=$(DATE_SYS_CALLS)
82+
BUILD_NAME:=$(BUILD_NAME)-DATE_SYS_CALLS-$(DATE_SYS_CALLS)
8183
endif
8284

8385
# Fill error messages for builtin error objects
8486
ifneq ($(ERROR_MESSAGES),)
8587
CMAKE_DEFINES:=$(CMAKE_DEFINES) -DENABLE_ERROR_MESSAGES=$(ERROR_MESSAGES)
88+
BUILD_NAME:=$(BUILD_NAME)-ERROR_MESSAGES-$(ERROR_MESSAGES)
8689
endif
8790

8891
# All-in-one build
@@ -91,16 +94,21 @@ BUILD_NAME:=
9194
BUILD_NAME:=$(BUILD_NAME)-ALL_IN_ONE-$(ALL_IN_ONE)
9295
endif
9396

94-
# Flag, indicating whether to use compiler's default libc (YES / NO)
95-
ifneq ($(USE_COMPILER_DEFAULT_LIBC),)
96-
CMAKE_DEFINES:=$(CMAKE_DEFINES) -DUSE_COMPILER_DEFAULT_LIBC=$(USE_COMPILER_DEFAULT_LIBC)
97+
# Flag, indicating whether to use compiler's default libc (ON / OFF)
98+
ifneq ($(COMPILER_DEFAULT_LIBC),)
99+
CMAKE_DEFINES:=$(CMAKE_DEFINES) -DCOMPILER_DEFAULT_LIBC=$(COMPILER_DEFAULT_LIBC)
100+
BUILD_NAME:=$(BUILD_NAME)-COMPILER_DEFAULT_LIBC-$(COMPILER_DEFAULT_LIBC)
97101
endif
98102

99103
# Apply strip to release binaries
100104
ifneq ($(STRIP_RELEASE_BINARY),)
101105
CMAKE_DEFINES:=$(CMAKE_DEFINES) -DSTRIP_RELEASE_BINARY=$(STRIP_RELEASE_BINARY)
102106
endif
103107

108+
# For testing build-options
109+
export BUILD_OPTIONS_TEST_MCU := LTO LOG DATE_SYS_CALLS ERROR_MESSAGES ALL_IN_ONE
110+
export BUILD_OPTIONS_TEST_NATIVE := $(BUILD_OPTIONS_TEST_MCU) VALGRIND VALGRIND_FREYA COMPILER_DEFAULT_LIBC
111+
104112
# Directories
105113
export ROOT_DIR := $(shell pwd)
106114
export BUILD_DIR_PREFIX := $(ROOT_DIR)/build/obj
@@ -138,6 +146,18 @@ export JERRY_TEST_TARGETS_CP := \
138146
$(foreach __MODE,$(DEBUG_MODES) $(RELEASE_MODES), \
139147
$(__MODE).$(NATIVE_SYSTEM)-cp)
140148

149+
# Build-options test targets
150+
export JERRY_BUILD_OPTIONS_TEST_TARGETS_NATIVE := \
151+
$(foreach __MODE,$(RELEASE_MODES), \
152+
$(__MODE).$(NATIVE_SYSTEM))
153+
154+
JERRY_BUILD_OPTIONS_TEST_TARGETS_NATIVE += unittests
155+
156+
export JERRY_BUILD_OPTIONS_TEST_TARGETS_MCU := \
157+
$(foreach __MODE,$(RELEASE_MODES), \
158+
$(foreach __SYSTEM,$(MCU_SYSTEMS), \
159+
$(__MODE).mcu_$(__SYSTEM)))
160+
141161
# JS test suites (in the format of id:path)
142162
export JERRY_TEST_SUITE_J := j:$(ROOT_DIR)/tests/jerry
143163
export JERRY_TEST_SUITE_JTS := jts:$(ROOT_DIR)/tests/jerry-test-suite
@@ -196,7 +216,9 @@ define WRITE_TOOLCHAIN_CONFIG
196216
endef
197217

198218
.PHONY: $(BUILD_DIR)/$(NATIVE_SYSTEM)/toolchain.config
199-
$(BUILD_DIR)/$(NATIVE_SYSTEM)/toolchain.config:
219+
.PHONY: $(BUILD_DIR)/$(NATIVE_SYSTEM)/unittests/toolchain.config
220+
$(BUILD_DIR)/$(NATIVE_SYSTEM)/toolchain.config \
221+
$(BUILD_DIR)/$(NATIVE_SYSTEM)/unittests/toolchain.config:
200222
$(Q) if [ "$$TOOLCHAIN" == "" ]; \
201223
then \
202224
arch=`uname -m`; \
@@ -235,6 +257,8 @@ endef
235257
$(foreach __SYSTEM,$(NATIVE_SYSTEM) $(MCU_SYSTEMS), \
236258
$(eval $(call GEN_MAKEFILE_RULE,$(BUILD_DIR)/$(__SYSTEM))))
237259

260+
$(eval $(call GEN_MAKEFILE_RULE,$(BUILD_DIR)/$(NATIVE_SYSTEM)/unittests))
261+
238262
# Targets to perform build and test steps in the build directories
239263

240264
# Make rule macro to build a/some target(s) and copy out the result(s).
@@ -274,7 +298,7 @@ $(foreach __TARGET,$(JERRY_STM32F4_TARGETS), \
274298

275299
$(eval $(call BUILD_RULE,build.mcu_stm32f4,stm32f4,$(patsubst %,%.bin,$(JERRY_STM32F4_TARGETS))))
276300

277-
$(eval $(call BUILD_RULE,unittests,$(NATIVE_SYSTEM),unittests))
301+
$(eval $(call BUILD_RULE,unittests,$(NATIVE_SYSTEM)/unittests,unittests))
278302

279303
# Make rule macro to test a build target with a test suite.
280304
#
@@ -303,6 +327,24 @@ $(foreach __TARGET,$(JERRY_TEST_TARGETS_CP), \
303327
$(foreach __SUITE,$(JERRY_TEST_SUITE_JTS_CP), \
304328
$(eval $(call JSTEST_RULE,$(__TARGET),$(firstword $(subst :, ,$(__SUITE))),$(lastword $(subst :, ,$(__SUITE)))))))
305329

330+
# Make rule macro to test a build target with a build option.
331+
#
332+
# $(1) - name of the target to test
333+
# $(2) - name of the option to test
334+
define OPTIONSTEST_RULE
335+
.PHONY: test-option.$(1)-$(2)
336+
test-option.$(1)-$(2):
337+
$$(Q)+$(MAKE) --no-print-directory $(2)=ON $(1)
338+
endef
339+
340+
$(foreach __TARGET,$(JERRY_BUILD_OPTIONS_TEST_TARGETS_NATIVE), \
341+
$(foreach __OPTION, $(BUILD_OPTIONS_TEST_NATIVE), \
342+
$(eval $(call OPTIONSTEST_RULE,$(__TARGET),$(__OPTION)))))
343+
344+
$(foreach __TARGET,$(JERRY_BUILD_OPTIONS_TEST_TARGETS_MCU), \
345+
$(foreach __OPTION, $(BUILD_OPTIONS_TEST_MCU), \
346+
$(eval $(call OPTIONSTEST_RULE,$(__TARGET),$(__OPTION)))))
347+
306348
# Targets to perform batch builds, checks, and tests
307349

308350
.PHONY: clean
@@ -344,6 +386,15 @@ test-js-precommit: \
344386
$(foreach __SUITE,$(JERRY_TEST_SUITE_J) $(JERRY_TEST_SUITE_JTS_PREC), \
345387
test-js.$(__TARGET).$(firstword $(subst :, ,$(__SUITE)))))
346388

389+
.PHONY: test-buildoptions
390+
test-buildoptions: \
391+
$(foreach __TARGET,$(JERRY_BUILD_OPTIONS_TEST_TARGETS_NATIVE), \
392+
$(foreach __OPTION, $(BUILD_OPTIONS_TEST_NATIVE), \
393+
test-option.$(__TARGET)-$(__OPTION))) \
394+
$(foreach __TARGET,$(JERRY_BUILD_OPTIONS_TEST_TARGETS_MCU), \
395+
$(foreach __OPTION, $(BUILD_OPTIONS_TEST_MCU), \
396+
test-option.$(__TARGET)-$(__OPTION))) \
397+
347398
.PHONY: precommit
348399
precommit: prerequisites
349400
$(Q)+$(MAKE) --no-print-directory clean

targets/mbedk64f/Makefile.mbedk64f

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2015 Samsung Electronics Co., Ltd.
1+
# Copyright 2015-2016 Samsung Electronics Co., Ltd.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -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_CMAKE_C_COMPILER_ID=GNU \

0 commit comments

Comments
 (0)