devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 0/4] Switch to meson build system
@ 2020-11-04 19:45 marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA
       [not found] ` <20201104194527.986901-1-marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA @ 2020-11-04 19:45 UTC (permalink / raw)
  To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA
  Cc: david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+, Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

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



^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v6 1/4] pylibfdt: allow build out of tree
       [not found] ` <20201104194527.986901-1-marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2020-11-04 19:45   ` marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA
       [not found]     ` <20201104194527.986901-2-marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  2020-11-04 19:45   ` [PATCH v6 2/4] build-sys: add meson build marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA
                     ` (3 subsequent siblings)
  4 siblings, 1 reply; 14+ messages in thread
From: marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA @ 2020-11-04 19:45 UTC (permalink / raw)
  To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA
  Cc: david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+, Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

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!

Signed-off-by: Marc-André Lureau <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 pylibfdt/Makefile.pylibfdt |  4 ++--
 pylibfdt/setup.py          | 27 +++++++++++++++++++--------
 2 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/pylibfdt/Makefile.pylibfdt b/pylibfdt/Makefile.pylibfdt
index 6866a0b..1b5f236 100644
--- a/pylibfdt/Makefile.pylibfdt
+++ b/pylibfdt/Makefile.pylibfdt
@@ -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
diff --git a/pylibfdt/setup.py b/pylibfdt/setup.py
index 53f2bef..ef40f15 100755
--- a/pylibfdt/setup.py
+++ b/pylibfdt/setup.py
@@ -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 <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>',
     description='Python binding for libfdt',
     ext_modules=[libfdt_module],
+    package_dir={'': srcdir},
     py_modules=['libfdt'],
 )
-- 
2.29.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v6 2/4] build-sys: add meson build
       [not found] ` <20201104194527.986901-1-marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  2020-11-04 19:45   ` [PATCH v6 1/4] pylibfdt: allow build out of tree marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA
@ 2020-11-04 19:45   ` marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA
  2020-11-04 19:45   ` [PATCH v6 3/4] travis: install meson marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA @ 2020-11-04 19:45 UTC (permalink / raw)
  To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA
  Cc: david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+, Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

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)

Signed-off-by: Marc-André Lureau <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 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

