include /usr/share/dpkg/pkg-info.mk
include /usr/share/dpkg/architecture.mk
include /usr/share/dpkg/buildflags.mk
-RUSTFLAGS = -C link-args="$(LDFLAGS)"
-export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS RUSTFLAGS
+include /usr/share/rustc/architecture.mk
-rust_cpu = $(subst i586,i686,$(1))
-DEB_HOST_RUST_TYPE := $(call rust_cpu,$(DEB_HOST_GNU_CPU))-unknown-$(DEB_HOST_GNU_SYSTEM)
-DEB_TARGET_RUST_TYPE := $(call rust_cpu,$(DEB_TARGET_GNU_CPU))-unknown-$(DEB_TARGET_GNU_SYSTEM)
+export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS
+export DEB_HOST_RUST_TYPE DEB_HOST_GNU_TYPE
-# Cargo looks for config in and writes cache to $CARGO_HOME/
-export CARGO_HOME = $(CURDIR)/.cargohome
-# Ask cargo to be verbose when building
-export VERBOSE = 1
+CARGO = $(CURDIR)/debian/bin/cargo
-DEB_DESTDIR := $(CURDIR)/debian/tmp
-VENDORDIR := $(CURDIR)/vendor
-INDEXDIR := $(CURDIR)/vendor/index
-DEPSDIR := $(CURDIR)/deps
+export CARGO_HOME = $(CURDIR)/debian/cargo_home
+export DEB_CARGO_CRATE=cargo_$(DEB_VERSION_UPSTREAM)
+RUSTFLAGS := --remap-path-prefix=$(CURDIR)=/usr/src/cargo-$(DEB_VERSION_UPSTREAM)
+
+# https://github.com/rust-lang/rust/issues/52108
+ifneq (,$(filter $(DEB_HOST_ARCH), mips64el))
+ RUSTFLAGS += -Ctarget-feature=+xgot
+endif
+
+export RUSTFLAGS
+
+# don't shrink, this can take ages
+# see https://github.com/rust-lang/cargo/issues/6490 for details
+export PROPTEST_MAX_SHRINK_ITERS = 0
+export CARGO_TEST_SLOW_CPU_MULTIPLIER = 4
+
+# To run a specific test, run something like:
+# $ debian/rules override_dh_auto_test-arch \
+# CARGO_TEST_FLAGS="package::include -- <args ...>"
+# See `cargo test --help` for more options.
+CARGO_TEST_FLAGS =
%:
dh $@ --with bash-completion
override_dh_auto_configure:
- # Prepare a fake registry by packing all deps
- ./debian/cargo-vendor-pack.py
-
-override_dh_auto_build:
- # Bootstrap cargo stage0
- ./debian/bootstrap.py \
- --no-clean \
- --no-clone \
- --no-git \
- --crate-index $(INDEXDIR)/ \
- --cargo-root $(CURDIR)/ \
- --target-dir $(DEPSDIR)/ \
- --host=$(DEB_HOST_RUST_TYPE) \
- --target=$(DEB_TARGET_RUST_TYPE)
- # Workaround for https://github.com/rust-lang/cargo/issues/1423
- mv $(DEPSDIR) $(CURDIR)/.deps
- ln -s `find $(CURDIR)/.deps -name 'cargo-*' -type f -executable` $(CURDIR)/cargo-stage0
- # Configure to build cargo using the just-built stage0
- ./configure \
- --prefix=/usr \
- --disable-debug \
- --enable-optimize \
- --local-rust-root=/usr \
- --local-cargo=$(CURDIR)/cargo-stage0
- # Build final cargo binary and docs
- $(MAKE)
- $(MAKE) doc
- cd target/doc/ && rm -f jquery.js && ln -s /usr/share/javascript/jquery/jquery.js
-
- # Restore from workarounds
- mv $(CURDIR)/.deps $(DEPSDIR)
+ $(CARGO) prepare-debian $(CURDIR)/vendor
-override_dh_auto_clean:
- -mv $(CURDIR)/.deps $(DEPSDIR)
- -$(RM) -r $(CURDIR)/deps/*.rlib \
- $(CURDIR)/deps/build_script* \
- $(CURDIR)/deps/cargo* \
- $(CURDIR)/deps/*.o \
- $(CURDIR)/target/ \
- $(CURDIR)/cargo-stage0 \
- $(CARGO_HOME) \
- $(VENDORDIR)
- dh_auto_clean
+override_dh_auto_build-arch:
+ $(CARGO) build
+
+override_dh_auto_build-indep:
+ $(CARGO) doc
+
+override_dh_auto_test-arch:
+ CFG_DISABLE_CROSS_TESTS=1 $(CARGO) test $(CARGO_TEST_FLAGS)
+
+override_dh_auto_test-indep:
+ # no arch-indep tests
override_dh_auto_install:
- # We pick stuff directly from target/
+ DESTDIR=$(CURDIR)/debian/cargo $(CARGO) install
-override_dh_auto_test:
- # we don't run tests at the moment due to too many deps
+override_dh_auto_clean:
+ $(CARGO) clean
+override_dh_clean:
+ # Upstream contains a lot of these
+ dh_clean -XCargo.toml.orig
+ rm -f Cargo.lock