Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build introspection #174

Merged
merged 33 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3870037
Build introspection
xhochy Apr 9, 2024
a4b1373
Add cross-native build for gobject-introspection
xhochy Apr 10, 2024
274591b
Fix test execution
xhochy Apr 10, 2024
466425f
Set OBJC correctly
xhochy Apr 10, 2024
2ef82e9
Install introspection from native build
xhochy Apr 10, 2024
bc0e10f
Add gobject environment for Windows
xhochy Apr 10, 2024
9ac8a16
Call conda
xhochy Apr 10, 2024
9f300b9
Add GIR_PREFIX to pkg-config
xhochy Apr 10, 2024
ae6738b
Add glib to introspection env
xhochy Apr 10, 2024
2cc1191
Remove broken private statement from comment
xhochy Apr 11, 2024
0da519d
Use newer VS
xhochy Apr 11, 2024
6e20136
MNT: Re-rendered with conda-build 24.3.0, conda-smithy 3.34.1, and co…
xhochy Apr 11, 2024
b1bf470
Limit to win
xhochy Apr 11, 2024
76fd146
MNT: Re-rendered with conda-build 24.3.0, conda-smithy 3.34.1, and co…
xhochy Apr 11, 2024
dd855bc
Verbose g-ir-scanner
xhochy Apr 11, 2024
9f2cc96
Verbose g-ir-scanner
xhochy Apr 15, 2024
7289605
Only build on win
xhochy Apr 15, 2024
a81851f
MNT: Re-rendered with conda-build 24.3.0, conda-smithy 3.34.1, and co…
xhochy Apr 15, 2024
b338c25
Different type of verbosity
xhochy Apr 15, 2024
195256a
Expand g-ir-scanner path
xhochy Apr 15, 2024
9484505
Remove 'call'
xhochy Apr 15, 2024
3aba447
Revert "Remove 'call'"
xhochy Apr 15, 2024
2c30cb5
Expand path globally
xhochy Apr 15, 2024
49a2c0c
Fix setting the PATH
xhochy Apr 15, 2024
ef1c109
Revert some debug changes
xhochy Apr 15, 2024
e5118b9
Ensure executables are placed in the right package
xhochy Apr 15, 2024
e680435
Now libffi is required on win again
xhochy Apr 15, 2024
3778ca4
Build on all platforms again
xhochy Apr 15, 2024
9e11f31
MNT: Re-rendered with conda-build 24.3.0, conda-smithy 3.34.1, and co…
xhochy Apr 15, 2024
f3bdadd
Remove patch that is probably not needed
xhochy Apr 15, 2024
400ace2
Remove vs pinning
xhochy Apr 15, 2024
f557d11
MNT: Re-rendered with conda-build 24.3.0, conda-smithy 3.34.1, and co…
xhochy Apr 15, 2024
29ad792
Remove unused code
xhochy Apr 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions recipe/bld.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,20 @@ mkdir %BUILD_PREFIX%\Library\etc
echo none / cygdrive binary,user 0 0 >%BUILD_PREFIX%\Library\etc\fstab
echo none /tmp usertemp binary,posix=0 0 0 >>%BUILD_PREFIX%\Library\etc\fstab

set "GIR_PREFIX=%cd%\g-ir-prefix"

call conda create -p %GIR_PREFIX% -y g-ir-build-tools gobject-introspection glib
if errorlevel 1 exit 1

set "PATH=%PATH%;%GIR_PREFIX%\Library;%GIR_PREFIX%\Library\bin"

mkdir forgebuild
cd forgebuild

@REM Find libffi with pkg-config
FOR /F "delims=" %%i IN ('cygpath.exe -m "%LIBRARY_PREFIX%"') DO set "LIBRARY_PREFIX_M=%%i"
set PKG_CONFIG_PATH=%LIBRARY_PREFIX_M%/lib/pkgconfig;%LIBRARY_PREFIX_M%/share/pkgconfig
FOR /F "delims=" %%i IN ('cygpath.exe -m "%GIR_PREFIX%"') DO set "GIR_PREFIX_M=%%i"
set PKG_CONFIG_PATH=%LIBRARY_PREFIX_M%/lib/pkgconfig;%LIBRARY_PREFIX_M%/share/pkgconfig;%GIR_PREFIX_M%/Library/lib/pkgconfig

