Skip to content

Commit

Permalink
Add a placeholder XML manifest to ruby.exe and all extension DLLs
Browse files Browse the repository at this point in the history
This allows to add a customized manifest within the installer build process later on.
The Microsoft mt.exe allows to add a manifest to a EXE or DLL file after the build.
But there is no such tool in gcc/llvm.
So adding a placeholder manifest allows to later change the XML with simple text replacement.
That way the ruby build doesn't need any patches and is not bound too much to the installer.

Also use a build directory like the MSYS2/MINGW-packages.
  • Loading branch information
larskanis committed Dec 23, 2024
1 parent 9d1787f commit 8e0366b
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 10 deletions.
24 changes: 14 additions & 10 deletions mingw-w64-ruby-head/PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
_realname=ruby
pkgbase=mingw-w64-ruby-head
pkgname="${MINGW_PACKAGE_PREFIX}-ruby-head"
pkgver=r20241214
pkgver=r20241223
pkgver() {
echo r`date +%Y%m%d`
}
Expand All @@ -25,7 +25,9 @@ source=("https://cache.ruby-lang.org/pub/ruby/snapshot/snapshot-master.tar.xz"
0001-Add-C-ext-win32-dll_directory-as-an-alternative-to-f.patch
0002-Don-t-add-an-exe-file-manifest.patch
ruby.ico
rubyw.ico)
rubyw.ico
placeholder-manifest.rc
placeholder.manifest.xml)
noextract=("snapshot-master.tar.xz")

# To update SHA256 hashs run: ridk exec sh -c "updpkgsums PKGBUILD"
Expand All @@ -35,7 +37,9 @@ sha256sums=('SKIP'
'a50c81ab8c178689485257f8eaa70bd8184b878a798780084668f838912e2832'
'da079dbfdc3d4e1b976ed15d58244ed6e0df201ec829bead578fb4a7177b9cab'
'6c80ba2ca49840e387a08b7fedc6e7acd298ac2ec853155209efb2af20397b22'
'c30fb04ac0e88ba634daaa811a81ea5a75027646617b895acd14df9518a4a55a')
'c30fb04ac0e88ba634daaa811a81ea5a75027646617b895acd14df9518a4a55a'
'c064d0de1b8f2d59a19ba2f7b32e5d61d009abe6c4e7fca43c833541c7f7fa71'
'c7a555d4826453efe7e33a2ebf78462b1fa665dffd7e4972143b48b1c9c71375')

prepare() {
bsdtar -xf snapshot-master.tar.xz || true
Expand All @@ -47,19 +51,19 @@ prepare() {
}

build() {
mkdir -p build-${MSYSTEM} && cd build-${MSYSTEM}

CFLAGS="-O3 -fstack-protector-strong"
LDFLAGS="-pipe -s -fstack-protector-strong"
PLACEHOLDER_RES=`cygpath -m ${srcdir}/build-${MSYSTEM}/placeholder-manifest.res`
LDFLAGS="-pipe -s -fstack-protector-strong ${PLACEHOLDER_RES}"
if [[ ${MSYSTEM} == CLANG* ]]; then
CFLAGS+=" -Wno-dll-attribute-on-redeclaration"
CFLAGS+=" -Wno-dll-attribute-on-redeclaration -Wno-shorten-64-to-32"
else
CFLAGS+=" -Wno-incompatible-pointer-types"
fi

[[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
mkdir -p "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"

cp ${srcdir}/*.ico .
windres --input ${srcdir}/placeholder-manifest.rc --output ${srcdir}/build-${MSYSTEM}/placeholder-manifest.res --output-format=coff

../snapshot-master/configure \
--prefix=${MINGW_PREFIX} \
Expand All @@ -76,15 +80,15 @@ build() {
}

check() {
cd "${srcdir}/build-${MINGW_CHOST}"
cd build-${MSYSTEM}
echo $PATH
make -l "TESTOPTS=-q" btest test-basic
# TODO: Full tests fail currently
# make -l "TESTOPTS=-q" test-all || true
}

package() {
cd "${srcdir}/build-${MINGW_CHOST}"
cd build-${MSYSTEM}
make -f GNUMakefile DESTDIR="${pkgdir}" install
for script in gem; do
install ${srcdir}/snapshot-master/bin/${script} \
Expand Down
2 changes: 2 additions & 0 deletions mingw-w64-ruby-head/placeholder-manifest.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include "winuser.h"
2 RT_MANIFEST placeholder.manifest.xml
43 changes: 43 additions & 0 deletions mingw-w64-ruby-head/placeholder.manifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
<!-- Enough space for a valid manifest in the DLL -->
</assembly>

0 comments on commit 8e0366b

Please sign in to comment.