Skip to content

Add Maven, CI #14

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

Merged
merged 24 commits into from
Apr 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d68677d
maven cmake example.
bmarwell Mar 27, 2019
694975a
gitignore update
bmarwell Mar 27, 2019
9c06ad2
added FIXME, updated project style, removed wrong copyright, use loca…
bmarwell Mar 29, 2019
8c41f7d
add mac and win64 maven-cmake profiles.
bmarwell Mar 29, 2019
65326b3
proper variable resolution in cmake profile win64.
bmarwell Mar 29, 2019
168bbeb
force cmake download on windows for now.
bmarwell Mar 31, 2019
0334f26
add travis-ci build file.
bmarwell Mar 31, 2019
41bf9bd
trigger travis build.
bmarwell Mar 31, 2019
564d42a
added properties for cmake and native-lib-loader to control build, re…
bmarwell Mar 31, 2019
916bf29
travis: do not fail on test completely if test errors, batch mode lon…
bmarwell Mar 31, 2019
46a3442
further cmake and native dependencies.
bmarwell Mar 31, 2019
c1e5ab3
cmake 2.x compat (languages keyword).
bmarwell Mar 31, 2019
0dda439
rework test, remove hardcoded library path (not needed).
bmarwell Mar 31, 2019
a008cbe
Simplify Travis-CI logic, add macOS builds (#11)
tresf Apr 1, 2019
5c096b9
Fix MSVC builds
tresf Apr 1, 2019
5a54b62
Adjust maven profiles
tresf Apr 1, 2019
4a7dd07
Fix builds on mingw
tresf Apr 1, 2019
f4170b0
Replace cmake-maven-plugin with the maven-antrun-plugin
bmarwell Apr 3, 2019
bdbc0ed
Remove hard-coded 64-bit archs, more cmake cleanup
tresf Apr 4, 2019
590dfd9
Fix mac folder
tresf Apr 4, 2019
f289839
Maven packaging (#18)
bmarwell Apr 10, 2019
f9f29c9
Move natives/README.md up one dir
tresf Apr 11, 2019
942ce30
Add back instructions for natives dir
tresf Apr 11, 2019
7c6e0e4
Updated default artifacts. Fixes #31. (#32)
bmarwell Apr 11, 2019
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
14 changes: 9 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
build/
# the maven convention for built files
target/

# Prerequisites
*.d
Expand All @@ -13,11 +15,6 @@ build/
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod
Expand All @@ -32,3 +29,10 @@ build/
*.exe
*.out
*.app

# IDE files: IntellIJ
.idea/
*.iml

# IDE files: eclipse
.settings/
75 changes: 75 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
language: java

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:
- cmake3
- g++
- os: linux
env: PROFILE=m32
addons:
apt:
packages:
- cmake3
- g++-multilib
- os: linux
env: PROFILE=mingw32
addons:
apt:
packages:
- cmake3
- g++-mingw-w64-i686
- os: linux
env: PROFILE=mingw64
addons:
apt:
packages:
- cmake3
- g++-mingw-w64-x86-64
- os: linux
env: PROFILE=armsf,armtrusty
addons:
apt:
packages:
- cmake3
- g++-arm-linux-gnueabi
- os: linux
env: PROFILE=aarch64
addons:
apt:
packages:
- cmake3
- g++-aarch64-linux-gnu
- os: linux
env: PROFILE=ppc64
addons:
apt:
packages:
- cmake3
- g++-powerpc64le-linux-gnu
- os: osx
addons:
homebrew:
packages:
- 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)


73 changes: 65 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
cmake_minimum_required(VERSION 3.9)
project(jssc VERSION 2.8.0 DESCRIPTION "Java Simple Serial Connector")
cmake_minimum_required(VERSION 3.0)
cmake_policy(SET CMP0048 NEW)
cmake_policy(SET CMP0042 NEW)

project(jssc VERSION 2.7.1 LANGUAGES CXX)

find_package(Java)
find_package(JNI)
Expand Down Expand Up @@ -56,15 +59,60 @@ else()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
endif()

add_library(jssc SHARED
src/cpp/${JSSC_PLATFORM}/jssc.cpp
)
# Detect platform if -DNATIVE_LIB_DIR is not provided
# TODO: Handle arm, hardfloat, etc
if(NOT NATIVE_LIB_DIR)
# windows, linux, darwin, etc
string(TOLOWER "${CMAKE_SYSTEM_NAME}" OS_NAME)
if(OS_NAME MATCHES "darwin")
set(OS_NAME "osx")
endif()

# 32-bit or 64-bit
#FIXME: Might fail on cross-compile
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
set(OS_BITS 64)
else()
set(OS_BITS 32)
endif()
SET(NATIVE_LIB_DIR ${OS_NAME}_${OS_BITS})
endif()
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/natives/${NATIVE_LIB_DIR})

