Skip to content

Commit 790ba85

Browse files
committed
Trying to fix windows dll build error
1 parent cfcd796 commit 790ba85

3 files changed

Lines changed: 17 additions & 23 deletions

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,12 @@ jobs:
5959
6060
- name: Run build script (Windows)
6161
if: matrix.os == 'windows-latest'
62-
shell: bash
62+
shell: cmd
6363
run: |
64-
chmod +x build.sh
65-
./build.sh
64+
:: Load the Visual Studio environment so Swift can find the Linker
65+
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
66+
:: Now run the bash script using the initialized environment
67+
bash -c "chmod +x build.sh && ./build.sh"
6668
6769
- name: Verify library was built
6870
shell: bash

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import PackageDescription
55

66
let package = Package(
77
name: "LoopAlgorithmToPython",
8-
defaultLocalization: "no",
8+
//defaultLocalization: "no",
99
platforms: [
1010
.macOS(.v13),
1111
.iOS(.v15),

build.sh

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22

33
echo "Building dynamic c library from Swift code..."
44

5-
# Run the Swift package commands
5+
# 1. Clean and Build
66
swift package clean
77
swift package update
88
echo "Building Swift package..."
9-
# Note: Windows requires the toolchain to be set up, which your YAML handles
109
swift build --configuration release --verbose
1110

1211
echo "Build completed. Locating artifacts..."
1312

14-
# Detect the operating system
13+
# 2. Detect OS and set Extension
1514
if [[ "$OSTYPE" == "darwin"* ]]; then
1615
echo "Detected macOS system..."
1716
OS_DIR="macos"
@@ -26,36 +25,29 @@ else
2625
EXT="so"
2726
fi
2827

29-
# THE FIX: Search the entire .build folder for the library.
30-
# Windows uses paths like .build/x86_64-unknown-windows-msvc/release/
28+
# 3. DYNAMIC SEARCH
29+
# We search the whole .build folder because Windows/Linux use subfolders
30+
# like .build/x86_64-unknown-windows-msvc/release/
3131
echo "Searching for *LoopAlgorithmToPython.$EXT in .build directory..."
3232
SOURCE_LIB=$(find .build -name "*LoopAlgorithmToPython.$EXT" | grep -i "release" | head -n 1)
3333

3434
if [ -z "$SOURCE_LIB" ] || [ ! -f "$SOURCE_LIB" ]; then
3535
echo "ERROR: Could not find the compiled library!"
36-
echo "Check above for Swift compiler errors."
37-
echo "Current directory contents:"
38-
ls -R .build 2>/dev/null | grep ":$" | head -n 20
36+
echo "Check the Swift compiler logs above for errors."
3937
exit 1
4038
fi
4139

4240
echo "Found library at: $SOURCE_LIB"
4341

44-
# Define destination
42+
# 4. Prepare Destination
4543
DEST_DIR="./loop_to_python_api/dlibs/$OS_DIR"
44+
# On Windows, we ensure the output follows the 'lib...' naming convention for your Python API
4645
DEST_LIB="$DEST_DIR/libLoopAlgorithmToPython.$EXT"
4746

48-
# Create destination directory
49-
if [ ! -d "$DEST_DIR" ]; then
50-
echo "Creating destination directory: $DEST_DIR"
51-
mkdir -p "$DEST_DIR"
52-
fi
53-
54-
# Copy the library
55-
echo "Copying library:"
56-
echo " From: $SOURCE_LIB"
57-
echo " To: $DEST_LIB"
47+
mkdir -p "$DEST_DIR"
5848

49+
# 5. Copy and Verify
50+
echo "Copying to: $DEST_LIB"
5951
if cp "$SOURCE_LIB" "$DEST_LIB"; then
6052
echo "✓ Library successfully copied!"
6153
ls -la "$DEST_LIB"

0 commit comments

Comments
 (0)