Skip to contentSkip to conversation

Switch to meson build system

PATCH In review [email protected] 4 participants 14 messages Nov 4, 2020 – Nov 9, 2021 8 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v6 cover Switch to meson build system

From: Marc-André Lureau <[email protected]>

Hi

This series switches the build system to meson. The main reason for this, bes= ide
using a more modern and simpler build system, is to enable subproject() suppo= rt
in QEMU (atm, QEMU embedds a minimal meson build itself).

v6:
- add "build-sys: replace makefiles to wrap meson/ninja", addressing concerns about meson usage, and replacing the old build system.
- a few minor fixes to meson.build files (warnings and such)

v5:
- squashed --build-lib change with "pylibfdt: allow build out of tree" as the two are actually related

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=C3=A9 Lureau (4):
pylibfdt: allow build out of tree
build-sys: add meson build
travis: install meson
build-sys: replace makefiles to wrap meson/ninja

 .travis.yml                |   6 +
 Makefile                   | 385 ++-----------------------------------
 Makefile.convert-dtsv0     |  14 --
 Makefile.dtc               |  23 ---
 Makefile.utils             |  31 ---
 README                     |  24 ++-
 libfdt/Makefile.libfdt     |  18 --
 libfdt/meson.build         |  50 +++++
 meson.build                | 129 +++++++++++++
 meson_options.txt          |  10 +
 pylibfdt/Makefile.pylibfdt |  30 ---
 pylibfdt/meson.build       |  13 ++
 pylibfdt/setup.py          |  27 ++-
 tests/Makefile.tests       | 100 ----------
 tests/meson.build          | 131 +++++++++++++
 tests/run_tests.sh         |  10 +-
 version_gen.h.in           |   1 +
 17 files changed, 398 insertions(+), 604 deletions(-)
 delete mode 100644 Makefile.convert-dtsv0
 delete mode 100644 Makefile.dtc
 delete mode 100644 Makefile.utils
 delete mode 100644 libfdt/Makefile.libfdt
 create mode 100644 libfdt/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 delete mode 100644 pylibfdt/Makefile.pylibfdt
 create mode 100644 pylibfdt/meson.build
 delete mode 100644 tests/Makefile.tests
 create mode 100644 tests/meson.build
 create mode 100644 version_gen.h.in

--=20
2.29.0

A message that is not in the archive (sent off-list or not yet received): 20201104194527.986901-1-marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#2 lore raw

PATCH v6 1/4 pylibfdt: allow build out of tree

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.h and output directories.

Other source paths are derived from the location of the setup.py script in the source tree.

--build-lib is changed to be relative to the current directory, instead of relative to setup.py. This has less surprising results!

---
 pylibfdt/Makefile.pylibfdt |  4 ++--
 pylibfdt/setup.py          | 27 +++++++++++++++++++--------
 2 files changed, 21 insertions(+), 10 deletions(-)
pylibfdt/Makefile.pylibfdt +2 -2
index 6866a0b..1b5f236 100644
@@ -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
@@ -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
pylibfdt/setup.py +19 -8
index 53f2bef..ef40f15 100755
@@ -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.29.0

A message that is not in the archive (sent off-list or not yet received): 20201104194527.986901-2-marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#4 lore raw

Re: [PATCH v6 1/4] pylibfdt: allow build out of tree

Quoted 4 lines · On Wed, Nov 4, 2020 at 1:45 PM <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.…

From: Marc-André Lureau <[email protected]>

With meson, we have to support out-of-tree build.

I noticed that meson still builds pylibfdt/libfdt.py and pylibfdt/libfdt_wrap.c in tree. And it makes the result unusable without installing. For example the README instructions don't work:

    $ cd pylibfdt
    $ python3 -c "import libfdt; help(libfdt)"

I tried to fix the in tree part with swig option '-outdir', but that didn't work.

Really what I'm after is what uses need to be supported? I'm looking at getting pip and pypi packaging to work. I'm actually wondering if pylibfdt needs to be so tightly coupled to the build system(s!) and source tree. The dependencies are really just libfdt headers and library which are easily installed either from source or a distro pkg. The '..libfdt/' references are problematic with the packaging tools. The easier route may be a standalone repo with a copy of libfdt.i and a different setup.py.

Rob

A message that is not in the archive (sent off-list or not yet received): CAL_JsqL=panX9EW+41vTwsaWLtJbsY=opPPbwH+nnEGZSVnYsQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#6 lore raw

Re: [PATCH v6 1/4] pylibfdt: allow build out of tree

Quoted 10 lines · Rob Herring
Quoted 4 lines · On Wed, Nov 4, 2020 at 1:45 PM <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.…

From: Marc-André Lureau <[email protected]>

With meson, we have to support out-of-tree build.

I noticed that meson still builds pylibfdt/libfdt.py and pylibfdt/libfdt_wrap.c in tree. And it makes the result unusable without installing. For example the README instructions don't work:

Quoted 5 lines
    $ cd pylibfdt
    $ python3 -c "import libfdt; help(libfdt)"

I tried to fix the in tree part with swig option '-outdir', but that didn't work.

Urgh. This has always fit poorly with the rest of the build system. In addition, I've discovered that with Fedora 35, I now get this scary warning:

