Skip to content

Build duckdb_java linux-amd64-musl #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/Java.yml
Original file line number Diff line number Diff line change
@@ -196,6 +196,57 @@ jobs:
path: |
build/release/duckdb_jdbc.jar
java-linux-amd64-musl:
name: Java Musllinux (amd64)
runs-on: ubuntu-latest
container:
image: alpine:latest
env:
GEN: ninja
DUCKDB_PLATFORM: linux_amd64_musl
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ inputs.git_ref }}

- name: Prepare Alpine Container
shell: sh

run: |
# Update package lists and install essential build tools
apk update
apk add --no-cache bash boost-dev build-base cmake gcc g++ git libstdc++ make ninja openjdk17 openjdk17-jdk pkgconfig
rm -rf /var/cache/apk/*
# Set Java environment variables
echo "JAVA_HOME=/usr/lib/jvm/java-17-openjdk" >> $GITHUB_ENV
echo "/usr/lib/jvm/java-17-openjdk/bin:${PATH}" >> $GITHUB_PATH
- name: Build
shell: bash
run: make release

- name: Java Tests
shell: bash
if: ${{ inputs.skip_tests != 'true' }}
run: make test

- name: Deploy
shell: bash
env:
AWS_ACCESS_KEY_ID: ${{ secrets.S3_DUCKDB_STAGING_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_DUCKDB_STAGING_KEY }}
run: |
cp build/release/duckdb_jdbc.jar duckdb_jdbc-linux-amd64-musl.jar
./scripts/upload-assets-to-staging.sh github_release duckdb_jdbc-linux-amd64-musl.jar
- uses: actions/upload-artifact@v3
with:
name: java-linux-amd64-musl
path: |
build/release/duckdb_jdbc.jar
java-combine:
if: ${{ inputs.override_git_describe == '' }}
@@ -206,6 +257,7 @@ jobs:
- java-linux-amd64
- java-windows-amd64
- java-osx-universal
- java-linux-amd64-musl

steps:
- uses: actions/checkout@v3
@@ -236,6 +288,11 @@ jobs:
name: java-osx-universal
path: jdbc-artifacts/java-osx-universal

- uses: actions/download-artifact@v3
with:
name: java-linux-amd64-musl
path: jdbc-artifacts/java-linux-amd64-musl

- name: Combine JARs
shell: bash
run: |
29 changes: 27 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -38,7 +38,6 @@ else()
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
endif()


set(OS_NAME "unknown")
set(OS_ARCH "amd64")

@@ -65,12 +64,31 @@ if(OVERRIDE_JDBC_OS_ARCH)
set(OS_ARCH ${OVERRIDE_JDBC_OS_ARCH})
endif()

# Check if the current system is Alpine Linux
function(is_alpine_linux RESULT)
if(UNIX AND NOT APPLE)
if(EXISTS "/etc/os-release")
file(READ "/etc/os-release" OS_RELEASE_CONTENTS)
string(FIND "${OS_RELEASE_CONTENTS}" "Alpine Linux" ALPINE_FOUND)

if(ALPINE_FOUND GREATER -1)
set(${RESULT} TRUE PARENT_SCOPE)
else()
set(${RESULT} FALSE PARENT_SCOPE)
endif()
else()
set(${RESULT} FALSE PARENT_SCOPE)
endif()
else()
set(${RESULT} FALSE PARENT_SCOPE)
endif()
endfunction()

add_jar(duckdb_jdbc ${JAVA_SRC_FILES} META-INF/services/java.sql.Driver
GENERATE_NATIVE_HEADERS duckdb-native)
add_jar(duckdb_jdbc_tests ${JAVA_TEST_FILES} INCLUDE_JARS duckdb_jdbc)



set(DUCKDB_SYSTEM_LIBS ${CMAKE_DL_LIBS})

if(MSVC)
@@ -82,6 +100,13 @@ target_compile_options(duckdb_java PRIVATE -fexceptions)
target_link_libraries(duckdb_java duckdb-native )
target_link_libraries(duckdb_java ${DUCKDB_SYSTEM_LIBS})

is_alpine_linux(IS_ALPINE)
if(IS_ALPINE)
message(STATUS "Detected Alpine Linux - Enabling static C++ library linking")
target_link_libraries(duckdb_java -static-libstdc++ -static-libgcc)
endif()


string(JOIN "_" LIB_SUFFIX ".so" ${OS_NAME} ${OS_ARCH})
set_target_properties(duckdb_java PROPERTIES SUFFIX ${LIB_SUFFIX})
set_target_properties(duckdb_java PROPERTIES PREFIX "lib")
2 changes: 1 addition & 1 deletion scripts/jdbc_maven_deploy.py
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ def exec(cmd):
jdbc_artifact_dir = sys.argv[2]
jdbc_root_path = sys.argv[3]

combine_builds = ['linux-amd64', 'osx-universal', 'windows-amd64', 'linux-aarch64']
combine_builds = ['linux-amd64', 'osx-universal', 'windows-amd64', 'linux-aarch64', 'linux-amd64-musl']

staging_dir = tempfile.mkdtemp()