Skip to content

Commit 462479a

Browse files
committed
Simplify CIL autobuild and index scripts
Refactored autobuild.sh and index-files.sh scripts for CIL to use direct CodeQL CLI commands and simplified dotnet invocation, to match windows implementations.
1 parent e70a576 commit 462479a

4 files changed

Lines changed: 8 additions & 122 deletions

File tree

binary/extractor/cil/tools/autobuild.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,4 @@
22

33
set -eu
44

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"
5+
"$CODEQL_DIST/codeql" database index-files --working-dir=. --language=cil "$CODEQL_EXTRACTOR_CIL_WIP_DATABASE"

binary/extractor/cil/tools/index-files.sh

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,8 @@
22

33
set -eu
44

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)"
5+
if [[ -z "${CODEQL_CIL_EXTRACTOR:-}" ]]; then
6+
CODEQL_CIL_EXTRACTOR=Semmle.Extraction.CSharp.IL
87
fi
98

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"
9+
exec dotnet "$CODEQL_EXTRACTOR_CIL_ROOT/tools/$CODEQL_PLATFORM/$CODEQL_CIL_EXTRACTOR.dll" "$1"

binary/tools/cil/autobuild.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,4 @@
22

33
set -eu
44

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"
5+
"$CODEQL_DIST/codeql" database index-files --working-dir=. --language=cil "$CODEQL_EXTRACTOR_CIL_WIP_DATABASE"

binary/tools/cil/index-files.sh

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,8 @@
22

33
set -eu
44

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)"
5+
if [[ -z "${CODEQL_CIL_EXTRACTOR:-}" ]]; then
6+
CODEQL_CIL_EXTRACTOR=Semmle.Extraction.CSharp.IL
87
fi
98

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"
9+
exec dotnet "$CODEQL_EXTRACTOR_CIL_ROOT/tools/$CODEQL_PLATFORM/$CODEQL_CIL_EXTRACTOR.dll" "$1"

0 commit comments

Comments
 (0)