33echo " Building dynamic c library from Swift code..."
44
55# 1. Clean and Build
6+ # Using -v (verbose) is critical for debugging why it's silent
67swift package clean
78swift package update
89echo " Building Swift package..."
9- swift build --configuration release --verbose
10+ swift build --configuration release -v
1011
1112echo " Build completed. Locating artifacts..."
1213
@@ -15,33 +16,46 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
1516 echo " Detected macOS system..."
1617 OS_DIR=" macos"
1718 EXT=" dylib"
19+ PREFIX=" lib"
1820elif [[ " $OSTYPE " == " msys" || " $OSTYPE " == " cygwin" || " $OS " == " Windows_NT" ]]; then
1921 echo " Detected Windows system..."
2022 OS_DIR=" windows"
2123 EXT=" dll"
24+ PREFIX=" " # Windows often drops the 'lib' prefix
2225else
2326 echo " Detected Linux system..."
2427 OS_DIR=" linux"
2528 EXT=" so"
29+ PREFIX=" lib"
2630fi
2731
2832# 3. DYNAMIC SEARCH
29- # We search the whole .build folder because Windows/Linux use subfolders
30- # like .build/x86_64-unknown-windows-msvc/release/
31- echo " Searching for *LoopAlgorithmToPython.$EXT in .build directory..."
32- SOURCE_LIB=$( find .build -name " *LoopAlgorithmToPython.$EXT " | grep -i " release" | head -n 1)
33+ echo " Searching for LoopAlgorithmToPython.$EXT in .build directory..."
34+
35+ # Try searching for both 'libLoopAlgorithmToPython' and 'LoopAlgorithmToPython'
36+ # We use -iname to ignore case and look specifically for the release folder
37+ SOURCE_LIB=$( find .build -type f \( -iname " libLoopAlgorithmToPython.$EXT " -o -iname " LoopAlgorithmToPython.$EXT " \) | grep -i " release" | head -n 1)
38+
39+ # If find fails, let's try a direct path check for the standard Windows output location
40+ if [ -z " $SOURCE_LIB " ]; then
41+ DIRECT_WIN_PATH=" .build/x86_64-unknown-windows-msvc/release/LoopAlgorithmToPython.dll"
42+ if [ -f " $DIRECT_WIN_PATH " ]; then
43+ SOURCE_LIB=" $DIRECT_WIN_PATH "
44+ fi
45+ fi
3346
3447if [ -z " $SOURCE_LIB " ] || [ ! -f " $SOURCE_LIB " ]; then
3548 echo " ERROR: Could not find the compiled library!"
36- echo " Check the Swift compiler logs above for errors."
49+ echo " Debugging: Current directory structure in .build:"
50+ ls -R .build 2> /dev/null | head -n 20
3751 exit 1
3852fi
3953
4054echo " Found library at: $SOURCE_LIB "
4155
4256# 4. Prepare Destination
4357DEST_DIR=" ./loop_to_python_api/dlibs/$OS_DIR "
44- # On Windows, we ensure the output follows the 'lib...' naming convention for your Python API
58+ # We force the destination name to 'libLoopAlgorithmToPython.dll' so your Python code remains consistent
4559DEST_LIB=" $DEST_DIR /libLoopAlgorithmToPython.$EXT "
4660
4761mkdir -p " $DEST_DIR "
0 commit comments