Skip to content

Commit 8e17994

Browse files
committed
Add GitHub Actions build script
1 parent 21f8a56 commit 8e17994

File tree

5 files changed

+70
-4
lines changed

5 files changed

+70
-4
lines changed

.github/workflows/publish.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: 📦 [javabind] Build and test C++ library
2+
3+
on:
4+
push:
5+
paths:
6+
- /include/**
7+
- /java/**
8+
- /test/**
9+
workflow_dispatch: {}
10+
11+
jobs:
12+
build-linux:
13+
name: 🧱 [Linux] Build and test C++ library
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Set up JDK for JNI headers
19+
uses: actions/setup-java@v4
20+
with:
21+
distribution: 'zulu'
22+
java-version: '14'
23+
- name: Set up build environment
24+
run: |
25+
cmake -E make_directory ${{github.workspace}}/build
26+
- name: Compile C++ sources
27+
working-directory: ${{github.workspace}}/build
28+
run: |
29+
cmake .. && make
30+
- name: Compile and run Java sources
31+
run: |
32+
./launch.sh
33+
34+
build-windows:
35+
name: 🧱 [Windows] Build and test C++ library
36+
runs-on: windows-latest
37+
38+
steps:
39+
- uses: actions/checkout@v4
40+
- name: Add MSBuild to PATH
41+
uses: microsoft/[email protected]
42+
- name: Set up JDK for JNI headers
43+
uses: actions/setup-java@v4
44+
with:
45+
distribution: 'zulu'
46+
java-version: '14'
47+
- name: Set up build environment
48+
run: |
49+
cmake -E make_directory ${{github.workspace}}/build
50+
- name: Compile C++ sources
51+
shell: cmd
52+
working-directory: ${{github.workspace}}/build
53+
run: |
54+
cmake .. && msbuild javabind.sln
55+
- name: Compile and run Java sources
56+
run: |
57+
launch.bat

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ target_include_directories(javabind INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_
2626
if(MSVC)
2727
target_compile_definitions(javabind INTERFACE _CRT_SECURE_NO_WARNINGS)
2828
# set warning level 4 and treat all warnings as errors
29-
target_compile_options(javabind INTERFACE ${SIMDPARSE_AVX2_COMPILE} /permissive- /W4 /WX /Zc:__cplusplus,enumTypes,lambda,referenceBinding,rvalueCast,strictStrings,ternary)
29+
target_compile_options(javabind INTERFACE ${SIMDPARSE_AVX2_COMPILE} /permissive- /wd5272 /W4 /WX /Zc:__cplusplus,enumTypes,lambda,referenceBinding,rvalueCast,strictStrings,ternary)
3030
else()
3131
# enable lots of warnings and treat all warnings as errors
3232
target_compile_options(javabind INTERFACE ${SIMDPARSE_AVX2_COMPILE} -Wall -Wextra -pedantic -Werror -Wfatal-errors)

include/javabind/core.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ namespace javabind
8383
struct JavaBooleanType : PrimitiveJavaType<JavaBooleanType, bool, jboolean>
8484
{
8585
constexpr static std::string_view class_name = "java.lang.Boolean";
86+
constexpr static std::string_view class_path = "java/lang/Boolean";
8687
constexpr static std::string_view java_name = "boolean";
8788
constexpr static std::string_view sig = "Z";
8889

@@ -123,6 +124,7 @@ namespace javabind
123124
struct JavaByteType : PrimitiveJavaType<JavaByteType, int8_t, jbyte>
124125
{
125126
constexpr static std::string_view class_name = "java.lang.Byte";
127+
constexpr static std::string_view class_path = "java/lang/Byte";
126128
constexpr static std::string_view java_name = "byte";
127129
constexpr static std::string_view sig = "B";
128130

@@ -163,6 +165,7 @@ namespace javabind
163165
struct JavaCharacterType : PrimitiveJavaType<JavaCharacterType, char16_t, jchar>
164166
{
165167
constexpr static std::string_view class_name = "java.lang.Character";
168+
constexpr static std::string_view class_path = "java/lang/Character";
166169
constexpr static std::string_view java_name = "char";
167170
constexpr static std::string_view sig = "C";
168171

@@ -203,6 +206,7 @@ namespace javabind
203206
struct JavaShortType : PrimitiveJavaType<JavaShortType, int16_t, jshort>
204207
{
205208
constexpr static std::string_view class_name = "java.lang.Short";
209+
constexpr static std::string_view class_path = "java/lang/Short";
206210
constexpr static std::string_view java_name = "short";
207211
constexpr static std::string_view sig = "S";
208212

@@ -243,6 +247,7 @@ namespace javabind
243247
struct JavaIntegerType : PrimitiveJavaType<JavaIntegerType, int32_t, jint>
244248
{
245249
constexpr static std::string_view class_name = "java.lang.Integer";
250+
constexpr static std::string_view class_path = "java/lang/Integer";
246251
constexpr static std::string_view java_name = "int";
247252
constexpr static std::string_view sig = "I";
248253

@@ -283,6 +288,7 @@ namespace javabind
283288
struct JavaLongType : PrimitiveJavaType<JavaLongType, int64_t, jlong>
284289
{
285290
constexpr static std::string_view class_name = "java.lang.Long";
291+
constexpr static std::string_view class_path = "java/lang/Long";
286292
constexpr static std::string_view java_name = "long";
287293
constexpr static std::string_view sig = "J";
288294

@@ -323,6 +329,7 @@ namespace javabind
323329
struct JavaFloatType : PrimitiveJavaType<JavaFloatType, float, jfloat>
324330
{
325331
constexpr static std::string_view class_name = "java.lang.Float";
332+
constexpr static std::string_view class_path = "java/lang/Float";
326333
constexpr static std::string_view java_name = "float";
327334
constexpr static std::string_view sig = "F";
328335

@@ -363,6 +370,7 @@ namespace javabind
363370
struct JavaDoubleType : PrimitiveJavaType<JavaDoubleType, double, jdouble>
364371
{
365372
constexpr static std::string_view class_name = "java.lang.Double";
373+
constexpr static std::string_view class_path = "java/lang/Double";
366374
constexpr static std::string_view java_name = "double";
367375
constexpr static std::string_view sig = "D";
368376

include/javabind/enum.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ namespace javabind
6060
jint ordinal = enum_value_ordinal(enum_class, env, javaEnumValue);
6161
return EnumValues<T>::ordinals_to_values.at(ordinal);
6262
}
63-
catch(const std::out_of_range& e) {
63+
catch (const std::out_of_range&) {
6464
throw std::runtime_error(msg() << "Enum " << class_name << " has not bound java value " << enum_value_name(enum_class, env, javaEnumValue));
6565
}
6666
}
@@ -70,7 +70,7 @@ namespace javabind
7070
try {
7171
return EnumValues<T>::values_to_objects.at(nativeEnumValue);
7272
}
73-
catch(const std::out_of_range& e) {
73+
catch (const std::out_of_range&) {
7474
throw std::runtime_error(msg() << "Enum " << class_name << " has not bound native value " << static_cast<std::underlying_type_t<native_type>>(nativeEnumValue));
7575
}
7676
}
@@ -85,4 +85,4 @@ namespace javabind
8585
values_to_objects.emplace(native_value, env->NewGlobalRef(value.ref()));
8686
ordinals_to_values.emplace(enum_value_ordinal(enumClass, env, value.ref()), native_value);
8787
}
88-
}
88+
}

launch.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
set -e
22
find java -name "*.java" > build/sources.txt
3+
mkdir -p jar
34
javac -d jar -cp java @build/sources.txt
45
java -Djava.library.path=build -cp jar -ea hu.info.hunyadi.test.TestJavaBind

0 commit comments

Comments
 (0)