Skip to content

Commit

Permalink
Merge branch 'lcm-proj:master' into file-level-comments
Browse files Browse the repository at this point in the history
  • Loading branch information
judfs authored Sep 22, 2024
2 parents 3771431 + f18f8a6 commit 45b8c46
Show file tree
Hide file tree
Showing 24 changed files with 325 additions and 217 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build wheels

on: [push, pull_request]

jobs:
unix:
name: ${{ matrix.os }} | ${{ matrix.arch }} | ${{ matrix.python }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# macos-13 is an intel runner, macos-14 is apple silicon
os: [ubuntu-latest, macos-13, macos-14]
arch: [auto, aarch64]
python: [cp37-*, cp38-*, cp39-*, cp310-*, cp311-*, cp312-*,
pp37-*, pp38-*, pp39-*, pp310-*]
include:
- os: macos-13
macos_deployment_target: 13
- os: macos-14
macos_deployment_target: 14
exclude:
- os: macos-13
arch: aarch64
- os: macos-14
arch: aarch64
- os: macos-14
python: cp37-*
- os: macos-14
python: pp37-*

steps:
- uses: actions/checkout@v4

- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Build wheels
uses: pypa/[email protected]
env:
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macos_deployment_target }}
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_BUILD: ${{ matrix.python }}

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
21 changes: 10 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
ubuntu:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04]
os: [ubuntu-24.04, ubuntu-22.04]
build_type: [Debug, Release]

runs-on: ${{ matrix.os }}
Expand All @@ -20,7 +20,7 @@ jobs:

- name: Install Dependencies
run: |
sudo apt install liblua5.3-dev lua5.3 libjchart2d-java
sudo apt install liblua5.3-dev lua5.3 libjchart2d-java libglib2.0-dev
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build ${{env.CMAKE_FLAGS}} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
LD_LIBRARY_PATH=/usr/local/lib/ build/lcm_log_writer build/example.log
fedora:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v3
Expand All @@ -66,7 +66,7 @@ jobs:
docker run -v $(pwd):/work -d --rm -it --name lcm-fedora lcm-fedora /bin/bash
- name: Configure CMake
run: docker exec lcm-fedora cmake -B ${{github.workspace}}/build ${{env.CMAKE_FLAGS}}
run: docker exec lcm-fedora cmake -B ${{github.workspace}}/build ${{env.CMAKE_FLAGS}} -DCMAKE_BUILD_TYPE=Debug

- name: Build
run: docker exec lcm-fedora cmake --build ${{github.workspace}}/build
Expand Down Expand Up @@ -97,7 +97,7 @@ jobs:
macos:
strategy:
matrix:
os: [macos-11, macos-12]
os: [macos-13, macos-14]

runs-on: ${{ matrix.os }}

Expand Down Expand Up @@ -184,15 +184,14 @@ jobs:
ctest --output-on-failure
docs:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Dependencies
run: |
sudo apt install doxygen liblua5.4-dev lua5.4
pip install sphinx-rtd-theme Sphinx myst-parser
sudo apt install doxygen liblua5.4-dev lua5.4 python3-sphinx-rtd-theme python3-sphinx python3-myst-parser libglib2.0-dev
- name: Build Docs
run: |
Expand All @@ -201,20 +200,20 @@ jobs:
make doc
- name: Archive Docs
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: archived-docs
path: build/docs/_build

formatting:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Dependencies
run: |
sudo apt install clang-format-12
sudo apt install clang-format-15
- name: Check formatting
run: |
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ docs/_build/
.idea/
.settings/
.project
.classpath
.classpath
.venv
.DS_Store
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ endif()

project(lcm)

# https://www.kitware.com/cmake-and-the-default-build-type/
# Set a default build type if none was specified
set(default_build_type "Release")

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
if(CMAKE_VERSION VERSION_LESS 3.7)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/3.7")
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ feedback and involvement on new features.

* Platforms:
* GNU/Linux
* Ubuntu (20.04 and 22.04)
* Fedora (37)
* macOS (11 and 12)
* Ubuntu (22.04 and 24.04)
* Fedora (40)
* macOS (13 and 14)
* Windows (2019 and 2022) via MSYS2
* Languages
* C
Expand Down
18 changes: 18 additions & 0 deletions cmake/FindGLib2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,24 @@ endfunction()