PYMOD pylibfdt/_libfdt.so
/usr/lib/python3.10/site-packages/setuptools/dist.py:498: UserWarning: The version specified ('1.6.1-g4eda2590-dirty') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details.
warnings.warn(
make[1]: Leaving directory '/home/dwg/src/dtc'

Merely replacing 'distutils' with 'setuptools' in the code does not fix this.

Quoted 8 lines

Really what I'm after is what uses need to be supported? I'm looking at getting pip and pypi packaging to work. I'm actually wondering if pylibfdt needs to be so tightly coupled to the build system(s!) and source tree. The dependencies are really just libfdt headers and library which are easily installed either from source or a distro pkg. The '..libfdt/' references are problematic with the packaging tools. The easier route may be a standalone repo with a copy of libfdt.i and a different setup.py.

Unfortunately, I don't know enough about either Meson or Python packaging to fix this. Simon?

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
#7 lore raw

Re: [PATCH v6 1/4] pylibfdt: allow build out of tree

Hi,

Quoted 21 lines · David Gibson
Quoted 10 lines · Rob Herring
Quoted 4 lines · On Wed, Nov 4, 2020 at 1:45 PM <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.…

From: Marc-André Lureau <[email protected]>

With meson, we have to support out-of-tree build.

I noticed that meson still builds pylibfdt/libfdt.py and pylibfdt/libfdt_wrap.c in tree. And it makes the result unusable without installing. For example the README instructions don't work:

Quoted 5 lines
    $ cd pylibfdt
    $ python3 -c "import libfdt; help(libfdt)"

I tried to fix the in tree part with swig option '-outdir', but that didn't work.

Urgh. This has always fit poorly with the rest of the build system. In addition, I've discovered that with Fedora 35, I now get this scary warning:

Quoted 7 lines

PYMOD pylibfdt/_libfdt.so
/usr/lib/python3.10/site-packages/setuptools/dist.py:498: UserWarning: The version specified ('1.6.1-g4eda2590-dirty') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details.
warnings.warn(
make[1]: Leaving directory '/home/dwg/src/dtc'

Merely replacing 'distutils' with 'setuptools' in the code does not fix this.

I don't know much about this. Python seems to want to use .' 'instead of '-' but I'm not sure why they decided this so recently.

Quoted 11 lines
Quoted 10 lines

Really what I'm after is what uses need to be supported? I'm looking at getting pip and pypi packaging to work. I'm actually wondering if pylibfdt needs to be so tightly coupled to the build system(s!) and source tree. The dependencies are really just libfdt headers and library which are easily installed either from source or a distro pkg. The '..libfdt/' references are problematic with the packaging tools. The easier route may be a standalone repo with a copy of libfdt.i and a different setup.py.

Quoted 2 lines

Unfortunately, I don't know enough about either Meson or Python packaging to fix this. Simon?

I'm not quite sure what the problem is with pip3, etc. I am not an expert on any of these but can probably find some help if we have a clear problem. Rob, do you have a patch that causes the problem?

I am not keen on splitting the repos as pylibfdt has a source dependency on libfdt.h

Regards,
Simon

A message that is not in the archive (sent off-list or not yet received): CAPnjgZ3zndvzBoAdqsW+n7Ao33nEiRr2CXGcBnm_=XDzGmM1_Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#9 lore raw

Re: [PATCH v6 1/4] pylibfdt: allow build out of tree

Quoted 30 lines · Simon Glass

Hi,

Quoted 26 lines · David Gibson
Quoted 10 lines · Rob Herring
Quoted 4 lines · On Wed, Nov 4, 2020 at 1:45 PM <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.…

From: Marc-André Lureau <[email protected]>

With meson, we have to support out-of-tree build.

I noticed that meson still builds pylibfdt/libfdt.py and pylibfdt/libfdt_wrap.c in tree. And it makes the result unusable without installing. For example the README instructions don't work:

Quoted 5 lines
    $ cd pylibfdt
    $ python3 -c "import libfdt; help(libfdt)"

I tried to fix the in tree part with swig option '-outdir', but that didn't work.

Urgh. This has always fit poorly with the rest of the build system. In addition, I've discovered that with Fedora 35, I now get this scary warning:

PYMOD pylibfdt/_libfdt.so
/usr/lib/python3.10/site-packages/setuptools/dist.py:498: UserWarning: The version specified ('1.6.1-g4eda2590-dirty') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details.
warnings.warn(
make[1]: Leaving directory '/home/dwg/src/dtc'

Quoted 5 lines
Quoted 2 lines

Merely replacing 'distutils' with 'setuptools' in the code does not fix this.

I don't know much about this. Python seems to want to use .' 'instead of '-' but I'm not sure why they decided this so recently.

I'm working on patches for both of these issues.

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines

Really what I'm after is what uses need to be supported? I'm looking at getting pip and pypi packaging to work. I'm actually wondering if pylibfdt needs to be so tightly coupled to the build system(s!) and source tree. The dependencies are really just libfdt headers and library which are easily installed either from source or a distro pkg. The '..libfdt/' references are problematic with the packaging tools. The easier route may be a standalone repo with a copy of libfdt.i and a different setup.py.

Quoted 6 lines
Quoted 2 lines

Unfortunately, I don't know enough about either Meson or Python packaging to fix this. Simon?

I'm not quite sure what the problem is with pip3, etc. I am not an expert on any of these but can probably find some help if we have a clear problem. Rob, do you have a patch that causes the problem?

Python has certain thoughts on what the directory structure looks like and building an sdist can't include something outside of pylibfdt/ (the headers specifically). Basically, this is what needs to work locally for an install from PyPI to work:

./setup.py sdist
pip install -f ./dist/ libfdt

We also need to statically link if we want to create a wheel (python binary) for PyPI. (setuptools has to be used for a wheel)

Quoted 2 lines

I am not keen on splitting the repos as pylibfdt has a source dependency on libfdt.h

Yes, but libfdt.h is part of the ABI and should only change in an ABI compatible way, right? If you really want the version of libfdt you built, you do have to install it AFAICT. I don't think the wrapper will load ../libfdt/libfdt.so.

I think the easiest way to solve these problems is moving setup.py up to the project root and perhaps dropping the pylibfdt parts from make/meson. Then working with the python bits all works 'the Python way'.

Rob

A message that is not in the archive (sent off-list or not yet received): CAL_Jsq+LDmauXEookk4DFiVcEWaGfC_7pxH=B-=N=ear6MzhvA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#11 lore raw

Re: [PATCH v6 1/4] pylibfdt: allow build out of tree

Hi Rob,

Quoted 75 lines · Rob Herring
Quoted 30 lines · Simon Glass

Hi,

Quoted 26 lines · David Gibson
Quoted 10 lines · Rob Herring
Quoted 4 lines · On Wed, Nov 4, 2020 at 1:45 PM <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.…

From: Marc-André Lureau <[email protected]>

With meson, we have to support out-of-tree build.

I noticed that meson still builds pylibfdt/libfdt.py and pylibfdt/libfdt_wrap.c in tree. And it makes the result unusable without installing. For example the README instructions don't work:

Quoted 5 lines
    $ cd pylibfdt
    $ python3 -c "import libfdt; help(libfdt)"

I tried to fix the in tree part with swig option '-outdir', but that didn't work.

Urgh. This has always fit poorly with the rest of the build system. In addition, I've discovered that with Fedora 35, I now get this scary warning:

PYMOD pylibfdt/_libfdt.so
/usr/lib/python3.10/site-packages/setuptools/dist.py:498: UserWarning: The version specified ('1.6.1-g4eda2590-dirty') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details.
warnings.warn(
make[1]: Leaving directory '/home/dwg/src/dtc'

Quoted 5 lines
Quoted 2 lines

Merely replacing 'distutils' with 'setuptools' in the code does not fix this.

I don't know much about this. Python seems to want to use .' 'instead of '-' but I'm not sure why they decided this so recently.

I'm working on patches for both of these issues.

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines

Really what I'm after is what uses need to be supported? I'm looking at getting pip and pypi packaging to work. I'm actually wondering if pylibfdt needs to be so tightly coupled to the build system(s!) and source tree. The dependencies are really just libfdt headers and library which are easily installed either from source or a distro pkg. The '..libfdt/' references are problematic with the packaging tools. The easier route may be a standalone repo with a copy of libfdt.i and a different setup.py.

Quoted 6 lines
Quoted 2 lines

Unfortunately, I don't know enough about either Meson or Python packaging to fix this. Simon?

I'm not quite sure what the problem is with pip3, etc. I am not an expert on any of these but can probably find some help if we have a clear problem. Rob, do you have a patch that causes the problem?

Python has certain thoughts on what the directory structure looks like and building an sdist can't include something outside of pylibfdt/ (the headers specifically). Basically, this is what needs to work locally for an install from PyPI to work:

./setup.py sdist
pip install -f ./dist/ libfdt

We also need to statically link if we want to create a wheel (python binary) for PyPI. (setuptools has to be used for a wheel)

Quoted 2 lines

I am not keen on splitting the repos as pylibfdt has a source dependency on libfdt.h

Yes, but libfdt.h is part of the ABI and should only change in an ABI compatible way, right? If you really want the version of libfdt you built, you do have to install it AFAICT. I don't think the wrapper will load ../libfdt/libfdt.so.

Quoted 4 lines

I think the easiest way to solve these problems is moving setup.py up to the project root and perhaps dropping the pylibfdt parts from make/meson. Then working with the python bits all works 'the Python way'.

That seems OK to me, but can we have the Makefile invoke the Python stuff? How does having a meson option (who uses it?) affect all this?

Regards,
Simon

A message that is not in the archive (sent off-list or not yet received): CAPnjgZ1wEb25Ow2v9K7Jp=1+Q2_6ufQGm+e8TjidPCNH5eNY2w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#13 lore raw

Re: [PATCH v6 1/4] pylibfdt: allow build out of tree

Quoted 79 lines · Simon Glass

Hi Rob,

Quoted 75 lines · Rob Herring
Quoted 30 lines · Simon Glass

Hi,

Quoted 26 lines · David Gibson
Quoted 10 lines · Rob Herring
Quoted 4 lines · On Wed, Nov 4, 2020 at 1:45 PM <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.…

From: Marc-André Lureau <[email protected]>

With meson, we have to support out-of-tree build.

I noticed that meson still builds pylibfdt/libfdt.py and pylibfdt/libfdt_wrap.c in tree. And it makes the result unusable without installing. For example the README instructions don't work:

Quoted 5 lines
    $ cd pylibfdt
    $ python3 -c "import libfdt; help(libfdt)"

I tried to fix the in tree part with swig option '-outdir', but that didn't work.

Urgh. This has always fit poorly with the rest of the build system. In addition, I've discovered that with Fedora 35, I now get this scary warning:

PYMOD pylibfdt/_libfdt.so
/usr/lib/python3.10/site-packages/setuptools/dist.py:498: UserWarning: The version specified ('1.6.1-g4eda2590-dirty') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details.
warnings.warn(
make[1]: Leaving directory '/home/dwg/src/dtc'

Quoted 5 lines
Quoted 2 lines

Merely replacing 'distutils' with 'setuptools' in the code does not fix this.

I don't know much about this. Python seems to want to use .' 'instead of '-' but I'm not sure why they decided this so recently.

I'm working on patches for both of these issues.

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines

Really what I'm after is what uses need to be supported? I'm looking at getting pip and pypi packaging to work. I'm actually wondering if pylibfdt needs to be so tightly coupled to the build system(s!) and source tree. The dependencies are really just libfdt headers and library which are easily installed either from source or a distro pkg. The '..libfdt/' references are problematic with the packaging tools. The easier route may be a standalone repo with a copy of libfdt.i and a different setup.py.

Quoted 6 lines
Quoted 2 lines

Unfortunately, I don't know enough about either Meson or Python packaging to fix this. Simon?

I'm not quite sure what the problem is with pip3, etc. I am not an expert on any of these but can probably find some help if we have a clear problem. Rob, do you have a patch that causes the problem?

Python has certain thoughts on what the directory structure looks like and building an sdist can't include something outside of pylibfdt/ (the headers specifically). Basically, this is what needs to work locally for an install from PyPI to work:

./setup.py sdist
pip install -f ./dist/ libfdt

We also need to statically link if we want to create a wheel (python binary) for PyPI. (setuptools has to be used for a wheel)

Quoted 2 lines

I am not keen on splitting the repos as pylibfdt has a source dependency on libfdt.h

Yes, but libfdt.h is part of the ABI and should only change in an ABI compatible way, right? If you really want the version of libfdt you built, you do have to install it AFAICT. I don't think the wrapper will load ../libfdt/libfdt.so.

Quoted 7 lines
Quoted 4 lines

I think the easiest way to solve these problems is moving setup.py up to the project root and perhaps dropping the pylibfdt parts from make/meson. Then working with the python bits all works 'the Python way'.

That seems OK to me, but can we have the Makefile invoke the Python stuff? How does having a meson option (who uses it?) affect all this?

Everyone. The goal is meson will replace at least the bulk of the makefiles and they just become wrappers. The issue is getting setup.py to do out of tree builds that I mentioned at the start of this thread.

Rob

A message that is not in the archive (sent off-list or not yet received): CAL_Jsq+gtg2md6h3PycEZdXqyqkvYyZ1x1MmShhvPMxV0idZgA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#15 lore raw

Re: [PATCH v6 1/4] pylibfdt: allow build out of tree

Quoted 85 lines · Rob Herring
Quoted 84 lines · Simon Glass

Hi Rob,

Quoted 79 lines · Rob Herring
Quoted 30 lines · Simon Glass

Hi,

Quoted 26 lines · David Gibson
Quoted 10 lines · Rob Herring
Quoted 4 lines · On Wed, Nov 4, 2020 at 1:45 PM <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.…

From: Marc-André Lureau <[email protected]>

With meson, we have to support out-of-tree build.

I noticed that meson still builds pylibfdt/libfdt.py and pylibfdt/libfdt_wrap.c in tree. And it makes the result unusable without installing. For example the README instructions don't work:

Quoted 5 lines
    $ cd pylibfdt
    $ python3 -c "import libfdt; help(libfdt)"

I tried to fix the in tree part with swig option '-outdir', but that didn't work.

Urgh. This has always fit poorly with the rest of the build system. In addition, I've discovered that with Fedora 35, I now get this scary warning:

PYMOD pylibfdt/_libfdt.so
/usr/lib/python3.10/site-packages/setuptools/dist.py:498: UserWarning: The version specified ('1.6.1-g4eda2590-dirty') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details.
warnings.warn(
make[1]: Leaving directory '/home/dwg/src/dtc'

Quoted 5 lines
Quoted 2 lines

Merely replacing 'distutils' with 'setuptools' in the code does not fix this.

I don't know much about this. Python seems to want to use .' 'instead of '-' but I'm not sure why they decided this so recently.

I'm working on patches for both of these issues.

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines

Really what I'm after is what uses need to be supported? I'm looking at getting pip and pypi packaging to work. I'm actually wondering if pylibfdt needs to be so tightly coupled to the build system(s!) and source tree. The dependencies are really just libfdt headers and library which are easily installed either from source or a distro pkg. The '..libfdt/' references are problematic with the packaging tools. The easier route may be a standalone repo with a copy of libfdt.i and a different setup.py.

Quoted 6 lines
Quoted 2 lines

Unfortunately, I don't know enough about either Meson or Python packaging to fix this. Simon?

I'm not quite sure what the problem is with pip3, etc. I am not an expert on any of these but can probably find some help if we have a clear problem. Rob, do you have a patch that causes the problem?

Python has certain thoughts on what the directory structure looks like and building an sdist can't include something outside of pylibfdt/ (the headers specifically). Basically, this is what needs to work locally for an install from PyPI to work:

./setup.py sdist
pip install -f ./dist/ libfdt

We also need to statically link if we want to create a wheel (python binary) for PyPI. (setuptools has to be used for a wheel)

Quoted 2 lines

I am not keen on splitting the repos as pylibfdt has a source dependency on libfdt.h

Yes, but libfdt.h is part of the ABI and should only change in an ABI compatible way, right? If you really want the version of libfdt you built, you do have to install it AFAICT. I don't think the wrapper will load ../libfdt/libfdt.so.

I think the easiest way to solve these problems is moving setup.py up to the project root and perhaps dropping the pylibfdt parts from make/meson. Then working with the python bits all works 'the Python way'.

Quoted 6 lines
Quoted 2 lines

That seems OK to me, but can we have the Makefile invoke the Python stuff? How does having a meson option (who uses it?) affect all this?

Everyone. The goal is meson will replace at least the bulk of the makefiles and they just become wrappers. The issue is getting setup.py to do out of tree builds that I mentioned at the start of this thread.

I'm ok with that, but could you please update the README to include "meson native" build instructions.

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
#16 lore raw

PATCH v6 2/4 build-sys: add meson build

In reply to a message not in the archive

From: 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          | 129 ++++++++++++++++++++++++++++++++++++++++++
 meson_options.txt    |  10 ++++
 pylibfdt/meson.build |  13 +++++
 tests/meson.build    | 131 +++++++++++++++++++++++++++++++++++++++++++
 version_gen.h.in     |   1 +
 6 files changed, 334 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
new file mode 100644
index 0000000..0307ffb
@@ -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 +129 -0

129 lines not on this page · raw message

meson_options.txt new file +10 -0
new file mode 100644
index 0000000..ea59c28
@@ -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
new file mode 100644
index 0000000..96a2865
@@ -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'))
tests/meson.build new file +131 -0

131 lines not on this page · raw message

version_gen.h.in new file +1 -0
new file mode 100644
index 0000000..7771abb
@@ -0,0 +1 @@
+#define DTC_VERSION "DTC @VCS_TAG@"
Signature · 1 line
2.29.0
#17 lore raw

PATCH v6 3/4 travis: install meson

In reply to a message not in the archive

From: Marc-André Lureau <[email protected]>

The next patch is going to switch the build-sys to meson.

---
 .travis.yml | 6 ++++++
 1 file changed, 6 insertions(+)
.travis.yml +6 -0
index a5163de..aad9f68 100644
@@ -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:
Signature · 1 line
2.29.0
#18 lore raw

PATCH v6 4/4 build-sys: replace makefiles to wrap meson/ninja

In reply to a message not in the archive

From: Marc-André Lureau <[email protected]>

---
 Makefile                   | 385 ++-----------------------------------
 Makefile.convert-dtsv0     |  14 --
 Makefile.dtc               |  23 ---
 Makefile.utils             |  31 ---
 README                     |  24 ++-
 libfdt/Makefile.libfdt     |  18 --
 pylibfdt/Makefile.pylibfdt |  30 ---
 tests/Makefile.tests       | 100 ----------
 tests/run_tests.sh         |  10 +-
 9 files changed, 39 insertions(+), 596 deletions(-)
 delete mode 100644 Makefile.convert-dtsv0
 delete mode 100644 Makefile.dtc
 delete mode 100644 Makefile.utils
 delete mode 100644 libfdt/Makefile.libfdt
 delete mode 100644 pylibfdt/Makefile.pylibfdt
 delete mode 100644 tests/Makefile.tests
Makefile +11 -374
index c187d5f..cc3caa6 100644
@@ -3,382 +3,19 @@
 # Device Tree Compiler
 #
 
-#
-# Version information will be constructed in this order:
-# EXTRAVERSION might be "-rc", for example.
-# LOCAL_VERSION is likely from command line.
-# CONFIG_LOCALVERSION from some future config system.
-#
-VERSION = 1
-PATCHLEVEL = 6
-SUBLEVEL = 0
-EXTRAVERSION =
-LOCAL_VERSION =
-CONFIG_LOCALVERSION =
-
-# Control the assumptions made (e.g. risking security issues) in the code.
-# See libfdt_internal.h for details
-ASSUME_MASK ?= 0
-
-CPPFLAGS = -I libfdt -I . -DFDT_ASSUME_MASK=$(ASSUME_MASK)
-WARNINGS = -Wall -Wpointer-arith -Wcast-qual -Wnested-externs \
-	-Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wshadow
-CFLAGS = -g -Os $(SHAREDLIB_CFLAGS) -Werror $(WARNINGS) $(EXTRA_CFLAGS)
-
-BISON = bison
-LEX = flex
-SWIG = swig
-PKG_CONFIG ?= pkg-config
-PYTHON ?= python3
-
-INSTALL = /usr/bin/install
-INSTALL_PROGRAM = $(INSTALL)
-INSTALL_LIB = $(INSTALL)
-INSTALL_DATA = $(INSTALL) -m 644
-INSTALL_SCRIPT = $(INSTALL)
-DESTDIR =
-PREFIX = $(HOME)
-BINDIR = $(PREFIX)/bin
-LIBDIR = $(PREFIX)/lib
-INCLUDEDIR = $(PREFIX)/include
-
-HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
-	    sed -e 's/\(cygwin\|msys\).*/\1/')
-
-NO_PYTHON ?= 0
-
-NO_VALGRIND := $(shell $(PKG_CONFIG) --exists valgrind; echo $$?)
-ifeq ($(NO_VALGRIND),1)
-	CPPFLAGS += -DNO_VALGRIND
-else
-	CFLAGS += $(shell $(PKG_CONFIG) --cflags valgrind)
-endif
-
-NO_YAML := $(shell $(PKG_CONFIG) --exists yaml-0.1; echo $$?)
-ifeq ($(NO_YAML),1)
-	CFLAGS += -DNO_YAML
-else
-	LDLIBS_dtc += $(shell $(PKG_CONFIG) --libs yaml-0.1)
-	CFLAGS += $(shell $(PKG_CONFIG) --cflags yaml-0.1)
-endif
-
-ifeq ($(HOSTOS),darwin)
-SHAREDLIB_EXT     = dylib
-SHAREDLIB_CFLAGS  = -fPIC
-SHAREDLIB_LDFLAGS = -fPIC -dynamiclib -Wl,-install_name -Wl,
-else ifeq ($(HOSTOS),$(filter $(HOSTOS),msys cygwin))
-SHAREDLIB_EXT     = so
-SHAREDLIB_CFLAGS  =
-SHAREDLIB_LDFLAGS = -shared -Wl,--version-script=$(LIBFDT_version) -Wl,-soname,
-else
-SHAREDLIB_EXT     = so
-SHAREDLIB_CFLAGS  = -fPIC
-SHAREDLIB_LDFLAGS = -fPIC -shared -Wl,--version-script=$(LIBFDT_version) -Wl,-soname,
-endif
-
-#
-# Overall rules
-#
-ifdef V
-VECHO = :
-else
-VECHO = echo "	"
-ARFLAGS = rc
-.SILENT:
-endif
-
-NODEPTARGETS = clean
-ifeq ($(MAKECMDGOALS),)
-DEPTARGETS = all
-else
-DEPTARGETS = $(filter-out $(NODEPTARGETS),$(MAKECMDGOALS))
-endif
-
-#
-# Rules for versioning
-#
-
-DTC_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
-VERSION_FILE = version_gen.h
-
-CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
-	  else if [ -x /bin/bash ]; then echo /bin/bash; \
-	  else echo sh; fi ; fi)
-
-nullstring :=
-space	:= $(nullstring) # end of line
-
-localver_config = $(subst $(space),, $(string) \
-			      $(patsubst "%",%,$(CONFIG_LOCALVERSION)))
-
-localver_cmd = $(subst $(space),, $(string) \
-			      $(patsubst "%",%,$(LOCALVERSION)))
-
-localver_scm = $(shell $(CONFIG_SHELL) ./scripts/setlocalversion)
-localver_full  = $(localver_config)$(localver_cmd)$(localver_scm)
-
-dtc_version = $(DTC_VERSION)$(localver_full)
-
-# Contents of the generated version file.
-define filechk_version
-	(echo "#define DTC_VERSION \"DTC $(dtc_version)\""; )
-endef
-
-define filechk
-	set -e;					\
-	echo '	CHK $@';			\
-	mkdir -p $(dir $@);			\
-	$(filechk_$(1)) < $< > [email protected];		\
-	if [ -r $@ ] && cmp -s $@ [email protected]; then	\
-		rm -f [email protected];			\
-	else					\
-		echo '	UPD $@';		\
-		mv -f [email protected] $@;		\
-	fi;
-endef
-
-
-include Makefile.convert-dtsv0
-include Makefile.dtc
-include Makefile.utils
-
-BIN += convert-dtsv0
-BIN += dtc
-BIN += fdtdump
-BIN += fdtget
-BIN += fdtput
-BIN += fdtoverlay
-
-SCRIPTS = dtdiff
-
-all: $(BIN) libfdt
-
-# We need both Python and swig to build/install pylibfdt.
-# This builds the given make ${target} if those deps are found.
-check_python_deps = \
-	if $(PKG_CONFIG) --cflags $(PYTHON) >/dev/null 2>&1; then \
-		if which swig >/dev/null 2>&1; then \
-			can_build=yes; \
-		fi; \
-	fi; \
-	if [ "$${can_build}" = "yes" ]; then \
-		$(MAKE) $${target}; \
-	else \
-		echo "\#\# Skipping pylibfdt (install python dev and swig to build)"; \
-	fi ;
-
-.PHONY: maybe_pylibfdt
-maybe_pylibfdt: FORCE
-	target=pylibfdt; $(check_python_deps)
-
-ifeq ($(NO_PYTHON),0)
-all: maybe_pylibfdt
-endif
-
-
-ifneq ($(DEPTARGETS),)
-ifneq ($(MAKECMDGOALS),libfdt)
--include $(DTC_OBJS:%.o=%.d)
--include $(CONVERT_OBJS:%.o=%.d)
--include $(FDTDUMP_OBJS:%.o=%.d)
--include $(FDTGET_OBJS:%.o=%.d)
--include $(FDTPUT_OBJS:%.o=%.d)
--include $(FDTOVERLAY_OBJS:%.o=%.d)
-endif
-endif
-
-
-
-#
-# Rules for libfdt
-#
-LIBFDT_dir = libfdt
-LIBFDT_archive = $(LIBFDT_dir)/libfdt.a
-LIBFDT_lib = $(LIBFDT_dir)/$(LIBFDT_LIB)
-LIBFDT_include = $(addprefix $(LIBFDT_dir)/,$(LIBFDT_INCLUDES))
-LIBFDT_version = $(addprefix $(LIBFDT_dir)/,$(LIBFDT_VERSION))
-
-include $(LIBFDT_dir)/Makefile.libfdt
-
-.PHONY: libfdt
-libfdt: $(LIBFDT_archive) $(LIBFDT_lib)
-
-$(LIBFDT_archive): $(addprefix $(LIBFDT_dir)/,$(LIBFDT_OBJS))
-
-$(LIBFDT_lib): $(addprefix $(LIBFDT_dir)/,$(LIBFDT_OBJS)) $(LIBFDT_version)
-	@$(VECHO) LD $@
-	$(CC) $(LDFLAGS) $(SHAREDLIB_LDFLAGS)$(LIBFDT_soname) -o $(LIBFDT_lib) \
-		$(addprefix $(LIBFDT_dir)/,$(LIBFDT_OBJS))
-	ln -sf $(LIBFDT_LIB) $(LIBFDT_dir)/$(LIBFDT_soname)
-
-ifneq ($(DEPTARGETS),)
--include $(LIBFDT_OBJS:%.o=$(LIBFDT_dir)/%.d)
-endif
-
-# This stops make from generating the lex and bison output during
-# auto-dependency computation, but throwing them away as an
-# intermediate target and building them again "for real"
-.SECONDARY: $(DTC_GEN_SRCS) $(CONVERT_GEN_SRCS)
-
-install-bin: all $(SCRIPTS)
-	@$(VECHO) INSTALL-BIN
-	$(INSTALL) -d $(DESTDIR)$(BINDIR)
-	$(INSTALL_PROGRAM) $(BIN) $(DESTDIR)$(BINDIR)
-	$(INSTALL_SCRIPT) $(SCRIPTS) $(DESTDIR)$(BINDIR)
-
-install-lib: all
-	@$(VECHO) INSTALL-LIB
-	$(INSTALL) -d $(DESTDIR)$(LIBDIR)
-	$(INSTALL_LIB) $(LIBFDT_lib) $(DESTDIR)$(LIBDIR)
-	ln -sf $(notdir $(LIBFDT_lib)) $(DESTDIR)$(LIBDIR)/$(LIBFDT_soname)
-	ln -sf $(LIBFDT_soname) $(DESTDIR)$(LIBDIR)/libfdt.$(SHAREDLIB_EXT)
-	$(INSTALL_DATA) $(LIBFDT_archive) $(DESTDIR)$(LIBDIR)
-
-install-includes:
-	@$(VECHO) INSTALL-INC
-	$(INSTALL) -d $(DESTDIR)$(INCLUDEDIR)
-	$(INSTALL_DATA) $(LIBFDT_include) $(DESTDIR)$(INCLUDEDIR)
-
-install: install-bin install-lib install-includes
-
-.PHONY: maybe_install_pylibfdt
-maybe_install_pylibfdt: FORCE
-	target=install_pylibfdt; $(check_python_deps)
-
-ifeq ($(NO_PYTHON),0)
-install: maybe_install_pylibfdt
-endif
-
-$(VERSION_FILE): Makefile FORCE
-	$(call filechk,version)
-
-
-dtc: $(DTC_OBJS)
-
-convert-dtsv0: $(CONVERT_OBJS)
-	@$(VECHO) LD $@
-	$(LINK.c) -o $@ $^
-
-fdtdump:	$(FDTDUMP_OBJS)
-
-fdtget:	$(FDTGET_OBJS) $(LIBFDT_lib)
-
-fdtput:	$(FDTPUT_OBJS) $(LIBFDT_lib)
-
-fdtoverlay: $(FDTOVERLAY_OBJS) $(LIBFDT_lib)
-
-dist:
-	git archive --format=tar --prefix=dtc-$(dtc_version)/ HEAD \
-		> ../dtc-$(dtc_version).tar
-	cat ../dtc-$(dtc_version).tar | \
-		gzip -9 > ../dtc-$(dtc_version).tar.gz
-
-
-#
-# Rules for pylibfdt
-#
-PYLIBFDT_dir = pylibfdt
-
-include $(PYLIBFDT_dir)/Makefile.pylibfdt
-
-.PHONY: pylibfdt
-pylibfdt: $(PYLIBFDT_dir)/_libfdt.so
-
-#
-# Release signing and uploading
-# This is for maintainer convenience, don't try this at home.
-#
-ifeq ($(MAINTAINER),y)
-GPG = gpg2
-KUP = kup
-KUPDIR = /pub/software/utils/dtc
-
-kup: dist
-	$(GPG) --detach-sign --armor -o ../dtc-$(dtc_version).tar.sign \
-		../dtc-$(dtc_version).tar
-	$(KUP) put ../dtc-$(dtc_version).tar.gz ../dtc-$(dtc_version).tar.sign \
-		$(KUPDIR)/dtc-$(dtc_version).tar.gz
-endif
-
-tags: FORCE
-	rm -f tags
-	find . \( -name tests -type d -prune \) -o \
-	       \( ! -name '*.tab.[ch]' ! -name '*.lex.c' \
-	       -name '*.[chly]' -type f -print \) | xargs ctags -a
-
-#
-# Testsuite rules
-#
-TESTS_PREFIX=tests/
-
-TESTS_BIN += dtc
-TESTS_BIN += convert-dtsv0
-TESTS_BIN += fdtput
-TESTS_BIN += fdtget
-TESTS_BIN += fdtdump
-TESTS_BIN += fdtoverlay
-ifeq ($(NO_PYTHON),0)
-TESTS_PYLIBFDT += maybe_pylibfdt
-endif
-
-ifneq ($(MAKECMDGOALS),libfdt)
-include tests/Makefile.tests
-endif
-
-#
-# Clean rules
-#
-STD_CLEANFILES = *~ *.o *.$(SHAREDLIB_EXT) *.d *.a *.i *.s core a.out vgcore.* \
-	*.tab.[ch] *.lex.c *.output
-
-clean: libfdt_clean pylibfdt_clean tests_clean
-	@$(VECHO) CLEAN
-	rm -f $(STD_CLEANFILES)
-	rm -f $(VERSION_FILE)
-	rm -f $(BIN)
-	rm -f dtc-*.tar dtc-*.tar.sign dtc-*.tar.asc
-
-#
-# Generic compile rules
-#
-%: %.o
-	@$(VECHO) LD $@
-	$(LINK.c) -o $@ $^ $(LDLIBS_$*)
-
-%.o: %.c
-	@$(VECHO) CC $@
-	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
-
-%.o: %.S
-	@$(VECHO) AS $@
-	$(CC) $(CPPFLAGS) $(AFLAGS) -D__ASSEMBLY__ -o $@ -c $<
-
-%.d: %.c
-	@$(VECHO) DEP $<
-	$(CC) $(CPPFLAGS) $(CFLAGS) -MM -MG -MT "$*.o $@" $< > $@
-
-%.d: %.S
-	@$(VECHO) DEP $<
-	$(CC) $(CPPFLAGS) -MM -MG -MT "$*.o $@" $< > $@
-
-%.i:	%.c
-	@$(VECHO) CPP $@
-	$(CC) $(CPPFLAGS) -E $< > $@
+BUILD_DIR=build
 
-%.s:	%.c
-	@$(VECHO) CC -S $@
-	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -S $<
+all: $(BUILD_DIR)/build.ninja
+	ninja -C build
 
-%.a:
-	@$(VECHO) AR $@
-	$(AR) $(ARFLAGS) $@ $^
+$(BUILD_DIR)/build.ninja:
+	meson $(BUILD_DIR)
 
-%.lex.c: %.l
-	@$(VECHO) LEX $@
-	$(LEX) -o$@ $<
+check:
+	meson test -C $(BUILD_DIR) -v
 
-%.tab.c %.tab.h %.output: %.y
-	@$(VECHO) BISON $@
-	$(BISON) -b $(basename $(basename $@)) -d $<
+checkm:
+	WITH_VALGRIND=1 meson test -C $(BUILD_DIR) -v
 
-FORCE:
+%::
+	ninja -C $(BUILD_DIR) $@
Makefile.convert-dtsv0 deleted +0 -14
deleted file mode 100644
index c12ed40..0000000
@@ -1,14 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-or-later
-#
-# This is not a complete Makefile of itself.
-# Instead, it is designed to be easily embeddable
-# into other systems of Makefiles.
-#
-
-CONVERT_SRCS = \
-	srcpos.c \
-	util.c
-
-CONVERT_GEN_SRCS = convert-dtsv0-lexer.lex.c
-
-CONVERT_OBJS = $(CONVERT_SRCS:%.c=%.o) $(CONVERT_GEN_SRCS:%.c=%.o)
Makefile.dtc deleted +0 -23
deleted file mode 100644
index 9c467b0..0000000
@@ -1,23 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-or-later
-# Makefile.dtc
-#
-# This is not a complete Makefile of itself.  Instead, it is designed to
-# be easily embeddable into other systems of Makefiles.
-#
-DTC_SRCS = \
-	checks.c \
-	data.c \
-	dtc.c \
-	flattree.c \
-	fstree.c \
-	livetree.c \
-	srcpos.c \
-	treesource.c \
-	util.c
-
-ifneq ($(NO_YAML),1)
-DTC_SRCS += yamltree.c
-endif
-
-DTC_GEN_SRCS = dtc-lexer.lex.c dtc-parser.tab.c
-DTC_OBJS = $(DTC_SRCS:%.c=%.o) $(DTC_GEN_SRCS:%.c=%.o)
Makefile.utils deleted +0 -31
deleted file mode 100644
index 9436b34..0000000
@@ -1,31 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-or-later
-#
-# This is not a complete Makefile of itself.  Instead, it is designed to
-# be easily embeddable into other systems of Makefiles.
-#
-
-FDTDUMP_SRCS = \
-	fdtdump.c \
-	util.c
-
-FDTDUMP_OBJS = $(FDTDUMP_SRCS:%.c=%.o)
-
-
-FDTGET_SRCS = \
-	fdtget.c \
-	util.c
-
-FDTGET_OBJS = $(FDTGET_SRCS:%.c=%.o)
-
-
-FDTPUT_SRCS = \
-	fdtput.c \
-	util.c
-
-FDTPUT_OBJS = $(FDTPUT_SRCS:%.c=%.o)
-
-FDTOVERLAY_SRCS = \
-	fdtoverlay.c \
-	util.c
-
-FDTOVERLAY_OBJS = $(FDTOVERLAY_SRCS:%.c=%.o)
README +19 -5
index 9465ee5..68a06f6 100644
@@ -7,6 +7,21 @@ DTC and LIBFDT are maintained by:
 David Gibson <[email protected]>
 Jon Loeliger <jdl-CYoMK+44s/[email protected]>
 
+Building
+--------
+
+This project is built with meson. See the manual for detailed usages:
+https://mesonbuild.com/Running-Meson.html
+
+In short, from the source directory, you can configure, build and test the
+project with those commands:
+$ meson builddir
+$ ninja -C builddir
+$ ninja -C builddir test
+
+For convenience, a Makefile wraps meson for you with the regular "make", "make
+check" and "make install" targets. Although further build tweaking will require
+you to invoke meson manually.
 
 Python library
 --------------
@@ -58,13 +73,12 @@ also install via the Makefile if you like, but the above is more common.
 
 To install both libfdt and pylibfdt you can use:
 
-    make install [SETUP_PREFIX=/path/to/install_dir] \
-            [PREFIX=/path/to/install_dir]
+    meson -C builddir install
 
 To disable building the python library, even if swig and Python are available,
 use:
 
-    make NO_PYTHON=1
+    meson configure builddir -Dpython=disabled
 
 
 More work remains to support all of libfdt, including access to numeric
@@ -74,8 +88,8 @@ values.
 Tests
 -----
 
-Test files are kept in the tests/ directory. Use 'make check' to build and run
-all tests.
+Test files are kept in the tests/ directory. Use 'ninja test' to build and run
+all tests (or 'make check' in the source directory).
 
 If you want to adjust a test file, be aware that tree_tree1.dts is compiled
 and checked against a binary tree from assembler macros in trees.S. So
libfdt/Makefile.libfdt deleted +0 -18
deleted file mode 100644
index b6d8fc0..0000000
@@ -1,18 +0,0 @@
-# SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
-# Makefile.libfdt
-#
-# This is not a complete Makefile of itself.  Instead, it is designed to
-# be easily embeddable into other systems of Makefiles.
-#
-LIBFDT_soname = libfdt.$(SHAREDLIB_EXT).1
-LIBFDT_INCLUDES = fdt.h libfdt.h libfdt_env.h
-LIBFDT_VERSION = version.lds
-LIBFDT_SRCS = fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c fdt_empty_tree.c \
-	fdt_addresses.c fdt_overlay.c fdt_check.c
-LIBFDT_OBJS = $(LIBFDT_SRCS:%.c=%.o)
-LIBFDT_LIB = libfdt-$(DTC_VERSION).$(SHAREDLIB_EXT)
-
-libfdt_clean:
-	@$(VECHO) CLEAN "(libfdt)"
-	rm -f $(STD_CLEANFILES:%=$(LIBFDT_dir)/%)
-	rm -f $(LIBFDT_dir)/$(LIBFDT_soname)
pylibfdt/Makefile.pylibfdt deleted +0 -30
deleted file mode 100644
index 1b5f236..0000000
@@ -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 = build __pycache__
-PYLIBFDT_CLEANDIRS = $(PYLIBFDT_CLEANDIRS_L:%=$(PYLIBFDT_dir)/%)
-
-SETUP = $(PYLIBFDT_dir)/setup.py
-SETUPFLAGS = --top-builddir .
-
-ifndef V
-SETUPFLAGS += --quiet
-endif
-
-$(PYMODULE): $(PYLIBFDT_srcs) $(LIBFDT_archive) $(SETUP) $(VERSION_FILE)
-	@$(VECHO) PYMOD $@
-	$(PYTHON) $(SETUP) $(SETUPFLAGS) build_ext --build-lib=$(PYLIBFDT_dir)
-
-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)
tests/Makefile.tests deleted +0 -100

100 lines not on this page · raw message

tests/run_tests.sh +9 -1
index 294585b..535f6e0 100755
@@ -1027,6 +1027,10 @@ pylibfdt_tests () {
     tot_tests=$((tot_tests + $total_tests))
 }
 
+setup_valgrind () {
+    VALGRIND="valgrind --tool=memcheck -q --error-exitcode=$VGCODE"
+}
+
 while getopts "vt:me" ARG ; do
     case $ARG in
 	"v")
@@ -1036,7 +1040,7 @@ while getopts "vt:me" ARG ; do
 	    TESTSETS=$OPTARG
 	    ;;
 	"m")
-	    VALGRIND="valgrind --tool=memcheck -q --error-exitcode=$VGCODE"
+	    setup_valgrind
 	    ;;
 	"e")
 	    STOP_ON_FAIL=1
