Skip to content

Commit

Permalink
Merge pull request #2167 from lf-lang/zephyr-esp-issue
Browse files Browse the repository at this point in the history
Use Zephyr's CMake extension to correctly build and link reactor-c
  • Loading branch information
edwardalee authored Jan 27, 2024
2 parents fb0ab5c + b19a61f commit 36b3d4a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
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

0 comments on commit 36b3d4a

Please sign in to comment.