1
0
Fork 0
dosbox-staging/.github/scripts/shrink-msys2.sh
krcroft 12ee84cfd4 Fixed --enabled-debug on Windows MSYS2
This fixes the prior logic that relies on the (*)curses library
and header existing in compiler-derived default locations
such as /usr/include, and /usr/lib. However, if the package manager
happens to not install them there, then they will not be found
and the check will fail.

Four scenarios:
1. `./configure` or `./configure --enable-debug=no` produce:
    (no mention of debugger; configure continues)

2. `./configure --enable-debug=wrong` produces:
    configure: error: --enable-debug=wrong was requested but the value "wrong" is invalid
    (terminates with exit code 1)

3. `./configure --enable-debug` produces:

    config.h:
    defines C_DEBUG 1

    With only ncurses library installed:

    configure: debugger was requested, finding curses library ...
    checking for NCURSES... yes
    configure: debugger enabled using the ncurses library

    Makefile:
    CPPFLAGS = ... -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -I/usr/local/ncurses ...
    LIBS = ...  -L/usr/local/ncurses -lncurses -ltinfo ...

    With only ncursesw installed:

    configure: debugger was requested, finding curses library ...
    checking for NCURSES... no
    checking for NCURSESW... yes
    configure: debugger enabled using the ncursesw library

    Makefile:
    CPPFLAGS = ... -I/opt/ncursesw ...
    LIBS = ... -L/opt/ncursesw -lncursesw ...

    With only pdcurses isntalled:

    configure: debugger was requested, finding curses library ...
    checking for NCURSES... no
    checking for NCURSESW... no
    checking for PDCURSES... yes
    configure: debugger enabled using the pdcurses library

    Makefile:
    CPPFLAGS = ... -I/usr/local/pdcurses ...
    LIBS = ...  -L/usr/local/pdcurses -lpdcurses -ltinfo ...

    Without any curses library installed:

    configure: debugger was requested, finding curses library ...
    checking for NCURSES... no
    checking for NCURSESW... no
    checking for PDCURSES... no
    configure: error: Package requirements were not met:
    <pkg-info prints info about missing package>
    (terminates with exit code 1)

4. `./configure --enable-debug=heavy` produces same as above, but:

    config.h:
    defines C_DEBUG 1
    defines C_HEAVY_DEBUG 1

    The configure message mentions heavy, for example:

    configure: debugger was requested, finding curses library ...
    checking for NCURSES... yes
    configure: debugger with heavy debugging enabled using the ncurses library
2019-12-14 17:51:11 +01:00

45 lines
1.1 KiB
Bash
Executable file

#!/bin/bash
# Copyright (c) 2019 Kevin R Croft <krcroft@gmail.com>
# SPDX-License-Identifier: GPL-2.0-or-later
# This script reduces the size of an MSYS2 and MingGW installation
# under Windows. Its main use is to shrink these areas to fit within
# GitHub's cache limits; however it can also be used by end-users wanting
# to save space.
#
# Usage: ./shrink-msys2.sh
#
set -xuo pipefail
set +e
# Clean all the package archives from pacman
pacman -Scc --noconfirm
# Strip binaries using their associated striping tool
for dir in /usr /mingw32 /mingw64; do
# Enter our directory if we have it
cd "${dir}" || continue
# Check if we have an associated stripping tool
if [[ ! -f "bin/strip.exe" ]]; then continue; fi
# Start stripping
find . -type f \
\( -iname '*.exe' \
-or -iname '*.a' \
-or -iname '*.dll' \
-or -iname '*.so' \
\) \
-a ! -iname 'strip.exe' \
-print0 \
| xargs -0 ./bin/strip.exe --strip-unneeded
done
# Delete documentation directories
rm -rf /mingw*/share/man
rm -rf /mingw*/share/doc
# This entire script is best-effort, so always return success
exit 0