Bug#946496: libsdl2: Please make autopkgtests cross-test-friendly

Steve Langasek steve.langasek at canonical.com
Tue Dec 10 00:51:27 GMT 2019


Package: libsdl2
Version: 2.0.10+dfsg1-1
Severity: minor
Tags: patch
User: ubuntu-devel at lists.ubuntu.com
Usertags: origin-ubuntu focal ubuntu-patch

Dear maintainers,

In Ubuntu, we are in the process of moving the i386 architecture to a
compatibility-only layer on amd64, and therefore we are also moving our
autopkgtest infrastructure to test i386 binaries in a cross-environment.

This requires changes to some tests so that they are cross-aware and can do
the right thing.

The libsdl2 tests currently fail in this environment, because they are build
tests that do not invoke the toolchain in a cross-aware manner.  I've
verified that the attached patch lets the tests successfully build (and run)
i386 tests on an amd64 host.

Note that upstream autopkgtest doesn't currently set DEB_HOST_ARCH so this
is a complete no-op in Debian for the moment.  Support for cross-testing in
autopkgtest is currently awaiting review at
https://salsa.debian.org/ci-team/autopkgtest/merge_requests/69 and once
landed, will still have no effect unless autopkgtest is invoked with a '-a'
option.  So this change should be safe to land in your package despite this
not being upstream in autopkgtest.

Thanks for considering,
-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                   https://www.debian.org/
slangasek at ubuntu.com                                     vorlon at debian.org
-------------- next part --------------
diff -Nru libsdl2-2.0.10+dfsg1/debian/tests/build libsdl2-2.0.10+dfsg1/debian/tests/build
--- libsdl2-2.0.10+dfsg1/debian/tests/build	2019-09-19 22:01:14.000000000 -0700
+++ libsdl2-2.0.10+dfsg1/debian/tests/build	2019-12-09 15:33:44.000000000 -0800
@@ -16,6 +16,13 @@
 
 WORKDIR=$(mktemp -d)
 trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
+
+if [ -n "${DEB_HOST_GNU_TYPE:-}" ]; then
+    CROSS_COMPILE="$DEB_HOST_GNU_TYPE-"
+else
+    CROSS_COMPILE=
+fi
+
 cd $WORKDIR
 cat <<EOF > use-sdl.c
 #undef NDEBUG
@@ -53,10 +60,10 @@
 
     case "$tool" in
     (pkg-config)
-        gcc $cflags -o use-${tool}-${mode} use-sdl.c `pkg-config $pcflags --cflags --libs sdl2`
+        ${CROSS_COMPILE}gcc $cflags -o use-${tool}-${mode} use-sdl.c `${CROSS_COMPILE}pkg-config $pcflags --cflags --libs sdl2`
         ;;
     (sdl2-config)
-        gcc $cflags -o use-${tool}-${mode} use-sdl.c `sdl2-config --cflags $scflags`
+        ${CROSS_COMPILE}gcc $cflags -o use-${tool}-${mode} use-sdl.c `sdl2-config --cflags $scflags`
         ;;
     (*)
         exit 1
diff -Nru libsdl2-2.0.10+dfsg1/debian/tests/build-all libsdl2-2.0.10+dfsg1/debian/tests/build-all
--- libsdl2-2.0.10+dfsg1/debian/tests/build-all	2019-09-19 22:01:14.000000000 -0700
+++ libsdl2-2.0.10+dfsg1/debian/tests/build-all	2019-12-09 16:21:37.000000000 -0800
@@ -9,7 +9,19 @@
 
 WORKDIR=$(mktemp -d)
 trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
+
+if [ -n "${DEB_HOST_GNU_TYPE:-}" ]; then
+    cat <<EOF > "$WORKDIR/toolchain.cmake"
+set(CMAKE_C_COMPILER $DEB_HOST_GNU_TYPE-gcc)
+set(CMAKE_CXX_COMPILER $DEB_HOST_GNU_TYPE-g++)
+set(PKG_CONFIG_EXECUTABLE $DEB_HOST_GNU_TYPE-pkg-config)
+EOF
+    CCFILE=-DCMAKE_TOOLCHAIN_FILE="$WORKDIR/toolchain.cmake"
+else
+    CCFILE=
+fi
+
 cp -R * $WORKDIR
 cd $WORKDIR
 mkdir build && cd build
-cmake .. -DSDL_TEST=ON && make && make test
+cmake .. "$CCFILE" -DSDL_TEST=ON && make && make test


More information about the Pkg-sdl-maintainers mailing list