Skip to content

Commit afb8e72

Browse files
Fixed CI executable find scripts for multi platforms
1 parent e106b8f commit afb8e72

File tree

3 files changed

+71
-25
lines changed

3 files changed

+71
-25
lines changed

CIUtils/find-elf.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
# Check if a directory is provided as an argument
4+
if [ -z "$1" ]; then
5+
echo "Usage: $0 <directory>"
6+
exit 1
7+
fi
8+
9+
# Directory to search
10+
directory=$1
11+
12+
# Find ELF files in the specified directory
13+
files=$(find "$directory" -type f -exec sh -c 'file -b "$1" | grep -q "ELF" && echo "$1"' _ {} \;)
14+
15+
# Initialize an empty string for the output
16+
output=""
17+
18+
# Loop through each file and format it
19+
for file in $files; do
20+
if [ -z "$output" ]; then
21+
output="\"$file\""
22+
else
23+
output="$output,\"$file\""
24+
fi
25+
done
26+
27+
# Print the formatted output
28+
echo $output

CIUtils/find-executable.sh

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,18 @@
11
#!/bin/bash
22

3-
# Check if a directory is provided as an argument
4-
if [ -z "$1" ]; then
5-
echo "Usage: $0 <directory>"
6-
exit 1
7-
fi
3+
# Detect the operating system
4+
os_type=$(uname)
85

9-
# Directory to search
10-
directory=$1
11-
12-
# Find ELF, Mach-O and Universal Binary files in the specified directory
13-
files=$(find "$directory" -type f -exec sh -c 'file -b "$1" | grep -q "ELF|Mach-O|universal binary" && echo "$1"' _ {} \;)
14-
15-
# Initialize an empty string for the output
16-
output=""
17-
18-
# Loop through each file and format it
19-
for file in $files; do
20-
if [ -z "$output" ]; then
21-
output="\"$file\""
22-
else
23-
output="$output,\"$file\""
24-
fi
25-
done
26-
27-
# Print the formatted output
28-
echo $output
6+
# Execute the corresponding script based on the operating system
7+
case "$os_type" in
8+
Linux)
9+
echo $(./find-elf.sh "$1")
10+
;;
11+
Darwin)
12+
echo $(./find-macho.sh "$1")
13+
;;
14+
*)
15+
echo "Unsupported OS: $os_type"
16+
exit 1
17+
;;
18+
esac

CIUtils/find-macho.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
# Check if a directory is provided as an argument
4+
if [ -z "$1" ]; then
5+
echo "Usage: $0 <directory>"
6+
exit 1
7+
fi
8+
9+
# Directory to search
10+
directory=$1
11+
12+
# Find Mach-O and Universal Binary files in the specified directory
13+
files=$(find "$directory" -type f -exec sh -c 'file -b "$1" | grep -q "Mach-O|universal binary" && echo "$1"' _ {} \;)
14+
15+
# Initialize an empty string for the output
16+
output=""
17+
18+
# Loop through each file and format it
19+
for file in $files; do
20+
if [ -z "$output" ]; then
21+
output="\"$file\""
22+
else
23+
output="$output,\"$file\""
24+
fi
25+
done
26+
27+
# Print the formatted output
28+
echo $output

0 commit comments

Comments
 (0)