diff --git a/libfdt/meson.build b/libfdt/meson.build
new file mode 100644
index 0000000..0307ffb
--- /dev/null
+++ b/libfdt/meson.build
@@ -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',
+)
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..b23ea1b
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,129 @@
+project('dtc', 'c',
+  version: '1.6.0',
+  license: ['GPL2+', 'BSD-2'],
+  default_options: 'werror=true',
+)
+
+cc = meson.get_compiler('c')
+
+add_project_arguments(
+  cc.get_supported_arguments([
+    '-Wpointer-arith',
+    '-Wcast-qual',
+    '-Wnested-externs',
+    '-Wstrict-prototypes',
+    '-Wmissing-prototypes',
+    '-Wredundant-decls',
+    '-Wshadow'
+  ]),
+  language: 'c'
+)
+
+if host_machine.system() == 'windows'
+  add_project_arguments(
+    '-D__USE_MINGW_ANSI_STDIO=1',
+    language: 'c'
+  )
+endif
+
+add_project_arguments(
+  '-DFDT_ASSUME_MASK=' + get_option('assume-mask').to_string(),
+  language: 'c'
+)
+
+yamltree = 'yamltree.c'
+yaml = dependency('yaml-0.1', required: get_option('yaml'))
+if not yaml.found()
+  add_project_arguments('-DNO_YAML', language: 'c')
+  yamltree = []
+endif
+
+valgrind = dependency('valgrind', required: get_option('valgrind'))
+if not valgrind.found()
+  add_project_arguments('-DNO_VALGRIND', language: 'c')
+endif
+
+py = import('python')
+py = py.find_installation(required: get_option('python'))
+swig = find_program('swig', required: get_option('python'))
+
+version_gen_h = vcs_tag(
+  input: 'version_gen.h.in',
+  output: 'version_gen.h',
+)
+
+subdir('libfdt')
+
+if get_option('tools')
+  flex = find_program('flex', required: true)
+  bison = find_program('bison', required: true)
+
+  util_dep = declare_dependency(
+    sources: ['util.c', version_gen_h],
+    include_directories: '.',
+    dependencies: libfdt_dep
+  )
+
+  lgen = generator(
+    flex,
+    output: '@PLAINNAME@.lex.c',
+    arguments: ['-o', '@OUTPUT@', '@INPUT@'],
+  )
+
+  pgen = generator(
+    bison,
+    output: ['@BASENAME@.tab.c', '@BASENAME@.tab.h'],
+    arguments: ['@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@'],
+  )
+
+  if cc.check_header('fnmatch.h')
+    executable(
+      'convert-dtsv0',
+      [
+        lgen.process('convert-dtsv0-lexer.l'),
+        'srcpos.c',
+      ],
+      dependencies: util_dep,
+      install: true,
+    )
+  endif
+
+  executable(
+    'dtc',
+    [
+      lgen.process('dtc-lexer.l'),
+      pgen.process('dtc-parser.y'),
+      'checks.c',
+      'data.c',
+      'dtc.c',
+      'flattree.c',
+      'fstree.c',
+      'livetree.c',
+      'srcpos.c',
+      'treesource.c',
+      yamltree,
+    ],
+    dependencies: [util_dep, yaml],
+    install: true,
+  )
+
+  foreach e: ['fdtdump', 'fdtget', 'fdtput', 'fdtoverlay']
+    executable(e, files(e + '.c'), dependencies: util_dep, install: true)
+  endforeach
+
+  install_data(
+    'dtdiff',
+    install_dir: get_option('prefix') / get_option('bindir'),
+    install_mode: 'rwxr-xr-x',
+  )
+endif
+
+if not meson.is_cross_build()
+  if py.found() and swig.found()
+    subdir('pylibfdt')
+  endif
+
+  if get_option('tools')
+    subdir('tests')
+  endif
+endif
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..ea59c28
--- /dev/null
+++ b/meson_options.txt
@@ -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')
diff --git a/pylibfdt/meson.build b/pylibfdt/meson.build
new file mode 100644
index 0000000..96a2865
--- /dev/null
+++ b/pylibfdt/meson.build
@@ -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'))
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..fa06824
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,131 @@
+trees = static_library('trees', files('trees.S'), c_args: '-D__ASSEMBLY__',
+                       include_directories: libfdt_inc)
+
+dumptrees = executable('dumptrees', files('dumptrees.c'),
+                       link_with: trees, dependencies: libfdt_dep)
+
+dumptrees_dtb = custom_target(
+  'dumptrees',
+  command: [dumptrees, meson.current_build_dir()],
+  output: [
+    'test_tree1.dtb',
+    'bad_node_char.dtb',
+    'bad_node_format.dtb',
+    'bad_prop_char.dtb',
+    'ovf_size_strings.dtb',
+    'truncated_property.dtb',
+    'truncated_string.dtb',
+    'truncated_memrsv.dtb',
+  ]
+)
+
+testutil_dep = declare_dependency(sources: ['testutils.c'], link_with: trees)
+
+tests = [
+  'add_subnode_with_nops',
+  'addr_size_cells',
+  'addr_size_cells2',
+  'appendprop1',
+  'appendprop2',
+  'appendprop_addrrange',
+  'boot-cpuid',
+  'char_literal',
+  'check_full',
+  'check_header',
+  'check_path',
+  'del_node',
+  'del_property',
+  'dtb_reverse',
+  'dtbs_equal_ordered',
+  'dtbs_equal_unordered',
+  'extra-terminating-null',
+  'find_property',
+  'fs_tree1',
+  'get_alias',
+  'get_mem_rsv',
+  'get_name',
+  'get_path',
+  'get_phandle',
+  'get_prop_offset',
+  'getprop',
+  'incbin',
+  'integer-expressions',
+  'mangle-layout',
+  'move_and_save',
+  'node_check_compatible',
+  'node_offset_by_compatible',
+  'node_offset_by_phandle',
+  'node_offset_by_prop_value',
+  'nop_node',
+  'nop_property',
+  'nopulate',
+  'notfound',
+  'open_pack',
+  'overlay',
+  'overlay_bad_fixup',
+  'parent_offset',
+  'path-references',
+  'path_offset',
+  'path_offset_aliases',
+  'phandle_format',
+  'property_iterate',
+  'propname_escapes',
+  'references',
+  'root_node',
+  'rw_oom',
+  'rw_tree1',
+  'set_name',
+  'setprop',
+  'setprop_inplace',
+  'sized_cells',
+  'string_escapes',
+  'stringlist',
+  'subnode_iterate',
+  'subnode_offset',
+  'supernode_atdepth_offset',
+  'sw_states',
+  'sw_tree1',
+  'utilfdt_test',
+]
+
+tests += [
+  'truncated_memrsv',
+  'truncated_property',
+  'truncated_string',
+]
+
+dl = cc.find_library('dl', required: false)
+if dl.found()
+  tests += [
+    'asm_tree_dump',
+    'value-labels',
+  ]
+endif
+
+foreach t: tests
+  executable(t, files(t + '.c'), dependencies: [testutil_dep, util_dep, libfdt_dep, dl])
+endforeach
+
+run_tests = find_program('run_tests.sh')
+
+env = []
+if not py.found()
+  env += 'NO_PYTHON=1'
+else
+  env += [
+    'PYTHON=' + py.path(),
+    'PYTHONPATH=' + meson.source_root() / 'pylibfdt',
+  ]
+endif
+if not yaml.found()
+  env += 'NO_YAML=1'
+endif
+
+test(
+  'run-test',
+  run_tests,
+  workdir: meson.current_build_dir(),
+  depends: dumptrees_dtb,
+  env: env,
+  timeout: 1800, # mostly for valgrind
+)
diff --git a/version_gen.h.in b/version_gen.h.in
new file mode 100644
index 0000000..7771abb
--- /dev/null
+++ b/version_gen.h.in
@@ -0,0 +1 @@
+#define DTC_VERSION "DTC @VCS_TAG@"
-- 
2.29.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v6 3/4] travis: install meson
       [not found] ` <20201104194527.986901-1-marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  2020-11-04 19:45   ` [PATCH v6 1/4] pylibfdt: allow build out of tree marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA
  2020-11-04 19:45   ` [PATCH v6 2/4] build-sys: add meson build marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA
@ 2020-11-04 19:45   ` marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA
  2020-11-04 19:45   ` [PATCH v6 4/4] build-sys: replace makefiles to wrap meson/ninja marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA
  2020-11-26 12:39   ` [PATCH v6 0/4] Switch to meson build system Marc-André Lureau
  4 siblings, 0 replies; 14+ messages in thread