@@ -1044,6 +1048,10 @@ while getopts "vt:me" ARG ; do
     esac
 done
 
+if [ -n "$WITH_VALGRIND" ]; then
+    setup_valgrind
+fi
+
 if [ -z "$TESTSETS" ]; then
     TESTSETS="libfdt utilfdt dtc dtbs_equal fdtget fdtput fdtdump fdtoverlay"
 
Signature · 1 line
2.29.0
#19 lore raw
In reply to a message not in the archive

Hi David,

Quoted 21 lines · On Wed, Nov 4, 2020 at 11:45 PM <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public…

From: Marc-André Lureau <[email protected]>

Hi

This series switches the build system to meson. The main reason for this, bes= ide
using a more modern and simpler build system, is to enable subproject() suppo= rt
in QEMU (atm, QEMU embedds a minimal meson build itself).

v6:
- add "build-sys: replace makefiles to wrap meson/ninja", addressing concerns about meson usage, and replacing the old build system.
- a few minor fixes to meson.build files (warnings and such)

v5:
- squashed --build-lib change with "pylibfdt: allow build out of tree" as the two are actually related

Quoted 4 lines

v4:
- made setup.py --top-builddir option default to CWD
- extend commit messages
- rebased

Apparently you committed some patches from v4. Was this intentional?

