summaryrefslogtreecommitdiffstats
path: root/scripts/Makefile.build
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/Makefile.build')
-rw-r--r--scripts/Makefile.build18
1 files changed, 18 insertions, 0 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index a467b9323442..9b50f2e02026 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -23,10 +23,14 @@ subdir-y :=
subdir-m :=
EXTRA_AFLAGS :=
EXTRA_CFLAGS :=
+EXTRA_RUSTCFLAGS :=
+EXTRA_CARGOFLAGS :=
EXTRA_CPPFLAGS :=
EXTRA_LDFLAGS :=
asflags-y :=
ccflags-y :=
+rustcflags-y :=
+cargoflags-y :=
cppflags-y :=
ldflags-y :=
@@ -299,6 +303,20 @@ quiet_cmd_cc_lst_c = MKLST $@
$(obj)/%.lst: $(src)/%.c FORCE
$(call if_changed_dep,cc_lst_c)
+# Compile Rust sources (.rs) via cargo
+# ---------------------------------------------------------------------------
+
+quiet_cmd_cargo = CARGO $(quiet_modtag) $@
+ cmd_cargo = cd $(src) && $(CARGO) build $(cargo_flags)
+
+# The .o from the Rust staticlib
+$(obj)/%.o: $(src)/out/lib%.a
+ $(Q)$(LD) -r -o $@ --whole-archive $<
+
+# The Rust staticlib from cargo
+$(obj)/out/lib%.a: FORCE
+ $(call cmd,cargo)
+
# Compile assembler sources (.S)
# ---------------------------------------------------------------------------