Add meson build system
v4 cover Add meson build system
From: Marc-André Lureau <[email protected]>
Hi
This series adds support for meson build system. The main reason for this, beside using a more modern and simpler build system, is to enable subproject() support in QEMU.
v4:
- made setup.py --top-builddir option default to CWD
- extend commit messages
- rebased
v3:
- remove workaround for meson#2992 which is now unnecessary
- add description to meson options
- pass NO_YAML & NO_PYTHON down to run_tests.sh
- commit comment tweaks
- rebased
v2:
- various misc improvements after David Gibson v1 review
- add various meson_options.txt build options
- add editorconfig patch
Marc-André Lureau (4):
pylibfdt: fix build-lib location
pylibfdt: allow build out of tree
build-sys: add meson build
travis: test meson build
.travis.yml | 16 +++++ libfdt/meson.build | 50 ++++++++++++++ meson.build | 127 ++++++++++++++++++++++++++++++++++++ meson_options.txt | 10 +++ pylibfdt/Makefile.pylibfdt | 4 +- pylibfdt/meson.build | 13 ++++ pylibfdt/setup.py | 27 +++++--- tests/meson.build | 130 +++++++++++++++++++++++++++++++++++++ version_gen.h.in | 1 + 9 files changed, 368 insertions(+), 10 deletions(-) create mode 100644 libfdt/meson.build create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 pylibfdt/meson.build create mode 100644 tests/meson.build create mode 100644 version_gen.h.in
Signature · 1 line
2.28.0
A message that is not in the archive (sent off-list or not yet received): 20201006082712.241224-1-marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
PATCH v4 1/4 pylibfdt: fix build-lib location
From: Marc-André Lureau <[email protected]>
setup.py build_ext is run from top_srcdir with the Makefile build-system, due to Makefile.pylibfdt inclusion in top_srcdir/Makefile.
--build-lib=../pylibfdt will produce output files in the parent directory of the current directory. Ex:
~/src/dtc$ make && ls ../pylibfdt
_libfdt.cpython-38-x86_64-linux-gnu.so
Fix it by changing the build-lib directory to $(cwd)/pylibfdt instead.
(note that setup.py install will rebuild it with the default 'build' directory, there doesn't seem to be a way to override that)
setup.py depend on where it's invoked from")
--- pylibfdt/Makefile.pylibfdt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
pylibfdt/Makefile.pylibfdt +1 -1
@@ -18,7 +18,7 @@ endif $(PYMODULE): $(PYLIBFDT_srcs) $(LIBFDT_archive) $(SETUP) $(VERSION_FILE) @$(VECHO) PYMOD $@ - $(PYTHON) $(SETUP) $(SETUPFLAGS) build_ext --build-lib=../$(PYLIBFDT_dir) + $(PYTHON) $(SETUP) $(SETUPFLAGS) build_ext --build-lib=$(PYLIBFDT_dir) install_pylibfdt: $(PYMODULE) @$(VECHO) INSTALL-PYLIB
Signature · 1 line
2.28.0
A message that is not in the archive (sent off-list or not yet received): 20201006082712.241224-2-marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Re: [PATCH v4 1/4] pylibfdt: fix build-lib location
Quoted 10 lines · On Tue, Oct 06, 2020 at 12:27:09PM +0400…
From: Marc-André Lureau <[email protected]>
setup.pybuild_extis run fromtop_srcdirwith theMakefilebuild-system, due to Makefile.pylibfdt inclusion in top_srcdir/Makefile.--build-lib=../pylibfdt will produce output files in the parent directory of the current directory. Ex:
~/src/dtc$ make && ls ../pylibfdt
_libfdt.cpython-38-x86_64-linux-gnu.so
So... this doesn't happen for me
$ git rev-parse HEAD cbca977ea121d7483b0c2351b17dca08a21cb1ca $ make [...] $ ls ../pylibfdt ls: cannot access '../pylibfdt': No such file or directory $ ls pylibfdt/ build/ _libfdt.cpython-38-x86_64-linux-gnu.so* libfdt.i libfdt.py libfdt_wrap.c Makefile.pylibfdt pylibfdt/ setup.py*
If I apply your patch, then the module ends up in $topdir/pylibfdt/pylibfdt instead, and make check no longer runs the python tests.
So.. why it's behaving incorrectly for you but not me, I don't know :/
Quoted 25 lines
Fix it by changing the build-lib directory to $(cwd)/pylibfdt instead.
(note that
setup.pyinstall will rebuild it with the default 'build' directory, there doesn't seem to be a way to override that)Fixes 1e4a0928f3b3b827824222572e551a60935607e3 ("pylibfdt: Don't have
setup.pydepend on where it's invoked from")Signed-off-by Marc-André Lureau <[email protected]>--- pylibfdt/Makefile.pylibfdt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)pylibfdt/Makefile.pylibfdt +1
-1@@ -18,7 +18,7 @@ endif $(PYMODULE): $(PYLIBFDT_srcs) $(LIBFDT_archive) $(SETUP) $(VERSION_FILE) @$(VECHO) PYMOD $@ - $(PYTHON) $(SETUP) $(SETUPFLAGS) build_ext --build-lib=../$(PYLIBFDT_dir) + $(PYTHON) $(SETUP) $(SETUPFLAGS) build_ext --build-lib=$(PYLIBFDT_dir) install_pylibfdt: $(PYMODULE) @$(VECHO) INSTALL-PYLIB
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v4 1/4] pylibfdt: fix build-lib location
Hi
Quoted 24 lines · David Gibson
Quoted 10 lines · On Tue, Oct 06, 2020 at 12:27:09PM +0400…
From: Marc-André Lureau <[email protected]>
setup.pybuild_extis run fromtop_srcdirwith theMakefilebuild-system, due to Makefile.pylibfdt inclusion in top_srcdir/Makefile.--build-lib=../pylibfdt will produce output files in the parent directory of the current directory. Ex:
~/src/dtc$ make && ls ../pylibfdt
_libfdt.cpython-38-x86_64-linux-gnu.soSo... this doesn't happen for me
$ git rev-parse HEAD cbca977ea121d7483b0c2351b17dca08a21cb1ca $ make [...] $ ls ../pylibfdt ls: cannot access '../pylibfdt': No such file or directory $ ls pylibfdt/ build/ _libfdt.cpython-38-x86_64-linux-gnu.so* libfdt.i libfdt.py libfdt_wrap.c Makefile.pylibfdt pylibfdt/ setup.py*
Quoted 5 lines
If I apply your patch, then the module ends up in $topdir/pylibfdt/pylibfdt instead, and make check no longer runs the python tests.
So.. why it's behaving incorrectly for you but not me, I don't know :/
This is interesting, I upgraded to f33 and I no longer have the issue. No idea.
Quoted 32 lines
Quoted 18 lines
Fix it by changing the build-lib directory to $(cwd)/pylibfdt instead.
(note that
setup.pyinstall will rebuild it with the default 'build' directory, there doesn't seem to be a way to override that)Fixes 1e4a0928f3b3b827824222572e551a60935607e3 ("pylibfdt: Don't have
setup.pydepend on where it's invoked from")Signed-off-by Marc-André Lureau <[email protected]>--- pylibfdt/Makefile.pylibfdt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)pylibfdt/Makefile.pylibfdt +0
-0pylibfdt/Makefile.pylibfdt endif · line 24
Quoted 8 lines
pylibfdt/Makefile.pylibfdt +1
-1@@ -18,7 +18,7 @@ endif $(PYMODULE): $(PYLIBFDT_srcs) $(LIBFDT_archive) $(SETUP) $(VERSION_FILE) @$(VECHO) PYMOD $@ - $(PYTHON) $(SETUP) $(SETUPFLAGS) build_ext --build-lib=../$(PYLIBFDT_dir) + $(PYTHON) $(SETUP) $(SETUPFLAGS) build_ext --build-lib=$(PYLIBFDT_dir) install_pylibfdt: $(PYMODULE) @$(VECHO) INSTALL-PYLIB--
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_!
A message that is not in the archive (sent off-list or not yet received): CAMxuvazSLvvO-OwwjDxuw8PY88nP0y5rpf7+O71jGXUPhGDsrg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH v4 1/4] pylibfdt: fix build-lib location
Quoted 27 lines · Marc-André Lureau
Hi
Quoted 24 lines · David Gibson
Quoted 10 lines · On Tue, Oct 06, 2020 at 12:27:09PM +0400…
From: Marc-André Lureau <[email protected]>
setup.pybuild_extis run fromtop_srcdirwith theMakefilebuild-system, due to Makefile.pylibfdt inclusion in top_srcdir/Makefile.--build-lib=../pylibfdt will produce output files in the parent directory of the current directory. Ex:
~/src/dtc$ make && ls ../pylibfdt
_libfdt.cpython-38-x86_64-linux-gnu.soSo... this doesn't happen for me
$ git rev-parse HEAD cbca977ea121d7483b0c2351b17dca08a21cb1ca $ make [...] $ ls ../pylibfdt ls: cannot access '../pylibfdt': No such file or directory $ ls pylibfdt/ build/ _libfdt.cpython-38-x86_64-linux-gnu.so* libfdt.i libfdt.py libfdt_wrap.c Makefile.pylibfdt pylibfdt/ setup.py*
Quoted 8 lines
Quoted 5 lines
If I apply your patch, then the module ends up in $topdir/pylibfdt/pylibfdt instead, and make check no longer runs the python tests.
So.. why it's behaving incorrectly for you but not me, I don't know :/
This is interesting, I upgraded to f33 and I no longer have the issue. No idea.
Oh dear, that's worrying. It suggests it depends on the version of setuptools installed, and I have no idea what we'd need to do to ensure consistent behaviour given that.
Quoted 29 lines
Quoted 28 lines
Quoted 27 lines
Fix it by changing the build-lib directory to $(cwd)/pylibfdt instead.
(note that
setup.pyinstall will rebuild it with the default 'build' directory, there doesn't seem to be a way to override that)Fixes 1e4a0928f3b3b827824222572e551a60935607e3 ("pylibfdt: Don't have
setup.pydepend on where it's invoked from")Signed-off-by Marc-André Lureau <[email protected]>--- pylibfdt/Makefile.pylibfdt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)pylibfdt/Makefile.pylibfdt +1
-1@@ -18,7 +18,7 @@ endif $(PYMODULE): $(PYLIBFDT_srcs) $(LIBFDT_archive) $(SETUP) $(VERSION_FILE) @$(VECHO) PYMOD $@ - $(PYTHON) $(SETUP) $(SETUPFLAGS) build_ext --build-lib=../$(PYLIBFDT_dir) + $(PYTHON) $(SETUP) $(SETUPFLAGS) build_ext --build-lib=$(PYLIBFDT_dir) install_pylibfdt: $(PYMODULE) @$(VECHO) INSTALL-PYLIB
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v4 1/4] pylibfdt: fix build-lib location
Hi
Quoted 33 lines · David Gibson
Quoted 31 lines · Marc-André Lureau
Hi
Quoted 28 lines · David Gibson
Quoted 10 lines · On Tue, Oct 06, 2020 at 12:27:09PM +0400…
From: Marc-André Lureau <[email protected]>
setup.pybuild_extis run fromtop_srcdirwith theMakefilebuild-system, due to Makefile.pylibfdt inclusion in top_srcdir/Makefile.--build-lib=../pylibfdt will produce output files in the parent directory of the current directory. Ex:
~/src/dtc$ make && ls ../pylibfdt
_libfdt.cpython-38-x86_64-linux-gnu.soSo... this doesn't happen for me
$ git rev-parse HEAD cbca977ea121d7483b0c2351b17dca08a21cb1ca $ make [...] $ ls ../pylibfdt ls: cannot access '../pylibfdt': No such file or directory $ ls pylibfdt/ build/ _libfdt.cpython-38-x86_64-linux-gnu.so* libfdt.i libfdt.py libfdt_wrap.c Makefile.pylibfdt pylibfdt/ setup.py*If I apply your patch, then the module ends up in $topdir/pylibfdt/pylibfdt instead, and make check no longer runs the python tests.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
So.. why it's behaving incorrectly for you but not me, I don't know :/
This is interesting, I upgraded to f33 and I no longer have the issue. No idea.
Oh dear, that's worrying. It suggests it depends on the version of setuptools installed, and I have no idea what we'd need to do to ensure consistent behaviour given that.
fwiw, the rest of the patches are independent of this issue, please have a look. thanks
Quoted 36 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Fix it by changing the build-lib directory to $(cwd)/pylibfdt instead.
(note that
setup.pyinstall will rebuild it with the default 'build' directory, there doesn't seem to be a way to override that)Fixes 1e4a0928f3b3b827824222572e551a60935607e3 ("pylibfdt: Don't have
setup.pydepend on where it's invoked from")Signed-off-by Marc-André Lureau <[email protected]>--- pylibfdt/Makefile.pylibfdt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)pylibfdt/Makefile.pylibfdt +0
-0@@ -18,7 +18,7 @@ endifQuoted 9 lines
Quoted 8 lines
pylibfdt/Makefile.pylibfdt endif · line 24
Quoted 7 lines
pylibfdt/Makefile.pylibfdt +1
-1$(PYMODULE): $(PYLIBFDT_srcs) $(LIBFDT_archive) $(SETUP) $(VERSION_FILE) @$(VECHO) PYMOD $@ - $(PYTHON) $(SETUP) $(SETUPFLAGS) build_ext --build-lib=../$(PYLIBFDT_dir) + $(PYTHON) $(SETUP) $(SETUPFLAGS) build_ext --build-lib=$(PYLIBFDT_dir) install_pylibfdt: $(PYMODULE) @$(VECHO) INSTALL-PYLIB--
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_!
PATCH v4 2/4 pylibfdt: allow build out of tree
In reply to a message not in the archiveFrom: Marc-André Lureau <[email protected]>
With meson, we have to support out-of-tree build.
Introduce a --top-builddir option, which will default to the current directory to lookup generated filed such as version_gen.h and output directories.
Other source paths are derived from the location of the setup.py script in the source tree.
--- pylibfdt/Makefile.pylibfdt | 2 +- pylibfdt/setup.py | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-)
pylibfdt/Makefile.pylibfdt +1 -1
@@ -10,7 +10,7 @@ PYLIBFDT_CLEANDIRS_L = build __pycache__ PYLIBFDT_CLEANDIRS = $(PYLIBFDT_CLEANDIRS_L:%=$(PYLIBFDT_dir)/%) SETUP = $(PYLIBFDT_dir)/setup.py -SETUPFLAGS = +SETUPFLAGS = --top-builddir . ifndef V SETUPFLAGS += --quiet
pylibfdt/setup.py +19 -8
@@ -19,23 +19,33 @@ import sys VERSION_PATTERN = '^#define DTC_VERSION "DTC ([^"]*)"$' +def get_top_builddir(): + if '--top-builddir' in sys.argv: + index = sys.argv.index('--top-builddir') + sys.argv.pop(index) + return sys.argv.pop(index) + else: + return os.getcwd() + + +srcdir = os.path.dirname(os.path.abspath(sys.argv[0])) +top_builddir = get_top_builddir() + + def get_version(): - version_file = "../version_gen.h" + version_file = os.path.join(top_builddir, 'version_gen.h') f = open(version_file, 'rt') m = re.match(VERSION_PATTERN, f.readline()) return m.group(1) -setupdir = os.path.dirname(os.path.abspath(sys.argv[0])) -os.chdir(setupdir) - libfdt_module = Extension( '_libfdt', - sources=['libfdt.i'], - include_dirs=['../libfdt'], + sources=[os.path.join(srcdir, 'libfdt.i')], + include_dirs=[os.path.join(srcdir, '../libfdt')], libraries=['fdt'], - library_dirs=['../libfdt'], - swig_opts=['-I../libfdt'], + library_dirs=[os.path.join(top_builddir, 'libfdt')], + swig_opts=['-I' + os.path.join(srcdir, '../libfdt')], ) setup(
@@ -44,5 +54,6 @@ setup( author='Simon Glass <[email protected]>', description='Python binding for libfdt', ext_modules=[libfdt_module], + package_dir={'': srcdir}, py_modules=['libfdt'], )
Signature · 1 line
2.28.0
A message that is not in the archive (sent off-list or not yet received): 20201006082712.241224-3-marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
David Gibson
AppliedRe: [PATCH v4 2/4] pylibfdt: allow build out of tree
Quoted 4 lines · On Tue, Oct 06, 2020 at 12:27:10PM +0400…
From: Marc-André Lureau <[email protected]>
With meson, we have to support out-of-tree build.
Quoted 8 lines
Introduce a --top-builddir option, which will default to the current directory to lookup generated filed such as
version_gen.hand output directories.Other source paths are derived from the location of the
setup.pyscript in the source tree.Signed-off-by Marc-André Lureau <[email protected]>
Applied, thanks.
Quoted 71 lines
--- pylibfdt/Makefile.pylibfdt | 2 +- pylibfdt/setup.py | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-)pylibfdt/Makefile.pylibfdt +1
-1@@ -10,7 +10,7 @@ PYLIBFDT_CLEANDIRS_L = build __pycache__ PYLIBFDT_CLEANDIRS = $(PYLIBFDT_CLEANDIRS_L:%=$(PYLIBFDT_dir)/%) SETUP = $(PYLIBFDT_dir)/setup.py -SETUPFLAGS = +SETUPFLAGS = --top-builddir . ifndef V SETUPFLAGS += --quietpylibfdt/setup.py +19
-8@@ -19,23 +19,33 @@ import sys VERSION_PATTERN = '^#define DTC_VERSION "DTC ([^"]*)"$' +def get_top_builddir(): + if '--top-builddir' in sys.argv: + index = sys.argv.index('--top-builddir') + sys.argv.pop(index) + return sys.argv.pop(index) + else: + return os.getcwd() + + +srcdir = os.path.dirname(os.path.abspath(sys.argv[0])) +top_builddir = get_top_builddir() + + def get_version(): - version_file = "../version_gen.h" + version_file = os.path.join(top_builddir, 'version_gen.h') f = open(version_file, 'rt') m = re.match(VERSION_PATTERN, f.readline()) return m.group(1) -setupdir = os.path.dirname(os.path.abspath(sys.argv[0])) -os.chdir(setupdir) - libfdt_module = Extension( '_libfdt', - sources=['libfdt.i'], - include_dirs=['../libfdt'], + sources=[os.path.join(srcdir, 'libfdt.i')], + include_dirs=[os.path.join(srcdir, '../libfdt')], libraries=['fdt'], - library_dirs=['../libfdt'], - swig_opts=['-I../libfdt'], + library_dirs=[os.path.join(top_builddir, 'libfdt')], + swig_opts=['-I' + os.path.join(srcdir, '../libfdt')], ) setup(@@ -44,5 +54,6 @@ setup( author='Simon Glass <[email protected]>', description='Python binding for libfdt', ext_modules=[libfdt_module], + package_dir={'': srcdir}, py_modules=['libfdt'], )
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v4 2/4] pylibfdt: allow build out of tree
Quoted 9 lines · David Gibson
Quoted 8 lines · On Tue, Oct 06, 2020 at 12:27:10PM +0400…
From: Marc-André Lureau <[email protected]>
With meson, we have to support out-of-tree build.
Introduce a --top-builddir option, which will default to the current directory to lookup generated filed such as
version_gen.hand output directories.
Quoted 6 lines
Quoted 4 lines
Other source paths are derived from the location of the
setup.pyscript in the source tree.Signed-off-by Marc-André Lureau <[email protected]>Applied, thanks.
Wait... no... unapplied. This somehow breaks the auto-detection & build of pylibfdt. After applying on a clean tree:
$ make check
[...]
********** TEST SUMMARY
* Total testcases: 2033
* PASS: 2033
* FAIL: 0
* Bad configuration: 0
* Strange test result: 0
**********That number doesn't include the pylibfdt tests (it should be 2070 including them). Plus, the extension module doesn't appear to have been built in the expected place:
$ ls pylibfdt/ libfdt.i Makefile.pylibfdt setup.py*
Explicitly running "make pylibfdt" works around it, but I'd rather not have to.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v4 2/4] pylibfdt: allow build out of tree
Hi
Quoted 35 lines · David Gibson
Quoted 9 lines · David Gibson
Quoted 8 lines · On Tue, Oct 06, 2020 at 12:27:10PM +0400…
From: Marc-André Lureau <[email protected]>
With meson, we have to support out-of-tree build.
Introduce a --top-builddir option, which will default to the current directory to lookup generated filed such as
version_gen.hand output directories.Quoted 6 lines
Quoted 4 lines
Other source paths are derived from the location of the
setup.pyscript in the source tree.Signed-off-by Marc-André Lureau <[email protected]>Applied, thanks.
Wait... no... unapplied. This somehow breaks the auto-detection & build of pylibfdt. After applying on a clean tree:
$ make check [...] ********** TEST SUMMARY * Total testcases: 2033 * PASS: 2033 * FAIL: 0 * Bad configuration: 0 * Strange test result: 0 **********That number doesn't include the pylibfdt tests (it should be 2070 including them). Plus, the extension module doesn't appear to have been built in the expected place:
Quoted 5 lines
$ ls pylibfdt/ libfdt.i Makefile.pylibfdt setup.py*Explicitly running "make pylibfdt" works around it, but I'd rather not have to.
Ah, this is where the first patch actually comes in then. I don't understand what's going on yet, but it's a part of the puzzle..
Sorry
A message that is not in the archive (sent off-list or not yet received): CAMxuvaw7Uv2NQQFfz_JNtTpVJLXYaY-zr=fQ7ccq=9ypwfa+yQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH v4 2/4] pylibfdt: allow build out of tree
Hi
Quoted 41 lines · Marc-André Lureau
Hi
Quoted 35 lines · David Gibson
Quoted 9 lines · David Gibson
Quoted 8 lines · On Tue, Oct 06, 2020 at 12:27:10PM +0400…
From: Marc-André Lureau <[email protected]>
With meson, we have to support out-of-tree build.
Introduce a --top-builddir option, which will default to the current directory to lookup generated filed such as
version_gen.hand output directories.Quoted 6 lines
Quoted 4 lines
Other source paths are derived from the location of the
setup.pyscript in the source tree.Signed-off-by Marc-André Lureau <[email protected]>Applied, thanks.
Wait... no... unapplied. This somehow breaks the auto-detection & build of pylibfdt. After applying on a clean tree:
$ make check [...] ********** TEST SUMMARY * Total testcases: 2033 * PASS: 2033 * FAIL: 0 * Bad configuration: 0 * Strange test result: 0 **********That number doesn't include the pylibfdt tests (it should be 2070 including them). Plus, the extension module doesn't appear to have been built in the expected place:
Quoted 8 lines
Quoted 5 lines
$ ls pylibfdt/ libfdt.i Makefile.pylibfdt setup.py*Explicitly running "make pylibfdt" works around it, but I'd rather not have to.
Ah, this is where the first patch actually comes in then. I don't understand what's going on yet, but it's a part of the puzzle..
Ok, I think I understand what's going on...
In the middle of the setup.py, there is a "os.chdir(setupdir)". So the --build-lib option isn't relative to the current directory, but to the setup.py.
In the next patch, I removed the need for os.chdir() and thus the two patches should be combined.
Sending a v5. Thanks
PATCH v4 3/4 build-sys: add meson build
In reply to a message not in the archiveFrom: Marc-André Lureau <[email protected]>
The meson build system allows projects to "vendor" dtc easily, thanks to subproject(). QEMU has recently switched to meson, and adding meson support to dtc will help to handle the QEMU submodule.
meson rules are arguably simpler to write and maintain than the hand-crafted/custom Makefile. meson support various backends, and default build options (including coverage, sanitizer, debug/release etc, see: https://mesonbuild.com/Builtin-options.html)
Compare to the Makefiles, the same build targets should be built and installed and the same tests should be run ("meson test" can be provided extra test arguments for running the equivalent of checkm/checkv).
There is no support EXTRAVERSION/LOCAL_VERSION/CONFIG_LOCALVERSION, instead the version is simply set with project(), and vcs_tag() is used for git/dirty version reporting (This is most common and is hopefully enough. If necessary, configure-time options could be added for extra versioning.).
libfdt shared library is build following regular naming conventions:
instead of libfdt.so.1 -> libfdt-1.6.0.so (with current build-sys), libfdt.so.1 -> libfdt.so.1.6.0. I am not sure why the current build system use an uncommon naming pattern. I also included a libfdt.pc pkg-config file, as convenience.
Both Linux native build and mingw cross-build pass. CI pass. Tests are only run on native build.
The current Makefiles are left in-tree, and make/check still work. Eventually, the Makefiles could be marked as deprecated, to start a transition period and avoid having to maintain 2 build systems in the near future.
(run_tests.sh could eventually be replaced by the meson test runner, which would have several advantages in term of flexibility/features, but this is left for another day)
--- libfdt/meson.build | 50 +++++++++++++++++ meson.build | 127 ++++++++++++++++++++++++++++++++++++++++++ meson_options.txt | 10 ++++ pylibfdt/meson.build | 13 +++++ tests/meson.build | 130 +++++++++++++++++++++++++++++++++++++++++++ version_gen.h.in | 1 + 6 files changed, 331 insertions(+) create mode 100644 libfdt/meson.build create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 pylibfdt/meson.build create mode 100644 tests/meson.build create mode 100644 version_gen.h.in
libfdt/meson.build new file +50 -0
@@ -0,0 +1,50 @@ +version_script = '-Wl,--version-script=@0@'.format(meson.current_source_dir() / 'version.lds') +if not cc.has_link_argument(version_script) + version_script = [] +endif + +sources = files( + 'fdt.c', + 'fdt_addresses.c', + 'fdt_check.c', + 'fdt_empty_tree.c', + 'fdt_overlay.c', + 'fdt_ro.c', + 'fdt_rw.c', + 'fdt_strerror.c', + 'fdt_sw.c', + 'fdt_wip.c', +) + +libfdt = library( + 'fdt', sources, + version: '1.6.0', + link_args: ['-Wl,--no-undefined', version_script], + link_depends: 'version.lds', + install: true, +) + +libfdt_inc = include_directories('.') + +libfdt_dep = declare_dependency( + include_directories: libfdt_inc, + link_with: libfdt, +) + +install_headers( + files( + 'fdt.h', + 'libfdt.h', + 'libfdt_env.h', + ) +) + +pkgconfig = import('pkgconfig') + +pkgconfig.generate( + libraries: libfdt, + version: meson.project_version(), + filebase: 'libfdt', + name: 'libfdt', + description: 'Flat Device Tree manipulation', +)
meson.build new file +127 -0
127 lines not on this page · raw message
meson_options.txt new file +10 -0
@@ -0,0 +1,10 @@ +option('tools', type: 'boolean', value: true, + description: 'Build tools') +option('assume-mask', type: 'integer', value: 0, + description: 'Control the assumptions made (e.g. risking security issues) in the code.') +option('yaml', type: 'feature', value: 'auto', + description: 'YAML support') +option('valgrind', type: 'feature', value: 'auto', + description: 'Valgrind support') +option('python', type: 'feature', value: 'auto', + description: 'Build pylibfdt Python library')
pylibfdt/meson.build new file +13 -0
@@ -0,0 +1,13 @@ +setup_py = find_program('setup.py') +setup_py = [setup_py.path(), '--quiet', '--top-builddir', meson.current_build_dir() / '..'] + +custom_target( + 'pylibfdt', + input: 'libfdt.i', + output: '_libfdt.so', + depends: version_gen_h, + command: [setup_py, 'build_ext', '--build-lib=' + meson.current_build_dir()], + build_by_default: true, +) + +meson.add_install_script(setup_py, 'install', '--prefix=' + get_option('prefix'), '--root=$DESTDIR')
tests/meson.build new file +130 -0
130 lines not on this page · raw message
version_gen.h.in new file +1 -0
@@ -0,0 +1 @@ +#define DTC_VERSION "DTC @VCS_TAG@"
Signature · 1 line
2.28.0
PATCH v4 4/4 travis: test meson build
In reply to a message not in the archiveFrom: Marc-André Lureau <[email protected]>
--- .travis.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
.travis.yml +16 -0
@@ -6,6 +6,12 @@ env: # COVERITY_SCAN_TOKEN (dgibson/dtc) - secure: "vlHvXe618//IM9LQaKzqsrUbjs7ng0L9UCST4kJbJnFQDXvVe5JiSmJGd4ef7mm0NUv5bMRl2W3xCiu6BYAu/NvU3tMNHoLG+JgCJs0+wLJXbWOwji/NmH7olqgJG+CmpaCMXjARF6+nrTnBYHJL6cYyf4KVoV4B0I/hLUW91+s=" +before_install: + - '[ $TRAVIS_CPU_ARCH = amd64 ] && sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu xenial-backports main universe" || sudo add-apt-repository -y "deb http://ports.ubuntu.com xenial-backports main universe"' + - sudo apt-get -q update + - sudo apt-get -t xenial-backports install -y python3 python3-setuptools python3-pip ninja-build + - sudo pip3 install meson + matrix: include: - addons:
@@ -25,12 +31,16 @@ matrix: script: - make - make check && make checkm + - meson build + - ninja -C build test # Check it builds properly without optional packages: # python, valgrind, libyaml - script: - make - make check + - meson build + - ninja -C build test - arch: arm64 addons:
@@ -42,6 +52,8 @@ matrix: script: - make - make check checkm + - meson build + - ninja -C build test - arch: ppc64le addons:
@@ -52,6 +64,8 @@ matrix: script: - make - make check + - meson build + - ninja -C build test - arch: s390x addons:
@@ -63,3 +77,5 @@ matrix: script: - make - make check checkm + - meson build + - ninja -C build test
Signature · 1 line
2.28.0