Quoted 54 lines

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=C3=A9 Lureau (4):
pylibfdt: allow build out of tree
build-sys: add meson build
travis: install meson
build-sys: replace makefiles to wrap meson/ninja

 .travis.yml                |   6 +
 Makefile                   | 385 ++-----------------------------------
 Makefile.convert-dtsv0     |  14 --
 Makefile.dtc               |  23 ---
 Makefile.utils             |  31 ---
 README                     |  24 ++-
 libfdt/Makefile.libfdt     |  18 --
 libfdt/meson.build         |  50 +++++
 meson.build                | 129 +++++++++++++
 meson_options.txt          |  10 +
 pylibfdt/Makefile.pylibfdt |  30 ---
 pylibfdt/meson.build       |  13 ++
 pylibfdt/setup.py          |  27 ++-
 tests/Makefile.tests       | 100 ----------
 tests/meson.build          | 131 +++++++++++++
 tests/run_tests.sh         |  10 +-
 version_gen.h.in           |   1 +
 17 files changed, 398 insertions(+), 604 deletions(-)
 delete mode 100644 Makefile.convert-dtsv0
 delete mode 100644 Makefile.dtc
 delete mode 100644 Makefile.utils
 delete mode 100644 libfdt/Makefile.libfdt
 create mode 100644 libfdt/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 delete mode 100644 pylibfdt/Makefile.pylibfdt
 create mode 100644 pylibfdt/meson.build
 delete mode 100644 tests/Makefile.tests
 create mode 100644 tests/meson.build
 create mode 100644 version_gen.h.in