@REM Avoid a Meson issue - https://github.com/mesonbuild/meson/issues/4827
set "PYTHONLEGACYWINDOWSSTDIO=1"
Expand All @@ -22,13 +30,10 @@ set "PYTHONIOENCODING=UTF-8"
@REM See hardcoded-paths.patch
set "CPPFLAGS=%CPPFLAGS% -D^"%LIBRARY_PREFIX_M%^""

meson setup --buildtype=release --prefix=%LIBRARY_PREFIX_M% --backend=ninja -Dselinux=disabled -Dxattr=false -Dlibmount=disabled -Dnls=enabled ..
if errorlevel 1 exit 1

type meson-logs\meson-log.txt
meson setup --buildtype=release --prefix=%LIBRARY_PREFIX_M% --backend=ninja -Dselinux=disabled -Dxattr=false -Dlibmount=disabled -Dnls=enabled -Dintrospection=enabled ..
if errorlevel 1 exit 1

ninja -v
ninja
if errorlevel 1 exit 1

@REM Lots of tests fail right now
Expand Down
108 changes: 78 additions & 30 deletions recipe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

set -exuo pipefail

meson_config_args=(
--buildtype=release
--backend=ninja
-Dlibdir=lib
-Dlibmount=disabled
-Dselinux=disabled
-Dxattr=false
-Dnls=enabled
)

# There are a couple of places in the source that hardcode a system prefix;
# in hardcoded-paths.patch we edit them to refer to the Conda prefix so
# that they will get appropriately rewritten.
Expand All @@ -12,39 +22,75 @@ export CPPFLAGS="$CPPFLAGS -DCONDA_PREFIX=\\\"$PREFIX\\\""
export PYTHON="python"
unset _CONDA_PYTHON_SYSCONFIGDATA_NAME

mkdir -p forgebuild
cd forgebuild

if [[ "$target_platform" == "osx-arm64" && "${CONDA_BUILD_CROSS_COMPILATION:-0}" == "1" ]]; then
# TODO: create this in the compiler activation recipe
echo "[host_machine]" > cross_file.txt
echo "system = 'darwin'" >> cross_file.txt
echo "cpu_family = 'aarch64'" >> cross_file.txt
echo "cpu = 'arm64'" >> cross_file.txt
echo "endian = 'little'" >> cross_file.txt
MESON_ARGS="$MESON_ARGS --cross-file cross_file.txt"
# TODO: do this in the compiler activation recipe as well
export OBJC=$CC
export OBJC_FOR_BUILD=$CC_FOR_BUILD
export PKG_CONFIG=$BUILD_PREFIX/bin/pkg-config
elif [[ "${CONDA_BUILD_CROSS_COMPILATION:-0}" == "1" ]]; then
# One of the tests uses objcopy to set up a special data file that can lead
# to cross errors if we use the wrong program. Note that the way our setup
# works, we actually pretend to Meson that we're doing a native build,
# though.
cat >machine_file.txt <<EOF
[binaries]
ld = '$LD'
objcopy = '$OBJCOPY'
# There is currently a cyclic dependency between glib and gobject-introspection:
# * https://discourse.gnome.org/t/dealing-with-glib-and-gobject-introspection-circular-dependency/18701
# * https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/433
# * https://gitlab.gnome.org/GNOME/glib/-/issues/2616
export GIR_PREFIX=$(pwd)/g-ir-prefix
conda create -p ${GIR_PREFIX} -y g-ir-build-tools gobject-introspection

cat <<EOF > $BUILD_PREFIX/bin/g-ir-scanner
#!/bin/bash

exec ${GIR_PREFIX}/bin/g-ir-scanner \$*
EOF
MESON_ARGS="$MESON_ARGS --native-file machine_file.txt"
chmod +x $BUILD_PREFIX/bin/g-ir-scanner
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${GIR_PREFIX}/lib/pkgconfig"

