Skip to content

Commit

Permalink
Refactor static lib built
Browse files Browse the repository at this point in the history
  • Loading branch information
marcboeker committed Oct 8, 2023
1 parent cc93f2c commit 4f572cc
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 44 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/deps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
- "Makefile"
- "cgo_*.go"
jobs:
update_sources:
prepare:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
Expand All @@ -20,25 +20,25 @@ 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:
name: duckdb_h
path: duckdb.h
retention-days: 1
darwin_amd64:
needs: update_sources
needs: prepare
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
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
Expand All @@ -47,16 +47,16 @@ 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
with:
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
Expand All @@ -65,16 +65,16 @@ 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
with:
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
Expand All @@ -83,16 +83,16 @@ 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
with:
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: |
Expand Down
65 changes: 36 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4f572cc

Please sign in to comment.