forked from miriamkw/LoopAlgorithmToPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·53 lines (44 loc) · 1.71 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·53 lines (44 loc) · 1.71 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
echo "Building dynamic library..."
# 1. Clean and Build
# Removing 'swift package update' from every CI run saves time; 'clean' is enough.
swift package clean
echo "Building Swift package..."
swift build --configuration release -v
echo "Build completed. Locating artifacts..."
# 2. Detect OS and set Extension
if [[ "$OSTYPE" == "darwin"* ]]; then
OS_DIR="macos"; EXT="dylib"; PREFIX="lib"
elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" || "$OS" == "Windows_NT" ]]; then
OS_DIR="windows"; EXT="dll"; PREFIX=""
else
OS_DIR="linux"; EXT="so"; PREFIX="lib"
fi
# 3. DYNAMIC SEARCH
echo "Searching for library in .build directory..."
# Try the most likely Windows path first if on Windows
if [ "$OS_DIR" == "windows" ]; then
# Swift 6 on Windows usually outputs here:
SOURCE_LIB=$(find .build -name "LoopAlgorithmToPython.dll" | grep -i "release" | head -n 1)
# Fallback: Check the explicit target-based path
if [ -z "$SOURCE_LIB" ]; then
SOURCE_LIB=".build/x86_64-unknown-windows-msvc/release/LoopAlgorithmToPython.dll"
fi
else
# Mac/Linux path
SOURCE_LIB=$(find .build -name "libLoopAlgorithmToPython.$EXT" | grep -i "release" | head -n 1)
fi
# 4. Verification and Copy
if [ -f "$SOURCE_LIB" ]; then
echo "Found library at: $SOURCE_LIB"
DEST_DIR="./loop_to_python_api/dlibs/$OS_DIR"
# Consistency: Force prefix 'lib' even on Windows for your Python loader
DEST_LIB="$DEST_DIR/libLoopAlgorithmToPython.$EXT"
mkdir -p "$DEST_DIR"
cp "$SOURCE_LIB" "$DEST_LIB"
echo "✓ Library successfully copied to $DEST_LIB"
else
echo "ERROR: Could not find the compiled library!"
echo "Check the build log above for 'swiftc' errors."
exit 1
fi