forked from sweetpad-dev/sweetpad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile.sh
31 lines (21 loc) · 872 Bytes
/
compile.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
set -Eeuo pipefail
# Path to your source file
SOURCE_FILE="setvbuf/setvbuf.c"
# Set locations
TEMP_DIR="./.temp"
OUT_DIR="./out"
# Ensure directories exist
mkdir -p $TEMP_DIR
mkdir -p $OUT_DIR
# Compile for arm64 architecture
clang -O2 -fpic -shared -arch arm64 -o $TEMP_DIR/setvbuf_arm64.so $SOURCE_FILE
# Compile for x86_64 architecture
clang -O2 -fpic -shared -arch x86_64 -o $TEMP_DIR/setvbuf_x86_64.so $SOURCE_FILE
# Create a Universal Binary from the architecture-specific files
lipo -create -output $OUT_DIR/setvbuf_universal.so $TEMP_DIR/setvbuf_arm64.so $TEMP_DIR/setvbuf_x86_64.so
# Optionally, remove the architecture-specific shared libraries if not needed
rm $TEMP_DIR/setvbuf_arm64.so $TEMP_DIR/setvbuf_x86_64.so
# Remove the temporary directory if not needed
rm -r $TEMP_DIR
echo "Universal binary created at out/setvbuf_universal.so"