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

Use Zephyr's CMake extension to correctly build and link reactor-c #2167

Merged
merged 12 commits into from
Jan 27, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ CodeBuilder generateCMakeCode(
cMakeCode.pr(" target_link_libraries(${LF_MAIN_TARGET} PUBLIC ${MATH_LIBRARY})");
cMakeCode.pr("endif()");

cMakeCode.pr("target_link_libraries(${LF_MAIN_TARGET} PRIVATE core)");
cMakeCode.pr("target_link_libraries(${LF_MAIN_TARGET} PRIVATE reactor-c)");

cMakeCode.pr("target_include_directories(${LF_MAIN_TARGET} PUBLIC .)");
cMakeCode.pr("target_include_directories(${LF_MAIN_TARGET} PUBLIC include/)");
Expand Down Expand Up @@ -472,10 +472,6 @@ private static String setUpMainTargetZephyr(
boolean hasMain, String executableName, Stream<String> cSources) {
var code = new CodeBuilder();
code.pr("add_subdirectory(core)");
code.pr("target_link_libraries(core PUBLIC zephyr_interface)");
// FIXME: Linking the reactor-c corelib with the zephyr kernel lib
// resolves linker issues but I am not yet sure if it is safe
code.pr("target_link_libraries(core PRIVATE kernel)");
code.newLine();

if (hasMain) {
Expand Down
15 changes: 15 additions & 0 deletions test/C/src/zephyr/unthreaded/picolib/Picolib.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// A smoke test verifying that we can compile and run using picolibc also.
target C {
platform: "Zephyr",
timeout: 10 sec,
fast: true,
files: "prj.conf"
}

main reactor {
timer t(0, 1 sec)

reaction(t) {=
printf("Hello\n");
=}
}
2 changes: 2 additions & 0 deletions test/C/src/zephyr/unthreaded/picolib/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_NEWLIB_LIBC=n
CONFIG_PICOLIBC=y
Loading