Skip to content

Commit

Permalink
Fixed CI executable find scripts for multi platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
FangCunWuChang committed Jul 31, 2024
1 parent e106b8f commit afb8e72
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 25 deletions.
28 changes: 28 additions & 0 deletions CIUtils/find-elf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Check if a directory is provided as an argument
if [ -z "$1" ]; then
echo "Usage: $0 <directory>"
exit 1
fi

# Directory to search
directory=$1

# Find ELF files in the specified directory
files=$(find "$directory" -type f -exec sh -c 'file -b "$1" | grep -q "ELF" && echo "$1"' _ {} \;)

# Initialize an empty string for the output
output=""

# Loop through each file and format it
for file in $files; do
if [ -z "$output" ]; then
output="\"$file\""
else
output="$output,\"$file\""
fi
done

# Print the formatted output
echo $output
40 changes: 15 additions & 25 deletions CIUtils/find-executable.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
#!/bin/bash

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

# Directory to search
directory=$1

# Find ELF, Mach-O and Universal Binary files in the specified directory
files=$(find "$directory" -type f -exec sh -c 'file -b "$1" | grep -q "ELF|Mach-O|universal binary" && echo "$1"' _ {} \;)

# Initialize an empty string for the output
output=""

# Loop through each file and format it
for file in $files; do
if [ -z "$output" ]; then
output="\"$file\""
else
output="$output,\"$file\""
fi
done

# Print the formatted output
echo $output
# Execute the corresponding script based on the operating system
case "$os_type" in
Linux)
echo $(./find-elf.sh "$1")
;;
Darwin)
echo $(./find-macho.sh "$1")
;;
*)
echo "Unsupported OS: $os_type"
exit 1
;;
esac
28 changes: 28 additions & 0 deletions CIUtils/find-macho.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Check if a directory is provided as an argument
if [ -z "$1" ]; then
echo "Usage: $0 <directory>"
exit 1
fi

# Directory to search
directory=$1

# Find Mach-O and Universal Binary files in the specified directory
files=$(find "$directory" -type f -exec sh -c 'file -b "$1" | grep -q "Mach-O|universal binary" && echo "$1"' _ {} \;)

# Initialize an empty string for the output
output=""

# Loop through each file and format it
for file in $files; do
if [ -z "$output" ]; then
output="\"$file\""
else
output="$output,\"$file\""
fi
done

# Print the formatted output
echo $output

0 comments on commit afb8e72

Please sign in to comment.