c-with-rust: make cmake call cargo
This commit is contained in:
parent
ec1a638e20
commit
6e48ce664e
@ -15,11 +15,14 @@ add_executable(
|
||||
blink.c
|
||||
)
|
||||
|
||||
add_subdirectory(rblink)
|
||||
add_dependencies(blink rblink)
|
||||
|
||||
# pull in common dependencies
|
||||
target_link_libraries(
|
||||
blink
|
||||
pico_stdlib
|
||||
/tmp/cargo-target/thumbv6m-none-eabi/release/librblink.a
|
||||
${CMAKE_CURRENT_BINARY_DIR}/rblink/librblink.a
|
||||
)
|
||||
|
||||
# create map/bin/hex file etc.
|
||||
|
@ -51,6 +51,9 @@ int c_main() {
|
||||
gpio_put(LED_PIN, 0);
|
||||
sleep_ms(sleep);
|
||||
sleep = add_half(sleep);
|
||||
if(sleep > 2000) {
|
||||
reset_usb_boot(LED_PIN, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,9 +5,6 @@ set -euxo pipefail
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
cd "$SCRIPT_DIR"/rblink
|
||||
CARGO_TARGET_DIR=/tmp/cargo-target cargo build --release --target thumbv6m-none-eabi
|
||||
|
||||
mkdir -p /tmp/8
|
||||
cd /tmp/8
|
||||
|
||||
|
20
c-with-rust/rblink/CMakeLists.txt
Normal file
20
c-with-rust/rblink/CMakeLists.txt
Normal file
@ -0,0 +1,20 @@
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(CARGO_CMD cargo build --target thumbv6m-none-eabi)
|
||||
set(TARGET_DIR "debug")
|
||||
else ()
|
||||
set(CARGO_CMD cargo build --release --target thumbv6m-none-eabi)
|
||||
set(TARGET_DIR "release")
|
||||
endif ()
|
||||
|
||||
set(RBLINK_A "${CMAKE_CURRENT_BINARY_DIR}/thumbv6m-none-eabi/${TARGET_DIR}/librblink.a")
|
||||
|
||||
add_custom_target(rblink ALL
|
||||
COMMENT "Compiling rblink module"
|
||||
COMMAND CARGO_TARGET_DIR=${CMAKE_CURRENT_BINARY_DIR} ${CARGO_CMD}
|
||||
COMMAND cp ${RBLINK_A} ${CMAKE_CURRENT_BINARY_DIR}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set_target_properties(rblink PROPERTIES LOCATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
add_test(NAME rblink_test
|
||||
COMMAND cargo test
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
Loading…
Reference in New Issue
Block a user