Skip to content

Commit

Permalink
Rust: Add crates-to-module adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
chrysn committed Jan 12, 2022
1 parent 2491bba commit 572375c
Show file tree
Hide file tree
Showing 11 changed files with 822 additions and 6 deletions.
6 changes: 0 additions & 6 deletions makefiles/cargo-settings.inc.mk
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# Rust's own version of the target triple / quadruple.
#
# This does not have a sane default, and needs to be set in the architecture
# files.
# RUST_TARGET = ...

# Flags that need to be added to the RIOT_CFLAGS passed to cargo in order to
# make bindgen happy
CARGO_EXTRACFLAGS ?=
Expand Down
3 changes: 3 additions & 0 deletions makefiles/cargo-targets.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ $(APPLICATION_RUST_MODULE).module: $(CARGO_LIB) FORCE
$(Q)cd $(BINDIR)/$(APPLICATION_RUST_MODULE)/ && $(AR) x $<
$(Q)# ... and move them back if any exist, careful to err if anything is duplicate
$(Q)rmdir $(BINDIR)/$(APPLICATION_RUST_MODULE)/bin/ || (mv -n $(BINDIR)/$(APPLICATION_RUST_MODULE)/bin/* $(BINDIR)/$(APPLICATION_RUST_MODULE)/ && rmdir $(BINDIR)/$(APPLICATION_RUST_MODULE)/bin/)

FORCE:
.phony: FORCE
5 changes: 5 additions & 0 deletions makefiles/vars.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,8 @@ export AFL_FLAGS # Additional command-line flags passed to afl durin
# LOG_LEVEL # Logging level as integer (NONE: 0, ERROR: 1, WARNING: 2, INFO: 3, DEBUG: 4, default: 3)
# KCONFIG_ADD_CONFIG # List of .config files to be merged used by Boards and CPUs. See kconfig.mk
# VERBOSE_ASSERT # Set to 1 to print the file and line of a failed assert when assertions blow

export RUST_TARGET # Rust's own version of the target triple / quadruple.
#
# It is set by the architecture (and thus eventually the CPU), and exported to
# be available when building Rust modules.
7 changes: 7 additions & 0 deletions sys/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -851,4 +851,11 @@ ifneq (,$(filter fido2_ctap,$(USEMODULE)))
USEMODULE += fido2
endif

# Right now, all pseudomodules pulling in rust_lib_catchall start with `rust_`;
# if later modules are defined that are not thusly named, they'll need to be
# added here.
ifneq (,$(filter rust_%,$(USEMODULE)))
include $(RIOTBASE)/sys/rust_lib_catchall/Makefile.dep
endif

include $(RIOTBASE)/sys/test_utils/Makefile.dep
7 changes: 7 additions & 0 deletions sys/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,10 @@ ifneq (,$(filter usbus_dfu riotboot_reset,$(USEMODULE)))
CFLAGS += -DCPU_RAM_BASE=$(RAM_START_ADDR)
CFLAGS += -DCPU_RAM_SIZE=$(RAM_LEN)
endif

# Right now, all pseudomodules pulling in rust_lib_catchall start with `rust_`;
# if later modules are defined that are not thusly named, they'll need to be
# added here.
ifneq (,$(filter rust_%,$(USEMODULE)))
include $(RIOTBASE)/sys/rust_lib_catchall/Makefile.include
endif
Loading

0 comments on commit 572375c

Please sign in to comment.