1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00
cdt/releng/scripts/check_dll_dependencies.sh
Jonah Graham 06c8b01d83 GitHub Action for Code Cleanliness Check
This commit runs GitHub actions for code cleanliness.
Because this includes compare and replace build,
this verifies that the commit is buildable and
clean.

The natives are not rebuilt here (yet) because
the GitHub actions runner does not have the
cross compiler tools installed.

Part of migration to GitHub - Issue #32
2022-10-09 12:14:53 -04:00

41 lines
1.5 KiB
Bash
Executable file

#!/bin/bash
###############################################################################
# Copyright (c) 2020 Kichwa Coders Canada Inc and others.
#
# This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
# which accompanies this distribution, and is available at
# https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
###############################################################################
set -eu
SCRIPT=$( basename "${BASH_SOURCE[0]}" )
if ! command -v x86_64-w64-mingw32-objdump &> /dev/null
then
echo "WARNING: Skipping ${SCRIPT} because mingw cross compiler tools are not available"
exit 0
fi
# This is the current set of allowed DLL dependencies for CDT code. Additional entries here are permitted,
# provided they are found on all Windows machines by default.
ALLOWED_DLLS="KERNEL32.DLL MSVCRT.DLL USER32.DLL PSAPI.DLL SHELL32.DLL ADVAPI32.DLL"
# In addition, the WINPTY.DLL is something CDT ships so is allowed to be a dependency
ALLOWED_DLLS+=" WINPTY.DLL"
exit_code=0
while read line; do
while read import; do
dllname=${import//DLL Name: /}
dllname_upper=${dllname^^}
if [[ ! " ${ALLOWED_DLLS} " =~ " ${dllname_upper} " ]]; then
echo "ERROR: $line has illegal import of ${dllname}"
exit_code=1
fi
done <<<$(x86_64-w64-mingw32-objdump -p $line | grep "DLL Name")
done <<<$(git ls-files -- \*.exe \*.dll)
exit ${exit_code}