xref: /openbmc/openbmc/poky/meta/recipes-core/glib-2.0/glib.inc (revision c9537f57ab488bf5d90132917b0184e2527970a5)
1SUMMARY = "A general-purpose utility library"
2DESCRIPTION = "GLib is a general-purpose utility library, which provides many useful data types, macros, type conversions, string utilities, file utilities, a main loop abstraction, and so on."
3HOMEPAGE = "https://developer.gnome.org/glib/"
4
5# pcre is under BSD;
6# docs/reference/COPYING is with a 'public domain'-like license!
7LICENSE = "LGPL-2.1-or-later & BSD-3-Clause & PD"
8LIC_FILES_CHKSUM = "file://COPYING;md5=41890f71f740302b785c27661123bff5 \
9                    file://glib/glib.h;beginline=4;endline=17;md5=72f7cc2847407f65d8981ef112e4e630 \
10                    file://LICENSES/LGPL-2.1-or-later.txt;md5=41890f71f740302b785c27661123bff5 \
11                    file://gmodule/gmodule.h;beginline=4;endline=17;md5=72f7cc2847407f65d8981ef112e4e630 \
12                    file://docs/reference/COPYING;md5=f51a5100c17af6bae00735cd791e1fcc"
13BUGTRACKER = "http://bugzilla.gnome.org"
14SECTION = "libs"
15
16CVE_PRODUCT = "glib"
17
18BBCLASSEXTEND = "native nativesdk"
19
20DEPENDS = "glib-2.0-native \
21           virtual/libintl \
22           virtual/libiconv \
23           libffi \
24           libpcre2 \
25           zlib"
26
27PACKAGES += "${PN}-codegen ${PN}-utils"
28
29LEAD_SONAME = "libglib-2.0.*"
30
31inherit meson gettext gi-docgen pkgconfig ptest-gnome upstream-version-is-even bash-completion gio-module-cache manpages gobject-introspection-data
32
33S = "${WORKDIR}/glib-${PV}"
34
35GIDOCGEN_MESON_OPTION = "documentation"
36
37PACKAGECONFIG ??= "libmount \
38                   ${@bb.utils.contains('GI_DATA_ENABLED', 'True', 'introspection', '', d)} \
39                   ${@bb.utils.contains('PTEST_ENABLED', '1', 'tests', '', d)}"
40PACKAGECONFIG:class-native = ""
41
42PACKAGECONFIG[libmount] = "-Dlibmount=enabled,-Dlibmount=disabled,util-linux"
43PACKAGECONFIG[manpages] = "-Dman-pages=enabled, -Dman-pages=disabled, python3-docutils-native"
44PACKAGECONFIG[libelf] = "-Dlibelf=enabled,-Dlibelf=disabled,elfutils"
45PACKAGECONFIG[tests] = "-Dtests=true -Dinstalled_tests=true,-Dtests=false -Dinstalled_tests=false,"
46PACKAGECONFIG[selinux] = "-Dselinux=enabled,-Dselinux=disabled,libselinux"
47PACKAGECONFIG[introspection] = "-Dintrospection=enabled,-Dintrospection=disabled,gobject-introspection-native gobject-introspection glib-2.0-initial"
48
49EXTRA_OEMESON = "-Ddtrace=disabled -Dsystemtap=disabled -Dsysprof=disabled"
50
51EXTRA_OEMESON:append:class-target = " ${@'-Dgir_dir_prefix=${libdir}' if d.getVar('MULTILIBS') else ''}"
52
53do_configure:prepend() {
54	sed -i -e '1s,#!.*,#!${USRBINPATH}/env python3,' ${S}/gio/gdbus-2.0/codegen/gdbus-codegen.in
55}
56
57FILES:${PN} = "${libdir}/lib*${SOLIBS} \
58               ${libdir}/gio \
59               ${libexecdir}/*gio-querymodules \
60               ${libexecdir}/*gio-launch-desktop \
61               ${datadir}/glib-2.0/dtds \
62               ${datadir}/glib-2.0/schemas \
63               ${libdir}/girepository-*/*.typelib \
64"
65FILES:${PN}-dev += "${libdir}/glib-2.0/include \
66                    ${libdir}/gio/modules/lib*${SOLIBSDEV} \
67                    ${libdir}/gio/modules/*.la \
68                    ${datadir}/glib-2.0/gettext/po/Makefile.in.in \
69                    ${datadir}/glib-2.0/schemas/gschema.dtd \
70                    ${datadir}/glib-2.0/valgrind/glib.supp \
71                    ${datadir}/gir-*/*.gir ${libdir}/gir-*/*.gir \
72                    ${datadir}/gettext/its"
73FILES:${PN}-dbg += "${datadir}/glib-2.0/gdb ${datadir}/gdb"
74FILES:${PN}-codegen = "${datadir}/glib-2.0/codegen/*.py \
75                       ${bindir}/gdbus-codegen"
76FILES:${PN}-utils = "${bindir}/*"
77
78SHAREDMIMEDEP = "shared-mime-info"
79SHAREDMIMEDEP:class-native = ""
80# When cross compiling for Windows we don't want to include this
81SHAREDMIMEDEP:mingw32 = ""
82
83RRECOMMENDS:${PN} += "${SHAREDMIMEDEP}"
84
85ARM_INSTRUCTION_SET:armv4 = "arm"
86ARM_INSTRUCTION_SET:armv5 = "arm"
87# Valgrind runtime detection works using hand-written assembly, which
88# doesn't support mips16e
89CPPFLAGS:append:class-target:mips16e = " -DNVALGRIND=1"
90
91# GLib generally requires gettext to be present so for USE_NLS to yes.  For
92# native builds as i18n is disabled globally we have to add a gettext-native dependency.
93USE_NLS:class-target = "yes"
94USE_NLS:class-nativesdk = "yes"
95DEPENDS:append:class-native = " gettext-native"
96
97EXEEXT = ""
98EXEEXT:mingw32 = ".exe"
99
100do_install:append () {
101	if [ -f ${D}${bindir}/gtester-report ]; then
102		sed ${D}${bindir}/gtester-report -i -e '1s|^#!.*|#!/usr/bin/env python3|'
103	fi
104
105	# Remove some unpackaged files
106	rm -rf ${D}${datadir}/glib-2.0/codegen/__pycache__
107	rm -f ${D}${datadir}/glib-2.0/codegen/*.pyc
108	rm -f ${D}${datadir}/glib-2.0/codegen/*.pyo
109
110	if [ -e ${D}${libdir}/charset.alias ]; then
111		rm -f ${D}${libdir}/charset.alias
112	fi
113
114        # Make sure gio-querymodules is unique among multilibs
115        if test "x${MLPREFIX}" != "x"; then
116                mv ${D}${libexecdir}/gio-querymodules${EXEEXT} ${D}${libexecdir}/${MLPREFIX}gio-querymodules${EXEEXT}
117        fi
118        # Autotools does this, meson does not
119        mkdir -p ${D}${libdir}/gio/modules
120}
121
122do_install:append:class-native () {
123	# Link gio-querymodules into ${bindir} as otherwise tools like meson won't find it
124        ln -rs ${D}${libexecdir}/gio-querymodules ${D}${bindir}
125}
126
127do_install:append:class-target () {
128	# Tests are only installed on targets, not native builds.  Separating this out
129	# keeps glib-2.0-native from depending on DISTRO_FEATURES
130	if [ -f ${D}${datadir}/installed-tests/glib/gdbus-serialization.test ]; then
131		if ${@bb.utils.contains("DISTRO_FEATURES", "x11", "false", "true", d)}; then
132			rm ${D}${datadir}/installed-tests/glib/gdbus-serialization.test
133		fi
134	fi
135	if [ -f ${D}${datadir}/installed-tests/glib/static-link.test ]; then
136        if test "x${MLPREFIX}" != "x"; then
137                mv ${D}${datadir}/installed-tests/glib/static-link.test ${D}${datadir}/installed-tests/glib/${MLPREFIX}static-link.test
138        fi
139	fi
140        # https://gitlab.gnome.org/GNOME/glib/-/issues/2810
141        rm -f ${D}${datadir}/installed-tests/glib/thread-pool-slow.test
142}
143do_install:append:class-target:libc-musl () {
144        # Remove failing tests on musl libc systems, this helps set baseline for musl testing
145        # they remain to be rootcaused and fixed but marked known failures here.
146        for t in convert.test collate.test gdatetime.test date.test converter-stream.test option-context.test; do
147                rm -rf ${D}${datadir}/installed-tests/glib/$t
148        done
149}
150# As we do not build python3 for windows, makes no sense to ship the script that's using it
151do_install:append:mingw32() {
152        rm -f ${D}${bindir}/gtester-report
153}
154
155CODEGEN_PYTHON_RDEPENDS = "python3 python3-packaging python3-xml"
156CODEGEN_PYTHON_RDEPENDS:mingw32 = ""
157
158RDEPENDS:${PN}-codegen += "${CODEGEN_PYTHON_RDEPENDS}"
159
160RDEPENDS:${PN}-ptest += "\
161            coreutils \
162            libgcc \
163            ${VIRTUAL-RUNTIME_dbus} \
164            desktop-file-utils \
165            gnome-desktop-testing \
166            tzdata \
167            tzdata-americas \
168            tzdata-asia \
169            tzdata-europe \
170            tzdata-posix \
171            shared-mime-info \
172            ${PN}-dev \
173            ${PN}-locale-ja \
174            ${PN}-locale-fr \
175            ${PN}-locale-el \
176            ${PN}-locale-hr \
177            ${PN}-locale-lt \
178            ${PN}-locale-pl \
179            ${PN}-locale-ru \
180            ${PN}-locale-th \
181            ${PN}-utils \
182            python3-core \
183            python3-modules \
184            ${@bb.utils.contains('GI_DATA_ENABLED', 'True', 'python3-dbusmock', '', d)} \
185            ${PN}-codegen \
186            locale-base-de-de \
187            locale-base-es-es \
188            locale-base-en-gb \
189            locale-base-en-us \
190            locale-base-fr-fr \
191            locale-base-ru-ru \
192           "
193INSANE_SKIP:${PN}-ptest = "dev-deps"
194
195RDEPENDS:${PN}-ptest:append:libc-glibc = "\
196            glibc-gconv-utf-16 \
197            glibc-charmap-utf-8 \
198            glibc-gconv-cp1255 \
199            glibc-charmap-cp1255 \
200            glibc-gconv-utf-32 \
201            glibc-gconv-utf-7 \
202            glibc-gconv-euc-jp \
203            glibc-gconv-iso8859-1 \
204            glibc-gconv-iso8859-15 \
205            glibc-charmap-invariant \
206            glibc-localedata-translit-cjk-variants \
207            locale-base-c \
208            locale-base-lt-lt \
209            locale-base-ja-jp.euc-jp \
210            locale-base-fa-ir \
211            locale-base-hr-hr \
212            locale-base-el-gr \
213            locale-base-pl-pl \
214            locale-base-pl-pl.iso-8859-2 \
215            locale-base-tr-tr \
216           "
217
218PE = "1"
219
220SHRT_VER = "${@oe.utils.trim_version("${PV}", 2)}"
221
222SRC_URI = "${GNOME_MIRROR}/glib/${SHRT_VER}/glib-${PV}.tar.xz \
223           file://run-ptest \
224           file://0001-Fix-DATADIRNAME-on-uclibc-Linux.patch \
225           file://0001-Remove-the-warning-about-deprecated-paths-in-schemas.patch \
226           file://0001-Install-gio-querymodules-as-libexec_PROGRAM.patch \
227           file://0001-Do-not-write-bindir-into-pkg-config-files.patch \
228           file://0001-meson-Run-atomics-test-on-clang-as-well.patch \
229           file://0001-gio-tests-resources.c-comment-out-a-build-host-only-.patch \
230           file://0010-Do-not-hardcode-python-path-into-various-tools.patch \
231           file://skip-timeout.patch \
232           "
233SRC_URI:append:class-native = " file://relocate-modules.patch \
234                                file://0001-meson.build-do-not-enable-pidfd-features-on-native-g.patch \
235                              "
236
237SRC_URI[sha256sum] = "88e960dd937057407d61fcb3b45a860704b25923c37ae2478b85f2ecb5a4021f"
238
239# Find any meson cross files in FILESPATH that are relevant for the current
240# build (using siteinfo) and add them to EXTRA_OEMESON.
241inherit siteinfo
242def find_meson_cross_files(d):
243    if bb.data.inherits_class('native', d):
244        return ""
245
246    thisdir = os.path.normpath(d.getVar("THISDIR"))
247    import collections
248    sitedata = siteinfo_data(d)
249    # filename -> found
250    files = collections.OrderedDict()
251    for path in d.getVar("FILESPATH").split(":"):
252        for element in sitedata:
253            filename = os.path.normpath(os.path.join(path, "meson.cross.d", element))
254            sanitized_path = filename.replace(thisdir, "${THISDIR}")
255            if sanitized_path == filename:
256                if os.path.exists(filename):
257                    bb.error("Cannot add '%s' to --cross-file, because it's not relative to THISDIR '%s' and sstate signature would contain this full path" % (filename, thisdir))
258                continue
259            files[filename.replace(thisdir, "${THISDIR}")] = os.path.exists(filename)
260
261    items = ["--cross-file=" + k for k,v in files.items() if v]
262    d.appendVar("EXTRA_OEMESON", " " + " ".join(items))
263    items = ["%s:%s" % (k, "True" if v else "False") for k,v in files.items()]
264    d.appendVarFlag("do_configure", "file-checksums", " " + " ".join(items))
265
266python () {
267    find_meson_cross_files(d)
268}
269