From 4f572ccaf2d9880866a5a045008e5cf9342f4826 Mon Sep 17 00:00:00 2001 From: Marc Boeker Date: Sun, 8 Oct 2023 16:42:32 +0200 Subject: [PATCH] Refactor static lib built --- .github/workflows/deps.yaml | 30 ++++++++--------- Makefile | 65 ++++++++++++++++++++----------------- 2 files changed, 51 insertions(+), 44 deletions(-) diff --git a/.github/workflows/deps.yaml b/.github/workflows/deps.yaml index 90e42224..852d6c98 100644 --- a/.github/workflows/deps.yaml +++ b/.github/workflows/deps.yaml @@ -10,7 +10,7 @@ on: - "Makefile" - "cgo_*.go" jobs: - update_sources: + prepare: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 @@ -20,8 +20,8 @@ jobs: run: make deps.sources - uses: actions/upload-artifact@v3 with: - name: lib - path: lib/ + name: duckdb + path: duckdb/ retention-days: 1 - uses: actions/upload-artifact@v3 with: @@ -29,7 +29,7 @@ jobs: path: duckdb.h retention-days: 1 darwin_amd64: - needs: update_sources + needs: prepare runs-on: macos-latest steps: - uses: actions/checkout@v3 @@ -37,8 +37,8 @@ jobs: ref: ${{ github.head_ref }} - uses: actions/download-artifact@v3 with: - name: lib - path: lib/ + name: duckdb + path: duckdb/ - shell: bash run: make deps.darwin.amd64 - uses: actions/upload-artifact@v3 @@ -47,7 +47,7 @@ jobs: path: deps/darwin_amd64/libduckdb.a retention-days: 1 darwin_arm64: - needs: update_sources + needs: prepare runs-on: macos-latest steps: - uses: actions/checkout@v3 @@ -55,8 +55,8 @@ jobs: ref: ${{ github.head_ref }} - uses: actions/download-artifact@v3 with: - name: lib - path: lib/ + name: duckdb + path: duckdb/ - shell: bash run: make deps.darwin.arm64 - uses: actions/upload-artifact@v3 @@ -65,7 +65,7 @@ jobs: path: deps/darwin_arm64/libduckdb.a retention-days: 1 linux_amd64: - needs: update_sources + needs: prepare runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 @@ -73,8 +73,8 @@ jobs: ref: ${{ github.head_ref }} - uses: actions/download-artifact@v3 with: - name: lib - path: lib/ + name: duckdb + path: duckdb/ - shell: bash run: make deps.linux.amd64 - uses: actions/upload-artifact@v3 @@ -83,7 +83,7 @@ jobs: path: deps/linux_amd64/libduckdb.a retention-days: 1 linux_arm64: - needs: update_sources + needs: prepare runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 @@ -91,8 +91,8 @@ jobs: ref: ${{ github.head_ref }} - uses: actions/download-artifact@v3 with: - name: lib - path: lib/ + name: duckdb + path: duckdb/ - name: Install cross compile toolchain shell: bash run: | diff --git a/Makefile b/Makefile index 24445be2..6bbe9b5e 100644 --- a/Makefile +++ b/Makefile @@ -17,50 +17,57 @@ FILES := $(wildcard $(SRC_DIR)/*) .PHONY: deps.source deps.source: - # We cannot download the tagged release as it thinks it is a dev release - # and therefore has no extensions available. They are only available in - # the tagged Git branch. - # curl -Lo duckdb.zip https://github.com/duckdb/duckdb/archive/refs/tags/v${DUCKDB_VERSION}.zip - # unzip -q -o duckdb.zip || true - # mv duckdb-${DUCKDB_VERSION} duckdb - # rm duckdb.zip - git clone -b v${DUCKDB_VERSION} --depth 1 https://github.com/duckdb/duckdb.git - cd duckdb/ && python3 scripts/amalgamation.py --extended --splits=10 && cd .. - - rm -rf lib - mkdir lib - cd duckdb/src/amalgamation && for f in *; do \ - echo '#ifdef GODUCKDB_FROM_SOURCE' > ../../../lib/$$f; cat $$f >> ../../../lib/$$f; echo '\n#endif' >> ../../../lib/$$f; \ - done - cp duckdb/src/include/duckdb.h duckdb.h - rm -rf duckdb .PHONY: deps.darwin.amd64 deps.darwin.amd64: if [ "$(shell uname -s | tr '[:upper:]' '[:lower:]')" != "darwin" ]; then echo "Error: must run build on darwin"; false; fi - cd lib && g++ -std=c++11 -O3 --target=x86_64-apple-macos11 -DGODUCKDB_FROM_SOURCE -DNDEBUG -c *.cpp || true - ar rvs libduckdb.a lib/*.o - mv libduckdb.a deps/darwin_amd64/libduckdb.a + + cd duckdb && \ + make -j 8 && \ + mkdir -p lib && \ + for f in `find . -name '*.o'`; do cp $$f lib; done && \ + cd lib && \ + ar rvs ../libduckdb.a *.o && \ + cd .. && \ + mv libduckdb.a ../deps/darwin_amd64/libduckdb.a .PHONY: deps.darwin.arm64 deps.darwin.arm64: if [ "$(shell uname -s | tr '[:upper:]' '[:lower:]')" != "darwin" ]; then echo "Error: must run build on darwin"; false; fi - cd lib && g++ -std=c++11 -O3 --target=arm64-apple-macos11 -DGODUCKDB_FROM_SOURCE -DNDEBUG -c *.cpp || true - ar rvs libduckdb.a lib/*.o - mv libduckdb.a deps/darwin_arm64/libduckdb.a + + cd duckdb && \ + make -j 8 && \ + mkdir -p lib && \ + for f in `find . -name '*.o'`; do cp $$f lib; done && \ + cd lib && \ + ar rvs ../libduckdb.a *.o && \ + cd .. && \ + mv libduckdb.a ../deps/darwin_arm64/libduckdb.a .PHONY: deps.linux.amd64 deps.linux.amd64: if [ "$(shell uname -s | tr '[:upper:]' '[:lower:]')" != "linux" ]; then echo "Error: must run build on linux"; false; fi - cd lib && g++ -std=c++11 -O3 -DGODUCKDB_FROM_SOURCE -DNDEBUG -c *.cpp || true - ar rvs libduckdb.a lib/*.o - mv libduckdb.a deps/linux_amd64/libduckdb.a + + cd duckdb && \ + make -j 8 && \ + mkdir -p lib && \ + for f in `find . -name '*.o'`; do cp $$f lib; done && \ + cd lib && \ + ar rvs ../libduckdb.a *.o && \ + cd .. && \ + mv libduckdb.a ../deps/linux_amd64/libduckdb.a .PHONY: deps.linux.arm64 deps.linux.arm64: if [ "$(shell uname -s | tr '[:upper:]' '[:lower:]')" != "linux" ]; then echo "Error: must run build on linux"; false; fi - cd lib && aarch64-linux-gnu-g++ -std=c++11 -O3 -DGODUCKDB_FROM_SOURCE -DNDEBUG -c *.cpp || true - aarch64-linux-gnu-gcc-ar rvs libduckdb.a lib/*.o - mv libduckdb.a deps/linux_arm64/libduckdb.a + + cd duckdb && \ + make -j 8 && \ + mkdir -p lib && \ + for f in `find . -name '*.o'`; do cp $$f lib; done && \ + cd lib && \ + ar rvs ../libduckdb.a *.o && \ + cd .. && \ + mv libduckdb.a ../deps/linux_arm64/libduckdb.a