From: marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA @ 2020-11-04 19:45 UTC (permalink / raw)
  To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA
  Cc: david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+, Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

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

Signed-off-by: Marc-André Lureau <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 .travis.yml | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/.travis.yml b/.travis.yml
index a5163de..aad9f68 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -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:
-- 
2.29.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v6 4/4] build-sys: replace makefiles to wrap meson/ninja
       [not found] ` <20201104194527.986901-1-marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
                     ` (2 preceding siblings ...)
  2020-11-04 19:45   ` [PATCH v6 3/4] travis: install meson marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA
@ 2020-11-04 19:45   ` marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA
  2020-11-26 12:39   ` [PATCH v6 0/4] Switch to meson build system Marc-André Lureau
  4 siblings, 0 replies; 14+ messages in thread
From: marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA @ 2020-11-04 19:45 UTC (permalink / raw)
  To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA
  Cc: david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+, Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

Signed-off-by: Marc-André Lureau <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 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

diff --git a/Makefile b/Makefile
index c187d5f..cc3caa6 100644
--- a/Makefile
+++ b/Makefile
@@ -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)) < $< > $@.tmp;		\
-	if [ -r $@ ] && cmp -s $@ $@.tmp; then	\
-		rm -f $@.tmp;			\
-	else					\
-		echo '	UPD $@';		\
-		mv -f $@.tmp $@;		\
-	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) $@
diff --git a/Makefile.convert-dtsv0 b/Makefile.convert-dtsv0
deleted file mode 100644
index c12ed40..0000000
--- a/Makefile.convert-dtsv0
+++ /dev/null
@@ -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)
diff --git a/Makefile.dtc b/Makefile.dtc
deleted file mode 100644
index 9c467b0..0000000
--- a/Makefile.dtc
+++ /dev/null
@@ -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)
diff --git a/Makefile.utils b/Makefile.utils
deleted file mode 100644
index 9436b34..0000000
--- a/Makefile.utils
+++ /dev/null
@@ -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)
diff --git a/README b/README
index 9465ee5..68a06f6 100644
--- a/README
+++ b/README
@@ -7,6 +7,21 @@ DTC and LIBFDT are maintained by:
 David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
 Jon Loeliger <jdl-CYoMK+44s/E@public.gmane.org>
 
+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
diff --git a/libfdt/Makefile.libfdt b/libfdt/Makefile.libfdt
deleted file mode 100644
index b6d8fc0..0000000
--- a/libfdt/Makefile.libfdt
+++ /dev/null
@@ -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)
diff --git a/pylibfdt/Makefile.pylibfdt b/pylibfdt/Makefile.pylibfdt
deleted file mode 100644
index 1b5f236..0000000
--- a/pylibfdt/Makefile.pylibfdt
+++ /dev/null
@@ -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)
diff --git a/tests/Makefile.tests b/tests/Makefile.tests
deleted file mode 100644
index cb66c9f..0000000
--- a/tests/Makefile.tests
+++ /dev/null
@@ -1,100 +0,0 @@
-LIB_TESTS_L = get_mem_rsv \
-	root_node find_property subnode_offset path_offset \
-	get_name getprop get_prop_offset get_phandle \
-	get_path supernode_atdepth_offset parent_offset \
-	node_offset_by_prop_value node_offset_by_phandle \
-	node_check_compatible node_offset_by_compatible \
-	get_alias \
-	char_literal \
-	sized_cells \
-	notfound \
-	addr_size_cells \
-	addr_size_cells2 \
-	appendprop_addrrange \
-	stringlist \
-	setprop_inplace nop_property nop_node \
-	sw_tree1 sw_states \
-	move_and_save mangle-layout nopulate \
-	open_pack rw_tree1 rw_oom set_name setprop del_property del_node \
-	appendprop1 appendprop2 propname_escapes \
-	string_escapes references path-references phandle_format \
-	boot-cpuid incbin \
-	extra-terminating-null \
-	dtbs_equal_ordered \
-	dtb_reverse dtbs_equal_unordered \
-	add_subnode_with_nops path_offset_aliases \
-	utilfdt_test \
-	integer-expressions \
-	property_iterate \
-	subnode_iterate \
-	overlay overlay_bad_fixup \
-	check_path check_header check_full \
-	fs_tree1
-LIB_TESTS = $(LIB_TESTS_L:%=$(TESTS_PREFIX)%)
-
-LIBTREE_TESTS_L = truncated_property truncated_string truncated_memrsv
-LIBTREE_TESTS = $(LIBTREE_TESTS_L:%=$(TESTS_PREFIX)%)
-
-DL_LIB_TESTS_L = asm_tree_dump value-labels
-DL_LIB_TESTS = $(DL_LIB_TESTS_L:%=$(TESTS_PREFIX)%)
-
-TESTS = $(LIB_TESTS) $(LIBTREE_TESTS) $(DL_LIB_TESTS)
-
-TESTS_TREES_L = test_tree1.dtb
-TESTS_TREES = $(TESTS_TREES_L:%=$(TESTS_PREFIX)%)
-
-TESTS_TARGETS = $(TESTS) $(TESTS_TREES)
-
-TESTS_DEPFILES = $(TESTS:%=%.d) \
-	$(addprefix $(TESTS_PREFIX),testutils.d trees.d dumptrees.d)
-
-TESTS_CLEANFILES_L = $(STD_CLEANFILES) \
-	*.dtb *.test.dts *.test.dt.yaml *.dtsv1 tmp.* *.bak \
-	dumptrees
-TESTS_CLEANFILES = $(TESTS) $(TESTS_CLEANFILES_L:%=$(TESTS_PREFIX)%)
-TESTS_CLEANDIRS_L = fs
-TESTS_CLEANDIRS = $(TESTS_CLEANDIRS_L:%=$(TESTS_PREFIX)%)
-
-.PHONY: tests
-tests:	$(TESTS) $(TESTS_TREES)
-
-$(LIB_TESTS): %: $(TESTS_PREFIX)testutils.o util.o $(LIBFDT_lib)
-
-# Not necessary on all platforms; allow -ldl to be excluded instead of forcing
-# other platforms to patch it out.
-LIBDL = -ldl
-$(DL_LIB_TESTS): %: %.o $(TESTS_PREFIX)testutils.o util.o $(LIBFDT_lib)
-	@$(VECHO) LD [libdl] $@
-	$(LINK.c) -o $@ $^ $(LIBDL)
-
-$(LIBTREE_TESTS): %: $(TESTS_PREFIX)testutils.o $(TESTS_PREFIX)trees.o \
-		util.o $(LIBFDT_lib)
-
-$(TESTS_PREFIX)dumptrees: $(TESTS_PREFIX)trees.o
-
-$(TESTS_TREES): $(TESTS_PREFIX)dumptrees
-	@$(VECHO) DUMPTREES
-	cd $(TESTS_PREFIX); ./dumptrees . >/dev/null
-
-tests_clean:
-	@$(VECHO) CLEAN "(tests)"
-	rm -f $(TESTS_CLEANFILES)
-	rm -rf $(TESTS_CLEANDIRS)
-
-check:	tests ${TESTS_BIN} $(TESTS_PYLIBFDT)
-	cd $(TESTS_PREFIX); ./run_tests.sh
-
-ifeq ($(NO_VALGRIND),1)
-checkm:
-	@echo "make checkm requires valgrind, but NO_VALGRIND=1"
-else
-checkm: tests ${TESTS_BIN} $(TESTS_PYLIBFDT)
-	cd $(TESTS_PREFIX); ./run_tests.sh -m
-endif
-
-checkv:	tests ${TESTS_BIN} $(TESTS_PYLIBFDT)
-	cd $(TESTS_PREFIX); ./run_tests.sh -v
-
-ifneq ($(DEPTARGETS),)
--include $(TESTS_DEPFILES)
-endif
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 294585b..535f6e0 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -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"
 
-- 
2.29.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v6 0/4] Switch to meson build system
       [not found] ` <20201104194527.986901-1-marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
                     ` (3 preceding siblings ...)
  2020-11-04 19:45   ` [PATCH v6 4/4] build-sys: replace makefiles to wrap meson/ninja marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA
