forked from RIOT-OS/RIOT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The idea is to integrate rust into the existing build system as well as possible and to not use a separate buildsystem like cargo or xargo. Makefile.base has been modified to include support for main.rs and lib.rs files and a Makefile.rust has been added which sets a few rust related variables. This is very loosly based on RIOT-OS#5740
- Loading branch information
Showing
13 changed files
with
193 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Function to get `lib*` name for a module. This is | ||
# needed because rustc expects files passed to | ||
# `--extern` to match the pattern `lib*.rlib`. | ||
define libname | ||
$(shell dirname $1)/lib$(shell basename $1) | ||
endef | ||
|
||
# Set module name and library name (see above). | ||
MODULE ?= $(shell basename $(CURDIR)) | ||
ifeq (lib,$(CRATE_TYPE)) | ||
LIBNAME = $(call libname,$(MODULE)) | ||
endif | ||
|
||
# Set crate metadata in case they aren't set. | ||
CRATE_TYPE ?= bin | ||
CRATE_NAME ?= $(shell basename $(MODULE)) | ||
|
||
# Make our custom targets known to rustc. | ||
export RUST_TARGET_PATH ?= $(RIOTBASE)/dist/rust | ||
|
||
# Set the rust target accordingly. | ||
ifeq ($(BOARD),native) | ||
RUST_TARGET=i586-unknown-linux-gnu | ||
else | ||
RUST_TARGET=$(CPU_ARCH) | ||
endif | ||
|
||
# Flags to pass to the rust compiler. | ||
RUSTC_FLAGS += --crate-name $(CRATE_NAME) \ | ||
--crate-type $(CRATE_TYPE) \ | ||
--target $(RUST_TARGET) \ | ||
--extern core=$(BINDIR)/libcore.rlib | ||
|
||
# Include dependencies in `RUSTC_FLAGS`. | ||
RUSTMODULE ?= $(filter rust/%, $(USEMODULE)) | ||
RUSTC_FLAGS += $(foreach dep,$(RUSTMODULE),--extern \ | ||
$(shell basename $(dep))=$(BINDIR)/$(call libname,$(dep)).rlib) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"arch": "arm", | ||
"cpu": "cortex-m0", | ||
"data-layout": "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", | ||
"executables": true, | ||
"llvm-target": "thumbv6m-none-eabi", | ||
"no-compiler-rt": true, | ||
"os": "none", | ||
"pre-link-args": [], | ||
"relocation-model": "static", | ||
"target-endian": "little", | ||
"target-pointer-width": "32" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"arch": "arm", | ||
"cpu": "cortex-m0plus", | ||
"data-layout": "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", | ||
"executables": true, | ||
"llvm-target": "thumbv6m-none-eabi", | ||
"no-compiler-rt": true, | ||
"os": "none", | ||
"pre-link-args": [], | ||
"relocation-model": "static", | ||
"target-endian": "little", | ||
"target-pointer-width": "32" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"arch": "arm", | ||
"cpu": "cortex-m1", | ||
"data-layout": "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", | ||
"executables": true, | ||
"llvm-target": "thumbv6m-none-eabi", | ||
"no-compiler-rt": true, | ||
"os": "none", | ||
"pre-link-args": [], | ||
"relocation-model": "static", | ||
"target-endian": "little", | ||
"target-pointer-width": "32" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"arch": "arm", | ||
"cpu": "cortex-m3", | ||
"data-layout": "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", | ||
"executables": true, | ||
"llvm-target": "thumbv7m-none-eabi", | ||
"no-compiler-rt": true, | ||
"os": "none", | ||
"pre-link-args": [], | ||
"relocation-model": "static", | ||
"target-endian": "little", | ||
"target-pointer-width": "32" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"arch": "arm", | ||
"cpu": "cortex-m4", | ||
"data-layout": "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", | ||
"executables": true, | ||
"features": "+soft-float", | ||
"llvm-target": "thumbv7em-none-eabi", | ||
"no-compiler-rt": true, | ||
"os": "none", | ||
"pre-link-args": [], | ||
"relocation-model": "static", | ||
"target-endian": "little", | ||
"target-pointer-width": "32" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"arch": "arm", | ||
"cpu": "cortex-m4", | ||
"data-layout": "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", | ||
"executables": true, | ||
"llvm-target": "thumbv7em-none-eabi", | ||
"no-compiler-rt": true, | ||
"os": "none", | ||
"pre-link-args": [], | ||
"relocation-model": "static", | ||
"target-endian": "little", | ||
"target-pointer-width": "32" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"arch": "arm", | ||
"cpu": "cortex-m7", | ||
"data-layout": "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", | ||
"executables": true, | ||
"features": "+soft-float", | ||
"llvm-target": "thumbv7em-none-eabi", | ||
"no-compiler-rt": true, | ||
"os": "none", | ||
"pre-link-args": [], | ||
"relocation-model": "static", | ||
"target-endian": "little", | ||
"target-pointer-width": "32" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"arch": "arm", | ||
"cpu": "cortex-m7", | ||
"data-layout": "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", | ||
"executables": true, | ||
"features": "+fp-only-sp", | ||
"llvm-target": "thumbv7em-none-eabi", | ||
"no-compiler-rt": true, | ||
"os": "none", | ||
"pre-link-args": [], | ||
"relocation-model": "static", | ||
"target-endian": "little", | ||
"target-pointer-width": "32" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"arch": "arm", | ||
"cpu": "cortex-m7", | ||
"data-layout": "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", | ||
"executables": true, | ||
"llvm-target": "thumbv7em-none-eabi", | ||
"no-compiler-rt": true, | ||
"os": "none", | ||
"pre-link-args": [], | ||
"relocation-model": "static", | ||
"target-endian": "little", | ||
"target-pointer-width": "32" | ||
} |