###############################################################################

find_package(PkgConfig)

if(${PkgConfig_FOUND})

pkg_check_modules(GLIB glib-2.0)

if(${GLIB_FOUND})
add_library(GLib2::glib UNKNOWN IMPORTED)
set_target_properties(GLib2::glib PROPERTIES
IMPORTED_LOCATION "${pkgcfg_lib_GLIB_glib-2.0}"
INTERFACE_COMPILE_OPTIONS "${GLIB_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${GLIB_INCLUDE_DIRS}"
)
return()
endif()

endif()

_glib2_find_library(GLIB glib)
_glib2_find_include(GLIB glib.h)
_glib2_find_include(GLIBCONFIG glibconfig.h GLIB)
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.fedora
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM fedora:37
FROM fedora:40

# cmake3: To build LCM
# clang: For compiling code with Clang
Expand Down
16 changes: 16 additions & 0 deletions docs/content/build-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ release or the latest `master`, we recommend referring to the copy of this
document (`docs/content/build-instructions.md`) found in your source
distribution.

## Installing the Python module

To build the Python module from source and install it, run:

```
pip3 install -v .
```

## CMake Overview

These instructions assume that you will build in a directory named `build` as
Expand All @@ -33,6 +41,14 @@ generators. To users familiar with CMake, we recommend using
A detailed description of how to use CMake is not specific to LCM and is beyond
the scope of these instructions.

By default CMake is configured to produce a release build. To build with debug symbols instead, use:

```shell
cmake .. -DCMAKE_BUILD_TYPE=Debug
```

when configuring a build directory in the following sections.

## Ubuntu and Debian

Required packages:
Expand Down
13 changes: 12 additions & 1 deletion docs/content/contributing-c.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

Run `./format_code.sh` before committing to format the code.

Configure with `cmake .. -DCMAKE_BUILD_TYPE=Debug` or `cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo` to debug.


