-
Notifications
You must be signed in to change notification settings - Fork 45
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
[Feat][Java] Initialize JAVA SDK: add INFO implementation #212
Merged
Merged
Changes from 9 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
35ae181
init java
Thespica b4c2e68
finish graph info test
Thespica 03cf6a4
Refine Status's methods
Thespica ca17558
Merge branch 'main' into java-graphinfo
acezen 56ed7d1
Update GraphInfoTest.java
Thespica efe5fc9
Create java.yml
Thespica 95b4bbe
Create install-llvm11.sh
Thespica 3bd69c4
Update java.yml
Thespica 7707502
Merge branch 'main' into java-graphinfo
Thespica 322e70e
Refine CI for JAVA SDK
acezen e7a4413
Update
acezen 05214a3
refine CI and license formate
Thespica 0d03574
upload README.md
Thespica b10ea92
refine README.md and ignore dependency-reduced-pom.xml
Thespica f27f6bf
Update README.md
Thespica ce95b0d
Merge branch 'main' into java-graphinfo
Thespica File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
name: GraphAr Java CI | ||
|
||
on: | ||
# Trigger the workflow on push or pull request, | ||
# but only for the main branch | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'java/**' | ||
- '.github/workflows/java.yml' | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- 'java/**' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Diito |
||
- '.github/workflows/java.yml' | ||
|
||
concurrency: | ||
group: ${{ github.repository }}-${{ github.event.number || github.head_ref || github.sha }}-${{ github.workflow }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
LLVM11_HOME: /opt/llvm11.0.0 | ||
LLVM_VER: 11.0.0 | ||
|
||
jobs: | ||
GraphAr-java: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: true | ||
|
||
- name: Install llvm-11 | ||
run: | | ||
bash ${GITHUB_WORKSPACE}/java/install-llvm11.sh | ||
|
||
|
||
# install GrahpAr C++ library first | ||
- name: Cache for ccache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.ccache | ||
key: ${{ matrix.os }}-build-ccache-${{ hashFiles('**/git-modules.txt') }} | ||
restore-keys: | | ||
${{ matrix.os }}-build-ccache- | ||
- name: Install dependencies | ||
run: | | ||
|
||
# install the latest arrow deb to test arrow | ||
wget -c https://apache.jfrog.io/artifactory/arrow/"$(lsb_release --id --short | tr 'A-Z' 'a-z')"/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb \ | ||
-P /tmp/ | ||
sudo apt-get install -y -V /tmp/apache-arrow-apt-source-latest-"$(lsb_release --codename --short)".deb | ||
sudo apt-get update -y | ||
sudo apt-get install -y libarrow-dev | ||
sudo apt-get install -y libboost-graph-dev ccache libcurl4-openssl-dev | ||
|
||
- name: CMake | ||
run: | | ||
mkdir build | ||
pushd build | ||
cmake ../cpp | ||
popd | ||
|
||
- name: Build GraphAr | ||
run: | | ||
pushd build | ||
make -j$(nproc) | ||
sudo make install | ||
popd | ||
|
||
# Install Java dependencies | ||
- uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'zulu' | ||
java-version: '8' | ||
java-package: 'jdk' | ||
cache: 'maven' | ||
server-id: ossrh | ||
server-username: MAVEN_USERNAME | ||
server-password: MAVEN_PASSWORD | ||
gpg-private-key: ${{ secrets.OSSRH_MAVEN_GPG_PRIVATE_KEY }} | ||
gpg-passphrase: MAVEN_GPG_PASSPHRASE | ||
|
||
- name: Set up Maven | ||
uses: stCarolas/setup-maven@master | ||
with: | ||
maven-version: 3.8.4 | ||
|
||
- name: Check environment | ||
run: | | ||
export PATH=$LLVM11_HOME/bin:$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH | ||
|
||
- name: Install fastFFI | ||
run: | | ||
git clone https://github.com/alibaba/fastffi | ||
pushd fastffi | ||
mvn clean install | ||
popd | ||
|
||
- name: Run test | ||
run: | | ||
pushd java | ||
mvn test | ||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea | ||
target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(gar-java) | ||
|
||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -g -std=c++17 -Wall") | ||
|
||
file(GLOB SOURCES "target/generated-sources/annotations/*.cc" "target/generated-test-sources/test-annotations/*.cc") | ||
|
||
set(LIBNAME "gar-jni") | ||
|
||
set(JAVA_AWT_LIBRARY NotNeeded) | ||
set(JAVA_AWT_INCLUDE_PATH NotNeeded) | ||
find_package(JNI REQUIRED) | ||
include_directories(SYSTEM ${JAVA_INCLUDE_PATH}) | ||
include_directories(SYSTEM ${JAVA_INCLUDE_PATH2}) | ||
|
||
include_directories("src/main/native") | ||
include_directories("src/test/native") | ||
|
||
find_package(gar REQUIRED) | ||
|
||
add_library(${LIBNAME} SHARED ${SOURCES}) | ||
target_link_libraries(${LIBNAME} ${CMAKE_JNI_LINKER_FLAGS} gar) | ||
|
||
set_target_properties(${LIBNAME} PROPERTIES LINKER_LANGUAGE CXX) | ||
|
||
add_custom_command(TARGET ${LIBNAME} | ||
POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${LIBNAME}> "${CMAKE_CURRENT_SOURCE_DIR}/target/classes/") | ||
|
||
add_custom_command(TARGET ${LIBNAME} | ||
POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_SOURCE_DIR}/target/native/bitcode | ||
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_OBJECTS:${LIBNAME}> ${CMAKE_CURRENT_SOURCE_DIR}/target/native/bitcode COMMAND_EXPAND_LISTS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Coming soon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<project name="llvm4jni"> | ||
<target name="make"> | ||
<echo message="Make native code" level="info"/> | ||
|
||
<mkdir dir="${project.build.directory}/native"/> | ||
|
||
<property environment="env"/> | ||
<fail unless="env.LLVM11_HOME" message="LLVM11_HOME not set."/> | ||
|
||
<condition property="platform" value="linux64"><os family="unix" arch="amd64" /> | ||
</condition> | ||
|
||
<condition property="platform" value="mac"><os family="mac" arch="x86_64" /> | ||
</condition> | ||
|
||
<fail unless="platform" message="Not a supported platform."/> | ||
|
||
<echo message="Native Library Name: ${native.library.name}" level="info"/> | ||
|
||
<exec executable="cmake" dir="${project.build.directory}/native" failonerror="true"> | ||
<arg line="-DCMAKE_AR="${env.LLVM11_HOME}/bin/llvm-ar" -DCMAKE_RANLIB="${env.LLVM11_HOME}/bin/llvm-ranlib" -DCMAKE_C_COMPILER="${env.LLVM11_HOME}/bin/clang" -DCMAKE_CXX_COMPILER="${env.LLVM11_HOME}/bin/clang++" -DCMAKE_CXX_FLAGS="-flto -fforce-emit-vtables" ${basedir}"/> | ||
</exec> | ||
|
||
<exec executable="make" dir="${project.build.directory}/native" failonerror="true"> | ||
<arg line="VERBOSE=1"/> | ||
</exec> | ||
</target> | ||
|
||
<target name="link-llvm-bitcode" depends="make"> | ||
<echo message="Link bitcode" level="info"/> | ||
|
||
<exec executable="sh" dir="${project.build.directory}/native" failonerror="true"> | ||
<arg line="-c '${env.LLVM11_HOME}/bin/llvm-link ./bitcode/* -o ${native.library.name}.bc'" /> | ||
</exec> | ||
|
||
<exec executable="cp" dir="${project.build.directory}/native" failonerror="true"> | ||
<arg line="${native.library.name}.bc ${project.build.directory}/classes"/> | ||
</exec> | ||
</target> | ||
|
||
<target name="run-llvm4jni" depends="link-llvm-bitcode"> | ||
<echo message="Run LLVM4JNI" level="info"/> | ||
|
||
<mkdir dir="${project.build.directory}/llvm4jni-output"/> | ||
|
||
<condition property="native.library.file" value="lib${native.library.name}.so"><os family="unix" arch="amd64" /> | ||
</condition> | ||
|
||
<condition property="native.library.file" value="lib${native.library.name}.dylib"><os family="mac" arch="x86_64" /> | ||
</condition> | ||
|
||
<java classname="com.alibaba.fastffi.llvm4jni.Main" | ||
fork="true" failonerror="true"> | ||
<arg value="-cp" /> | ||
<arg value="${project.build.directory}/classes" /> | ||
<arg value="-bc" /> | ||
<arg value="${project.build.directory}/native/${native.library.name}.bc" /> | ||
<!-- | ||
<arg value="-lib" /> | ||
<arg value="${project.build.directory}/native/${native.library.file}" /> | ||
--> | ||
<arg value="-output" /> | ||
<arg value="${project.build.directory}/llvm4jni-output" /> | ||
<arg value="-v" /> | ||
<arg value="INFO" /> | ||
<jvmarg value="-Dllvm4jni.supportIndirectCall=simple" /> | ||
<jvmarg value="-Dllvm4jni.supportLocalConstant=true" /> | ||
<jvmarg value="-Dllvm4jni.maximumBytecodeSize=128" /> | ||
<classpath> | ||
<pathelement path="${compile_classpath}"/> | ||
</classpath> | ||
</java> | ||
</target> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this file since we don't need to build llvm from the source |
||
|
||
workdir=/tmp/install-llvm | ||
mkdir -p $workdir | ||
|
||
mkdir -p $LLVM11_HOME/include/binutils | ||
curl -L --output $LLVM11_HOME/include/binutils/plugin-api.h \ | ||
https://raw.githubusercontent.com/bminor/binutils-gdb/binutils-2_37-branch/include/plugin-api.h | ||
|
||
cd $workdir | ||
curl -L -O https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VER/llvm-project-$LLVM_VER.tar.xz | ||
tar xf llvm-project-$LLVM_VER.tar.xz | ||
cd llvm-project-$LLVM_VER | ||
mkdir build | ||
cd build | ||
cmake ../llvm -DLLVM_ENABLE_PROJECTS="clang;llvm;lld" \ | ||
-DLLVM_ENABLE_TERMINFO=OFF \ | ||
-DLLVM_TARGETS_TO_BUILD=X86 \ | ||
-DCMAKE_BUILD_TYPE=MinSizeRel \ | ||
-DCMAKE_INSTALL_PREFIX=$LLVM11_HOME \ | ||
-DLLVM_BINUTILS_INCDIR=$LLVM11_HOME/include/binutils \ | ||
-DCMAKE_CXX_FLAGS_MINSIZEREL="-Os -DNDEBUG -static-libgcc -static-libstdc++ -s" | ||
make install -j`nproc` | ||
|
||
# cleanup | ||
cd / | ||
rm -rf $workdir |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include
cpp/src/**
since the cpp may affect java