diff --git a/samples/zephyr/CMakeLists.txt b/samples/zephyr/CMakeLists.txt index 987d38a10fd..2d178c91749 100644 --- a/samples/zephyr/CMakeLists.txt +++ b/samples/zephyr/CMakeLists.txt @@ -3,8 +3,17 @@ project(NONE) add_library(libsupcpp STATIC IMPORTED) -set_property(TARGET libsupcpp PROPERTY IMPORTED_LOCATION $ENV{GCCARMEMB_TOOLCHAIN_PATH}/arm-none-eabi/lib/thumb/libsupc++.a ) +set_property(TARGET libsupcpp PROPERTY IMPORTED_LOCATION $ENV{GCCARMEMB_TOOLCHAIN_PATH}/arm-none-eabi/lib/thumb/libsupc++.a) target_link_libraries(app libsupcpp) -target_sources(app PRIVATE src/empty.c build/program.o ) +set_property(TARGET app PROPERTY LINKER_LANGUAGE C) + +target_sources(app PRIVATE build/program.o) + +set_source_files_properties(program.o PROPERTIES EXTERNAL_OBJECT true GENERATED true) + +add_custom_command( + OUTPUT program.o + COMMAND cp kotlin/program.o program.o +) diff --git a/samples/zephyr/build.sh b/samples/zephyr/build.sh index 8aa7922b56b..6bf9e158233 100755 --- a/samples/zephyr/build.sh +++ b/samples/zephyr/build.sh @@ -28,28 +28,23 @@ mkdir -p $DIR/build && cd $DIR/build export ZEPHYR_GCC_VARIANT=gccarmemb export GCCARMEMB_TOOLCHAIN_PATH=$GCC_ARM -# This is a kind of forward declaration for `program.o`. See below. -touch program.o - [ -f CMakeCache.txt ] || cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DBOARD=$BOARD .. || exit 1 +# We need generated headers to be consumed by `cinterop`, +# so we preconfigure the project with `make zephyr`. make zephyr . $DIR/c_interop/platforms/$BOARD.sh -# We need generated headers to be consumed by `cinterop`, -# so we preconfigure the project with `make zephyr`. -# But `program.o` should exist at that stage to be detected by the configuration tools. -# So we create an empty `program.o` above, and then override it with the compiler result below. -# TODO: do something with this mess. - rm -f program.o +mkdir -p $DIR/build/kotlin + konanc $DIR/src/main.kt \ -target zephyr_$BOARD \ -r $DIR/c_interop/platforms/build \ -l $BOARD \ - -opt -g -o program || exit 1 + -opt -g -o $DIR/build/kotlin/program || exit 1 make || exit 1 diff --git a/samples/zephyr/src/empty.c b/samples/zephyr/src/empty.c deleted file mode 100644 index 7912ed644f7..00000000000 --- a/samples/zephyr/src/empty.c +++ /dev/null @@ -1,2 +0,0 @@ -// This is a placeholder empty C file. -// It is needed for Zephyr to detect the project as C project.