Modifying lcm-gen does not rebuild the tests. [#490](https://github.com/lcm-proj/lcm/issues/490). The following is a workaround:

```bash
cd build
rm -r test && make -j
make test
```

## Code Quality

Code in the directory `lcmgen` leaks memory. It is not an uncommon practice to allow this for short lived CLI tools.
Code in the directory `lcmgen` leaks memory. It is not an uncommon practice to allow this for short lived CLI tools. It is preferred to avoid and clean up after this practice though. [#484](https://github.com/lcm-proj/lcm/issues/484).
9 changes: 8 additions & 1 deletion examples/cpp/lcm_log_writer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ cmake_minimum_required(VERSION 3.5)

project(lcm_log_writer)

# Include this directory for finding GLib2, using the file FindGLib2.cmake.
# **WARNING** If you want to reuse this example, you will need to copy
# FindGLib2.cmake to your new project and adjust your CMAKE_MODULE_PATH.
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../../../cmake")

find_package(GLib2 REQUIRED)

find_package(lcm REQUIRED)
include(${LCM_USE_FILE})

Expand All @@ -16,4 +23,4 @@ target_include_directories(pjs_messages-cpp INTERFACE

# Create executable
add_executable(lcm_log_writer "main.cpp")
lcm_target_link_libraries(lcm_log_writer pjs_messages-cpp ${LCM_NAMESPACE}lcm)
lcm_target_link_libraries(lcm_log_writer pjs_messages-cpp ${LCM_NAMESPACE}lcm-static)
8 changes: 4 additions & 4 deletions format_code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ set -o pipefail
IFS=$'\n\t'

# Bash script to automatically format LCM source code (currently C and C++).
# Requires `clang-format-12` utility, which is part of the LLVM project. More
# Requires `clang-format-15` utility, which is part of the LLVM project. More
# information can be found here: https://clang.llvm.org/docs/ClangFormat.html
#
# To install `clang-format-12` on Ubuntu do:
# To install `clang-format-15` on Ubuntu do:
#
# $ sudo apt install clang-format-12
# $ sudo apt install clang-format-15
#
# This script does not format Java, Python, or Lua source code. At the moment,
# it only formats C and C++ sources, i.e., *.h, *.c, *.hpp, and *.cpp. It only
Expand All @@ -33,7 +33,7 @@ LCM_FORMAT_DIRS=(
"${LCM_ROOT}/test:/gtest/"
)

CLANG_FORMAT="clang-format-12"
CLANG_FORMAT="clang-format-15"

# Function: show_usage
#
Expand Down
4 changes: 2 additions & 2 deletions lcm-logger/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
add_executable(lcm-logger lcm_logger.c glib_util.c)
target_link_libraries(lcm-logger lcm GLib2::glib)
target_link_libraries(lcm-logger lcm-static GLib2::glib)

add_executable(lcm-logplayer lcm_logplayer.c)
target_link_libraries(lcm-logplayer lcm GLib2::glib)
target_link_libraries(lcm-logplayer lcm-static GLib2::glib)

install(TARGETS
lcm-logger
Expand Down
2 changes: 1 addition & 1 deletion lcm-logger/glib_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#ifdef WIN32
#define SIGKILL 2
#include "../lcm/windows/WinPorting.h"
//#include <Winsock2.h>
// #include <Winsock2.h>
#else
#include <sys/stat.h>
#include <sys/types.h>
Expand Down
45 changes: 31 additions & 14 deletions lcm-python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
# FindPython added in 3.12
cmake_minimum_required(VERSION 3.12)

execute_process(
COMMAND "${Python_EXECUTABLE}" -c "if True:
from sysconfig import get_path
from os.path import sep
print(get_path('platlib').replace(get_path('data') + sep, ''))"
OUTPUT_VARIABLE PYTHON_SITE
OUTPUT_STRIP_TRAILING_WHITESPACE)
option(LCM_PIP_BUILD "When true, adjusts install path to something appropriate for a Python wheel" OFF)

if (NOT LCM_PIP_BUILD)
execute_process(
COMMAND "${Python_EXECUTABLE}" -c "if True:
from sysconfig import get_path
from os.path import sep
print(get_path('platlib').replace(get_path('data') + sep, ''))"
OUTPUT_VARIABLE PYTHON_SITE
OUTPUT_STRIP_TRAILING_WHITESPACE)

set(PYTHON_INSTALL_DIR ${PYTHON_SITE}/lcm)
else()
set(PYTHON_INSTALL_DIR lcm)
endif()


set(lcm_python_sources
module.c
Expand All @@ -28,11 +37,19 @@ if (WIN32 AND NOT CYGWIN)
set_target_properties(lcm-python PROPERTIES SUFFIX .pyd)
endif ()

find_package (Python COMPONENTS Interpreter Development)
if (WIN32)
find_package(Python COMPONENTS Interpreter Development.Module)

target_include_directories(lcm-python PRIVATE
${Python_INCLUDE_DIRS}
)
target_include_directories(lcm-python PRIVATE
${Python_INCLUDE_DIRS}
)
else ()
find_package(Python3 COMPONENTS Interpreter Development.Module)

target_include_directories(lcm-python PRIVATE
${Python3_INCLUDE_DIRS}
)
endif ()

target_link_libraries(lcm-python PRIVATE
lcm-static
Expand All @@ -47,13 +64,13 @@ else()
endif()

install(TARGETS lcm-python
RUNTIME DESTINATION ${PYTHON_SITE}/lcm
LIBRARY DESTINATION ${PYTHON_SITE}/lcm
RUNTIME DESTINATION ${PYTHON_INSTALL_DIR}
LIBRARY DESTINATION ${PYTHON_INSTALL_DIR}
)

lcm_copy_file_target(lcm-python-init
${CMAKE_CURRENT_SOURCE_DIR}/lcm/__init__.py
${CMAKE_BINARY_DIR}/python/lcm/__init__.py
)

install(FILES lcm/__init__.py DESTINATION ${PYTHON_SITE}/lcm)
install(FILES lcm/__init__.py DESTINATION ${PYTHON_INSTALL_DIR})
Loading

0 comments on commit 45b8c46

Please sign in to comment.