# version.h using #cmakedefine for version from pom.xml.
set(JSSC_VERSION "0.0.0-UNKNOWN")
file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml POM_FILE)
foreach(POM_LINE ${POM_FILE})
# Assume first "<version>" is the project version
if(POM_LINE MATCHES "<version>")
string(REGEX REPLACE "^[ \t]+|<[^>]*>" "" DETECTED_VERSION "${POM_LINE}")
string(STRIP "${DETECTED_VERSION}" DETECTED_VERSION)
if(DETECTED_VERSION STREQUAL "")
MESSAGE(WARNING "Could not parse version from pom.xml, defaulting to \"${JSSC_VERSION}\"")
else()
SET(JSSC_VERSION "${DETECTED_VERSION}")
MESSAGE(STATUS "Found version \"${JSSC_VERSION}\" in pom.xml")
endif()
break()
endif()
endforeach()
configure_file(src/cpp/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h @ONLY)

add_library(jssc SHARED src/cpp/${JSSC_PLATFORM}/jssc.cpp)

target_include_directories(jssc PRIVATE ${JNI_INCLUDE_DIRS} ${JSSC_ADDITIONAL_INCLUDES})
target_include_directories(jssc PRIVATE ${JNI_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} ${JSSC_ADDITIONAL_INCLUDES})

set_target_properties(jssc PROPERTIES VERSION ${PROJECT_VERSION})
set_target_properties(jssc PROPERTIES PUBLIC_HEADER src/jssc_SerialNativeInterface.h)
set_target_properties(jssc PROPERTIES PUBLIC_HEADER ${CMAKE_CURRENT_BINARY_DIR}/jssc_SerialNativeInterface.h)
set_target_properties(jssc PROPERTIES POSITION_INDEPENDENT_CODE ON)
if(WIN32)
# Fix paths for MSVC (Debug/Release) and MINGW
set_target_properties(jssc PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
set_target_properties(jssc PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
endif()
if(FORCE_M32)
# Build 32-bit binary on Linux
set_target_properties(jssc PROPERTIES COMPILE_FLAGS -m32 LINK_FLAGS -m32)
endif()

# Call strip on non-debug builds
if(CMAKE_STRIP AND NOT CMAKE_BUILD_TYPE MATCHES "Deb")
Expand All @@ -73,3 +121,12 @@ if(CMAKE_STRIP AND NOT CMAKE_BUILD_TYPE MATCHES "Deb")
endif()
add_custom_command(TARGET jssc POST_BUILD COMMAND "${CMAKE_STRIP}" ${STRIP_ARGS} $<TARGET_FILE:jssc>)
endif()

# Handle compiler warnings
if(MSVC)
#TODO Treat warnings as errors /WX
target_compile_options(jssc PRIVATE /W4)
else()
#TODO Treat warnings as errors -Werror
target_compile_options(jssc PRIVATE -Wall -Wextra -pedantic)
endif()
Loading