if [[ "${CONDA_BUILD_CROSS_COMPILATION:-0}" == 1 ]]; then
unset _CONDA_PYTHON_SYSCONFIGDATA_NAME
(
export CC=$CC_FOR_BUILD
export CXX=$CXX_FOR_BUILD
if [[ "${target_platform}" == osx-* ]]; then
export OBJC=$OBJC_FOR_BUILD
fi
export AR="$($CC_FOR_BUILD -print-prog-name=ar)"
export NM="$($CC_FOR_BUILD -print-prog-name=nm)"
export OBJCOPY="$($CC_FOR_BUILD -print-prog-name=objcopy)"
export LDFLAGS="${LDFLAGS//$PREFIX/$BUILD_PREFIX} -liconv"
export PKG_CONFIG_PATH="${BUILD_PREFIX}/lib/pkgconfig:${GIR_PREFIX}/lib/pkgconfig"

# Unset them as we're ok with builds that are either slow or non-portable
unset CFLAGS
unset CXXFLAGS
export CPPFLAGS="-isystem $BUILD_PREFIX/include -DCONDA_PREFIX=\\\"$BUILD_PREFIX\\\""
export host_alias=$build_alias

meson setup native-build \
"${meson_config_args[@]}" \
--prefix="$BUILD_PREFIX" \
-Dintrospection=enabled \
-Dlocalstatedir="$BUILD_PREFIX/var" \
|| { cat native-build/meson-logs/meson-log.txt ; exit 1 ; }

# This script would generate the functions.txt and dump.xml and save them
# This is loaded in the native build. We assume that the functions exported
# by glib are the same for the native and cross builds
export GI_CROSS_LAUNCHER=$GIR_PREFIX/libexec/gi-cross-launcher-save.sh
ninja -C native-build -j${CPU_COUNT}
ninja -C native-build install

# Store generated introspection information
mkdir -p introspection/lib
cp -ap $BUILD_PREFIX/lib/girepository-1.0 introspection/lib
mkdir -p introspection/share
cp -ap $BUILD_PREFIX/share/gir-1.0 introspection/share
)
export GI_CROSS_LAUNCHER=$GIR_PREFIX/libexec/gi-cross-launcher-load.sh
export MESON_ARGS="${MESON_ARGS} -Dintrospection=disabled"
else
export MESON_ARGS="${MESON_ARGS} -Dintrospection=enabled"
fi

meson setup --buildtype=release --prefix="$PREFIX" --backend=ninja -Dlibdir=lib -Dlocalstatedir="$PREFIX/var" \
-Dlibmount=disabled -Dselinux=disabled -Dxattr=false -Dnls=enabled $MESON_ARGS .. \
|| { cat meson-logs/meson-log.txt ; exit 1 ; }
meson setup builddir \
${MESON_ARGS} \
"${meson_config_args[@]}" \
--prefix="$PREFIX" \
-Dlocalstatedir="$PREFIX/var" \
|| { cat builddir/meson-logs/meson-log.txt ; exit 1 ; }

ninja -j${CPU_COUNT} -v
ninja -C builddir -j${CPU_COUNT} -v

if [ "${target_platform}" == 'linux-aarch64' ] || [ "${target_platform}" == "linux-ppc64le" ]; then
export MESON_TEST_TIMEOUT_MULTIPLIER=16
Expand All @@ -54,6 +100,8 @@ fi

