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

Add system includes and fix uart undefined symbols #45

Merged
merged 8 commits into from
Mar 8, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Build
on:
workflow_dispatch:
push:
branches:
master
pull_request:

env:
Expand All @@ -16,7 +18,7 @@ jobs:
matrix:
zephyr_version: [3.4.0, 2.7.3, 2.6.0, 2.5.0, 2.4.0, 2.3.0]
board: [qemu_x86, qemu_cortex_m3, native_posix, qemu_riscv32, qemu_riscv64]
test: [samples/rust-app]
test: [samples/rust-app, samples/serial]
exclude:
- board: qemu_riscv32
zephyr_version: 2.3.0
Expand All @@ -38,12 +40,11 @@ jobs:
zephyr_version: 2.7.3
- board: qemu_riscv64
zephyr_version: 2.7.3
- board: native_posix
test: samples/serial
include:
- fails: false
- run: true
- test: samples/rust-app
fails: true
run: false
- run: false
runs-on: ubuntu-latest
container:
image: ghcr.io/${{ github.repository }}:zephyr-rust-${{ matrix.zephyr_version }}-1.68.0
Expand Down
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,16 @@ add_custom_command(OUTPUT ${rust_generated_project}/Cargo.toml
)
add_custom_target(rust_generated_project DEPENDS ${rust_generated_project}/Cargo.toml)

# external_project_cflags comes from the example: zephyr/samples/application_development/external_lib/CMakeLists.txt
zephyr_get_include_directories_for_lang_as_string( C includes)
zephyr_get_system_include_directories_for_lang_as_string(C system_includes)
zephyr_get_compile_definitions_for_lang_as_string( C definitions)
# `options` is not included because many of the flags are not supported by clang
# `-imacros ${AUTOCONF_H}` is needed and would have been in `options`
#zephyr_get_compile_options_for_lang_as_string( C options)

set(external_project_cflags
"${includes} ${definitions} -imacros ${AUTOCONF_H}"
"${includes} ${definitions} ${system_includes} -imacros ${AUTOCONF_H}"
)

# Add the Cargo project only if CONFIG_RUST because this will alawys invoke Cargo.
Expand Down
2 changes: 0 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,7 @@ TODO

* Figure out how to fail tests through assertions in code
* Support #[test]
* CI
* Ability to build multiple independent apps
* Investigate DWARF errors in final link
* More safe bindings (e.g. GPIO)

Features Not Planned to Support
Expand Down
12 changes: 12 additions & 0 deletions ci/build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,19 @@ parallel \
-j8 \
--results log/build \
--resume \
--halt now,fail=1 \
ZEPHYR_VERSION={1} ./build-cmd.sh west build -d /tmp/build -p auto -b {2} {3} \
::: $ZEPHYR_VERSIONS \
::: qemu_x86 qemu_cortex_m3 \
::: samples/rust-app samples/serial samples/futures

# native_posix does not support UART_INTERRUPT_DRIVEN
parallel \
-j8 \
--results log/build \
--resume \
--halt now,fail=1 \
ZEPHYR_VERSION={1} ./build-cmd.sh west build -d /tmp/build -p auto -b {2} {3} \
::: $ZEPHYR_VERSIONS \
::: native_posix \
::: samples/rust-app samples/futures
6 changes: 4 additions & 2 deletions rust/zephyr-sys/wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@
#include <all_syscalls.h>
#include <device.h>
#include <drivers/uart.h>
#include <uart_buffered.h>
#include <drivers/eeprom.h>
#else
#include <zephyr/kernel.h>
#include <all_syscalls.h>
#include <zephyr/device.h>
#include <zephyr/drivers/uart.h>
#include <uart_buffered.h>
#include <zephyr/drivers/eeprom.h>
#endif

#ifdef CONFIG_UART_BUFFERED
#include <uart_buffered.h>
#endif

#ifdef CONFIG_POSIX_CLOCK
#include <posix/time.h>
#endif
Expand Down
6 changes: 6 additions & 0 deletions samples/futures/src/main.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#include <version.h>

#if KERNEL_VERSION_MAJOR < 3
#include <zephyr.h>
#else
#include <zephyr/kernel.h>
#endif

extern void rust_test_main(void);
extern void rust_sem_thread(void *, void *, void *);
Expand Down
2 changes: 0 additions & 2 deletions samples/serial/src/main.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <zephyr.h>
#include <drivers/uart.h>
#include <uart_buffered.h>

extern void rust_main(struct uart_buffered_rx_handle rx,
Expand Down
8 changes: 6 additions & 2 deletions uart-buffered/src/uart_buffered.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#define __ZEPHYR_SUPERVISOR__

#include <kernel.h>
#include <drivers/uart.h>
#include <version.h>

#if KERNEL_VERSION_MAJOR < 3
#include <logging/log.h>
#else
#include <zephyr/logging/log.h>
#endif

#include "uart_buffered.h"

Expand Down
2 changes: 2 additions & 0 deletions uart-buffered/src/uart_buffered.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
#if KERNEL_VERSION_MAJOR < 3
#include <zephyr.h>
#include <kernel.h>
#include <drivers/uart.h>
#else
#include <zephyr/kernel.h>
#include <zephyr/drivers/uart.h>
#endif

typedef uint16_t fifo_index_t;
Expand Down
3 changes: 0 additions & 3 deletions uart-buffered/src/uart_buffered_api.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#include <kernel.h>
#include <drivers/uart.h>

#include "uart_buffered.h"

static void k_poll_signal_wait(struct k_poll_signal *signal)
Expand Down