From: "Marc-André Lureau" <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
Cc: Devicetree Compiler
<devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH v3 1/4] pylibfdt: allow build out of tree
Date: Mon, 21 Sep 2020 12:22:06 +0400 [thread overview]
Message-ID: <CAMxuvaxTsdcpnrED54ydCKTKbVGRnYOW3fiL5tfyNTsiUM+cyQ@mail.gmail.com> (raw)
In-Reply-To: <20200921062751.GB17169-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org>
Hi
On Mon, Sep 21, 2020 at 10:29 AM David Gibson
<david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org> wrote:
>
> On Tue, Sep 15, 2020 at 11:27:02PM +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. Fix path lookup.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> > ---
> > pylibfdt/Makefile.pylibfdt | 2 +-
> > pylibfdt/setup.py | 25 +++++++++++++++++--------
> > 2 files changed, 18 insertions(+), 9 deletions(-)
> >
> > diff --git a/pylibfdt/Makefile.pylibfdt b/pylibfdt/Makefile.pylibfdt
> > index 6866a0b..32ae1c5 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
> > diff --git a/pylibfdt/setup.py b/pylibfdt/setup.py
> > index 53f2bef..f8ec924 100755
> > --- a/pylibfdt/setup.py
> > +++ b/pylibfdt/setup.py
> > @@ -19,23 +19,31 @@ import sys
> > VERSION_PATTERN = '^#define DTC_VERSION "DTC ([^"]*)"$'
> >
> >
> > +def get_top_builddir():
> > + assert '--top-builddir' in sys.argv
>
> I see you've added the option to the Makefile, but if this were
> invoked manually, I'm not sure that you want to just die if the
> --top-builddir option isn't included.
>
> Even if you do, I think you want a more meaningful error than an
> assertion failure.
The assertion is quite explicit:
Traceback (most recent call last):
File "pylibfdt/setup.py", line 30, in <module>
top_builddir = get_top_builddir()
File "pylibfdt/setup.py", line 23, in get_top_builddir
assert '--top-builddir' in sys.argv
AssertionError
Having extra arguments to setuptools is tricky:
https://stackoverflow.com/questions/677577/distutils-how-to-pass-a-user-defined-parameter-to-setup-py
Since it's a programmer error, that you are not suppose to run into
because you'd use make or ninja, it seems enough to me. But if you
insist, I can update to print a more friendly message somehow.
>
> > + index = sys.argv.index('--top-builddir')
> > + sys.argv.pop(index)
> > + return sys.argv.pop(index)
> > +
> > +
> > +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 +52,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
next prev parent reply other threads:[~2020-09-21 8:22 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-15 19:27 [PATCH v3 0/4] Add meson build system marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA
[not found] ` <20200915192705.1716282-1-marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2020-09-15 19:27 ` [PATCH v3 1/4] pylibfdt: allow build out of tree marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA
[not found] ` <20200915192705.1716282-2-marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2020-09-21 6:27 ` David Gibson
[not found] ` <20200921062751.GB17169-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org>
2020-09-21 8:22 ` Marc-André Lureau [this message]
[not found] ` <CAMxuvaxTsdcpnrED54ydCKTKbVGRnYOW3fiL5tfyNTsiUM+cyQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-09-28 8:00 ` David Gibson
[not found] ` <20200928080038.GD501872-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org>
2020-09-29 11:46 ` Marc-André Lureau
[not found] ` <CAMxuvaxx0+5n4YAj1OM_F0B-7wZkZnWZ7vQC6wfvAuCCvvti1w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-09-29 14:00 ` David Gibson
[not found] ` <20200929140036.GA8432-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org>
2020-09-29 15:37 ` Marc-André Lureau
[not found] ` <CAMxuvawbCOsFupbSq09HyOsknGx2Sq9gM8vjbedZFUpkJGF24A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-10-02 3:40 ` David Gibson
2020-09-15 19:27 ` [PATCH v3 2/4] pylibfdt: fix build lib location marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA
[not found] ` <20200915192705.1716282-3-marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2020-09-21 6:33 ` David Gibson
[not found] ` <20200921063325.GC17169-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org>
2020-09-21 8:09 ` Marc-André Lureau
[not found] ` <CAMxuvaxfb0gj285VfrozQp9KJT2XcN7yqyJWFE42tRZM9e1hig-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-09-25 10:16 ` David Gibson
[not found] ` <20200925101647.GB2298-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org>
2020-09-25 13:21 ` Marc-André Lureau
2020-10-02 3:41 ` David Gibson
2020-09-15 19:27 ` [PATCH v3 3/4] build-sys: add meson build marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA
2020-09-15 19:27 ` [PATCH v3 4/4] travis: test " marcandre.lureau-H+wXaHxf7aLQT0dZR+AlfA
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=CAMxuvaxTsdcpnrED54ydCKTKbVGRnYOW3fiL5tfyNTsiUM+cyQ@mail.gmail.com \
--to=marcandre.lureau-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org \
--cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@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).