Embed manifest with VS2013 or later

Since VS2013, `link.exe` supports `-manifest:embed` option.
[`/MANIFEST` (Create side-by-side assembly manifest)](https://learn.microsoft.com/en-us/cpp/build/reference/manifest-create-side-by-side-assembly-manifest?view=msvc-170&viewFallbackFrom=msvc-120)
This commit is contained in:
Nobuyoshi Nakada 2024-03-12 22:57:41 +09:00
Родитель f8cab4ef8e
Коммит 5d71880df6
1 изменённых файлов: 14 добавлений и 2 удалений

Просмотреть файл

@ -338,7 +338,9 @@ ARFLAGS = -machine:$(MACHINE) -out:
LD = $(CC)
LDSHARED = $(LD) -LD
XCFLAGS = -DRUBY_EXPORT $(INCFLAGS) $(XCFLAGS)
!if $(MSC_VER) >= 1400
!if $(MSC_VER) >= 1800
LDFLAGS = $(LDFLAGS) -manifest:embed,ID=2
!elseif $(MSC_VER) >= 1400
# Prevents VC++ 2005 (cl ver 14) warnings
MANIFESTTOOL = mt -nologo
LDSHARED_0 = @if exist $(@).manifest $(MINIRUBY) -run -e wait_writable -- -n 10 $@
@ -1074,7 +1076,7 @@ s,@LIBPATHFLAG@, -libpath:%s,;t t
s,@RPATHFLAG@,,;t t
s,@LIBARG@,%s.lib,;t t
s,@LINK_SO@,$$(LDSHARED) -Fe$$(@) $$(OBJS) $$(LIBS) $$(LOCAL_LIBS) -link $$(DLDFLAGS) -implib:$$(*F:.so=)-$$(arch).lib -pdb:$$(*F:.so=)-$$(arch).pdb -def:$$(DEFFILE),;t t
!if $(MSC_VER) >= 1400
!if $(MSC_VER) >= 1400 && $(MSC_VER) < 1800
s,@LINK_SO@,@if exist $$(@).manifest $$(RUBY) -run -e wait_writable -- -n 10 $$(@),;t t
s,@LINK_SO@,@if exist $$(@).manifest $(MANIFESTTOOL) -manifest $$(@).manifest -outputresource:$$(@);2,;t t
s,@LINK_SO@,@if exist $$(@).manifest $$(RM) $$(@:/=\).manifest,;t t
@ -1154,9 +1156,11 @@ $(PROGRAM): $(MAINOBJ) $(LIBRUBY_SO) $(RUBY_INSTALL_NAME).res
$(ECHO) linking $(@:\=/)
$(Q) $(PURIFY) $(CC) $(MAINOBJ) $(EXTOBJS) $(RUBY_INSTALL_NAME).res \
$(OUTFLAG)$@ $(LIBRUBYARG) -link $(LDFLAGS) $(XLDFLAGS)
! if defined(LDSHARED_0)
$(Q) $(LDSHARED_0)
$(Q) $(LDSHARED_1)
$(Q) $(LDSHARED_2)
! endif
!endif
!if "$(WPROGRAM)" != ""
@ -1165,9 +1169,11 @@ $(WPROGRAM): $(MAINOBJ) $(WINMAINOBJ) $(LIBRUBY_SO) $(RUBYW_INSTALL_NAME).res
$(Q) $(PURIFY) $(CC) $(MAINOBJ) $(WINMAINOBJ) \
$(RUBYW_INSTALL_NAME).res $(OUTFLAG)$@ $(LIBRUBYARG) \
-link $(LDFLAGS) $(XLDFLAGS) -subsystem:Windows
! if defined(LDSHARED_0)
$(Q) $(LDSHARED_0)
$(Q) $(LDSHARED_1)
$(Q) $(LDSHARED_2)
! endif
!endif
!if "$(STUBPROGRAM)" != ""
@ -1175,9 +1181,11 @@ $(STUBPROGRAM): rubystub.$(OBJEXT) $(LIBRUBY) $(LIBRUBY_SO) $(RUBY_INSTALL_NAME)
$(ECHO) linking $(@:\=/)
$(Q) $(PURIFY) $(CC) rubystub.$(OBJEXT) $(RUBY_INSTALL_NAME).res \
$(OUTFLAG)$@ $(LIBRUBYARG) -link $(LDFLAGS) $(XLDFLAGS)
! if defined(LDSHARED_0)
$(Q) $(LDSHARED_0)
$(Q) $(LDSHARED_1)
$(Q) $(LDSHARED_2)
! endif
!endif
!if "$(LIBRUBY_SO_UPDATE)" == ""
@ -1207,10 +1215,12 @@ $(LIBRUBY_SO): $(LIBRUBY_A) $(DLDOBJS) $(RUBYDEF) $(RUBY_SO_NAME).res
$(RUBY_SO_NAME).res $(SOLIBS) $(EXTSOLIBS) $(LIBS) -Fe$@ -link $(LDFLAGS) \
$(LIBRUBY_DLDFLAGS)
@$(RM) dummy.lib dummy.exp
!if defined(LDSHARED_0)
$(Q) $(LDSHARED_0)
$(Q) $(LDSHARED_1)
$(Q) $(LDSHARED_2)
# | findstr -v -c:LNK4049 -c:LNK4217
!endif
$(RUBYDEF): $(LIBRUBY_A) $(RBCONFIG)
$(ECHO) generating $(@:\=/)
@ -1416,8 +1426,10 @@ rubyspec-capiext: $(RUBYSPEC_CAPIEXT_EXTS)
$(Q)echo> $*.def EXPORTS
$(Q)echo>> $*.def Init_$(*F)
$(Q)$(LDSHARED) -Fe$(@) $(INCFLAGS) $(CFLAGS) $(CPPFLAGS) $< $(LIBRUBYARG) -link $(DLDFLAGS) $(LIBS) $(LOCAL_LIBS) -implib:$*.lib -pdb:$*.pdb -def:$*.def
!if defined(LDSHARED_0)
$(Q)$(LDSHARED_0)
$(Q)$(LDSHARED_1)
$(Q)$(LDSHARED_2)
!endif
exts: rubyspec-capiext