qt: playlist: use item title if available
[vlc.git] / contrib / src / main-rust.mak
blobaf877f39543a900e1d80aa84dded5ebdac236474
1 # Cargo/Rust specific makefile rules for VLC 3rd party libraries ("contrib")
2 # Copyright (C) 2003-2020 the VideoLAN team
4 # This file is under the same license as the vlc package.
6 ifdef HAVE_WIN32
7 ifndef HAVE_WINSTORE
8 ifeq ($(HOST),i686-w64-mingw32)
9 RUST_TARGET = i686-pc-windows-gnu # ARCH is i386
10 else ifeq ($(HOST),x86_64-w64-mingw32)
11 RUST_TARGET = $(ARCH)-pc-windows-gnu
12 else
13 # Not supported on armv7/aarch64 yet
14 endif
15 endif
16 else ifdef HAVE_ANDROID
17 RUST_TARGET = $(HOST)
18 else ifdef HAVE_IOS
19 ifneq ($(ARCH),arm) # iOS 32bit is Tier 3
20 ifneq ($(ARCH),i386) # iOS 32bit is Tier 3
21 ifndef HAVE_TVOS # tvOS is Tier 3
22 RUST_TARGET = $(ARCH)-apple-ios
23 endif
24 endif
25 endif
26 else ifdef HAVE_MACOSX
27 ifneq ($(ARCH),aarch64) # macOS ARM-64 is unsupported
28 RUST_TARGET = $(ARCH)-apple-darwin
29 endif
30 else ifdef HAVE_SOLARIS
31 RUST_TARGET = x86_64-sun-solaris
32 else ifdef HAVE_LINUX
33 ifeq ($(HOST),arm-linux-gnueabihf)
34 RUST_TARGET = arm-unknown-linux-gnueabihf #add eabihf
35 else
36 RUST_TARGET = $(ARCH)-unknown-linux-gnu
37 endif
38 else ifdef HAVE_BSD
39 RUST_TARGET = $(HOST)
40 endif
42 # For now, VLC don't support Tier 3 platforms (ios 32bit, tvOS).
43 # Supporting a Tier 3 platform means building an untested rust toolchain.
44 # TODO Let's hope tvOS move from Tier 3 to Tier 2 before the VLC 4.0 release.
45 ifneq ($(RUST_TARGET),)
46 BUILD_RUST="1"
47 endif
49 RUSTUP_HOME= $(BUILDBINDIR)/.rustup
50 CARGO_HOME = $(BUILDBINDIR)/.cargo
52 CARGO = . $(CARGO_HOME)/env && RUSTUP_HOME=$(RUSTUP_HOME) CARGO_HOME=$(CARGO_HOME) cargo
54 CARGO_INSTALL_ARGS = --target=$(RUST_TARGET) --prefix=$(PREFIX) \
55 --library-type staticlib --release
57 # Use the .cargo-vendor source if present, otherwise use crates.io
58 CARGO_INSTALL_ARGS += \
59 $(shell test -d $<-vendor && echo --frozen --offline || echo --locked)
61 CARGO_INSTALL = $(CARGO) install $(CARGO_INSTALL_ARGS)
63 CARGOC_INSTALL = export TARGET_CC=$(CC) && export TARGET_AR=$(AR) && \
64 export TARGET_CFLAGS="$(CFLAGS)" && \
65 export RUSTFLAGS="-C panic=abort -C opt-level=z" && \
66 $(CARGO) capi install $(CARGO_INSTALL_ARGS)
68 download_vendor = \
69 $(call download,$(CONTRIB_VIDEOLAN)/$(2)/$(1)) || (\
70 echo "" && \
71 echo "WARNING: cargo vendor archive for $(1) not found" && \
72 echo "" && \
73 touch $@);
75 # Extract and move the vendor archive if the checksum is valid. Succeed even in
76 # case of error (download or checksum failed). In that case, the cargo-vendor
77 # archive won't be used (crates.io will be used directly).
78 .%-vendor: $(SRC)/%-vendor/SHA512SUMS
79 $(RM) -R $(patsubst .%,%,$@)
80 -$(call checksum,$(SHA512SUM),SHA512,.) \
81 $(foreach f,$(filter %.tar.bz2,$^), && tar xvjfo $(f) && \
82 mv $(patsubst %.tar.bz2,%,$(notdir $(f))) $(patsubst .%,%,$@))
83 touch $@
85 CARGO_VENDOR_SETUP = \
86 if test -d $@-vendor; then \
87 mkdir -p $(UNPACK_DIR)/.cargo; \
88 echo "[source.crates-io]" > $(UNPACK_DIR)/.cargo/config.toml; \
89 echo "replace-with = \"vendored-sources\"" >> $(UNPACK_DIR)/.cargo/config.toml; \
90 echo "[source.vendored-sources]" >> $(UNPACK_DIR)/.cargo/config.toml; \
91 echo "directory = \"../$@-vendor\"" >> $(UNPACK_DIR)/.cargo/config.toml; \
92 echo "Using cargo vendor archive for $(UNPACK_DIR)"; \
93 fi;