Skip to content

Commit 937bdd3

Browse files
committed
Generate .S list
1 parent ace3765 commit 937bdd3

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

scripts/update_cmakelists.sh

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,35 +26,54 @@ case "$(uname -s)" in
2626
;;
2727
esac
2828

29-
function update_cmakelists() {
29+
function update_cmakelists_source() {
3030
src_root="$here/Sources/$1"
31-
31+
3232
# Build an array with the rest of the arguments
3333
shift
3434
src_exts=("$@")
3535
echo "Finding source files (${src_exts[@]}) under $src_root"
36-
36+
3737
num_exts=${#src_exts[@]}
38-
38+
3939
# Build file extensions argument for `find`
4040
declare -a exts_arg
4141
exts_arg+=(-name "${src_exts[0]}")
4242
for (( i=1; i<$num_exts; i++ ));
4343
do
4444
exts_arg+=(-o -name "${src_exts[$i]}")
4545
done
46-
46+
4747
# Wrap quotes around each filename since it might contain spaces
4848
srcs=$($find "${src_root}" -type f \( "${exts_arg[@]}" \) -printf ' "%P"\n' | LC_ALL=POSIX sort)
4949
echo "$srcs"
50-
50+
5151
# Update list of source files in CMakeLists.txt
5252
# The first part in `BEGIN` (i.e., `undef $/;`) is for working with multi-line;
5353
# the second is so that we can pass in a variable to replace with.
5454
perl -pi -e 'BEGIN { undef $/; $replace = shift } s/add_library\(([^\n]+)\n([^\)]+)/add_library\($1\n$replace/' "$srcs" "$src_root/CMakeLists.txt"
5555
echo "Updated $src_root/CMakeLists.txt"
5656
}
5757

58-
update_cmakelists "CCryptoBoringSSL" "*.c"
59-
update_cmakelists "CCryptoBoringSSLShims" "*.c"
60-
update_cmakelists "Crypto" "*.swift"
58+
function update_cmakelists_assembly() {
59+
src_root="$here/Sources/$1"
60+
echo "Finding assembly files (.S) under $src_root"
61+
62+
mac_asms=$($find "${src_root}" -type f -name "*.mac.x86_64.S" -printf ' %P\n' | LC_ALL=POSIX sort)
63+
linux_asms=$($find "${src_root}" -type f -name "*.linux.x86_64.S" -printf ' %P\n' | LC_ALL=POSIX sort)
64+
echo "$mac_asms"
65+
echo "$linux_asms"
66+
67+
# Update list of assembly files in CMakeLists.txt
68+
# The first part in `BEGIN` (i.e., `undef $/;`) is for working with multi-line;
69+
# the second is so that we can pass in a variable to replace with.
70+
perl -pi -e 'BEGIN { undef $/; $replace = shift } s/Darwin\)\n(.+)target_sources\(([^\n]+)\n([^\)]+)/Darwin\)\n$1target_sources\($2\n$replace/' "$mac_asms" "$src_root/CMakeLists.txt"
71+
perl -pi -e 'BEGIN { undef $/; $replace = shift } s/Linux\)\n(.+)target_sources\(([^\n]+)\n([^\)]+)/Linux\)\n$1target_sources\($2\n$replace/' "$linux_asms" "$src_root/CMakeLists.txt"
72+
echo "Updated $src_root/CMakeLists.txt"
73+
}
74+
75+
update_cmakelists_source "CCryptoBoringSSL" "*.c"
76+
update_cmakelists_source "CCryptoBoringSSLShims" "*.c"
77+
update_cmakelists_source "Crypto" "*.swift"
78+
79+
update_cmakelists_assembly "CCryptoBoringSSL" "x86_64"

0 commit comments

Comments
 (0)