Skip to content

Commit 4ece696

Browse files
committed
Add C# IL extractor autobuild and indexing scripts
Introduces autobuild.sh and index-files.sh scripts for the C# IL extractor. These scripts set up environment variables, determine platform-specific extractor paths, and automate extraction of DLL and EXE assemblies for CodeQL analysis.
1 parent 9a6c536 commit 4ece696

2 files changed

Lines changed: 71 additions & 0 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
if [[ -z "${CODEQL_EXTRACTOR_CIL_ROOT:-}" ]]; then
6+
export CODEQL_EXTRACTOR_CIL_ROOT="$(dirname "$(dirname "${BASH_SOURCE[0]}")")"
7+
fi
8+
9+
# For C# IL, autobuild and buildless extraction are the same - just extract the DLLs
10+
exec "${CODEQL_EXTRACTOR_CIL_ROOT}/tools/index-files.sh"
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
# Get the extractor root directory
6+
if [[ -z "${CODEQL_EXTRACTOR_CIL_ROOT:-}" ]]; then
7+
export CODEQL_EXTRACTOR_CIL_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
8+
fi
9+
10+
# Get the trap directory from CodeQL environment
11+
TRAP_DIR="${CODEQL_EXTRACTOR_CIL_TRAP_DIR}"
12+
SRC_ARCHIVE="${CODEQL_EXTRACTOR_CIL_SOURCE_ARCHIVE_DIR}"
13+
14+
echo "C# IL Extractor: Starting extraction"
15+
echo "Source root: $(pwd)"
16+
echo "TRAP directory: ${TRAP_DIR}"
17+
echo "Extractor root: ${CODEQL_EXTRACTOR_CIL_ROOT}"
18+
19+
# Ensure TRAP directory exists
20+
mkdir -p "${TRAP_DIR}"
21+
mkdir -p "${SRC_ARCHIVE}"
22+
23+
# Determine the platform-specific extractor path
24+
case "$(uname -s)-$(uname -m)" in
25+
Darwin-arm64)
26+
PLATFORM_DIR="osx-arm64"
27+
;;
28+
Darwin-x86_64)
29+
PLATFORM_DIR="osx-x64"
30+
;;
31+
Linux-x86_64)
32+
PLATFORM_DIR="linux-x64"
33+
;;
34+
*)
35+
PLATFORM_DIR="win64"
36+
;;
37+
esac
38+
39+
EXTRACTOR_DLL="${CODEQL_EXTRACTOR_CIL_ROOT}/tools/${PLATFORM_DIR}/Semmle.Extraction.CSharp.IL.dll"
40+
41+
if [[ ! -f "${EXTRACTOR_DLL}" ]]; then
42+
echo "ERROR: Extractor not found at ${EXTRACTOR_DLL}"
43+
exit 1
44+
fi
45+
46+
# Create a temporary file list
47+
FILE_LIST=$(mktemp)
48+
trap "rm -f ${FILE_LIST}" EXIT
49+
50+
# Find all DLL and EXE files in the source root
51+
find . -type f \( -name "*.dll" -o -name "*.exe" \) > "${FILE_LIST}"
52+
53+
FILE_COUNT=$(wc -l < "${FILE_LIST}" | tr -d ' ')
54+
echo "Found ${FILE_COUNT} assemblies to extract"
55+
56+
if [[ "${FILE_COUNT}" -gt 0 ]]; then
57+
# Run the extractor with the file list
58+
dotnet "${EXTRACTOR_DLL}" "${FILE_LIST}"
59+
fi
60+
61+
echo "C# IL Extractor: Completed extraction"

0 commit comments

Comments
 (0)