Skip to content

Commit 6e7335f

Browse files
author
Tobias Kaupat
committed
Preparation to switch to GNU Toolchain
1 parent adf5bf7 commit 6e7335f

File tree

11 files changed

+3050
-15
lines changed

11 files changed

+3050
-15
lines changed

README.md

+22
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,32 @@ After cloning without `--recurse-submodules` the submodules must be loaded
2222

2323
* llvm-config is missing on windows
2424

25+
## Setup
26+
27+
For debugging the GNU Toolchain is required
28+
29+
rustup toolchain install stable-x86_64-pc-windows-gnu
30+
rustup default stable-x86_64-pc-windows-gnu
31+
32+
MSVC Toolchain is not working for debugging:
33+
34+
rustup default stable-msvc
35+
36+
37+
## Build
38+
39+
cargo build
40+
41+
To see all errors use:
42+
43+
cargo build -vv
44+
2545
## Generate C Bindings
2646

2747
C-Bindings are based on `src/bindings.h` and generated with [bindgen](https://github.com/rust-lang/rust-bindgen)
2848

49+
`bindgen` is executed during build in `build.rs`.
50+
2951

3052

3153

build.rs

+22-13
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,37 @@ fn main() {
1313
.file("c-lib/add.c")
1414
.compile("libadd.a");
1515

16-
17-
1816
// Build FreeRTOS for Windows
1917
let freertos_src_path = PathBuf::from("FreeRTOS/FreeRTOS/Source/");
2018
let freertos_plus_src_path = PathBuf::from("FreeRTOS/FreeRTOS-Plus/Source/");
2119
let freertos_demo_path = PathBuf::from("FreeRTOS/FreeRTOS/Demo");
20+
//let demo = "WIN32-MingW";
21+
let port = "MSVC-MingW";
22+
23+
let demo = "WIN32-MSVC";
24+
//let port = "MSVC-MingW";
2225

2326
cc::Build::new()
2427
// TODO: This is the windows specific part that needs to be env specific
2528
.include(freertos_src_path.join("include"))
26-
//.include(freertos_demo_path.join("WIN32-MSVC"))
27-
.include(freertos_demo_path.join("WIN32-MSVC/Trace_Recorder_Configuration"))
29+
//.include(freertos_demo_path.join(demo)
30+
.include(freertos_demo_path.join(demo).join("Trace_Recorder_Configuration"))
2831
.include(freertos_plus_src_path.join("FreeRTOS-Plus-Trace/Include"))
29-
.include(freertos_src_path.join("portable/MSVC-MingW"))
30-
.file(freertos_demo_path.join("WIN32-MSVC/Run-time-stats-utils.c"))
32+
.include(freertos_src_path.join("portable").join(port))
33+
// TODO: Make runtime stats not needed or move to /src/ports/win/...
34+
.file(freertos_demo_path.join(demo).join("Run-time-stats-utils.c"))
3135

3236
// Files related to port
33-
.include("src/ports/win")
34-
.file("src/ports/win/hooks.c")
37+
.include("src/freertos/ports/win")
38+
.file("src/freertos/ports/win/hooks.c")
39+
.file("src/freertos/ports/win/heap.c")
40+
.file("src/freertos/freertos_shim.c")
3541

42+
// FreeRTOS Plus Trace is needed for windows Demo
3643
.file(freertos_plus_src_path.join("FreeRTOS-Plus-Trace/trcKernelPort.c"))
3744
.file(freertos_plus_src_path.join("FreeRTOS-Plus-Trace/trcSnapshotRecorder.c"))
45+
46+
// FreeRTOS
3847
.file(freertos_src_path.join("croutine.c"))
3948
.file(freertos_src_path.join("event_groups.c"))
4049
.file(freertos_src_path.join("portable/MemMang/heap_5.c"))
@@ -43,9 +52,7 @@ fn main() {
4352
.file(freertos_src_path.join("list.c"))
4453
.file(freertos_src_path.join("queue.c"))
4554
.file(freertos_src_path.join("tasks.c"))
46-
.file(freertos_src_path.join("portable/MSVC-MingW/port.c"))
47-
48-
//.file("src/freertos_shim.c")
55+
.file(freertos_src_path.join("portable").join(port).join("port.c"))
4956

5057
.compile("libfreertos.a");
5158

@@ -67,10 +74,12 @@ fn main() {
6774
// The input header we would like to generate
6875
// bindings for.
6976
.header("src/bindings.h")
77+
.header("src/freertos/freertos_shim.h")
7078
//portmacro.h
7179
//.clang_arg(format!("-I{}", freertos_src_path.join("portable/MSVC-MingW").to_str().unwrap()))
72-
.clang_arg(format!("-I{}", freertos_demo_path.join("WIN32-MSVC").to_str().unwrap()))
73-
.clang_arg(format!("-I{}", freertos_demo_path.join("WIN32-MSVC/Trace_Recorder_Configuration").to_str().unwrap()))
80+
.clang_arg(format!("-I{}", freertos_src_path.join("include").to_str().unwrap()))
81+
.clang_arg(format!("-I{}", freertos_demo_path.join(demo).to_str().unwrap()))
82+
.clang_arg(format!("-I{}", freertos_demo_path.join(demo).join("Trace_Recorder_Configuration").to_str().unwrap()))
7483
.clang_arg(format!("-I{}", freertos_plus_src_path.join("FreeRTOS-Plus-Trace/Include").to_str().unwrap()))
7584
// Make the generated code #![no_std] compatible
7685
.use_core()

src/bindings.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#include "../c-lib/add.h"
2+
#include "FreeRTOS.h"
3+
#include "./freertos/ports/include/heap.h"
24

3-
#include "../FreeRTOS/FreeRTOS/Source/include/FreeRTOS.h"

0 commit comments

Comments
 (0)