Skip to content

Commit

Permalink
fix: configure target and setup important compilation flags for rust
Browse files Browse the repository at this point in the history
  • Loading branch information
neithanmo committed Mar 8, 2024
1 parent 6469fc1 commit 52d03e9
Showing 1 changed file with 37 additions and 6 deletions.
43 changes: 37 additions & 6 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ include $(CURDIR)/../deps/ledger-zxlib/makefiles/Makefile.app_testing
# #{TODO} --> Need for an special mode?
# DEFINES += REVIEW_SCREEN_ENABLED APP_BLIND_MODE_ENABLED

ifeq ($(APP_TESTING),1)
DEFINES += APP_TESTING
DEFINES += ZEMU_LOGGING
endif

ifndef COIN
COIN=TODO
endif
Expand Down Expand Up @@ -71,19 +76,45 @@ $(error ICONNAME is not set)
endif

include $(CURDIR)/../deps/ledger-zxlib/makefiles/Makefile.platform
include $(CURDIR)/../deps/ledger-zxlib/makefiles/Makefile.devices

$(info TARGET_NAME = [$(TARGET_NAME)])
$(info ICONNAME = [$(ICONNAME)])

ifndef ICONNAME
$(error ICONNAME is not set)
endif

ifeq ($(TARGET_NAME),TARGET_NANOS)
RUST_TARGET:=thumbv6m-none-eabi
endif

ifeq ($(TARGET_NAME),TARGET_NANOX)
RUST_TARGET:=thumbv6m-none-eabi
endif

ifeq ($(TARGET_NAME),TARGET_NANOS2)
#RUST_TARGET:=thumbv8m.main-none-eabi
RUST_TARGET:=thumbv6m-none-eabi
endif

ifeq ($(TARGET_NAME),TARGET_STAX)
RUST_TARGET:=thumbv6m-none-eabi
endif

$(info ************ RUST_TARGET = [$(RUST_TARGET)])

CFLAGS += -Wvla
# #{TODO} --> Need Rust?
# LDFLAGS += -z muldefs
# LDLIBS += -Lrust/target/thumbv6m-none-eabi/release -lrslib
# APP_SOURCE_PATH += $(CURDIR)/rust/include
LDFLAGS += -z muldefs
LDLIBS += -lm -lgcc -lc
LDLIBS += -L$(MY_DIR)rust/target/$(RUST_TARGET)/release -lrslib

APP_CUSTOM_LINK_DEPENDENCIES = rust
LDLIBS += -Lrust/target/thumbv6m-none-eabi/release -lrslib
APP_SOURCE_PATH += $(CURDIR)/rust/include

.PHONY: rust
rust:
cd rust && CARGO_HOME="$(CURDIR)/rust/.cargo" cargo build --target thumbv6m-none-eabi --release
cd rust && RUSTC_BOOTSTRAP=1 CARGO_HOME="$(CURDIR)/rust/.cargo" cargo build --target $(RUST_TARGET) --release

# Before linking, we need to be sure rust lib is there
bin/app.elf: rust
Expand Down

0 comments on commit 52d03e9

Please sign in to comment.