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

Modernize CMake #653

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions .cmake-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
with section("format"):
# Same as for our C code
line_width = 120
tab_size = 4

# Smaller diffs
dangle_parens = True

# Settling cross platform disputes
line_ending = 'unix'

# Format keywords consistently
keyword_case = 'upper'

with section("markup"):
# What character to use for bulleted lists
bullet_char = '-'
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
env:
CC: ${{ matrix.compiler }}

- name: Build, execute sanititzed unit tests
- name: Build, execute sanitized unit tests
run: |
tools/ci/run_ci.sh --run-tests --sanitizer ${{ matrix.sanitizer }}
env:
Expand Down
42 changes: 10 additions & 32 deletions .github/workflows/compliance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: Compliance
on: pull_request

jobs:
check-gitlint:
name: Run gitlint
lint-code:
name: Run compliance checks
runs-on: ubuntu-20.04

steps:
Expand All @@ -13,47 +13,25 @@ jobs:
with:
fetch-depth: 0

- name: Install gitlint
- name: Install compliance tools
run: |
pip3 install gitlint
sudo apt update
sudo apt -qy --no-install-recommends install clang-format-10
pip3 install -r tools/requirements-compliance.txt

- name: Check commits with gitlint
run: |
tools/ci/run_ci.sh --branch-target origin/${{ github.base_ref }} --run-gitlint

check-clang-format:
name: Run clang-format
runs-on: ubuntu-20.04

steps:
- name: Checkout code including full history
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Install clang-format
run: |
sudo apt update
sudo apt -qy --no-install-recommends install clang-format-10

- name: Check commits with clang-format
- name: Check C code (delta) with clang-format
run: |
tools/ci/run_ci.sh --branch-target origin/${{ github.base_ref }} --run-clang-format

check-pylint:
name: Run pylint
runs-on: ubuntu-20.04

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install pylint
- name: Check CMakeLists.txt files with cmake-lint
run: |
pip3 install pylint -r tests/integration/requirements.txt
tools/ci/run_ci.sh --run-cmake-lint

- name: Check python code with pylint
- name: Check Python code with pylint
run: |
python -c "import sys; print(sys.version)"
cd tests
pylint integration
11 changes: 10 additions & 1 deletion .github/workflows/multiarch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ jobs:
githubToken: ${{ github.token }}
install: |
apt update
apt -qy --no-install-recommends install libcunit1-dev ninja-build unzip wget build-essential cmake
apt -qy --no-install-recommends install \
autoconf \
build-essential \
cmake \
git \
libcunit1-dev \
ninja-build \
unzip \
wget \
;
run: |
tools/ci/run_ci.sh --run-build --run-tests
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ cmake_minimum_required(VERSION 3.13)

project(wakaama C)

include(wakaama.cmake)

add_subdirectory(examples)

# Enable "test" target
enable_testing()
add_subdirectory(tests)

add_subdirectory(examples)
35 changes: 20 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ Developers mailing list: https://dev.eclipse.org/mailman/listinfo/wakaama-dev
+- shared (utility functions for connection handling and command-
line interface)

## Checking out the code

### Using Wakaama as library

```
git clone https://github.com/eclipse/wakaama.git
```

### Working on Wakaama

When working on Wakaama itself, or intending to run the example client application, submodules must be checked out:

```
git clone --recurse-submodules https://github.com/eclipse/wakaama.git
```

## Compiling

Expand Down Expand Up @@ -75,11 +90,12 @@ LWM2M_CLIENT_MODE and LWM2M_SERVER_MODE can be defined at the same time.
- Git commit message linter: gitlint
- Build system: ninja
- C code formatting: clang-format, version 10
- CMake list files formatting: cmake-format, version 0.6.13
- Unit testing: CUnit

On Ubuntu 20.04, used in CI, the dependencies can be installed as such:
- `apt install build-essential clang-format clang-format-10 clang-tools-10 cmake gcovr git libcunit1-dev ninja-build python3-pip`
- `pip3 install gitlint`
- `pip3 install -r tools/requirements-compliance.txt`