--=20
2.29.0

A message that is not in the archive (sent off-list or not yet received): CAMxuvazBvmGo+SXREbzq3Yp3=CYbW8B9M67P5oS1ttdJBwRQfA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#21 lore raw
Quoted 24 lines · Marc-André Lureau

Hi David,

Quoted 21 lines · On Wed, Nov 4, 2020 at 11:45 PM <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public…

From: Marc-André Lureau <[email protected]>

Hi

This series switches the build system to meson. The main reason for this, bes= ide
using a more modern and simpler build system, is to enable subproject() suppo= rt
in QEMU (atm, QEMU embedds a minimal meson build itself).

v6:
- add "build-sys: replace makefiles to wrap meson/ninja", addressing concerns about meson usage, and replacing the old build system.
- a few minor fixes to meson.build files (warnings and such)

v5:
- squashed --build-lib change with "pylibfdt: allow build out of tree" as the two are actually related

Quoted 6 lines
Quoted 4 lines

v4:
- made setup.py --top-builddir option default to CWD
- extend commit messages
- rebased

Apparently you committed some patches from v4. Was this intentional?

Uh, no, not really - I probably missed the newer versions at the time.

They're in the non-rebasing tree now, so you'll need to rebase whatever updates where in v6 on top of those, sorry.

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