@@ -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
105113export ROOT_DIR := $(shell pwd)
106114export 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)
142162export JERRY_TEST_SUITE_J := j:$(ROOT_DIR ) /tests/jerry
143163export JERRY_TEST_SUITE_JTS := jts:$(ROOT_DIR ) /tests/jerry-test-suite
@@ -196,7 +216,9 @@ define WRITE_TOOLCHAIN_CONFIG
196216endef
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
348399precommit : prerequisites
349400 $(Q ) +$(MAKE ) --no-print-directory clean
0 commit comments