include /usr/share/dpkg/buildflags.mk
include /usr/share/rustc/architecture.mk
-# For cross-compiling; perhaps we should add this to dh-cargo or debcargo
-export PKG_CONFIG = $(DEB_HOST_GNU_TYPE)-pkg-config
-export PKG_CONFIG_ALLOW_CROSS = 1
-RUSTFLAGS += -C linker=$(DEB_HOST_GNU_TYPE)-gcc
+export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS
+export DEB_HOST_RUST_TYPE DEB_HOST_GNU_TYPE
-# Pass on dpkg-buildflags stuff
-RUSTFLAGS += $(foreach flag,$(LDFLAGS),-C link-arg=$(flag))
-export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS RUSTFLAGS
+CARGO = $(CURDIR)/debian/bin/cargo
-# Cargo looks for config in and writes cache to $CARGO_HOME/
-export CARGO_HOME = $(CURDIR)/debian/cargohome
-# Ask cargo to be verbose when building
-export VERBOSE = 1
+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:
- cp -a $(CURDIR)/Cargo.lock $(CURDIR)/.Cargo.lock.orig
-ifneq ($(filter pkg.cargo.mkstage0,$(DEB_BUILD_PROFILES)),)
- # NOTE: this very likely doesn't work any more, see bootstrap.py for details
- # Instead, you can try to bootstrap by setting PATH to a binary cargo
- # downloaded from upstream; or by cross-compiling, see "build-cross" below
- # Preserved in case someone wants to resurrect it later:
- # Bootstrap cargo stage0
- ./debian/bootstrap.py \
- --no-clean \
- --no-clone \
- --no-git \
- --no-download \
- --crate-index $(CURDIR)/vendor/index / \
- --cargo-root $(CURDIR)/ \
- --target-dir $(CURDIR)/deps \
- --host=$(DEB_HOST_RUST_TYPE) \
- --target=$(DEB_TARGET_RUST_TYPE)
- # Workaround for https://github.com/rust-lang/cargo/issues/1423
- ln -s `find $(CURDIR)/deps -name 'cargo-*' -type f -executable` $(CURDIR)/cargo-stage0
-else
- ln -s `which cargo` $(CURDIR)/cargo-stage0
-endif
- # Configure to build cargo using the just-built stage0
- ./configure \
- --prefix=/usr \
- --disable-debug \
- --enable-optimize \
- --local-rust-root=/usr \
- --release-channel=stable \
- --cargo=$(CURDIR)/cargo-stage0 \
- --build=$(DEB_BUILD_RUST_TYPE) \
- --host=$(DEB_HOST_RUST_TYPE) \
- --target=$(DEB_TARGET_RUST_TYPE)
+ $(CARGO) prepare-debian $(CURDIR)/vendor
override_dh_auto_build-arch:
- RUST_BACKTRACE=1 $(MAKE)
+ $(CARGO) build
override_dh_auto_build-indep:
-ifeq (,$(findstring nodoc,$(DEB_BUILD_PROFILES)))
- $(MAKE) doc
- cd target/doc/ && rm -f jquery.js && ln -s /usr/share/javascript/jquery/jquery.js
-endif
+ $(CARGO) doc
+
+override_dh_auto_test-arch:
+ CFG_DISABLE_CROSS_TESTS=1 $(CARGO) test $(CARGO_TEST_FLAGS)
-override_dh_auto_test:
- RUST_BACKTRACE=1 CFG_DISABLE_CROSS_TESTS=1 dh_auto_test
+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_clean:
- -mv $(CURDIR)/.Cargo.lock.orig $(CURDIR)/Cargo.lock
- dh_auto_clean
- -$(RM) -r $(CURDIR)/target/ \
- $(CURDIR)/.cargo \
- $(CURDIR)/config.mk \
- $(CURDIR)/config.stamp \
- $(CURDIR)/Makefile \
- $(CURDIR)/cargo-stage0
-
-CROSS_SBUILD = sbuild --profiles=nocheck \
- --build-failed-commands '%SBUILD_SHELL' \
- --host=$(DEB_HOST_ARCH) \
- --no-arch-all $(EXTRA_SBUILD_FLAGS)
-
-SBUILD_REPO_EXPERIMENTAL = --extra-repository="deb http://httpredir.debian.org/debian experimental main"
-
-# Sometimes this is necessary, if the mirrors have different versions for different architectures
-ifeq (1,$(SBUILD_USE_INCOMING))
-CROSS_SBUILD += --extra-repository="deb http://incoming.debian.org/debian-buildd buildd-unstable main"
-SBUILD_REPO_EXPERIMENTAL += --extra-repository="deb http://incoming.debian.org/debian-buildd buildd-experimental main"
-endif
-
-crossbuild:
- $(CROSS_SBUILD) .
+ $(CARGO) clean
-crossbuild-experimental:
- $(CROSS_SBUILD) $(SBUILD_REPO_EXPERIMENTAL) --build-dep-resolver=aspcud .
+override_dh_clean:
+ # Upstream contains a lot of these
+ dh_clean -XCargo.toml.orig
+ rm -f Cargo.lock