core-rs.mk 934 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #######################################
  2. # Rust library
  3. #######################################
  4. #######################################
  5. # Rust library
  6. #######################################
  7. RUST_LIB_SRC = $(realpath $(PROJECT_DIR)/../core-rs)
  8. RUST_LIB_NAME = flipper_core
  9. ifeq ($(ARCH), 'x86_64')
  10. RUST_LIB_TARGET = x86_64-unknown-linux-gnu
  11. else
  12. RUST_LIB_TARGET = thumbv7em-none-eabihf
  13. endif
  14. RUST_LIB_FLAGS = --target=$(RUST_LIB_TARGET)
  15. ifeq ($(DEBUG), 1)
  16. RUST_LIB_PATH = $(RUST_LIB_SRC)/target/$(RUST_LIB_TARGET)/debug
  17. else
  18. RUST_LIB_FLAGS += --release
  19. RUST_LIB_PATH = $(RUST_LIB_SRC)/target/$(RUST_LIB_TARGET)/release
  20. endif
  21. RUST_LIB_CMD = cd $(RUST_LIB_SRC) && cargo build -p flipper-core $(RUST_LIB_FLAGS)
  22. LD_FLAGS += -l$(RUST_LIB_NAME)
  23. LD_FLAGS += -L$(RUST_LIB_PATH)
  24. $(RUST_LIB_PATH)/lib$(RUST_LIB_NAME).a: rust_lib
  25. rust_lib:
  26. $(RUST_LIB_CMD)
  27. clean:
  28. -rm -fR $(BUILD_DIR)
  29. cd $(RUST_LIB_SRC) && cargo clean