### Code formatting
New code must be formatted with [clang-format](https://clang.llvm.org/docs/ClangFormat.html).
Expand Down Expand Up @@ -136,18 +152,7 @@ Options:
* ``make``
* ``./lwm2mclient [Options]``

DTLS feature requires the tinydtls submodule. To include it, on the first run,
use the following commands to retrieve the sources:
* ``git submodule init``
* ``git submodule update``

You need to install autoconf and automake to build with tinydtls.

Build with tinydtls:
* Create a build directory and change to that.
* ``cmake -DDTLS=1 [wakaama directory]/examples/client``
* ``make``
* ``./lwm2mclient [Options]``
Next to lwm2mclient a DTLS enabled variant named lwm2mclient_tinydtls gets built.

The lwm2mclient features nine LWM2M objects:
- Security Object (id: 0)
Expand All @@ -172,7 +177,7 @@ The lwm2mclient features nine LWM2M objects:
exec | 2 | E | No | Yes | | |
dec | 3 | R/W | No | Yes | Float | |

The lwm2mclient opens udp port 56830 and tries to register to a LWM2M Server at
The lwm2mclient opens UDP port 56830 and tries to register to a LWM2M Server at
127.0.0.1:5683. It features a basic command line interface. Type 'help' for a
list of supported commands.

Expand All @@ -193,7 +198,7 @@ Options:

```

If DTLS feature enable:
Additional values for the lwm2mclient_tinydtls binary:
```
-i Set the device management or bootstrap server PSK identity. If not set use none secure mode
-s Set the device management or bootstrap server Pre-Shared-Key. If not set use none secure mode
Expand Down
11 changes: 0 additions & 11 deletions coap/coap.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion core/observe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ int prv_lwm2m_observe_cancel(lwm2m_context_t * contextP,

observationP->status = STATE_DEREG_PENDING;

int ret = transaction_send(contextP, transactionP);
ret = transaction_send(contextP, transactionP);
if (ret != 0) lwm2m_free(cancelP);
return ret;
}
Expand Down
58 changes: 0 additions & 58 deletions core/wakaama.cmake

This file was deleted.

13 changes: 0 additions & 13 deletions data/data.cmake

This file was deleted.

10 changes: 5 additions & 5 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
cmake_minimum_required(VERSION 3.13)

# Our examples are designed for POSIX systems
add_compile_definitions(_POSIX_C_SOURCE=200809)
add_compile_options(-pedantic)

add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/bootstrap_server)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/client)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/lightclient)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/server)
add_subdirectory(bootstrap_server)
add_subdirectory(client)
add_subdirectory(lightclient)
add_subdirectory(server)
28 changes: 5 additions & 23 deletions examples/bootstrap_server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,9 @@ cmake_minimum_required(VERSION 3.13)

project(bootstrap_server C)

if(DTLS)
message(FATAL_ERROR "DTLS option is not supported.")
endif()
include(../../wakaama.cmake)

include(${CMAKE_CURRENT_LIST_DIR}/../../core/wakaama.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/../../coap/coap.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/../../data/data.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/../shared/shared.cmake)

add_compile_definitions(LWM2M_BOOTSTRAP_SERVER_MODE)

include_directories(${WAKAAMA_HEADERS_DIR} ${COAP_HEADERS_DIR} ${DATA_HEADERS_DIR} ${WAKAAMA_SOURCES_DIR} ${SHARED_INCLUDE_DIRS})

SET(SOURCES
${CMAKE_CURRENT_LIST_DIR}/bootstrap_server.c
${CMAKE_CURRENT_LIST_DIR}/bootstrap_info.c
${CMAKE_CURRENT_LIST_DIR}/bootstrap_info.h
)

SET(AUXILIARY_FILES ${CMAKE_CURRENT_LIST_DIR}/bootstrap_server.ini)

add_executable(${PROJECT_NAME} ${SOURCES} ${AUXILIARY_FILES} ${WAKAAMA_SOURCES} ${COAP_SOURCES} ${DATA_SOURCES} ${SHARED_SOURCES})

SOURCE_GROUP(wakaama FILES ${WAKAAMA_SOURCES})
add_executable(bootstrap_server bootstrap_info.c bootstrap_server.c bootstrap_info.h bootstrap_server.ini)
target_compile_definitions(bootstrap_server PRIVATE LWM2M_BOOTSTRAP_SERVER_MODE)
target_sources_wakaama(bootstrap_server)
target_sources_shared(bootstrap_server)