Skip to content

Commit

Permalink
Add GitHub Actions build script
Browse files Browse the repository at this point in the history
  • Loading branch information
hunyadi committed Nov 15, 2024
1 parent 21f8a56 commit f6b07eb
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 1 deletion.
57 changes: 57 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: 📦 [javabind] Build and test C++ library

on:
push:
paths:
- /include/**
- /java/**
- /test/**
workflow_dispatch: {}

jobs:
build-linux:
name: 🧱 [Linux] Build and test C++ library
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up JDK for JNI headers
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '8'
- name: Set up build environment
run: |
cmake -E make_directory ${{github.workspace}}/build
- name: Compile C++ sources
working-directory: ${{github.workspace}}/build
run: |
cmake .. && make
- name: Compile and run Java sources
run: |
./launch.sh
build-windows:
name: 🧱 [Windows] Build and test C++ library
runs-on: windows-latest

steps:
- uses: actions/checkout@v4
- name: Add MSBuild to PATH
uses: microsoft/[email protected]
- name: Set up JDK for JNI headers
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '8'
- name: Set up build environment
run: |
cmake -E make_directory ${{github.workspace}}/build
- name: Compile C++ sources
shell: cmd
working-directory: ${{github.workspace}}/build
run: |
cmake .. && msbuild javabind.sln
- name: Compile and run Java sources
run: |
launch.bat
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ target_include_directories(javabind INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_
if(MSVC)
target_compile_definitions(javabind INTERFACE _CRT_SECURE_NO_WARNINGS)
# set warning level 4 and treat all warnings as errors
target_compile_options(javabind INTERFACE ${SIMDPARSE_AVX2_COMPILE} /permissive- /W4 /WX /Zc:__cplusplus,enumTypes,lambda,referenceBinding,rvalueCast,strictStrings,ternary)
target_compile_options(javabind INTERFACE ${SIMDPARSE_AVX2_COMPILE} /permissive- /wd5272 /W4 /WX /Zc:__cplusplus,enumTypes,lambda,referenceBinding,rvalueCast,strictStrings,ternary)
else()
# enable lots of warnings and treat all warnings as errors
target_compile_options(javabind INTERFACE ${SIMDPARSE_AVX2_COMPILE} -Wall -Wextra -pedantic -Werror -Wfatal-errors)
Expand Down
8 changes: 8 additions & 0 deletions include/javabind/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ namespace javabind
struct JavaBooleanType : PrimitiveJavaType<JavaBooleanType, bool, jboolean>
{
constexpr static std::string_view class_name = "java.lang.Boolean";
constexpr static std::string_view class_path = "java/lang/Boolean";
constexpr static std::string_view java_name = "boolean";
constexpr static std::string_view sig = "Z";

Expand Down Expand Up @@ -123,6 +124,7 @@ namespace javabind
struct JavaByteType : PrimitiveJavaType<JavaByteType, int8_t, jbyte>
{
constexpr static std::string_view class_name = "java.lang.Byte";
constexpr static std::string_view class_path = "java/lang/Byte";
constexpr static std::string_view java_name = "byte";
constexpr static std::string_view sig = "B";

Expand Down Expand Up @@ -163,6 +165,7 @@ namespace javabind
struct JavaCharacterType : PrimitiveJavaType<JavaCharacterType, char16_t, jchar>
{
constexpr static std::string_view class_name = "java.lang.Character";
constexpr static std::string_view class_path = "java/lang/Character";
constexpr static std::string_view java_name = "char";
constexpr static std::string_view sig = "C";

Expand Down Expand Up @@ -203,6 +206,7 @@ namespace javabind
struct JavaShortType : PrimitiveJavaType<JavaShortType, int16_t, jshort>
{
constexpr static std::string_view class_name = "java.lang.Short";
constexpr static std::string_view class_path = "java/lang/Short";
constexpr static std::string_view java_name = "short";
constexpr static std::string_view sig = "S";

Expand Down Expand Up @@ -243,6 +247,7 @@ namespace javabind
struct JavaIntegerType : PrimitiveJavaType<JavaIntegerType, int32_t, jint>
{
constexpr static std::string_view class_name = "java.lang.Integer";
constexpr static std::string_view class_path = "java/lang/Integer";
constexpr static std::string_view java_name = "int";
constexpr static std::string_view sig = "I";

Expand Down Expand Up @@ -283,6 +288,7 @@ namespace javabind
struct JavaLongType : PrimitiveJavaType<JavaLongType, int64_t, jlong>
{
constexpr static std::string_view class_name = "java.lang.Long";
constexpr static std::string_view class_path = "java/lang/Long";
constexpr static std::string_view java_name = "long";
constexpr static std::string_view sig = "J";

Expand Down Expand Up @@ -323,6 +329,7 @@ namespace javabind
struct JavaFloatType : PrimitiveJavaType<JavaFloatType, float, jfloat>
{
constexpr static std::string_view class_name = "java.lang.Float";
constexpr static std::string_view class_path = "java/lang/Float";
constexpr static std::string_view java_name = "float";
constexpr static std::string_view sig = "F";

Expand Down Expand Up @@ -363,6 +370,7 @@ namespace javabind
struct JavaDoubleType : PrimitiveJavaType<JavaDoubleType, double, jdouble>
{
constexpr static std::string_view class_name = "java.lang.Double";
constexpr static std::string_view class_path = "java/lang/Double";
constexpr static std::string_view java_name = "double";
constexpr static std::string_view sig = "D";

Expand Down
1 change: 1 addition & 0 deletions launch.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
set -e
find java -name "*.java" > build/sources.txt
mkdir -p jar
javac -d jar -cp java @build/sources.txt
java -Djava.library.path=build -cp jar -ea hu.info.hunyadi.test.TestJavaBind

0 comments on commit f6b07eb

Please sign in to comment.