Package: meson
Version: 0.64.0-1
Tags: patch
User: debian-cr...@lists.debian.org
Usertags: ftcbfs
Control: affects -1 + src:zim-tools

zim-tools fails to cross build from source, because it cannot resolve
its dependency on docopt. It's a plain dependency without setting a
method. In this case, meson is supposed to try pkg-config and cmake. It
does try pkg-config. docopt doesn't ship a .pc file, but it does ship
.cmake files. meson refuses to consider the native installed cmake,
which feels roughly correct as it wouldn't otherwise know the right
paths without a suitable toolchain file.

IRC user nirbheek pointed out that we can set these things in a meson
crossfile and how. The task for generating this file (at this time)
still falls to debcrossgen even though I know you want to move it to
env2mfile. For that reason I'm sending a patch to debcrossgen and hope
that you can port it to env2mfile as needed.

The attached patch makes zim-tools cross buildable.

Helmut
diff --minimal -Nru meson-0.64.0/debian/changelog meson-0.64.0/debian/changelog
--- meson-0.64.0/debian/changelog       2022-11-06 15:17:12.000000000 +0100
+++ meson-0.64.0/debian/changelog       2022-11-09 09:47:50.000000000 +0100
@@ -1,3 +1,10 @@
+meson (0.64.0-1.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * debcrossgen: add cmake. (Closes: #-1)
+
+ -- Helmut Grohne <hel...@subdivi.de>  Wed, 09 Nov 2022 09:47:50 +0100
+
 meson (0.64.0-1) unstable; urgency=medium
 
   * New upstream release.
diff --minimal -Nru meson-0.64.0/debian/debcrossgen 
meson-0.64.0/debian/debcrossgen
--- meson-0.64.0/debian/debcrossgen     2022-09-15 00:16:06.000000000 +0200
+++ meson-0.64.0/debian/debcrossgen     2022-11-09 09:47:49.000000000 +0100
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#! /usr/bin/python3
 
 # Copyright 2017 Jussi Pakkanen
 
@@ -96,6 +96,10 @@
     host_cpu = cpu_map.get(data['DEB_HOST_ARCH'],
                            data['DEB_HOST_ARCH'])
     host_endian = data['DEB_HOST_ARCH_ENDIAN']
+    try:
+        cmake = locate_path("cmake")
+    except ValueError:
+        cmake = None
     with open(options.outfile, "w") as ofile:
         ofile.write('[binaries]\n')
         c = "%s-gcc%s" % (host_arch, options.gccsuffix)
@@ -114,6 +118,8 @@
             ofile.write("cups-config = '%s'\n" % locate_path("cups-config"))
         except ValueError:
             pass # cups-config is optional
+        if cmake:
+            ofile.write("cmake = '%s'\n" % cmake)
         ofile.write('\n[properties]\n')
         write_args_from_envvars(ofile)
         ofile.write('\n[host_machine]\n')
@@ -121,6 +127,14 @@
         ofile.write("cpu_family = '%s'\n" % host_cpu_family)
         ofile.write("cpu = '%s'\n" % host_cpu)
         ofile.write("endian = '%s'\n" % host_endian)
+        if cmake:
+            ofile.write("\n[cmake]\n")
+            ofile.write("CMAKE_C_COMPILER = '%s'\n" % locate_path(c))
+            ofile.write("CMAKE_CXX_COMPILER = '%s'\n" % locate_path(cpp))
+            system_name_map = dict(linux="Linux", kfreebsd="kFreeBSD", 
hurd="GNU")
+            ofile.write("CMAKE_SYSTEM_NAME = '%s'\n" % 
system_name_map[data['DEB_HOST_ARCH_OS']])
+            system_processor_map = dict(arm='armv7l', mips64el='mips64', 
powerpc64le='ppc64le')
+            ofile.write("CMAKE_SYSTEM_PROCESSOR = '%s'\n" % 
system_processor_map.get(data['DEB_HOST_GNU_CPU'], data['DEB_HOST_GNU_CPU']))
 
 if __name__ == '__main__':
     print('WARNING: this tool is deprecated, use "meson env2mfile" instead.')

Reply via email to