@ 2020-11-26 12:39   ` Marc-André Lureau
       [not found]     ` <CAMxuvazBvmGo+SXREbzq3Yp3=CYbW8B9M67P5oS1ttdJBwRQfA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  4 siblings, 1 reply; 14+ messages in thread
From: Marc-André Lureau @ 2020-11-26 12:39 UTC (permalink / raw)
  To: Devicetree Compiler; +Cc: David Gibson

Hi David,

On Wed, Nov 4, 2020 at 11:45 PM <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
>
> From: Marc-André Lureau <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>
> 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

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


>
> 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
>
>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v6 0/4] Switch to meson build system
       [not found]     ` <CAMxuvazBvmGo+SXREbzq3Yp3=CYbW8B9M67P5oS1ttdJBwRQfA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2020-12-04  0:37       ` David Gibson
  0 siblings, 0 replies; 14+ messages in thread
From: David Gibson @ 2020-12-04  0:37 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: Devicetree Compiler

[-- Attachment #1: Type: text/plain, Size: 1494 bytes --]

On Thu, Nov 26, 2020 at 04:39:00PM +0400, Marc-André Lureau wrote:
> Hi David,
> 
> On Wed, Nov 4, 2020 at 11:45 PM <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> >
> > From: Marc-André Lureau <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> >
> > 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
> 
> 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.

-- 
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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v6 1/4] pylibfdt: allow build out of tree
       [not found]     ` <20201104194527.986901-2-marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2021-11-05 21:01       ` Rob Herring
       [not found]         ` <CAL_JsqL=panX9EW+41vTwsaWLtJbsY=opPPbwH+nnEGZSVnYsQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Rob Herring @ 2021-11-05 21:01 UTC (permalink / raw)
  To: Marc-André Lureau, Simon Glass; +Cc: Devicetree Compiler, David Gibson

On Wed, Nov 4, 2020 at 1:45 PM <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
>
> From: Marc-André Lureau <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>
> 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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v6 1/4] pylibfdt: allow build out of tree
       [not found]         ` <CAL_JsqL=panX9EW+41vTwsaWLtJbsY=opPPbwH+nnEGZSVnYsQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2021-11-08  5:14           ` David Gibson
  2021-11-08 15:58             ` Simon Glass
  0 siblings, 1 reply; 14+ messages in thread
