mirror of
https://github.com/dgibson/dtc.git
synced 2026-01-22 01:30:34 -05:00
meson: port python bindings to build natively via meson and meson-python
We get full build parallelism and fewer confusing ancient distutils paths. The python wheels build fully standalone, including linking libfdt as a static library. For convenience, when running pip install a meson option is passed that prevents building tools or installing headers/pkgconfig files. meson-python would otherwise include them in the wheel itself, in case they are needed, but this is essentially a bit useless so don't bother. The old setuptools-based build is now redundant and goes away. Signed-off-by: Eli Schwartz <eschwartz@gentoo.org> Message-ID: <20250430152601.43554-3-eschwartz@gentoo.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
7ebfcac852
commit
ecb21febfd
9 changed files with 73 additions and 213 deletions
|
|
@ -1,30 +0,0 @@
|
|||
# SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
|
||||
# Makefile.pylibfdt
|
||||
#
|
||||
|
||||
PYLIBFDT_srcs = $(PYLIBFDT_dir)/libfdt.i
|
||||
PYMODULE = $(PYLIBFDT_dir)/_libfdt.so
|
||||
PYLIBFDT_CLEANFILES_L = libfdt_wrap.c libfdt.py *.pyc *.so
|
||||
PYLIBFDT_CLEANFILES = $(PYLIBFDT_CLEANFILES_L:%=$(PYLIBFDT_dir)/%)
|
||||
PYLIBFDT_CLEANDIRS_L = __pycache__ libfdt.egg-info
|
||||
PYLIBFDT_CLEANDIRS = build $(PYLIBFDT_CLEANDIRS_L:%=$(PYLIBFDT_dir)/%)
|
||||
|
||||
SETUP = ./setup.py
|
||||
|
||||
ifndef V
|
||||
SETUPFLAGS += --quiet
|
||||
endif
|
||||
|
||||
$(PYMODULE): WARNINGS = # suppress warnings from generated code
|
||||
$(PYMODULE): $(PYLIBFDT_srcs) $(LIBFDT_archive) $(SETUP)
|
||||
@$(VECHO) PYMOD $@
|
||||
CFLAGS="$(CFLAGS) -Wno-error" $(PYTHON) $(SETUP) $(SETUPFLAGS) build_ext
|
||||
|
||||
install_pylibfdt: $(PYMODULE)
|
||||
@$(VECHO) INSTALL-PYLIB
|
||||
$(PYTHON) $(SETUP) $(SETUPFLAGS) install --prefix=$(PREFIX)
|
||||
|
||||
pylibfdt_clean:
|
||||
@$(VECHO) CLEAN "(pylibfdt)"
|
||||
rm -f $(PYLIBFDT_CLEANFILES)
|
||||
rm -rf $(PYLIBFDT_CLEANDIRS)
|
||||
|
|
@ -1,13 +1,21 @@
|
|||
setup_py = find_program('../setup.py')
|
||||
setup_py = [setup_py, '--quiet', '--top-builddir', meson.project_build_root()]
|
||||
|
||||
pylibfdt = custom_target(
|
||||
'pylibfdt',
|
||||
libfdt_c = custom_target(
|
||||
'swig',
|
||||
input: 'libfdt.i',
|
||||
depends: libfdt,
|
||||
output: '_libfdt.so',
|
||||
command: [setup_py, 'build_ext'],
|
||||
build_by_default: true,
|
||||
output: ['libfdt.c', 'libfdt.py'],
|
||||
install: true,
|
||||
install_dir: [false, py.get_install_dir(pure: false)],
|
||||
command: [swig, '-python', '-I'+meson.current_source_dir() / '../libfdt', '-o', '@OUTPUT0@', '@INPUT@']
|
||||
)
|
||||
|
||||
meson.add_install_script(setup_py, 'install', '--prefix=' + get_option('prefix'), '--root=$DESTDIR')
|
||||
nowarn_gen = cc.get_supported_arguments(
|
||||
'-Wno-cast-qual',
|
||||
'-Wno-missing-prototypes',
|
||||
'-Wno-redundant-decls',
|
||||
)
|
||||
pylibfdt = py.extension_module(
|
||||
'_libfdt',
|
||||
libfdt_c,
|
||||
c_args: ['-DPY_SSIZE_T_CLEAN'] + nowarn_gen,
|
||||
dependencies: [libfdt_dep, py.dependency()],
|
||||
install: true,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue