58 lines
1.9 KiB
Bash
Executable File
58 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Regenerate MinGW import libraries for the in-scope companion DLLs (T3).
|
|
# Conventions and derivation: docs/companion-conventions.md.
|
|
#
|
|
# --kill-at strips the @N decoration dlltool would otherwise read off the
|
|
# .def and write into the import name; applying it to a cdecl DLL would
|
|
# mislabel the import's ABI, so it is passed only for the stdcall entries
|
|
# below (arkkdm and Kinect10 both export under their plain, undecorated
|
|
# names despite being stdcall -- see docs/companion-conventions.md).
|
|
#
|
|
# Usage: tools/gen_importlibs.sh [source_dir]
|
|
# Must be run with the i686 cross toolchain on PATH (source ./activate.sh).
|
|
|
|
set -euo pipefail
|
|
|
|
SELF_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd "$SELF_DIR/.." && pwd)"
|
|
SRC_DIR="${1:-/mnt/f/Users/Aaron Thapa/Downloads/KDM-2016021900/contents}"
|
|
OUT_DIR="$REPO_ROOT/re/importlibs"
|
|
|
|
for tool in gendef i686-w64-mingw32-dlltool; do
|
|
command -v "$tool" >/dev/null 2>&1 || {
|
|
echo "gen_importlibs.sh: required tool '$tool' not found on PATH; source activate.sh first" >&2
|
|
exit 1
|
|
}
|
|
done
|
|
|
|
mkdir -p "$OUT_DIR"
|
|
|
|
declare -A CONV=( # name -> cdecl | stdcall
|
|
[libavs-win32]=cdecl
|
|
[libavs-win32-ea3]=cdecl
|
|
[libafp-win32]=cdecl
|
|
[libafputils-win32]=cdecl
|
|
[ess]=cdecl
|
|
[arkkdm]=stdcall
|
|
[libacio]=cdecl
|
|
[Kinect10]=stdcall
|
|
)
|
|
|
|
WORK="$(mktemp -d)"
|
|
trap 'rm -rf "$WORK"' EXIT
|
|
|
|
for name in "${!CONV[@]}"; do
|
|
dll="$SRC_DIR/$name.dll"
|
|
[ -f "$dll" ] || { echo "gen_importlibs.sh: missing $dll" >&2; exit 1; }
|
|
|
|
cp "$dll" "$WORK/$name.dll"
|
|
(cd "$WORK" && gendef "$name.dll")
|
|
|
|
dlltool_flags=(-d "$WORK/$name.def" -l "$OUT_DIR/lib$name.dll.a" -D "$name.dll")
|
|
[ "${CONV[$name]}" = stdcall ] && dlltool_flags+=(--kill-at)
|
|
i686-w64-mingw32-dlltool "${dlltool_flags[@]}"
|
|
|
|
cp "$WORK/$name.def" "$OUT_DIR/$name.def"
|
|
echo "generated $OUT_DIR/lib$name.dll.a (${CONV[$name]}) from $WORK/$name.def"
|
|
done
|