From: David Gibson @ 2021-11-08  5:14 UTC (permalink / raw)
  To: Rob Herring; +Cc: Marc-André Lureau, Simon Glass, Devicetree Compiler

[-- Attachment #1: Type: text/plain, Size: 2103 bytes --]

On Fri, Nov 05, 2021 at 04:01:38PM -0500, Rob Herring wrote:
> On Wed, Nov 4, 2020 at 1:45 PM <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> >
> > From: Marc-André Lureau <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> >
> > 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.

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.


> 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?

-- 
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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v6 1/4] pylibfdt: allow build out of tree
  2021-11-08  5:14           ` David Gibson
@ 2021-11-08 15:58             ` Simon Glass
       [not found]               ` <CAPnjgZ3zndvzBoAdqsW+n7Ao33nEiRr2CXGcBnm_=XDzGmM1_Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Simon Glass @ 2021-11-08 15:58 UTC (permalink / raw)
  To: David Gibson; +Cc: Rob Herring, Marc-André Lureau, Devicetree Compiler

Hi,

On Sun, 7 Nov 2021 at 22:14, David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org> wrote:
>
> On Fri, Nov 05, 2021 at 04:01:38PM -0500, Rob Herring wrote:
> > On Wed, Nov 4, 2020 at 1:45 PM <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> > >
> > > From: Marc-André Lureau <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> > >
> > > 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.
>
> 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.

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.

>
>
> > 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?

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v6 1/4] pylibfdt: allow build out of tree
       [not found]               ` <CAPnjgZ3zndvzBoAdqsW+n7Ao33nEiRr2CXGcBnm_=XDzGmM1_Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2021-11-08 16:59                 ` Rob Herring
       [not found]                   ` <CAL_Jsq+LDmauXEookk4DFiVcEWaGfC_7pxH=B-=N=ear6MzhvA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Rob Herring @ 2021-11-08 16:59 UTC (permalink / raw)
  To: Simon Glass; +Cc: David Gibson, Marc-André Lureau, Devicetree Compiler

