Skip to content
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

Issue #7: Use OCLint instead of beautifier #8

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 2 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
root = true

[*]
indent_style = tab
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{yml,yaml}]
indent_style = space
[*.{yml,yaml,oclint}]
indent_size = 2

7 changes: 7 additions & 0 deletions .oclint
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
disable-rules:
- LongMethod # HighNcssMethod is enough
- AvoidDefaultArgumentsOnVirtualMethods
rule-paths: []
rule-configurations:
- key: LONG_LINE
value: 120
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ before_install:
- sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-4.9 90
- g++-4.9 --version
- lcov --version
- eval "$(curl -sL https://raw.githubusercontent.com/ryuichis/oclint-cpp-travis-ci-examples/master/oclint-ci-install.sh)"

install:
- gem install coveralls-lcov
Expand All @@ -19,9 +20,11 @@ before_script:
- mkdir build && cd build
- cmake -DCMAKE_BUILD_TYPE:string="Debug" -Dexample:bool=on -Dtests:bool=on ..
# - cmake -Dexamples:bool=on .. # cannot build the GUI example
- cp compile_commands.json ..

script:
- cd $TRAVIS_BUILD_DIR
- oclint-json-compilation-database
- cd build
- make -j $(nproc)
- cd tests
Expand Down
85 changes: 43 additions & 42 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8)

# For compatibility with PROJECT_VERSION* variables
if((${CMAKE_VERSION} VERSION_GREATER "3.0") OR (${CMAKE_VERSION} VERSION_EQUAL "3.0"))
cmake_policy(SET CMP0048 OLD)
cmake_policy(SET CMP0048 OLD)
endif()

# Set project name
Expand All @@ -15,7 +15,7 @@ set(PROJECT_VERSION_PATCH "3")
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")

if(${PROJECT_VERSION_PATCH})
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
endif()

# Set options
Expand All @@ -30,27 +30,28 @@ option(tests "Build the unit tests")

option(INSTALL_LIB_DIR "Installation directory for libraries")
if(${INSTALL_LIB_DIR} STREQUAL "OFF")
set(INSTALL_LIB_DIR "lib")
set(INSTALL_LIB_DIR "lib")
endif()

# Set build type
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_BUILD_TYPE "Release")
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS "ON")
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")

# Set definitions
if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
add_definitions("-O3")
add_definitions("-O3")
endif()

if(${tests})
add_definitions("-g -O0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
add_definitions("-g -O0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
endif()

add_definitions("-std=c++11")
add_definitions("-Wall -Wextra -pedantic")
add_definitions("-Wall -Wextra -pedantic -Wno-attributes")

# Find libraries
find_package(Threads)
Expand All @@ -59,51 +60,51 @@ find_package(Boost 1.54 REQUIRED COMPONENTS system)
include_directories(${Boost_INCLUDE_DIR})

if(${examples-only} STREQUAL "OFF")
# Include headers
include_directories("include")

# Build library
if((${build-library}) OR (${install-headers} STREQUAL "OFF"))
# Find source code
file(GLOB_RECURSE CPPS "src/regilo/*.cpp")
file(GLOB_RECURSE HPPS "include/regilo/*.hpp")

# Configure files
configure_file("src/regilo/version.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/gen/regilo/version.cpp")
list(APPEND CPPS "${CMAKE_CURRENT_BINARY_DIR}/gen/regilo/version.cpp")

# Create library
add_library(${PROJECT_NAME} SHARED ${CPPS} ${HPPS})
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")

# Link libraries
target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
endif()

# Install library
if(${install-headers} STREQUAL "OFF")
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${INSTALL_LIB_DIR})
endif()

# Install headers
if(${install-library} STREQUAL "OFF")
install(DIRECTORY include/${PROJECT_NAME}/ DESTINATION include/${PROJECT_NAME})
endif()
# Include headers
include_directories("include")

# Build library
if((${build-library}) OR (${install-headers} STREQUAL "OFF"))
# Find source code
file(GLOB_RECURSE CPPS "src/regilo/*.cpp")
file(GLOB_RECURSE HPPS "include/regilo/*.hpp")

# Configure files
configure_file("src/regilo/version.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/gen/regilo/version.cpp")
list(APPEND CPPS "${CMAKE_CURRENT_BINARY_DIR}/gen/regilo/version.cpp")

# Create library
add_library(${PROJECT_NAME} SHARED ${CPPS} ${HPPS})
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")

# Link libraries
target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
endif()

# Install library
if(${install-headers} STREQUAL "OFF")
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${INSTALL_LIB_DIR})
endif()

# Install headers
if(${install-library} STREQUAL "OFF")
install(DIRECTORY include/${PROJECT_NAME}/ DESTINATION include/${PROJECT_NAME})
endif()
endif()

# Add examples
if((${example}) OR (${examples}))
add_subdirectory("examples/regilo-scan")
add_subdirectory("examples/regilo-scan")
endif()

if((${example-gui}) OR (${examples}))
add_subdirectory("examples/regilo-visual")
add_subdirectory("examples/regilo-visual")
endif()

# Add unit tests
if(${tests})
add_subdirectory("tests")
add_subdirectory("tests")
endif()

# Add uninstall
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,13 @@ regilo::NeatoSocketController controller;
controller.connect("10.0.0.1:12345");

// Set the test mode and LDS rotation
controller.setTestMode(true);
controller.setLdsRotation(true);
controller.startScanner();

// Grab a scan from the robot
regilo::ScanData data = controller.getScan();

// Unset the test mode and LDS rotation
controller.setLdsRotation(false);
controller.setTestMode(false);
controller.stopScanner();
```

### Hokuyo
Expand Down
29 changes: 14 additions & 15 deletions cmake/cmake_uninstall.cmake.in
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
endif()

file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
execute_process(COMMAND
@CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}"
OUTPUT_VARIABLE rm_out
RESULT_VARIABLE rm_resval
)
if(NOT "${rm_resval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
endif()
else()
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
endif()
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
execute_process(COMMAND
@CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}"
OUTPUT_VARIABLE rm_out
RESULT_VARIABLE rm_resval
)
if(NOT "${rm_resval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
endif()
else()
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
endif()
endforeach()

Loading