if [[ "$target_platform" != osx-* && "${CONDA_BUILD_CROSS_COMPILATION:-0}" != "1" ]] ; then # too many tests fail on macOS
# Disable this test as it fails if gdb is installed system-wide, otherwise it will be skipped.
echo 'exit(0)' > ../glib/tests/assert-msg-test.py
echo 'exit(0)' > glib/tests/assert-msg-test.py
pushd builddir
meson test --no-suite flaky --timeout-multiplier ${MESON_TEST_TIMEOUT_MULTIPLIER}
popd
fi
6 changes: 6 additions & 0 deletions recipe/install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ if NOT [%PKG_NAME%] == [glib] (
if errorlevel 1 exit 1
del %LIBRARY_PREFIX%\bin\gobject-query.exe
if errorlevel 1 exit 1
del %LIBRARY_PREFIX%\bin\gi-compile-repository.exe
if errorlevel 1 exit 1
del %LIBRARY_PREFIX%\bin\gi-inspect-typelib.exe
if errorlevel 1 exit 1
del %LIBRARY_PREFIX%\bin\gi-decompile-typelib.exe
if errorlevel 1 exit 1
del %LIBRARY_PREFIX%\bin\gtester*
if errorlevel 1 exit 1

Expand Down
12 changes: 9 additions & 3 deletions recipe/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ set -exuo pipefail

unset _CONDA_PYTHON_SYSCONFIGDATA_NAME

cd forgebuild
ninja install || (cat meson-logs/meson-log.txt; false)
ninja -C builddir install || (cat meson-logs/meson-log.txt; false)
# remove libtool files
find $PREFIX -name '*.la' -delete

Expand Down Expand Up @@ -36,7 +35,7 @@ if [[ "$PKG_NAME" != glib ]]; then
cp "${RECIPE_DIR}/scripts/${CHANGE}.sh" "${PREFIX}/etc/conda/${CHANGE}.d/${PKG_NAME}_${CHANGE}.sh"
done
fi
rm $PREFIX/bin/{gdbus*,glib-*,gobject*,gtester*}
rm $PREFIX/bin/{gdbus*,glib-*,gobject*,gtester*,gi-*}
if [[ "$PKG_NAME" == glib-tools ]]; then
mv .keep/* $PREFIX/bin
fi
Expand All @@ -46,4 +45,11 @@ if [[ "$PKG_NAME" != glib ]]; then
rm -r $PREFIX/share/aclocal/{glib-*,gsettings*}
rm -r $PREFIX/share/gettext/its
rm -r $PREFIX/share/glib-*
else
# Manually install introspection data during cross-compilation
# These files are the only difference when running with a different setting of -Dintrospection
if [[ "${CONDA_BUILD_CROSS_COMPILATION:-0}" == 1 ]]; then
cp -ap introspection/lib/girepository-1.0 $PREFIX/lib
cp -ap introspection/share/gir-1.0 $PREFIX/share
fi
fi
14 changes: 11 additions & 3 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ source:
- 0002-Increase-some-test-timeouts.patch # [win]

build:
number: 4
number: 5
ignore_run_exports_from:
- python *

Expand All @@ -45,6 +45,11 @@ requirements:
- python >=2.7
- packaging
- setuptools
- libffi # [build_platform != target_platfrom]
- libintl-devel # [(build_platform != target_platform) and (not linux)]
- zlib # [build_platform != target_platfrom]
- pcre2 # [build_platform != target_platfrom]
- libiconv # [build_platform != target_platfrom]
host:
- libffi
- libintl-devel # [not linux]
Expand Down Expand Up @@ -141,7 +146,6 @@ outputs:
- python *
- {{ compiler('cxx') }} # [unix]
- libiconv
- libffi
- pcre2
- zlib
- m2-sed # [win]
Expand Down Expand Up @@ -185,7 +189,11 @@ outputs:
- test.c
- test-win.bat
commands:
- test -f ${PREFIX}/lib/libglib-2.0${SHLIB_EXT} # [not win]
- test -f ${PREFIX}/share/gir-1.0/GLib-2.0.gir # [unix]
- test -f ${PREFIX}/lib/girepository-1.0/GLib-2.0.typelib # [unix]
- test -f ${PREFIX}/lib/libglib-2.0${SHLIB_EXT} # [unix]
- if not exist %LIBRARY_PREFIX%\share\gir-1.0\GLib-2.0.gir exit 1 # [win]
- if not exist %LIBRARY_PREFIX%\lib\girepository-1.0\GLib-2.0.typelib exit 1 # [win]
- glib-compile-resources --help
- gobject-query --help
- gtester --help # [not win]
Expand Down