On Mon, Nov 8, 2021 at 9:58 AM Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> wrote:
>
> Hi,
>
> On Sun, 7 Nov 2021 at 22:14, David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org> wrote:
> >
> > On Fri, Nov 05, 2021 at 04:01:38PM -0500, Rob Herring wrote:
> > > On Wed, Nov 4, 2020 at 1:45 PM <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> > > >
> > > > From: Marc-André Lureau <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> > > >
> > > > 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.
> >
> > 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.
>
> 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.

> > > 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?
>
> 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)

> 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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v6 1/4] pylibfdt: allow build out of tree
       [not found]                   ` <CAL_Jsq+LDmauXEookk4DFiVcEWaGfC_7pxH=B-=N=ear6MzhvA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2021-11-09  0:09                     ` Simon Glass
       [not found]                       ` <CAPnjgZ1wEb25Ow2v9K7Jp=1+Q2_6ufQGm+e8TjidPCNH5eNY2w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Simon Glass @ 2021-11-09  0:09 UTC (permalink / raw)
  To: Rob Herring; +Cc: David Gibson, Marc-André Lureau, Devicetree Compiler

Hi Rob,

On Mon, 8 Nov 2021 at 09:59, Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote:
>
> On Mon, Nov 8, 2021 at 9:58 AM Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> wrote:
> >
> > Hi,
> >
> > On Sun, 7 Nov 2021 at 22:14, David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org> wrote:
> > >
> > > On Fri, Nov 05, 2021 at 04:01:38PM -0500, Rob Herring wrote:
> > > > On Wed, Nov 4, 2020 at 1:45 PM <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> > > > >
> > > > > From: Marc-André Lureau <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> > > > >
> > > > > 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.
> > >
> > > 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.
> >
> > 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.
>
> > > > 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?
> >
> > 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)
>
> > 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'.

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v6 1/4] pylibfdt: allow build out of tree
       [not found]                       ` <CAPnjgZ1wEb25Ow2v9K7Jp=1+Q2_6ufQGm+e8TjidPCNH5eNY2w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2021-11-09  1:07                         ` Rob Herring
       [not found]                           ` <CAL_Jsq+gtg2md6h3PycEZdXqyqkvYyZ1x1MmShhvPMxV0idZgA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Rob Herring @ 2021-11-09  1:07 UTC (permalink / raw)
  To: Simon Glass; +Cc: David Gibson, Marc-André Lureau, Devicetree Compiler

