aboutsummaryrefslogtreecommitdiff
path: root/tools/depends/native/rustup/Makefile
blob: c9f1c07570d1ef1a110ad8e5ff47f990ac4e6f04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
include ../../Makefile.include RUSTUP-VERSION ../../download-files.include
DEPS = ../../Makefile.include Makefile RUSTUP-VERSION ../../download-files.include

PREFIX=$(NATIVEPREFIX)
PLATFORM=$(NATIVEPLATFORM)

ifeq ($(CROSS_COMPILING),yes)
  ifeq ($(TARGET_PLATFORM),webos)
    RUST_TARGET = armv7-unknown-linux-gnueabi
  else
    RUST_TARGET = $(HOST)
  endif
endif

APP=$(PLATFORM)/bin/$(APPNAME)

export RUSTUP_HOME=$(PREFIX)/.rustup
export CARGO_HOME=$(PREFIX)/.cargo

RUST_TOOLCHAIN_VERSION=1.75.0
RUSTUP_ENV_VARS = RUSTUP_HOME=$(PREFIX)/.rustup \
	CARGO_HOME=$(PREFIX)/.cargo
RUSTUP = $(RUSTUP_ENV_VARS) $(PREFIX)/bin/rustup

CLEANUP_CMD=[ -e $(PREFIX)/bin/rustup ] \
	&& $(RUSTUP) self uninstall -y \
	&& rm -f $(PREFIX)/bin/rustup \
	&& rm -f $(PREFIX)/bin/cargo || true

all: .installed-$(PLATFORM)

$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE)
	rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM)
	cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE)

$(APP): $(PLATFORM)
	./$(PLATFORM)/rustup-init.sh -y --no-modify-path \
		--profile minimal \
		--default-toolchain=$(RUST_TOOLCHAIN_VERSION)

.installed-$(PLATFORM): $(APP)
	ln -sf $(CARGO_HOME)/bin/rustup $(PREFIX)/bin/rustup
	ln -sf $(CARGO_HOME)/bin/cargo $(PREFIX)/bin/cargo

	$(RUSTUP) default $(RUST_TOOLCHAIN_VERSION)

ifdef RUST_TARGET
	$(RUSTUP) target add $(RUST_TARGET)
endif

	touch $@

clean:
	$(CLEANUP_CMD)
	rm -f .installed-$(PLATFORM)

distclean::
	$(CLEANUP_CMD)
	rm -rf $(PLATFORM) .installed-$(PLATFORM)