diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..ea85d122e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,90 @@ +name: build + +on: [push, pull_request] + +env: + MAVEN_OPTS: -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn + +jobs: + ubuntu: + runs-on: [ubuntu-latest] + strategy: + fail-fast: false + matrix: + include: + - profile: x86 + packages: g++-multilib + + - profile: x86_64 + packages: g++- + + - profile: armhf + packages: g++-arm-linux-gnueabihf + + - profile: aarch64 + packages: g++-aarch64-linux-gnu + + - profile: riscv64 + packages: g++-riscv64-linux-gnu + + - profile: ppc64 + packages: g++-powerpc64le-linux-gnu + + - profile: mingw32 + packages: g++-mingw-w64-i686 + + - profile: mingw64 + packages: g++-mingw-w64-x86-64 + + - profile: mingwaarch64 + packages: clang + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Java + uses: actions/setup-java@v3 + with: + java-version: 11 + distribution: temurin + + - run: sudo apt-get install socat ${{ matrix.packages }} + - run: mvn -P "${{ matrix.profile }}" --batch-mode + + macos: + runs-on: [macos-latest] + strategy: + fail-fast: false + matrix: + include: + - profile: aarch64 + - profile: x86_64 + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 + with: + java-version: 11 + distribution: temurin + + - run: brew install socat + - run: mvn -P "${{ matrix.profile }}" --batch-mode + + windows: + runs-on: [windows-latest] + strategy: + fail-fast: false + matrix: + include: + - profile: aarch64 + + - profile: x86_64 + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 + with: + java-version: 11 + distribution: temurin + + - run: mvn -P "${{ matrix.profile }}" --batch-mode \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b62c60ee9..000000000 --- a/.travis.yml +++ /dev/null @@ -1,88 +0,0 @@ -language: java - -jdk: - - openjdk11 - -cache: - directories: - - $HOME/.m2 - - $HOME/.jabba/jdk - -before_cache: - - rm -rf $HOME/.m2/repository/com/github/java-native - -matrix: - include: - - os: linux - addons: - apt: - packages: - - g++ - - os: linux - env: PROFILE=x86 - addons: - apt: - packages: - - g++-multilib - - os: linux - env: PROFILE=mingw32 - addons: - apt: - packages: - - g++-mingw-w64-i686 - - os: linux - env: PROFILE=mingw64 - addons: - apt: - packages: - - g++-mingw-w64-x86-64 - - os: linux - env: PROFILE=mingwaarch64 - addons: - apt: - packages: - - clang - - os: linux - env: PROFILE=armhf - addons: - apt: - packages: - - g++-arm-linux-gnueabihf - - os: linux - env: PROFILE=aarch64 - addons: - apt: - packages: - - g++-aarch64-linux-gnu - - os: linux - env: PROFILE=ppc64 - addons: - apt: - packages: - - g++-powerpc64le-linux-gnu - - os: osx - - os: osx - osx_image: xcode12.5 # xcode 12+ needed for cross-compile - env: PROFILE=aarch64 - -addons: - homebrew: - packages: - - maven - - ant - - cmake - apt: - packages: - - maven - - ant - - cmake - -install: - - mvn dependency:resolve - -script: if [ -z "$PROFILE" ]; then mvn --batch-mode; else mvn -P "$PROFILE" --batch-mode; fi - -after_success: - - bash <(curl -s https://codecov.io/bash) - - diff --git a/CMakeLists.txt b/CMakeLists.txt index ce202316f..528e37651 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -191,9 +191,12 @@ if(CMAKE_STRIP AND NOT CMAKE_BUILD_TYPE MATCHES "Deb") add_custom_command(TARGET jssc POST_BUILD COMMAND "${CMAKE_STRIP}" ${STRIP_ARGS} $) endif() -# Copy native library back to source tree + add_custom_command(TARGET jssc POST_BUILD + # Copy native library back to source tree COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/natives/ ${CMAKE_CURRENT_SOURCE_DIR}/src/main/resources-precompiled/natives/ + # Copy native library back to target/classes tree + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/natives/ ${CMAKE_CURRENT_BINARY_DIR}/../classes/natives/ ) # Handle compiler warnings diff --git a/pom.xml b/pom.xml index 5229404b5..728a27139 100644 --- a/pom.xml +++ b/pom.xml @@ -279,6 +279,7 @@ maven-surefire-plugin ${plugin.surfire.version} + false @@ -495,6 +496,32 @@ + + + riscv64 + + Riscv64 + + linux + riscv64 + 64 + + + + + + riscv32 + + Riscv32 + + linux + riscv32 + 32 + + + + + x86_64 diff --git a/src/test/java/jssc/SerialNativeInterfaceTest.java b/src/test/java/jssc/SerialNativeInterfaceTest.java index 6890aab04..ccbd0f3cd 100644 --- a/src/test/java/jssc/SerialNativeInterfaceTest.java +++ b/src/test/java/jssc/SerialNativeInterfaceTest.java @@ -1,5 +1,6 @@ package jssc; +import org.junit.Assume; import org.junit.Test; import static org.hamcrest.CoreMatchers.is; @@ -41,6 +42,8 @@ public void testPrintVersion() { @Test(expected = java.io.IOException.class) public void reportsWriteErrorsAsIOException() throws Exception { + Assume.assumeFalse(SerialNativeInterface.getOsType() == SerialNativeInterface.OS_WINDOWS); + long fd = -1; /*bad file by intent*/ byte[] buf = new byte[]{ 0x6A, 0x73, 0x73, 0x63, 0x0A }; SerialNativeInterface testTarget = new SerialNativeInterface(); diff --git a/toolchain/Riscv32.cmake b/toolchain/Riscv32.cmake new file mode 100644 index 000000000..2b4a5df01 --- /dev/null +++ b/toolchain/Riscv32.cmake @@ -0,0 +1,10 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(TOOLCHAIN_PREFIX riscv32-linux-gnu) +set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) +set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++) +set(CMAKE_STRIP ${TOOLCHAIN_PREFIX}-strip CACHE FILEPATH "" FORCE) +set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX}/) +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) + diff --git a/toolchain/Riscv64.cmake b/toolchain/Riscv64.cmake new file mode 100644 index 000000000..abfa3e9a2 --- /dev/null +++ b/toolchain/Riscv64.cmake @@ -0,0 +1,10 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(TOOLCHAIN_PREFIX riscv64-linux-gnu) +set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) +set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++) +set(CMAKE_STRIP ${TOOLCHAIN_PREFIX}-strip CACHE FILEPATH "" FORCE) +set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX}/) +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) +