gbuild: ExternalProject: improve NMAKE handling
[LibreOffice.git] / solenv / gbuild / platform / com_MSC_class.mk
blobc5c2f1d84b6a85460815263d6b45955de4a5a2c9
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 .
20 # Convert path to file URL.
21 define gb_Helper_make_url
22 file:///$(strip $(1))
23 endef
25 # YaccTarget class
27 define gb_YaccTarget__command
28 $(call gb_Output_announce,$(2),$(true),YAC,3)
29 $(call gb_Helper_abbreviate_dirs,\
30 mkdir -p $(dir $(3)) && \
31 $(gb_YACC) $(T_YACCFLAGS) --defines=$(4) -o $(5) $(1) && touch $(3) )
33 endef
35 # CObject class
37 # $(call gb_CObject__command_pattern,object,flags,source,dep-file,compiler-plugins)
38 define gb_CObject__command_pattern
39 $(call gb_Helper_abbreviate_dirs,\
40 mkdir -p $(dir $(1)) $(dir $(4)) && \
41 unset INCLUDE && \
42 $(if $(filter YES,$(CXXOBJECT_X64)), $(CXX_X64_BINARY), \
43 $(if $(filter %.c,$(3)), $(gb_CC), \
44 $(if $(filter -clr,$(2)), \
45 $(MSVC_CXX) -I$(SRCDIR)/solenv/clang-cl,$(gb_CXX)))) \
46 $(DEFS) \
47 $(gb_LTOFLAGS) \
48 $(2) \
49 $(if $(EXTERNAL_CODE), \
50 $(if $(filter -clr,$(2)),,$(if $(COM_IS_CLANG),-Wno-undef)), \
51 $(gb_DEFS_INTERNAL)) \
52 $(if $(WARNINGS_NOT_ERRORS),,$(gb_CFLAGS_WERROR)) \
53 -Fd$(PDBFILE) \
54 $(PCHFLAGS) \
55 $(gb_COMPILERDEPFLAGS) \
56 -I$(dir $(3)) \
57 $(INCLUDE) \
58 $(if $(filter YES,$(CXXOBJECT_X64)), -U_X86_ -D_AMD64_,) \
59 -c $(3) \
60 -Fo$(1)) $(if $(filter $(true),$(gb_SYMBOL)),/link /DEBUG:FASTLINK) \
61 $(call gb_create_deps,$(4),$(1),$(3))
62 endef
64 # PrecompiledHeader class
66 # Note: MSVC has a race condition when dealing with .pdb files, that can result in error C1033 when
67 # the .pdb file already exists and two cl.exe invocations try to modify it at the same time (which
68 # is apparently most likely when generating both .pch files). The no-exceptions variant should be
69 # rarely needed now, but in case this turns out to be a problem in practice, this will need to
70 # be handled somehow (such as order-dependency of one on another).
72 gb_PrecompiledHeader_get_enableflags = -Yu$(1).hxx \
73 -FI$(1).hxx \
74 -Fp$(call gb_PrecompiledHeader_get_target,$(1)) \
75 $(gb_PCHWARNINGS)
77 # MSVC PCH needs extra .obj created during the creation of the PCH file
78 gb_PrecompiledHeader_get_objectfile = $(1).obj
80 define gb_PrecompiledHeader__command
81 $(call gb_Output_announce,$(2),$(true),PCH,1)
82 $(call gb_Helper_abbreviate_dirs,\
83 mkdir -p $(dir $(1)) $(dir $(call gb_PrecompiledHeader_get_dep_target,$(2))) && \
84 unset INCLUDE && \
85 $(gb_CXX) \
86 $(4) $(5) -Fd$(PDBFILE) \
87 $(if $(EXTERNAL_CODE),$(if $(COM_IS_CLANG),-Wno-undef),$(gb_DEFS_INTERNAL)) \
88 $(gb_LTOFLAGS) \
89 $(gb_COMPILERDEPFLAGS) \
90 -I$(dir $(3)) \
91 $(6) \
92 -c $(3) \
93 -Yc$(notdir $(patsubst %.cxx,%.hxx,$(3))) -Fp$(1) -Fo$(1).obj) $(call gb_create_deps,$(call gb_PrecompiledHeader_get_dep_target_tmp,$(2)),$(1),$(3))
94 endef
96 # AsmObject class
98 gb_AsmObject_get_source = $(1)/$(2).asm
100 define gb_AsmObject__command
101 $(call gb_Output_announce,$(2),$(true),ASM,3)
102 $(call gb_Helper_abbreviate_dirs,\
103 mkdir -p $(dir $(1)) $(dir $(4)) && \
104 "$(ML_EXE)" /c /Cp $(gb_AFLAGS) -D$(COM) /Fo$(1) $(3)) && \
105 echo "$(1) : $(3)" > $(4)
106 endef
109 # LinkTarget class
111 gb_LinkTarget_CFLAGS := $(gb_CFLAGS)
112 gb_LinkTarget_CXXFLAGS := $(gb_CXXFLAGS)
113 gb_LinkTarget_CXXCLRFLAGS := $(gb_CXXCLRFLAGS)
115 gb_LinkTarget_INCLUDE :=\
116 $(subst -I. , ,$(SOLARINC)) \
117 $(foreach inc,$(subst ;, ,$(JDKINC)),-I$(inc)) \
118 -I$(BUILDDIR)/config_$(gb_Side) \
120 # We must name the .pdb like libname.pdb, not libname.\(dll\|exe\|pyd\).pdb,
121 # otherwise WinDbg does not find it.
122 define gb_LinkTarget__get_pdb_filename
123 $(patsubst %.dll,%.pdb,$(patsubst %.exe,%.pdb,$(patsubst %.pyd,%.pdb,$(1))))
124 endef
126 gb_LinkTarget_get_pdbfile_in = \
127 $(WORKDIR)/LinkTarget/$(call gb_LinkTarget__get_workdir_linktargetname,$(1)).objects.pdb
129 gb_LinkTarget_get_pdbfile_out = \
130 $(call gb_LinkTarget__get_pdb_filename,$(WORKDIR)/LinkTarget/$(call gb_LinkTarget__get_workdir_linktargetname,$(1)))
132 gb_LinkTarget_get_ilkfile = \
133 $(WORKDIR)/LinkTarget/$(call gb_LinkTarget__get_workdir_linktargetname,$(1)).ilk
135 gb_LinkTarget_get_manifestfile = \
136 $(WORKDIR)/LinkTarget/$(call gb_LinkTarget__get_workdir_linktargetname,$(1)).manifest
138 gb_LinkTarget_get_linksearchpath_for_layer = \
139 -LIBPATH:$(WORKDIR)/LinkTarget/StaticLibrary \
140 -LIBPATH:$(INSTDIR)/$(SDKDIRNAME)/lib \
141 $(if $(filter OXT,$(1)),\
142 -LIBPATH:$(WORKDIR)/LinkTarget/ExtensionLibrary, \
143 -LIBPATH:$(WORKDIR)/LinkTarget/Library)
145 # avoid fatal error LNK1170 for Library_merged
146 define gb_LinkTarget_MergedResponseFile
147 cat $${RESPONSEFILE} | sed 's/ /\n/g' | grep -v '^$$' > $${RESPONSEFILE}.1 && \
148 mv $${RESPONSEFILE}.1 $${RESPONSEFILE} &&
149 endef
151 ifeq ($(CPUNAME),X86_64)
152 MSC_SUBSYSTEM_VERSION=$(COMMA)5.02
153 else
154 MSC_SUBSYSTEM_VERSION=$(COMMA)5.01
155 endif
157 define gb_LinkTarget__command
158 $(call gb_Output_announce,$(2),$(true),LNK,4)
159 $(call gb_Helper_abbreviate_dirs,\
160 rm -f $(1) && \
161 RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),100, \
162 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
163 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
164 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
165 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \
166 $(foreach object,$(CXXCLROBJECTS),$(call gb_CxxClrObject_get_target,$(object))) \
167 $(foreach object,$(GENCXXCLROBJECTS),$(call gb_GenCxxClrObject_get_target,$(object))) \
168 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \
169 $(foreach extraobjectlist,$(EXTRAOBJECTLISTS),$(shell cat $(extraobjectlist))) \
170 $(PCHOBJS) $(NATIVERES)) && \
171 $(if $(filter $(call gb_Library__get_workdir_linktargetname,merged),$(2)),$(call gb_LinkTarget_MergedResponseFile)) \
172 unset INCLUDE && \
173 $(if $(filter YES,$(LIBRARY_X64)), $(LINK_X64_BINARY), $(gb_LINK)) \
174 $(if $(filter Library CppunitTest,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \
175 $(if $(filter StaticLibrary,$(TARGETTYPE)),-LIB) \
176 $(if $(filter Executable,$(TARGETTYPE)),$(gb_Executable_TARGETTYPEFLAGS)) \
177 $(if $(filter YES,$(LIBRARY_X64)),,$(if $(filter YES,$(TARGETGUI)), -SUBSYSTEM:WINDOWS$(MSC_SUBSYSTEM_VERSION), -SUBSYSTEM:CONSOLE$(MSC_SUBSYSTEM_VERSION))) \
178 $(if $(filter YES,$(LIBRARY_X64)), -MACHINE:X64) \
179 $(if $(filter YES,$(LIBRARY_X64)), \
180 -LIBPATH:$(COMPATH)/lib/$(if $(filter 140,$(VCVER)),amd64,x64) \
181 -LIBPATH:$(WINDOWS_SDK_HOME)/lib/x64 \
182 -LIBPATH:$(UCRTSDKDIR)lib/$(UCRTVERSION)/ucrt/x64 \
183 $(if $(filter 80 81 10,$(WINDOWS_SDK_VERSION)),-LIBPATH:$(WINDOWS_SDK_HOME)/lib/$(WINDOWS_SDK_LIB_SUBDIR)/um/x64)) \
184 $(T_LDFLAGS) \
185 @$${RESPONSEFILE} \
186 $(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_ilibfilename,$(lib))) \
187 $(foreach lib,$(LINKED_STATIC_LIBS),$(call gb_StaticLibrary_get_filename,$(lib))) \
188 $(if $(filter-out StaticLibrary,$(TARGETTYPE)),\
189 $(T_LIBS) user32.lib \
190 -manifestfile:$(WORKDIR)/LinkTarget/$(2).manifest \
191 -pdb:$(call gb_LinkTarget__get_pdb_filename,$(WORKDIR)/LinkTarget/$(2))) \
192 $(if $(ILIBTARGET),-out:$(1) -implib:$(ILIBTARGET),-out:$(1)); RC=$$?; rm $${RESPONSEFILE} \
193 $(if $(filter Library,$(TARGETTYPE)),; if [ ! -f $(ILIBTARGET) ]; then rm -f $(1); exit 42; fi) \
194 $(if $(filter Library,$(TARGETTYPE)),&& if [ -f $(WORKDIR)/LinkTarget/$(2).manifest ]; then mt.exe $(MTFLAGS) -nologo -manifest $(WORKDIR)/LinkTarget/$(2).manifest -outputresource:$(1)\;2 && touch -r $(1) $(WORKDIR)/LinkTarget/$(2).manifest $(ILIBTARGET); fi) \
195 $(if $(filter Executable,$(TARGETTYPE)),&& if [ -f $(WORKDIR)/LinkTarget/$(2).manifest ]; then mt.exe $(MTFLAGS) -nologo -manifest $(WORKDIR)/LinkTarget/$(2).manifest -outputresource:$(1)\;1 && touch -r $(1) $(WORKDIR)/LinkTarget/$(2).manifest; fi) \
196 $(if $(filter YES,$(TARGETGUI)),&& if [ -f $(SRCDIR)/solenv/inc/DeclareDPIAware.manifest ]; then mt.exe $(MTFLAGS) -nologo -manifest $(SRCDIR)/solenv/inc/DeclareDPIAware.manifest -updateresource:$(1)\;1 ; fi) \
197 $(if $(filter Library,$(TARGETTYPE)),&& \
198 echo $(notdir $(1)) > $(WORKDIR)/LinkTarget/$(2).exports.tmp && \
199 $(if $(filter YES,$(LIBRARY_X64)),$(LINK_X64_BINARY),$(gb_LINK)) \
200 -dump -exports $(ILIBTARGET) \
201 >> $(WORKDIR)/LinkTarget/$(2).exports.tmp && \
202 $(call gb_Helper_replace_if_different_and_touch,$(WORKDIR)/LinkTarget/$(2).exports.tmp,$(WORKDIR)/LinkTarget/$(2).exports,$(1))) \
203 ; exit $$RC)
204 endef
206 define gb_MSVCRT_subst
207 $(if $(MSVC_USE_DEBUG_RUNTIME),$(subst msvcrt,msvcrtd,$(subst msvcprt,msvcprtd,$(subst libcmt,libcmtd,$(subst libvcruntime,libvcruntimed,$(subst libucrt,libucrtd,$(subst libcpmt,libcpmtd,$(subst msvcmrt,msvcmrtd,$(1)))))))),$(1))
208 endef
210 define gb_LinkTarget_use_system_win32_libs
211 $(call gb_LinkTarget_add_libs,$(1),$(foreach lib,$(2),$(call gb_MSVCRT_subst,$(lib)).lib))
212 $(if $(call gb_LinkTarget__is_merged,$(1)),\
213 $(call gb_LinkTarget_add_libs,$(call gb_Library_get_linktarget,merged),$(foreach lib,$(2),$(call gb_MSVCRT_subst,$(lib)).lib)))
214 endef
216 # Flags common for PE executables (EXEs and DLLs)
217 gb_Windows_PE_TARGETTYPEFLAGS := \
218 -release \
219 -opt:noref \
220 -incremental:no \
221 -debug \
222 $(if $(filter NO,$(LIBRARY_X64)), -safeseh) \
223 -nxcompat \
224 -dynamicbase \
225 -manifest
227 ifeq ($(ENABLE_LTO),TRUE)
228 gb_Windows_PE_TARGETTYPEFLAGS += -LTCG
229 endif
231 # Library class
234 gb_Library_DEFS := -D_DLL
235 gb_Library_TARGETTYPEFLAGS := \
236 -DLL \
237 $(gb_Windows_PE_TARGETTYPEFLAGS)
239 gb_Library_get_rpath :=
241 gb_Library_SYSPRE := i
242 gb_Library_PLAINEXT := .lib
244 gb_Library_LAYER := \
245 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):OOO) \
246 $(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):NONE) \
247 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):URELIB) \
248 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):OOO) \
249 $(foreach lib,$(gb_Library_PLAINLIBS_OXT),$(lib):OXT) \
250 $(foreach lib,$(gb_Library_PRIVATELIBS_URE),$(lib):URELIB) \
251 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):URELIB) \
252 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):URELIB) \
253 $(foreach lib,$(gb_Library_EXTENSIONLIBS),$(lib):OXT) \
254 $(foreach lib,$(gb_Library_PLAINLIBS_SHLXTHDL),$(lib):SHLXTHDL) \
256 gb_Library_ILIBFILENAMES :=\
257 $(foreach lib,$(gb_Library_KNOWNLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
259 gb_Library_DLLEXT := .dll
260 gb_Library_UDK_MAJORVER := 3
261 gb_Library_RTEXT := MSC$(gb_Library_DLLEXT)
262 gb_Library_OOOEXT := $(gb_Library_DLLPOSTFIX)$(gb_Library_DLLEXT)
263 gb_Library_UNOEXT := .uno$(gb_Library_DLLEXT)
264 gb_Library_UNOVEREXT := $(gb_Library_UDK_MAJORVER)$(gb_Library_DLLEXT)
265 gb_Library_RTVEREXT := $(gb_Library_UDK_MAJORVER)$(gb_Library_RTEXT)
267 gb_Library_FILENAMES :=\
268 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):$(lib)$(gb_Library_OOOEXT)) \
269 $(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):$(lib)$(gb_Library_DLLEXT)) \
270 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):$(lib)$(gb_Library_DLLEXT)) \
271 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):$(lib)$(gb_Library_DLLEXT)) \
272 $(foreach lib,$(gb_Library_PLAINLIBS_OXT),$(lib):$(lib)$(gb_Library_DLLEXT)) \
273 $(foreach lib,$(gb_Library_PLAINLIBS_SHLXTHDL),$(lib):$(lib)$(gb_Library_DLLEXT)) \
274 $(foreach lib,$(gb_Library_PRIVATELIBS_URE),$(lib):$(lib)$(gb_Library_OOOEXT)) \
275 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):$(lib)$(gb_Library_RTVEREXT)) \
276 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(lib)$(gb_Library_UNOVEREXT)) \
277 $(foreach lib,$(gb_Library_EXTENSIONLIBS),$(lib):$(lib)$(gb_Library_UNOEXT)) \
279 # An assembly is a special kind of library for CLI
280 define gb_Library_Assembly
281 $(call gb_Library_Library,$(1))
282 $(call gb_LinkTarget_get_target,$(call gb_Library_get_linktarget,$(1))) : NATIVERES :=
284 endef
286 define gb_Library_Library_platform
287 $(call gb_LinkTarget_set_ilibtarget,$(2),$(3))
289 $(call gb_LinkTarget_add_auxtargets,$(2),\
290 $(patsubst %.lib,%.exp,$(3)) \
291 $(call gb_LinkTarget_get_manifestfile,$(2)) \
292 $(call gb_LinkTarget_get_pdbfile_in,$(2)) \
293 $(call gb_LinkTarget_get_pdbfile_out,$(2)) \
294 $(call gb_LinkTarget_get_ilkfile,$(2)) \
297 $(call gb_Library_add_default_nativeres,$(1),$(1)/default)
299 $(call gb_LinkTarget_get_target,$(2)) \
300 $(call gb_LinkTarget_get_headers_target,$(2)) : PDBFILE = $(call gb_LinkTarget_get_pdbfile_in,$(2))
302 endef
304 define gb_Library_add_default_nativeres
305 $(call gb_WinResTarget_WinResTarget_init,$(2))
306 $(call gb_WinResTarget_set_rcfile,$(2),include/default)
307 $(call gb_WinResTarget_add_defs,$(2),\
308 -DVERVARIANT="$(LIBO_VERSION_PATCH)" \
309 -DRES_APP_VENDOR="$(OOO_VENDOR)" \
310 -DORG_NAME="$(call gb_Library_get_filename,$(1))"\
311 -DINTERNAL_NAME="$(subst $(gb_Library_DLLEXT),,$(call gb_Library_get_filename,$(1)))" \
312 -DADDITIONAL_VERINFO1="" \
313 -DADDITIONAL_VERINFO2="" \
314 -DADDITIONAL_VERINFO3="" \
316 $(call gb_Library_add_nativeres,$(1),$(2))
317 $(call gb_Library_get_clean_target,$(1)) : $(call gb_WinResTarget_get_clean_target,$(2))
319 endef
321 define gb_LinkTarget_add_nativeres
322 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_WinResTarget_get_target,$(2))
323 $(call gb_LinkTarget_get_target,$(1)) : NATIVERES += $(call gb_WinResTarget_get_target,$(2))
325 endef
327 define gb_LinkTarget_set_nativeres
328 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_WinResTarget_get_target,$(2))
329 $(call gb_LinkTarget_get_target,$(1)) : NATIVERES := $(call gb_WinResTarget_get_target,$(2))
331 endef
333 define gb_Library_get_ilibfilename
334 $(patsubst $(1):%,%,$(filter $(1):%,$(gb_Library_ILIBFILENAMES)))
335 endef
337 gb_Library_get_sdk_link_dir = $(INSTDIR)/$(SDKDIRNAME)/lib
339 gb_Library_get_sdk_link_lib = $(gb_Library_get_ilib_target)
341 # StaticLibrary class
343 gb_StaticLibrary_get_filename = $(1).lib
344 gb_StaticLibrary_PLAINEXT := .lib
346 define gb_StaticLibrary_StaticLibrary_platform
347 $(call gb_LinkTarget_get_target,$(2)) \
348 $(call gb_LinkTarget_get_headers_target,$(2)) : PDBFILE = $(call gb_LinkTarget_get_pdbfile_in,$(2))
350 $(call gb_LinkTarget_add_auxtargets,$(2),\
351 $(call gb_LinkTarget_get_pdbfile_in,$(2)) \
354 endef
356 # Executable class
358 gb_Executable_EXT := .exe
359 gb_Executable_EXT_for_build := .exe
360 gb_Executable_TARGETTYPEFLAGS := $(gb_Windows_PE_TARGETTYPEFLAGS)
362 gb_Executable_get_rpath :=
364 # surprisingly some executables have exports so link.exe creates import lib
365 define gb_Executable_Executable_platform
366 $(call gb_LinkTarget_set_ilibtarget,$(2),$(3))
368 $(call gb_LinkTarget_add_auxtargets,$(2),\
369 $(patsubst %.lib,%.exp,$(3)) \
370 $(call gb_LinkTarget_get_pdbfile_out,$(2)) \
371 $(call gb_LinkTarget_get_pdbfile_in,$(2)) \
372 $(call gb_LinkTarget_get_manifestfile,$(2)) \
375 $(call gb_LinkTarget_get_target,$(2)) \
376 $(call gb_LinkTarget_get_headers_target,$(2)) : PDBFILE := $(call gb_LinkTarget_get_pdbfile_in,$(2))
378 endef
380 # CppunitTest class
382 gb_CppunitTest_UNITTESTFAILED := $(GBUILDDIR)/platform/unittest-failed-WNT.sh
383 gb_CppunitTest_PYTHONDEPS := $(call gb_Package_get_target,python3)
384 gb_CppunitTest_DEFS := -D_DLL
385 ifeq ($(GNUMAKE_WIN_NATIVE),TRUE)
386 gb_CppunitTest_CPPTESTPRECOMMAND := $(call gb_Helper_prepend_ld_path,$(shell cygpath -w $(gb_Library_DLLDIR));$(shell cygpath -w $(WORKDIR)/UnpackedTarball/cppunit/src/cppunit/$(if $(MSVC_USE_DEBUG_RUNTIME),DebugDll,ReleaseDll)))
387 else
388 gb_CppunitTest_CPPTESTPRECOMMAND := $(call gb_Helper_prepend_ld_path,$(shell cygpath -u $(gb_Library_DLLDIR)):$(shell cygpath -u $(WORKDIR)/UnpackedTarball/cppunit/src/cppunit/$(if $(MSVC_USE_DEBUG_RUNTIME),DebugDll,ReleaseDll)))
389 endif
390 gb_CppunitTest_get_filename = test_$(1).dll
391 gb_CppunitTest_get_ilibfilename = itest_$(1).lib
393 define gb_CppunitTest_CppunitTest_platform
394 $(call gb_LinkTarget_set_ilibtarget,$(2),$(3))
396 $(call gb_LinkTarget_add_auxtargets,$(2),\
397 $(patsubst %.lib,%.exp,$(3)) \
398 $(3) \
399 $(call gb_LinkTarget_get_manifestfile,$(2)) \
400 $(call gb_LinkTarget_get_pdbfile_out,$(2)) \
401 $(call gb_LinkTarget_get_pdbfile_in,$(2)) \
402 $(call gb_LinkTarget_get_ilkfile,$(2)) \
405 $(call gb_LinkTarget_get_target,$(2)) \
406 $(call gb_LinkTarget_get_headers_target,$(2)) : PDBFILE = $(call gb_LinkTarget_get_pdbfile_in,$(2))
408 endef
410 # JunitTest class
412 ifneq ($(OOO_TEST_SOFFICE),)
413 gb_JunitTest_SOFFICEARG:=$(OOO_TEST_SOFFICE)
414 else
415 ifneq ($(gb_JunitTest_DEBUGRUN),)
416 gb_JunitTest_SOFFICEARG:=connect:pipe,name=$(USER)
417 else
418 gb_JunitTest_SOFFICEARG:=path:$(INSTROOT)/$(LIBO_BIN_FOLDER)/soffice
419 endif
420 endif
423 define gb_JunitTest_JunitTest_platform
424 $(call gb_JunitTest_get_target,$(1)) : DEFS := \
425 -Dorg.openoffice.test.arg.soffice="$(gb_JunitTest_SOFFICEARG)" \
426 -Dorg.openoffice.test.arg.env=PATH="$$$$PATH" \
427 -Dorg.openoffice.test.arg.user=$(call gb_Helper_make_url,$(call gb_JunitTest_get_userdir,$(1)))
428 -Dorg.openoffice.test.arg.workdir=$(call gb_JunitTest_get_userdir,$(1)) \
430 endef
433 define gb_Module_DEBUGRUNCOMMAND
434 printf "\nAttach the debugger to soffice.bin\n\n"
435 unset VCL_HIDE_WINDOWS && \
436 OFFICESCRIPT=`mktemp` && \
437 printf "$(INSTROOT)/$(LIBO_BIN_FOLDER)/soffice.exe" > $${OFFICESCRIPT} && \
438 printf " --norestore --nologo '--accept=pipe,name=$(USER);urp;'\n" >> $${OFFICESCRIPT} && \
439 $(SHELL) $${OFFICESCRIPT} && \
440 rm $${OFFICESCRIPT}
441 endef
446 # PythonTest class
448 gb_PythonTest_PRECOMMAND := $(gb_CppunitTest_CPPTESTPRECOMMAND)
449 gb_PythonTest_DEPS := $(call gb_Package_get_target,python3) $(call gb_Executable_get_target,python)
451 ifeq ($(strip $(CPPUNITTRACE)),TRUE)
452 gb_CppunitTest_GDBTRACE := '$(DEVENV)' /debugexe
453 endif
455 # SrsPartTarget class
457 ifeq ($(gb_FULLDEPS),$(true))
458 # FIXME this is used before TargetLocations is read?
459 gb_SrsPartTarget__command_target = $(WORKDIR)/LinkTarget/Executable/makedepend.exe
460 define gb_SrsPartTarget__command_dep
461 $(call gb_Helper_abbreviate_dirs,\
462 $(call gb_Executable_get_target,makedepend) \
463 $(INCLUDE) \
464 $(DEFS) \
465 -D__RSC \
466 $(2) \
467 -o .src \
468 -p $(dir $(call gb_SrsPartTarget_get_target,$(1))) \
469 -f $(call gb_SrsPartTarget_get_dep_target,$(1)))
470 endef
471 else
472 gb_SrsPartTarget__command_target =
473 gb_SrsPartTarget__command_dep =
474 endif
476 # WinResTarget class
478 gb_WinResTarget_POSTFIX :=.res
480 define gb_WinResTarget__command
481 $(call gb_Output_announce,$(2),$(true),RC ,1)
482 $(call gb_Helper_abbreviate_dirs,\
483 mkdir -p $(dir $(1)) && \
484 $(gb_RC) \
485 $(DEFS) $(FLAGS) \
486 $(INCLUDE) \
487 -Fo$(1) \
488 $(RCFILE) )
489 endef
491 $(eval $(call gb_Helper_make_dep_targets,\
492 WinResTarget \
495 ifeq ($(gb_FULLDEPS),$(true))
496 # FIXME this is used before TargetLocations is read?
497 gb_WinResTarget__command_target = $(WORKDIR)/LinkTarget/Executable/makedepend.exe
498 define gb_WinResTarget__command_dep
499 $(call gb_Output_announce,RC:$(2),$(true),DEP,1)
500 $(call gb_Helper_abbreviate_dirs,\
501 mkdir -p $(dir $(1)) && \
502 $(call gb_Executable_get_target,makedepend) \
503 $(INCLUDE) \
504 $(DEFS) \
505 $(RCFILE) \
506 -o .res \
507 -p $(dir $(3)) \
508 -f $(1))
509 endef
510 else
511 gb_WinResTarget__command_target =
512 gb_WinResTarget__command_dep =
513 endif
515 # InstallModuleTarget class
517 define gb_InstallModuleTarget_InstallModuleTarget_platform
518 $(call gb_InstallModuleTarget_add_defs,$(1),\
519 $(gb_CPUDEFS) \
520 $(gb_OSDEFS) \
521 -DCOMID=MSC \
524 endef
526 # ExternalProject class
528 # Use the gcc wrappers for a autoconf based project
530 # gb_ExternalProject_register_targets project state_target
531 define gb_ExternalProject_use_autoconf
532 $(call gb_ExternalProject_get_preparation_target,$(1)) : $(call gb_Executable_get_runtime_dependencies,gcc-wrapper) \
533 $(call gb_Executable_get_runtime_dependencies,g++-wrapper)
534 $(call gb_ExternalProject_get_state_target,$(1),$(2)): WRAPPERS := $(gb_AUTOCONF_WRAPPERS)
535 endef
537 # Set INCLUDE and LIB variables and unset MAKE/MAKEFLAGS when using nmake
539 # gb_ExternalProject_use_nmake project state_target
540 define gb_ExternalProject_use_nmake
541 $(call gb_ExternalProject_get_state_target,$(1),$(2)): NMAKE := $(gb_NMAKE_VARS)
542 endef
544 # if ccache is enabled, then split it and use lastword as REAL_FOO
545 # /opt/lo/bin/ccache /cygdrive/c/PROGRA~2/MICROS~2.0/VC/bin/cl.exe
547 gb_AUTOCONF_WRAPPERS = \
548 REAL_CC="$(shell cygpath -w $(filter-out -%,$(CC)))" \
549 REAL_CC_FLAGS="$(filter -%,$(CC))" \
550 CC="$(call gb_Executable_get_target,gcc-wrapper)" \
551 REAL_CXX="$(shell cygpath -w $(filter-out -%,$(CXX)))" \
552 REAL_CXX_FLAGS="$(filter -%,$(CXX))" \
553 CXX="$(call gb_Executable_get_target,g++-wrapper)" \
554 LD="$(shell cygpath -w $(COMPATH)/bin/link.exe) -nologo"
556 gb_ExternalProject_INCLUDE := \
557 $(subst -I,,$(subst $(WHITESPACE),;,$(subst -I. , ,$(SOLARINC))))
559 gb_NMAKE_VARS = \
560 CC="$(shell cygpath -w $(filter-out -%,$(CC))) $(filter -%,$(CC))" \
561 INCLUDE="$(gb_ExternalProject_INCLUDE)" \
562 LIB="$(ILIB)" \
563 MAKEFLAGS= \
564 MAKE=
566 # InstallScript class
568 gb_InstallScript_EXT := .inf
570 # CliAssemblyTarget class
572 gb_CliAssemblyTarget_POLICYEXT := $(gb_Library_DLLEXT)
573 gb_CliAssemblyTarget_get_dll = $(call gb_Library__get_dir_for_layer,NONE)/$(1)$(gb_CliAssemblyTarget_POLICYEXT)
575 # Extension class
577 gb_Extension_LICENSEFILE_DEFAULT := $(INSTROOT)/license.txt
579 # UnpackedTarget class
581 gb_UnpackedTarget_TARFILE_LOCATION := $(shell cygpath -u $(TARFILE_LOCATION))
583 # UnoApiHeadersTarget class
585 ifeq ($(DISABLE_DYNLOADING),TRUE)
586 gb_UnoApiHeadersTarget_select_variant = $(if $(filter udkapi,$(1)),comprehensive,$(2))
587 else
588 gb_UnoApiHeadersTarget_select_variant = $(2)
589 endif
591 # UIConfig class
593 # use responsefile because cui has too many files for command line
594 define gb_UIConfig__command
595 $(call gb_Helper_abbreviate_dirs,\
596 RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),100,$(if $(UI_IMAGELISTS),$(strip $(UI_IMAGELISTS)),/dev/null)) \
597 && tr " " "\000" < $$RESPONSEFILE | tr -d "\r\n" > $$RESPONSEFILE.0 \
598 && $(SORT) -u --files0-from=$$RESPONSEFILE.0 > $@ \
599 && rm $$RESPONSEFILE $$RESPONSEFILE.0 \
602 endef
604 # UIMenubarTarget class
606 define gb_UIMenubarTarget__command
607 $(call gb_Output_announce,$(2),$(true),UIM,1)
608 cp $(3) $(1)
610 endef
612 gb_UIMenubarTarget_UIMenubarTarget_platform :=
614 # Python
615 gb_Python_PRECOMMAND := PATH="$(shell cygpath -w $(INSTDIR)/program)" PYTHONHOME="$(INSTDIR)/program/python-core-$(PYTHON_VERSION)" PYTHONPATH="$(INSTDIR)/program/python-core-$(PYTHON_VERSION)/lib;$(INSTDIR)/program/python-core-$(PYTHON_VERSION)/lib/lib-dynload:$(INSTDIR)/program"
616 gb_Python_INSTALLED_EXECUTABLE := $(INSTROOT)/$(LIBO_BIN_FOLDER)/python.exe
618 gb_ICU_PRECOMMAND := PATH="$(shell cygpath -w $(WORKDIR_FOR_BUILD)/UnpackedTarball/icu/source/lib)"
620 # vim: set noet sw=4: