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 .
22 ifeq ($(strip $(DEBUGCPPUNIT
)),TRUE
)
23 gb_CppunitTest_GDBTRACE
:= gdb
-nx
-ex
"add-auto-load-safe-path $(INSTDIR)" --command
=$(SRCDIR
)/solenv
/bin
/gdbtrycatchtrace-stdout
-return-child-result
--args
24 else ifneq ($(strip $(CPPUNITTRACE
)),)
25 gb_CppunitTest_GDBTRACE
:= $(CPPUNITTRACE
)
26 gb_CppunitTest__interactive
:= $(true
)
29 ifneq ($(strip $(VALGRIND
)),)
30 gb_CppunitTest_VALGRINDTOOL
:= valgrind
--tool
=$(VALGRIND
) --num-callers
=50 --error-exitcode
=1 --trace-children
=yes
--trace-children-skip
='*/java,*/gij'
31 ifeq ($(strip $(VALGRIND
)),memcheck
)
32 G_SLICE
:= always-malloc
33 GLIBCXX_FORCE_NEW
:= 1
37 ifneq (,$(filter perfcheck
,$(MAKECMDGOALS
)))
38 $(if
$(ENABLE_VALGRIND
),,$(call gb_Output_error
,Running performance tests with empty
$$(ENABLE_VALGRIND
) does not make sense
))
39 gb_CppunitTest_VALGRINDTOOL
:= valgrind
--tool
=callgrind
--dump-instr
=yes
--instr-atstart
=no
43 # gb_CppunitTest_get_filename
44 gb_CppunitTest_RUNTIMEDEPS
:= $(call gb_Executable_get_runtime_dependencies
,cppunittester
)
45 gb_CppunitTest_CPPTESTCOMMAND
:= $(call gb_Executable_get_target_for_build
,cppunittester
)
47 # i18npool dlopens localedata_* libraries.
48 gb_CppunitTest_RUNTIMEDEPS
+= \
49 $(call gb_Library_get_target
,localedata_en
) \
50 $(call gb_Library_get_target
,localedata_es
) \
51 $(call gb_Library_get_target
,localedata_euro
) \
52 $(call gb_Library_get_target
,localedata_others
) \
54 define gb_CppunitTest__make_args
56 "-env:BRAND_BASE_DIR=$(call gb_Helper_make_url,$(INSTROOT))" \
57 "-env:BRAND_SHARE_SUBDIR=$(LIBO_SHARE_FOLDER)" \
58 "-env:UserInstallation=$(call gb_Helper_make_url,$(call gb_CppunitTest_get_target,$*).user)" \
60 $(if
$(strip $(CONFIGURATION_LAYERS
)),\
61 "-env:CONFIGURATION_LAYERS=$(strip $(CONFIGURATION_LAYERS))") \
62 $(if
$(strip $(UNO_TYPES
)),\
63 "-env:UNO_TYPES=$(foreach item,$(UNO_TYPES),$(call gb_Helper_make_url,$(item)))") \
64 $(if
$(strip $(UNO_SERVICES
)),\
65 "-env:UNO_SERVICES=$(foreach item,$(UNO_SERVICES),$(call gb_Helper_make_url,$(item)))") \
66 $(if
$(strip $(JAVA_URE
)),\
67 -env
:URE_MORE_JAVA_TYPES
=$(call gb_Helper_make_url
,$(call gb_Jar_get_target
,unoil
))) \
68 -env
:URE_INTERNAL_LIB_DIR
=$(call gb_Helper_make_url
,$(INSTROOT
)/$(LIBO_URE_LIB_FOLDER
)) \
69 -env
:LO_LIB_DIR
=$(call gb_Helper_make_url
,$(INSTROOT
)/$(LIBO_LIB_FOLDER
)) \
70 -env
:LO_JAVA_DIR
=$(call gb_Helper_make_url
,$(INSTROOT
)/$(LIBO_SHARE_JAVA_FOLDER
)) \
71 --protector
$(call gb_Library_get_target
,unoexceptionprotector
) unoexceptionprotector \
72 --protector
$(call gb_Library_get_target
,unobootstrapprotector
) unobootstrapprotector \
75 --protector
$(call gb_Library_get_target
,vclbootstrapprotector
) vclbootstrapprotector \
80 .PHONY
: $(call gb_CppunitTest_get_clean_target
,%)
81 $(call gb_CppunitTest_get_clean_target
,%) :
82 $(call gb_Helper_abbreviate_dirs
,\
83 rm -f
$(call gb_CppunitTest_get_target
,$*) $(call gb_CppunitTest_get_target
,$*).log
)
85 .PHONY
: $(call gb_CppunitTest_get_target
,%)
86 $(call gb_CppunitTest_get_target
,%) :|
$(gb_CppunitTest_RUNTIMEDEPS
)
87 $(call gb_Output_announce
,$*,$(true
),CUT
,2)
88 $(call gb_Helper_abbreviate_dirs
,\
89 mkdir
-p
$(dir $@
) && \
90 rm -fr
$@.user
&& mkdir
$@.user
&& \
91 $(if
$(gb_CppunitTest__use_confpreinit
), \
92 $(INSTDIR
)/program
/lokconf_init
$(call gb_CppunitTest__make_args
) &&) \
93 $(if
$(gb_CppunitTest__interactive
),, \
94 $(if
$(value gb_CppunitTest_postprocess
), \
95 rm -fr
$@.core
&& mkdir
$@.core
&& cd
$@.core
&&)) \
96 ($(gb_CppunitTest_CPPTESTPRECOMMAND
) \
97 $(if
$(G_SLICE
),G_SLICE
=$(G_SLICE
)) \
98 $(if
$(GLIBCXX_FORCE_NEW
),GLIBCXX_FORCE_NEW
=$(GLIBCXX_FORCE_NEW
)) \
99 $(if
$(HEADLESS
),,VCL_HIDE_WINDOWS
=1) \
100 $(if
$(strip $(PYTHON_URE
)),\
101 PYTHONDONTWRITEBYTECODE
=1) \
102 $(ICECREAM_RUN
) $(gb_CppunitTest_GDBTRACE
) $(gb_CppunitTest_VALGRINDTOOL
) $(gb_CppunitTest_CPPTESTCOMMAND
) \
103 $(call gb_LinkTarget_get_target
,$(call gb_CppunitTest_get_linktarget
,$*)) \
104 $(call gb_CppunitTest__make_args
) \
105 $(if
$(gb_CppunitTest__interactive
),, \
107 ||
($(if
$(value gb_CppunitTest_postprocess
), \
109 $(call gb_CppunitTest_postprocess
,$(gb_CppunitTest_CPPTESTCOMMAND
),$@.core
,$$RET) >> $@.log
2>&1;) \
110 cat
$@.log
; $(SRCDIR
)/solenv
/bin
/unittest-failed.sh Cppunit
$* $(OS
)))))
112 define gb_CppunitTest_CppunitTest
113 $(call gb_CppunitTest__CppunitTest_impl
,$(1),$(call gb_CppunitTest_get_linktarget
,$(1)))
117 # call gb_CppunitTest__CppunitTest_impl,cppunittest,linktarget
118 define gb_CppunitTest__CppunitTest_impl
119 $(call gb_LinkTarget_LinkTarget
,$(2),CppunitTest_
$(1),NONE
)
120 $(call gb_LinkTarget_set_targettype
,$(2),CppunitTest
)
121 $(call gb_LinkTarget_add_libs
,$(2),$(gb_STDLIBS
))
122 $(call gb_LinkTarget_add_defs
,$(2),\
123 $(gb_CppunitTest_DEFS
) \
125 $(call gb_LinkTarget_use_external
,$(2),cppunit
)
126 $(call gb_LinkTarget_set_include
,$(2),\
128 $(filter -I
%,$(CPPUNIT_CFLAGS
)) \
130 $(call gb_LinkTarget_add_defs
,$(2), \
131 $(filter-out -I
%,$(CPPUNIT_CFLAGS
)) \
132 -DCPPUNIT_PLUGIN_EXPORT
='extern "C" SAL_DLLPUBLIC_EXPORT' \
134 $(call gb_CppunitTest_get_target
,$(1)) : $(call gb_LinkTarget_get_target
,$(2))
135 $(call gb_CppunitTest_get_clean_target
,$(1)) : $(call gb_LinkTarget_get_clean_target
,$(2))
136 $(call gb_CppunitTest_CppunitTest_platform
,$(1),$(2),$(gb_CppunitTest_DLLDIR
)/$(call gb_CppunitTest_get_ilibfilename
,$(1)))
137 $(call gb_CppunitTest_get_target
,$(1)) : ARGS
:=
138 $(call gb_CppunitTest_get_target
,$(1)) : CONFIGURATION_LAYERS
:=
139 $(call gb_CppunitTest_get_target
,$(1)) : JAVA_URE
:= $(false
)
140 $(call gb_CppunitTest_get_target
,$(1)) : PYTHON_URE
:= $(false
)
141 $(call gb_CppunitTest_get_target
,$(1)) : URE
:= $(false
)
142 $(call gb_CppunitTest_get_target
,$(1)) : VCL
:= $(false
)
143 $(call gb_CppunitTest_get_target
,$(1)) : UNO_SERVICES
:=
144 $(call gb_CppunitTest_get_target
,$(1)) : UNO_TYPES
:=
145 $(call gb_CppunitTest_get_target
,$(1)) : HEADLESS
:= --headless
146 $$(eval
$$(call gb_Module_register_target
,$(call gb_CppunitTest_get_target
,$(1)),$(call gb_CppunitTest_get_clean_target
,$(1))))
147 $(call gb_Helper_make_userfriendly_targets
,$(1),CppunitTest
)
151 # Add additional command line arguments for the test.
153 # You should practically never need to use this, as there are special
154 # functions for adding many commonly used arguments.
155 define gb_CppunitTest_add_arguments
156 $(call gb_CppunitTest_get_target
,$(1)) : ARGS
+= $(2)
160 define gb_CppunitTest_use_ure
161 $(call gb_CppunitTest_use_rdb
,$(1),ure
/services
)
162 $(call gb_CppunitTest_get_target
,$(1)) : URE
:= $(true
)
163 $(call gb_CppunitTest_get_target
,$(1)) : $(call gb_Library_get_target
,$(gb_CPPU_ENV
)_uno
)
164 $(call gb_CppunitTest_get_target
,$(1)) : $(call gb_Library_get_target
,affine_uno
)
165 $(call gb_CppunitTest_get_target
,$(1)) : $(call gb_Library_get_target
,unobootstrapprotector
)
166 $(call gb_CppunitTest_get_target
,$(1)) : $(call gb_Library_get_target
,unoexceptionprotector
)
170 # $(2) == $(true) if headless:
171 define gb_CppunitTest__use_vcl
172 $(call gb_CppunitTest_get_target
,$(1)) : VCL
:= $(true
)
173 $(call gb_CppunitTest_get_target
,$(1)) : $(call gb_Library_get_target
,vclbootstrapprotector
)
174 ifeq ($(GUIBASE
),unx
)
175 $(call gb_CppunitTest_get_target
,$(1)) : $(call gb_Library_get_target
,desktop_detector
)
176 $(call gb_CppunitTest_get_target
,$(1)) : $(if
$(filter $(2),$(true
)), \
177 $(call gb_Library_get_target
,vclplug_gen
) \
178 $(if
$(ENABLE_GTK
),$(call gb_Library_get_target
,vclplug_gtk
)) \
179 $(if
$(ENABLE_GTK3
),$(call gb_Library_get_target
,vclplug_gtk3
)) \
180 $(if
$(ENABLE_KDE
),$(call gb_Library_get_target
,vclplug_kde
)) \
181 $(if
$(ENABLE_KDE4
),$(call gb_Library_get_target
,vclplug_kde4
)) \
182 $(if
$(ENABLE_TDE
),$(call gb_Library_get_target
,vclplug_tde
)))
187 define gb_CppunitTest_use_confpreinit
188 $(call gb_CppunitTest_use_executable
,$(1),lokconf_init
)
189 $(call gb_CppunitTest_get_target
,$(1)) : gb_CppunitTest__use_confpreinit
:= TRUE
193 define gb_CppunitTest_use_vcl
194 $(call gb_CppunitTest__use_vcl
,$(1),$(true
))
198 define gb_CppunitTest_use_vcl_non_headless
199 $(call gb_CppunitTest_get_target
,$(1)) : HEADLESS
:=
200 $(call gb_CppunitTest__use_vcl
,$(1),$(false
))
204 define gb_CppunitTest__use_api
205 $(call gb_CppunitTest_get_target
,$(1)) : $(call gb_UnoApi_get_target
,$(2))
206 $(call gb_CppunitTest_get_target
,$(1)) : UNO_TYPES
+= $(call gb_UnoApi_get_target
,$(2))
210 define gb_CppunitTest_use_api
211 $(call gb_LinkTarget_use_api
,$(call gb_CppunitTest_get_linktarget
,$(1)),$(2))
212 $(foreach rdb
,$(2),$(call gb_CppunitTest__use_api
,$(1),$(rdb
)))
216 define gb_CppunitTest_use_udk_api
217 $(call gb_CppunitTest_use_api
,$(1),udkapi
)
221 define gb_CppunitTest_use_sdk_api
222 $(call gb_CppunitTest_use_api
,$(1),udkapi offapi
)
226 define gb_CppunitTest_use_rdb
227 $(call gb_CppunitTest_get_target
,$(1)) : $(call gb_Rdb_get_target_for_build
,$(2))
228 $(call gb_CppunitTest_get_target
,$(1)) : UNO_SERVICES
+= $(call gb_Rdb_get_target_for_build
,$(2))
232 define gb_CppunitTest_use_rdbs
233 $(foreach rdb
,$(2),$(call gb_CppunitTest_use_rdb
,$(1),$(rdb
)))
237 define gb_CppunitTest_use_component
238 $(call gb_CppunitTest_get_target
,$(1)) : \
239 $(call gb_ComponentTarget_get_target
,$(2))
240 $(call gb_CppunitTest_get_target
,$(1)) : \
241 UNO_SERVICES
+= $(call gb_ComponentTarget_get_target
,$(2))
245 define gb_CppunitTest_set_componentfile
246 $(call gb_ComponentTarget_ComponentTarget
,CppunitTest
/$(2),\
247 $(call gb_Helper_make_url
,$(gb_CppunitTest_DLLDIR
))/,\
248 $(call gb_CppunitTest_get_filename
,$(1)))
249 $(call gb_CppunitTest_get_target
,$(1)) : \
250 $(call gb_ComponentTarget_get_target
,CppunitTest
/$(2))
251 $(call gb_CppunitTest_get_clean_target
,$(1)) : \
252 $(call gb_ComponentTarget_get_clean_target
,CppunitTest
/$(2))
253 $(call gb_CppunitTest_use_component
,$(1),CppunitTest
/$(2))
257 # Given a list of component files, filter out those corresponding
258 # to libraries not built in this configuration.
259 define gb_CppunitTest__filter_not_built_components
261 $(if
$(filter SCRIPTING
,$(BUILD_TYPE
)),, \
264 scripting
/source
/basprov
/basprov \
265 scripting
/util
/scriptframe
) \
266 $(if
$(filter DBCONNECTIVITY
,$(BUILD_TYPE
)),, \
268 forms
/util
/frm
),$(1))
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 instdir configuration
282 define gb_CppunitTest_use_instdir_configuration
283 $(call gb_CppunitTest_get_target
,$(1)) : $(call gb_Package_get_target
,postprocess_registry
)
284 $(call gb_CppunitTest__use_configuration
,$(1),xcsxcu
,$(INSTROOT
)/$(LIBO_SHARE_FOLDER
)/registry
)
288 # Use configuration in $(WORKDIR)/unittest/registry.
289 define gb_CppunitTest_use_unittest_configuration
290 $(call gb_CppunitTest_get_target
,$(1)) : $(call gb_Package_get_target
,test_unittest
)
291 $(call gb_CppunitTest__use_configuration
,$(1),xcsxcu
,$(WORKDIR
)/unittest
/registry
)
295 # Use standard configuration: instdir config + unittest config (in this order!)
296 define gb_CppunitTest_use_configuration
297 $(call gb_CppunitTest_use_instdir_configuration
,$(1))
298 $(call gb_CppunitTest_use_unittest_configuration
,$(1))
302 define gb_CppunitTest_use_executable
303 $(call gb_CppunitTest_get_target
,$(1)) : $(call gb_Executable_get_target
,$(2))
307 define gb_CppunitTest_use_java_ure
308 $(call gb_CppunitTest_get_target
,$(1)) : JAVA_URE
:= $(true
)
309 $(call gb_CppunitTest_get_target
,$(1)) : \
310 $(foreach jar
,java_uno juh jurt unoil unoloader
,$(call gb_Jar_get_target
,$(jar
))) \
311 $(call gb_Library_get_target
,affine_uno_uno
) \
312 $(call gb_Library_get_target
,java_uno
) \
313 $(call gb_Library_get_target
,jpipe
) \
314 $(call gb_Library_get_target
,juhx
) \
315 $(call gb_Library_get_target
,juhx
) \
316 $(call gb_Library_get_target
,jvmaccess
) \
317 $(call gb_Library_get_target
,jvmfwk
) \
318 $(call gb_Package_get_target
,jvmfwk_javavendors
) \
319 $(call gb_Package_get_target
,jvmfwk_jreproperties
)
323 define gb_CppunitTest_use_jar
324 $(call gb_CppunitTest__use_java_ure
,$(1))
325 $(call gb_CppunitTest_get_target
,$(1)) : $(call gb_Jar_get_target
,$(2))
329 define gb_CppunitTest_use_jars
330 $(foreach jar
,$(2),$(call gb_CppunitTest_use_jar
,$(1),$(jar
)))
334 define gb_CppunitTest_use_python_ure
335 $(call gb_CppunitTest_get_target
,$(1)) : PYTHON_URE
:= $(true
)
336 $(call gb_CppunitTest_get_target
,$(1)) :\
337 $(call gb_Library_get_target
,pythonloader
) \
338 $(call gb_Library_get_target
,pyuno
) \
339 $(if
$(filter-out WNT
,$(OS
)),\
340 $(call gb_Library_get_target
,pyuno_wrapper
) \
342 $(if
$(SYSTEM_PYTHON
),, \
343 $(if
$(filter MACOSX
,$(OS
)),\
344 $(call gb_GeneratedPackage_get_target
,python3
),\
345 $(call gb_Package_get_target
,python3
) \
348 $(call gb_Package_get_target
,pyuno_python_scripts
)
352 define gb_CppunitTest__forward_to_Linktarget
353 gb_CppunitTest_
$(1) = $$(call gb_LinkTarget_
$(1),$$(call gb_CppunitTest_get_linktarget
,$$(1)),$$(2),$$(3),CppunitTest_
$$(1))
357 $(eval
$(foreach method
,\
362 add_exception_objects \
363 use_executable_objects \
364 use_library_objects \
366 use_static_libraries \
375 set_precompiled_header \
388 disable_standard_system_libs \
389 use_system_darwin_frameworks \
390 use_system_win32_libs \
392 use_internal_bootstrap_api \
393 use_internal_comprehensive_api \
394 set_library_path_flags \
398 set_visibility_default \
399 set_warnings_not_errors \
401 set_generated_cxx_suffix \
403 $(call gb_CppunitTest__forward_to_Linktarget
,$(method
))\
406 # vim: set noet sw=4: