diff --git a/.github/workflows/deps.yaml b/.github/workflows/deps.yaml index c3f1be49..8f04897e 100644 --- a/.github/workflows/deps.yaml +++ b/.github/workflows/deps.yaml @@ -83,9 +83,23 @@ jobs: name: linux_arm64 path: deps/linux_arm64/libduckdb.a retention-days: 1 + windows_amd64: + needs: prepare + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + - shell: bash + run: make deps.windows.amd64 + - uses: actions/upload-artifact@v3 + with: + name: windows_amd64 + path: deps/windows_amd64/libduckdb.a + retention-days: 1 commit: runs-on: ubuntu-latest - needs: [darwin_amd64, darwin_arm64, linux_amd64, linux_arm64] + needs: [darwin_amd64, darwin_arm64, linux_amd64, linux_arm64, windows_amd64] steps: - uses: actions/checkout@v3 with: @@ -96,6 +110,7 @@ jobs: rm -f deps/darwin_arm64/libduckdb.a rm -f deps/linux_amd64/libduckdb.a rm -f deps/linux_arm64/libduckdb.a + rm -f deps/windows_amd64/libduckdb.a rm -f duckdb.h - uses: actions/download-artifact@v3 with: @@ -117,6 +132,10 @@ jobs: with: name: linux_arm64 path: deps/linux_arm64 + - uses: actions/download-artifact@v3 + with: + name: windows_amd64 + path: deps/windows_amd64 - name: Push static libraries uses: stefanzweifel/git-auto-commit-action@v4 with: diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index c67c9891..4287f32a 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -12,8 +12,8 @@ jobs: strategy: matrix: - os: [ubuntu-latest, macos-12] - go: ["1.18"] + os: [ubuntu-latest, macos-12, windows-latest] + go: ["1.20"] fail-fast: false steps: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 01383843..d8116c66 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,7 @@ To upgrade to a new version of DuckDB: -1. Create a new branch with the current version number in it. E.g. `v0.9.0`. +1. Create a new branch with the current version number in it. E.g. `v0.9.2`. 2. Change `DUCKDB_VERSION` in `Makefile` to match the version in the branch name. 3. Push the updated `Makefile` and create a PR. 4. Wait for Github Actions to pre-compile the static libraries in `deps`. They will be committed automatically to the branch. diff --git a/Makefile b/Makefile index 69fd8db9..db2a6ce6 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ FILES := $(wildcard $(SRC_DIR)/*) .PHONY: deps.header deps.header: git clone -b v${DUCKDB_VERSION} --depth 1 https://github.com/duckdb/duckdb.git - cp duckdb/src/include/duckdb.h duckdb.h + sed 's/__declspec(dllimport)//g' duckdb/src/include/duckdb.h > duckdb.h .PHONY: deps.darwin.amd64 deps.darwin.amd64: @@ -76,3 +76,21 @@ deps.linux.arm64: ar rvs ../libduckdb.a *.o && \ cd .. && \ mv libduckdb.a ../deps/linux_arm64/libduckdb.a + +.PHONY: deps.windows.amd64 +deps.windows.amd64: + git clone -b v${DUCKDB_VERSION} --depth 1 https://github.com/duckdb/duckdb.git + cd duckdb && \ + mkdir -p build && \ + cmake -G "MinGW Makefiles" \ + -DENABLE_EXTENSION_AUTOLOADING=1 \ + -DENABLE_EXTENSION_AUTOINSTALL=1 \ + -DBUILD_SHELL=0 \ + -DBUILD_UNITTESTS=0 \ + -DCMAKE_BUILD_TYPE=Release -B build && \ + cd build && \ + MAKEFLAGS=-j4 cmake --build . --config Release && \ + cd ../build && \ + for f in `find . -name '*.obj'`; do gcc-ar rvs ../libduckdb.a $$f; done && \ + cd .. && \ + mv libduckdb.a ../deps/windows_amd64/libduckdb.a diff --git a/cgo_static.go b/cgo_static.go index 342b22a6..5da4e145 100644 --- a/cgo_static.go +++ b/cgo_static.go @@ -1,13 +1,13 @@ -//go:build !duckdb_use_lib && (darwin || (linux && (amd64 || arm64))) +//go:build !duckdb_use_lib && (darwin || (linux && (amd64 || arm64)) || (windows && amd64)) package duckdb /* -#cgo LDFLAGS: -lduckdb -#cgo darwin,amd64 LDFLAGS: -lc++ -L${SRCDIR}/deps/darwin_amd64 -#cgo darwin,arm64 LDFLAGS: -lc++ -L${SRCDIR}/deps/darwin_arm64 -#cgo linux,amd64 LDFLAGS: -lstdc++ -lm -ldl -L${SRCDIR}/deps/linux_amd64 -#cgo linux,arm64 LDFLAGS: -lstdc++ -lm -ldl -L${SRCDIR}/deps/linux_arm64 +#cgo darwin,amd64 LDFLAGS: -lduckdb -lc++ -L${SRCDIR}/deps/darwin_amd64 +#cgo darwin,arm64 LDFLAGS: -lduckdb -lc++ -L${SRCDIR}/deps/darwin_arm64 +#cgo linux,amd64 LDFLAGS: -lduckdb -lstdc++ -lm -ldl -L${SRCDIR}/deps/linux_amd64 +#cgo linux,arm64 LDFLAGS: -lduckdb -lstdc++ -lm -ldl -L${SRCDIR}/deps/linux_arm64 +#cgo windows,amd64 LDFLAGS: -lduckdb -lws2_32 -lstdc++ -Wl,-Bstatic -lpthread -lm -L${SRCDIR}/deps/windows_amd64 #include */ import "C" diff --git a/deps/darwin_amd64/libduckdb.a b/deps/darwin_amd64/libduckdb.a index 1a9e0083..7a21acdf 100644 Binary files a/deps/darwin_amd64/libduckdb.a and b/deps/darwin_amd64/libduckdb.a differ diff --git a/deps/darwin_arm64/libduckdb.a b/deps/darwin_arm64/libduckdb.a index 62c92bb5..76fbf70d 100644 Binary files a/deps/darwin_arm64/libduckdb.a and b/deps/darwin_arm64/libduckdb.a differ diff --git a/deps/windows_amd64/libduckdb.a b/deps/windows_amd64/libduckdb.a new file mode 100644 index 00000000..79361a4c Binary files /dev/null and b/deps/windows_amd64/libduckdb.a differ diff --git a/deps/windows_amd64/vendor.go b/deps/windows_amd64/vendor.go new file mode 100644 index 00000000..bbf9e273 --- /dev/null +++ b/deps/windows_amd64/vendor.go @@ -0,0 +1,3 @@ +// Package windows_amd64 is required to provide support for vendoring modules +// DO NOT REMOVE +package windows_amd64 diff --git a/duckdb.h b/duckdb.h index 86b0b1b4..46bf0652 100644 --- a/duckdb.h +++ b/duckdb.h @@ -15,7 +15,7 @@ #if defined(DUCKDB_BUILD_LIBRARY) && !defined(DUCKDB_BUILD_LOADABLE_EXTENSION) #define DUCKDB_API __declspec(dllexport) #else -#define DUCKDB_API __declspec(dllimport) +#define DUCKDB_API #endif #else #define DUCKDB_API