From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 545281382C5 for ; Wed, 24 Jan 2018 16:23:56 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8815BE0891; Wed, 24 Jan 2018 16:23:55 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 5A6B9E0891 for ; Wed, 24 Jan 2018 16:23:55 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id E4AE7335C2F for ; Wed, 24 Jan 2018 16:23:53 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 7CE2815D for ; Wed, 24 Jan 2018 16:23:52 +0000 (UTC) From: "Michael Haubenwallner" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michael Haubenwallner" Message-ID: <1516810965.22b59662d21039f8f3246d12a2ac0bbb93d35683.haubi@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: profiles/prefix/windows/winnt/ X-VCS-Repository: repo/gentoo X-VCS-Files: profiles/prefix/windows/winnt/profile.bashrc X-VCS-Directories: profiles/prefix/windows/winnt/ X-VCS-Committer: haubi X-VCS-Committer-Name: Michael Haubenwallner X-VCS-Revision: 22b59662d21039f8f3246d12a2ac0bbb93d35683 X-VCS-Branch: master Date: Wed, 24 Jan 2018 16:23:52 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 7a2f9575-66d5-472f-88e0-2cb12611d365 X-Archives-Hash: df4b0a2c5b347e8c40928477abe8c829 commit: 22b59662d21039f8f3246d12a2ac0bbb93d35683 Author: Michael Haubenwallner gentoo org> AuthorDate: Wed Jan 24 16:10:36 2018 +0000 Commit: Michael Haubenwallner gentoo org> CommitDate: Wed Jan 24 16:22:45 2018 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=22b59662 prefix/winnt/profiles.bashrc: improve winnt helpers With Gentoo Parity wrapping the Visual Studio compiler, build systems unaware of Windows can create .so import libraries just fine. But Windows aware build systems do prefer .lib import libraries, so we do create .lib -> .so symlinks, resolved by Gentoo Parity later on again. Additionally, they don't know about the additional .dll to install. So we wrap the cp utility to also copy the dll when the library is copied. profiles/prefix/windows/winnt/profile.bashrc | 159 +++++++++++++++++++++++++-- 1 file changed, 149 insertions(+), 10 deletions(-) diff --git a/profiles/prefix/windows/winnt/profile.bashrc b/profiles/prefix/windows/winnt/profile.bashrc index f1c5c365338..7d1251609c0 100644 --- a/profiles/prefix/windows/winnt/profile.bashrc +++ b/profiles/prefix/windows/winnt/profile.bashrc @@ -1,4 +1,4 @@ -# Copyright 1999-2009 Gentoo Foundation +# Copyright 1999-2018 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # On windows, binary files (executables, shared libraries) in use @@ -13,6 +13,20 @@ # Need to explicitly set PKG_CONFIG_PATH for cross EPREFIX. export PKG_CONFIG_PATH="${EPREFIX}/lib/pkgconfig:${EPREFIX}/usr/lib/pkgconfig" +windows_setup_dllhelper() { + case ${CATEGORY}/${PN} in + sys-libs/zlib |\ + '') + # When a package build system does not know about Windows at all, + # still it can be built for Windows using Gentoo Parity. + # But as there is another file to install (the real dll), + # and installation is done using cp, we override cp to + # additionally copy the dll when the library is copied. + windows_setup_dllhelper_cp + ;; + esac +} + windows_cleanup_removed_files() { local removedlist=$1 rm -f "${removedlist}".new @@ -78,17 +92,36 @@ windows_prepare_file() { post_src_install() { cd "${ED}" - find . -name '*.exe' | while read f; do - if file "${f}" | grep "GUI" > /dev/null 2>&1; then - if test ! -f "${f%.exe}"; then - einfo "Windows GUI Executable $f will have no symlink." + find . -name '*.exe' -o -name '*.dll.a' -o -name '*.so' | + while read f + do + f=${f#./} + case ${f} in + *.exe) + if file "./${f}" | grep "GUI" > /dev/null 2>&1; then + if test ! -f "./${f%.exe}"; then + einfo "Windows GUI Executable $f will have no symlink." + fi + else + if test ! -f "./${f%.exe}"; then + ebegin "creating ${f%.exe} -> ${f} for console accessibility." + eend $(ln -sf "$(basename "${f}")" "./${f%.exe}" && echo 0 || echo 1) + fi fi - else - if test ! -f "${f%.exe}"; then - ebegin "creating ${f%.exe} -> ${f} for console accessibility." - eend $(ln -sf "$(basename "${f}")" "${f%.exe}" && echo 0 || echo 1) + ;; + *.dll.a) + if test ! -f "./${f%.a}.lib"; then + ebegin "creating ${f%.a}.lib -> ${f##*/} for libtool linkability" + eend $(ln -sf "$(basename "${f}")" "./${f%.a}.lib" && echo 0 || echo 1) fi - fi + ;; + *.so) + if test ! -f "${f%.so}.dll.lib"; then + ebegin "creating ${f%.so}.dll.lib -> ${f##*/} for libtool linkability" + eend $(ln -sf "$(basename "${f}")" "./${f%.so}.dll.lib" && echo 0 || echo 1) + fi + ;; + esac done } @@ -149,3 +182,109 @@ pre_pkg_postrm() { local removedlist="${EROOT}var/lib/portage/files2bremoved" windows_cleanup_removed_files $removedlist } + +windows_setup_dllhelper_cp() { + if ! [[ $(type -P cp) -ef ${T}/dllhelper/cp ]] + then + mkdir -p "${T}/dllhelper" + cat > "${T}/dllhelper/cp" <<'EOCP' +#!/usr/bin/env bash + +mysrcs=() +myopts=() +mydest= +force_dest_file_opt= + +nextargs=( "$@" ) + +while [[ $# > 0 ]] +do + arg=${1} + shift + case ${arg} in + --) + mysrcs+=( "${@}" ) + break + ;; + -S) + myopts+=( "${arg}" ${1+"$1"} ) + ${1:+shift} + ;; + -t) + mydest="${1-}" + ${1:+shift} + ;; + -T) + force_dest_file_opt=${arg} + ;; + -*) + myopts+=( "${arg}" ) + ;; + *) + mysrcs+=( "${arg}" ) + ;; + esac +done + +me=${0##*/} +nextPATH= +oIFS=$IFS +IFS=: +for p in ${PATH} +do + [[ ${p}/${me} -ef ${0} ]] && continue + nextPATH+=${nextPATH:+:}${p} +done +IFS=${oIFS} + +PATH=${nextPATH} + +${me} "${nextargs[@]}" +ret=$? +[[ ${ret} == 0 ]] || exit ${ret} + +if [[ -z ${mydest} ]] +then + [[ ${#mysrcs[@]} < 2 ]] && exit 0 + : "${mysrcs[@]}" "${#mysrcs[@]}" + mydest=${mysrcs[${#mysrcs[@]}-1]} + unset mysrcs[${#mysrcs[@]}-1] +elif [[ ${#mysrcs[@]} == 0 ]] +then + exit 0 +fi + +for src in ${mysrcs[@]} +do + ret=0 + [[ ${src##*/} != lib*.so* ]] && continue + for ext in dll pdb + do + [[ ${src##*/} == *.${ext} ]] && continue + [[ -f ${src} && -f ${src}.${ext} ]] || continue + if [[ -d ${mydest} && ! -n ${force_dest_file_opt} ]] + then + # When copying to directory we keep the basename. + ${me} -T "${myopts[@]}" "${src}.${ext}" "${mydest}/${src##*/}.${ext}" + ret=$? + elif [[ ${mydest##*/} == ${src##*/} ]] + then + # Copy the dll only when we keep the basename. + ${me} -T "${myopts[@]}" "${src}.${ext}" "${mydest}.${ext}" + ret=$? + fi + [[ ${ret} == 0 ]] || exit ${ret} + done +done + +exit 0 +EOCP + chmod +x "${T}/dllhelper/cp" + PATH="${T}/dllhelper:${PATH}" + fi +} + +if [[ ${EBUILD_PHASE} == 'setup' ]] +then + windows_setup_dllhelper +fi