On Mon, Nov 8, 2021 at 6:09 PM Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> wrote:
>
> Hi Rob,
>
> On Mon, 8 Nov 2021 at 09:59, Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote:
> >
> > On Mon, Nov 8, 2021 at 9:58 AM Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> wrote:
> > >
> > > Hi,
> > >
> > > On Sun, 7 Nov 2021 at 22:14, David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6iEOx6SR5NKn@public.gmane.orgu> wrote:
> > > >
> > > > On Fri, Nov 05, 2021 at 04:01:38PM -0500, Rob Herring wrote:
> > > > > On Wed, Nov 4, 2020 at 1:45 PM <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> > > > > >
> > > > > > From: Marc-André Lureau <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> > > > > >
> > > > > > 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.
> > > >
> > > > 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.
> > >
> > > 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.
> >
> > > > > 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?
> > >
> > > 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)
> >
> > > 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'.
>
> 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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v6 1/4] pylibfdt: allow build out of tree
       [not found]                           ` <CAL_Jsq+gtg2md6h3PycEZdXqyqkvYyZ1x1MmShhvPMxV0idZgA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2021-11-09  1:48                             ` David Gibson
  0 siblings, 0 replies; 14+ messages in thread
From: David Gibson @ 2021-11-09  1:48 UTC (permalink / raw)
  To: Rob Herring; +Cc: Simon Glass, Marc-André Lureau, Devicetree Compiler

[-- Attachment #1: Type: text/plain, Size: 5099 bytes --]

On Mon, Nov 08, 2021 at 07:07:56PM -0600, Rob Herring wrote:
> On Mon, Nov 8, 2021 at 6:09 PM Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> wrote:
> >
> > Hi Rob,
> >
> > On Mon, 8 Nov 2021 at 09:59, Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote:
> > >
> > > On Mon, Nov 8, 2021 at 9:58 AM Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> wrote:
> > > >
> > > > Hi,
> > > >
> > > > On Sun, 7 Nov 2021 at 22:14, David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6ryscVyMRj84@public.gmane.org.au> wrote:
> > > > >
> > > > > On Fri, Nov 05, 2021 at 04:01:38PM -0500, Rob Herring wrote:
> > > > > > On Wed, Nov 4, 2020 at 1:45 PM <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> > > > > > >
> > > > > > > From: Marc-André Lureau <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> > > > > > >
> > > > > > > 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.
> > > > >
> > > > > 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.
> > > >
> > > > 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.
> > >
> > > > > > 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?
> > > >
> > > > 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)
> > >
> > > > 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'.
> >
> > 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.

-- 
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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-11-09  1:48 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-04 19:45 [PATCH v6 0/4] Switch to meson build system marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA
     [not found] ` <20201104194527.986901-1-marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2020-11-04 19:45   ` [PATCH v6 1/4] pylibfdt: allow build out of tree marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA
     [not found]     ` <20201104194527.986901-2-marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2021-11-05 21:01       ` Rob Herring
     [not found]         ` <CAL_JsqL=panX9EW+41vTwsaWLtJbsY=opPPbwH+nnEGZSVnYsQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-11-08  5:14           ` David Gibson
2021-11-08 15:58             ` Simon Glass
     [not found]               ` <CAPnjgZ3zndvzBoAdqsW+n7Ao33nEiRr2CXGcBnm_=XDzGmM1_Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-11-08 16:59                 ` Rob Herring
     [not found]                   ` <CAL_Jsq+LDmauXEookk4DFiVcEWaGfC_7pxH=B-=N=ear6MzhvA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-11-09  0:09                     ` Simon Glass
     [not found]                       ` <CAPnjgZ1wEb25Ow2v9K7Jp=1+Q2_6ufQGm+e8TjidPCNH5eNY2w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-11-09  1:07                         ` Rob Herring
     [not found]                           ` <CAL_Jsq+gtg2md6h3PycEZdXqyqkvYyZ1x1MmShhvPMxV0idZgA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-11-09  1:48                             ` David Gibson
2020-11-04 19:45   ` [PATCH v6 2/4] build-sys: add meson build marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA
2020-11-04 19:45   ` [PATCH v6 3/4] travis: install meson marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA
2020-11-04 19:45   ` [PATCH v6 4/4] build-sys: replace makefiles to wrap meson/ninja marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA
2020-11-26 12:39   ` [PATCH v6 0/4] Switch to meson build system Marc-André Lureau
     [not found]     ` <CAMxuvazBvmGo+SXREbzq3Yp3=CYbW8B9M67P5oS1ttdJBwRQfA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-12-04  0:37       ` David Gibson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).