This is an automated email from the ASF dual-hosted git repository.

mseidel pushed a commit to branch AOO42X
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit bc01e889163b95849e5617a241242df2f94536ec
Author: Damjan Jovanovic <dam...@apache.org>
AuthorDate: Sun Oct 1 09:48:00 2023 +0200

    For gbuild, when linking a binary on Windows produces a .manifest file,
    embed this manifest into the binary like dmake did.
    
    Unfortunately our old version of LINK.EXE doesn't have the /MANIFEST:EMBED
    option, so the manifest has to be be embedded by calling MT.EXE in a
    separate step.
    
    Also, stop delivering the .manifest files to ${OUTDIR} now.
    
    Patch by: me
    Fixes: #127731 - AOO fails to open ODBC manager
    
    (cherry picked from commit 104751b68faf29eef4f137251f7b9ecd22ed8074)
---
 main/solenv/gbuild/platform/windows.mk | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/main/solenv/gbuild/platform/windows.mk 
b/main/solenv/gbuild/platform/windows.mk
index d65332ea6e..7f60d6b537 100644
--- a/main/solenv/gbuild/platform/windows.mk
+++ b/main/solenv/gbuild/platform/windows.mk
@@ -32,6 +32,7 @@ gb_AS := ml
 gb_CC := cl
 gb_CXX := cl
 gb_LINK := link
+gb_MT := mt
 gb_AWK := awk
 gb_CLASSPATHSEP := ;
 gb_RC := rc
@@ -448,6 +449,8 @@ gb_LinkTarget_INCLUDE_STL := $(filter %/stl, $(subst -I. , 
,$(SOLARINC)))
 
 gb_LinkTarget_get_pdbfile = $(call gb_LinkTarget_get_target,)pdb/$(1).pdb
 
+# Runs the linker command to generate the binary.
+# If a .manifest file is generated, embeds it into the binary.
 define gb_LinkTarget__command
 $(call gb_Output_announce,$(2),$(true),LNK,4)
 $(call gb_Helper_abbreviate_dirs_native,\
@@ -472,7 +475,14 @@ $(call gb_Helper_abbreviate_dirs_native,\
                $(patsubst %,%.lib,$(EXTERNAL_LIBS)) \
                $(foreach lib,$(LINKED_STATIC_LIBS),$(call 
gb_StaticLibrary_get_filename,$(lib))) \
                $(LIBS) \
-               $(if $(DLLTARGET),-out:$(DLLTARGET) -implib:$(1),-out:$(1)); 
RC=$$?; rm $${RESPONSEFILE} \
+               $(if $(DLLTARGET),-out:$(DLLTARGET) -implib:$(1),-out:$(1)); \
+       RC=$$?; \
+       if [ -f $(if $(DLLTARGET),$(DLLTARGET),$(1)).manifest ]; then \
+               $(gb_MT) \
+                       -manifest $(if $(DLLTARGET),$(DLLTARGET),$(1)).manifest 
\
+                       -outputresource:$(if $(DLLTARGET),$(DLLTARGET),$(1)); \
+       fi; \
+       rm $${RESPONSEFILE} \
        $(if $(DLLTARGET),; if [ ! -f $(DLLTARGET) ]; then rm -f $(1) && false; 
fi) ; exit $$RC)
 endef
 
@@ -677,7 +687,6 @@ $(call gb_LinkTarget_set_auxtargets,$(2),\
 
 $(call gb_Executable_get_target,$(1)) \
 $(call gb_Executable_get_clean_target,$(1)) : AUXTARGETS := $(call 
gb_Executable_get_target,$(1)).manifest
-$(call gb_Deliver_add_deliverable,$(call 
gb_Executable_get_target,$(1)).manifest,$(call 
gb_LinkTarget_get_target,$(2)).manifest,$(1))
 
 $(call gb_LinkTarget_get_target,$(2)) \
 $(call gb_LinkTarget_get_headers_target,$(2)) : PDBFILE = $(call 
gb_LinkTarget_get_pdbfile,$(2))

Reply via email to