1 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
23 # $(1): "Cppunit" or "Python"
24 # $(2): the name of the unit test that failed
25 define gb_UNIT_FAILED_MSG
26 printf
'\nError: a unit test failed, please do one of:\n\nexport DEBUGCPPUNIT=TRUE # for exception catching\nexport GDBCPPUNITTRACE="gdb --args" # for interactive debugging\nexport VALGRIND=memcheck # for memory checking\n\nand retry using: make %sTest_%s\n\n' $(1) $(2)
29 ifeq ($(strip $(DEBUGCPPUNIT
)),TRUE
)
30 gb_CppunitTest_GDBTRACE
:= gdb
-nx
-ex
"add-auto-load-safe-path $(OUTDIR)/lib" --command
=$(SOLARENV
)/bin
/gdbtrycatchtrace-stdout
-return-child-result
--args
31 else ifneq ($(strip $(GDBCPPUNITTRACE
)),)
32 gb_CppunitTest_GDBTRACE
:= $(GDBCPPUNITTRACE
)
33 gb_CppunitTest__interactive
:= $(true
)
36 ifneq ($(strip $(VALGRIND
)),)
37 gb_CppunitTest_VALGRINDTOOL
:= valgrind
--tool
=$(VALGRIND
) --num-callers
=50 --error-exitcode
=1 --trace-children
=yes
--leak-check
=no
38 ifeq ($(strip $(VALGRIND
)),memcheck
)
39 G_SLICE
:= always-malloc
40 GLIBCXX_FORCE_NEW
:= 1
45 # gb_CppunitTest_TARGETTYPE
46 # gb_CppunitTest_get_filename
47 # DBGSV_ERROR_OUT => in non-product builds, ensure that tools-based assertions do not pop up as message box, but are routed to the shell
48 gb_CppunitTest_CPPTESTDEPS
:= $(call gb_Executable_get_runtime_dependencies
,cppunit
/cppunittester
)
49 gb_CppunitTest_CPPTESTCOMMAND
:= $(call gb_Executable_get_target_for_build
,cppunit
/cppunittester
)
51 gb_CppunitTest__get_linktargetname
= CppunitTest
/$(call gb_CppunitTest_get_filename
,$(1))
53 define gb_CppunitTest__make_args
55 "-env:BRAND_BASE_DIR=$(call gb_Helper_make_url,$(OUTDIR)/unittest/install)" \
57 $(if
$(strip $(CONFIGURATION_LAYERS
)),\
58 "-env:CONFIGURATION_LAYERS=$(strip $(CONFIGURATION_LAYERS))") \
59 $(if
$(strip $(UNO_TYPES
)),\
60 "-env:UNO_TYPES=$(foreach item,$(UNO_TYPES),$(call gb_Helper_make_url,$(item)))") \
61 $(if
$(strip $(UNO_SERVICES
)),\
62 "-env:UNO_SERVICES=$(foreach item,$(UNO_SERVICES),$(call gb_Helper_make_url,$(item)))") \
63 $(foreach dir,URE_INTERNAL_LIB_DIR LO_LIB_DIR
,\
64 -env
:$(dir)=$(call gb_Helper_make_url
,$(gb_CppunitTest_LIBDIR
))) \
65 --protector unoexceptionprotector
$(gb_Library_DLLEXT
) unoexceptionprotector \
66 --protector unobootstrapprotector
$(gb_Library_DLLEXT
) unobootstrapprotector \
70 .PHONY
: $(call gb_CppunitTest_get_clean_target
,%)
71 $(call gb_CppunitTest_get_clean_target
,%) :
72 $(call gb_Helper_abbreviate_dirs
,\
73 rm -f
$(call gb_CppunitTest_get_target
,$*) $(call gb_CppunitTest_get_target
,$*).log
)
75 .PHONY
: $(call gb_CppunitTest_get_target
,%)
76 $(call gb_CppunitTest_get_target
,%) :|
$(gb_CppunitTest_CPPTESTDEPS
)
77 $(call gb_Output_announce
,$*,$(true
),CUT
,2)
78 $(call gb_Helper_abbreviate_dirs
,\
79 mkdir
-p
$(dir $@
) && \
80 $(if
$(gb_CppunitTest__interactive
),, \
81 $(if
$(value gb_CppunitTest_postprocess
), \
82 rm -fr
$@.core
&& mkdir
$@.core
&& cd
$@.core
&&)) \
83 ($(gb_CppunitTest_CPPTESTPRECOMMAND
) \
84 $(if
$(G_SLICE
),G_SLICE
=$(G_SLICE
)) \
85 $(if
$(GLIBCXX_FORCE_NEW
),GLIBCXX_FORCE_NEW
=$(GLIBCXX_FORCE_NEW
)) \
86 $(if
$(DBGSV_ERROR_OUT
),DBGSV_ERROR_OUT
=$(DBGSV_ERROR_OUT
)) \
87 DISABLE_SAL_DBGBOX
=t \
88 $(if
$(SAL_DIAGNOSE_ABORT
),SAL_DIAGNOSE_ABORT
=$(SAL_DIAGNOSE_ABORT
)) \
89 $(ICECREAM_RUN
) $(gb_CppunitTest_GDBTRACE
) $(gb_CppunitTest_VALGRINDTOOL
) $(gb_CppunitTest_CPPTESTCOMMAND
) \
90 $(call gb_LinkTarget_get_target
,CppunitTest
/$(call gb_CppunitTest_get_libfilename
,$*)) \
91 $(call gb_CppunitTest__make_args
) \
92 $(if
$(gb_CppunitTest__interactive
),, \
94 ||
(RET
=$$?
&& cat
$@.log
&& $(call gb_UNIT_FAILED_MSG
,Cppunit
,$*) \
95 $(if
$(value gb_CppunitTest_postprocess
), \
96 && $(call gb_CppunitTest_postprocess
,$(gb_CppunitTest_CPPTESTCOMMAND
),$@.core
,$$RET)) \
99 define gb_CppunitTest_CppunitTest
100 $(call gb_CppunitTest__CppunitTest_impl
,$(1),$(call gb_CppunitTest__get_linktargetname
,$(1)))
104 define gb_CppunitTest__CppunitTest_impl
105 $(call gb_LinkTarget_LinkTarget
,$(2),CppunitTest_
$(1))
106 $(call gb_LinkTarget_set_targettype
,$(2),CppunitTest
)
107 $(call gb_LinkTarget_add_libs
,$(2),$(gb_STDLIBS
))
108 $(call gb_LinkTarget_add_defs
,$(2),\
109 $(gb_CppunitTest_DEFS
) \
111 $(call gb_LinkTarget_use_external
,$(2),cppunit
)
112 $(call gb_LinkTarget_set_include
,$(2),\
114 $(filter -I
%,$(CPPUNIT_CFLAGS
)) \
116 $(call gb_LinkTarget_add_defs
,$(2), \
117 $(filter-out -I
%,$(CPPUNIT_CFLAGS
)) \
118 -DCPPUNIT_PLUGIN_EXPORT
='extern "C" SAL_DLLPUBLIC_EXPORT' \
120 $(call gb_CppunitTest_get_target
,$(1)) : $(call gb_LinkTarget_get_target
,$(2))
121 $(call gb_CppunitTest_get_clean_target
,$(1)) : $(call gb_LinkTarget_get_clean_target
,$(2))
122 $(call gb_CppunitTest_CppunitTest_platform
,$(1),$(2),$(gb_CppunitTest_DLLDIR
)/$(call gb_CppunitTest_get_libfilename
,$(1)))
123 $(call gb_CppunitTest_get_target
,$(1)) : ARGS
:=
124 $(call gb_CppunitTest_get_target
,$(1)) : CONFIGURATION_LAYERS
:=
125 $(call gb_CppunitTest_get_target
,$(1)) : URE
:= $(false
)
126 $(call gb_CppunitTest_get_target
,$(1)) : UNO_SERVICES
:=
127 $(call gb_CppunitTest_get_target
,$(1)) : UNO_TYPES
:=
128 $(call gb_CppunitTest_get_target
,$(1)) : DBGSV_ERROR_OUT
:= shell
129 $(call gb_CppunitTest_get_target
,$(1)) : SAL_DIAGNOSE_ABORT
:=
130 $$(eval
$$(call gb_Module_register_target
,$(call gb_CppunitTest_get_target
,$(1)),$(call gb_CppunitTest_get_clean_target
,$(1))))
131 $(call gb_Helper_make_userfriendly_targets
,$(1),CppunitTest
)
135 define gb_CppunitTest_abort_on_assertion
136 $(call gb_CppunitTest_get_target
,$(1)) : DBGSV_ERROR_OUT
:= abort
137 $(call gb_CppunitTest_get_target
,$(1)) : SAL_DIAGNOSE_ABORT
:= TRUE
141 define gb_CppunitTest_set_args
142 $$(call gb_Output_error
,gb_CppunitTest_set_args
: use gb_CppunitTest_add_arguments instead.
))
145 # Add additional command line arguments for the test.
147 # You should practically never need to use this, as there are special
148 # functions for adding many commonly used arguments.
149 define gb_CppunitTest_add_arguments
150 $(call gb_CppunitTest_get_target
,$(1)) : ARGS
+= $(2)
154 define gb_CppunitTest_uses_ure
155 $$(call gb_Output_error
,gb_CppunitTest_uses_ure
: use gb_CppunitTest_use_ure instead.
))
158 define gb_CppunitTest_use_ure
159 $(call gb_CppunitTest_use_rdb
,$(1),ure
/services
)
160 $(call gb_CppunitTest_get_target
,$(1)) : URE
:= $(true
)
161 $(call gb_CppunitTest_get_target
,$(1)) : $(call gb_Library_get_target
,$(gb_CPPU_ENV
)_uno
)
162 $(call gb_CppunitTest_get_target
,$(1)) : $(call gb_Library_get_target
,unobootstrapprotector
)
163 $(call gb_CppunitTest_get_target
,$(1)) : $(call gb_Library_get_target
,unoexceptionprotector
)
164 $(call gb_CppunitTest_get_target
,$(1)) : $(call gb_Package_get_target
,cppuhelper_unorc
)
168 define gb_CppunitTest_add_type_rdb
169 $$(call gb_Output_error
,\
170 gb_CppunitTest_add_type_rdb
: use gb_CppunitTest_use_api instead.
)
173 define gb_CppunitTest_use_type_rdb
174 $$(call gb_Output_error
,\
175 gb_CppunitTest_use_type_rdb
: use gb_CppunitTest_use_api instead.
)
178 define gb_CppunitTest__use_api
179 $(call gb_CppunitTest_get_target
,$(1)) : $(call gb_UnoApi_get_target
,$(2))
180 $(call gb_CppunitTest_get_target
,$(1)) : UNO_TYPES
+= $(call gb_UnoApi_get_target
,$(2))
184 define gb_CppunitTest_add_type_rdbs
185 $$(call gb_Output_error
,\
186 gb_CppunitTest_add_type_rdbs
: use gb_CppunitTest_use_api instead.
)
189 define gb_CppunitTest_use_type_rdbs
190 $$(call gb_Output_error
,\
191 gb_CppunitTest_use_type_rdbs
: use gb_CppunitTest_use_api instead.
)
194 define gb_CppunitTest_use_api
195 $(call gb_LinkTarget_use_api
,$(call gb_CppunitTest__get_linktargetname
,$(1)),$(2))
196 $(foreach rdb
,$(2),$(call gb_CppunitTest__use_api
,$(1),$(rdb
)))
200 define gb_CppunitTest_use_udk_api
201 $(call gb_CppunitTest_use_api
,$(1),udkapi
)
205 define gb_CppunitTest_use_sdk_api
206 $(call gb_CppunitTest_use_api
,$(1),udkapi offapi
)
210 define gb_CppunitTest_add_service_rdb
211 $$(call gb_Output_error
,\
212 gb_CppunitTest_add_service_rdb
: use gb_CppunitTest_use_rdb instead.
)
215 define gb_CppunitTest_use_service_rdb
216 $$(call gb_Output_error
,gb_CppunitTest_use_service_rdb
: use gb_CppunitTest_use_rdb instead.
))
219 define gb_CppunitTest_use_rdb
220 $(call gb_CppunitTest_get_target
,$(1)) : $(call gb_Rdb_get_outdir_target
,$(2))
221 $(call gb_CppunitTest_get_target
,$(1)) : UNO_SERVICES
+= $(call gb_Rdb_get_outdir_target
,$(2))
225 define gb_CppunitTest_add_service_rdbs
226 $$(call gb_Output_error
,\
227 gb_CppunitTest_add_service_rdbs
: use gb_CppunitTest_use_rdbs instead.
)
230 define gb_CppunitTest_use_service_rdbs
231 $$(call gb_Output_error
,gb_CppunitTest_use_service_rdbs
: use gb_CppunitTest_use_rdbs instead.
))
234 define gb_CppunitTest_use_rdbs
235 $(foreach rdb
,$(2),$(call gb_CppunitTest_use_rdb
,$(1),$(rdb
)))
239 define gb_CppunitTest_add_component
240 $$(call gb_Output_error
,\
241 gb_CppunitTest_add_component
: use gb_CppunitTest_use_component instead.
)
244 define gb_CppunitTest_use_component
245 $(call gb_CppunitTest_get_target
,$(1)) : \
246 $(call gb_ComponentTarget_get_outdir_target
,$(2))
247 $(call gb_CppunitTest_get_target
,$(1)) : \
248 UNO_SERVICES
+= $(call gb_ComponentTarget_get_outdir_target
,$(2))
252 # Given a list of component files, filter out those corresponding
253 # to libraries not built in this configuration.
254 define gb_CppunitTest__filter_not_built_components
256 $(if
$(filter SCRIPTING
,$(BUILD_TYPE
)),, \
259 scripting
/source
/basprov
/basprov \
260 scripting
/util
/scriptframe
) \
261 $(if
$(filter DBCONNECTIVITY
,$(BUILD_TYPE
)),, \
263 forms
/util
/frm
),$(1))
266 define gb_CppunitTest_add_components
267 $$(call gb_Output_error
,\
268 gb_CppunitTest_add_components
: use gb_CppunitTest_use_components instead.
)
271 define gb_CppunitTest_use_components
272 $(foreach component
,$(call gb_CppunitTest__filter_not_built_components
,$(2)),$(call gb_CppunitTest_use_component
,$(1),$(component
)))
276 define gb_CppunitTest__use_configuration
277 $(call gb_CppunitTest_get_target
,$(1)) : CONFIGURATION_LAYERS
+= $(2):$(call gb_Helper_make_url
,$(3))
281 # Use standard configuration.
282 define gb_CppunitTest_use_configuration
283 $(call gb_CppunitTest_get_target
,$(1)) : $(call gb_Configuration_get_target
,registry
)
284 $(call gb_CppunitTest__use_configuration
,$(1),xcsxcu
,$(gb_Configuration_registry
))
288 # Use configuration for filters.
290 # Okay, this is not exactly true, because there may be configuration
291 # for more things than just filters in spool, but it is good enough.
292 define gb_CppunitTest_use_filter_configuration
293 $(call gb_CppunitTest_get_target
,$(1)) : $(call gb_Configuration_get_target
,fcfg_langpack
)
294 $(call gb_CppunitTest__use_configuration
,$(1),module
,$(gb_Configuration_registry
)/spool
)
298 define gb_CppunitTest_use_extra_configuration
299 $$(call gb_Output_error
,gb_CppunitTest_use_extra_configuration
: use gb_CppunitTest_use_unittest_configuration instead.
))
302 # Use configuration in $(OUTDIR)/unittest/registry.
303 define gb_CppunitTest_use_unittest_configuration
304 $(call gb_CppunitTest_get_target
,$(1)) : $(call gb_Package_get_target
,test_unittest
)
305 $(call gb_CppunitTest__use_configuration
,$(1),xcsxcu
,$(OUTDIR
)/unittest
/registry
)
309 define gb_CppunitTest_use_executable
310 $(call gb_CppunitTest_get_target
,$(1)) : \
311 $(call gb_CppunitTestFakeExecutable_get_target
,$(2))
313 $(call gb_CppunitTest_get_clean_target
,$(1)) : \
314 $(call gb_CppunitTestFakeExecutable_get_clean_target
,$(2))
316 $(call gb_CppunitTestFakeExecutable_get_target
,$(2)) : \
317 $(call gb_Executable_get_target
,$(2))
318 $(call gb_Helper_abbreviate_dirs
,mkdir
-p
$$(dir $$@
) && cp
$$< $$@
)
320 .PHONY
: $(call gb_CppunitTestFakeExecutable_get_clean_target
,$(2))
321 $(call gb_CppunitTestFakeExecutable_get_clean_target
,$(2)) :
322 $(call gb_Helper_abbreviate_dirs
, \
323 rm -f
$(call gb_CppunitTestFakeExecutable_get_target
,$(2)))
327 define gb_CppunitTest__forward_to_Linktarget
328 gb_CppunitTest_
$(1) = $$(call gb_LinkTarget_
$(1),$$(call gb_CppunitTest__get_linktargetname
,$$(1)),$$(2),$$(3),CppunitTest_
$$(1))
332 $(eval
$(foreach method
,\
337 add_exception_objects \
338 add_executable_objects \
339 use_executable_objects \
340 add_library_objects \
341 use_library_objects \
344 add_linked_static_libs \
345 use_static_libraries \
346 add_noexception_objects \
353 add_package_headers \
356 set_precompiled_header \
357 add_precompiled_header \
371 disable_standard_system_libs \
372 use_system_darwin_frameworks \
373 use_system_win32_libs \
375 use_internal_bootstrap_api \
376 use_internal_comprehensive_api \
377 set_library_path_flags \
383 set_visibility_default \
385 $(call gb_CppunitTest__forward_to_Linktarget
,$(method
))\
388 # vim: set noet sw=4: