From: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
To: marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v5 1/3] pylibfdt: allow build out of tree
Date: Wed, 21 Oct 2020 14:35:49 +1100 [thread overview]
Message-ID: <20201021033549.GC95552@yekko.fritz.box> (raw)
In-Reply-To: <20201012073405.1682782-2-marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 3622 bytes --]
On Mon, Oct 12, 2020 at 11:34:03AM +0400, 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.
>
> 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>
Applied, thanks.
> ---
> 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'],
> )
--
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 --]
next prev parent reply other threads:[~2020-10-21 3:35 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-12 7:34 [PATCH v5 0/3] Add meson build system marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA
[not found] ` <20201012073405.1682782-1-marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2020-10-12 7:34 ` [PATCH v5 1/3] pylibfdt: allow build out of tree marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA
[not found] ` <20201012073405.1682782-2-marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2020-10-21 3:35 ` David Gibson [this message]
2020-10-12 7:34 ` [PATCH v5 2/3] build-sys: add meson build marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA
[not found] ` <20201012073405.1682782-3-marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2020-10-21 3:44 ` David Gibson
[not found] ` <20201021034438.GD95552-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org>
2020-10-21 7:05 ` Marc-André Lureau
[not found] ` <CAMxuvazLYGVnQxQec9t0GNRF5_g8JvPKiX1=tNqqAY4itZ1JYg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-10-22 4:15 ` David Gibson
[not found] ` <20201022041538.GH1821515-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org>
2020-10-27 16:09 ` Marc-André Lureau
[not found] ` <CAMxuvax2Rc3ADTxCBWHb0b6OoGDWRsg3GEe+gH6YPe0M0+pNXw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-10-27 16:12 ` Marc-André Lureau
2020-10-27 20:08 ` Rob Herring
[not found] ` <CAL_Jsq+bOxx=2rahno6yqbV_T7_DpzGjKsqmu9=iWcum-PjBKg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-10-27 20:31 ` Marc-André Lureau
2020-10-28 6:03 ` David Gibson
2020-10-12 7:34 ` [PATCH v5 3/3] travis: test " marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA
[not found] ` <20201012073405.1682782-4-marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2020-10-21 3:58 ` David Gibson
[not found] ` <20201021035800.GE95552-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org>
2020-10-21 6:57 ` Marc-André Lureau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201021033549.GC95552@yekko.fritz.box \
--to=david-xt8fgy+axnrb3ne2bgzf6laj5h9x9tb+@public.gmane.org \
--cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).