Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni via buildroot <buildroot@buildroot.org>
To: James Hilliard <james.hilliard1@gmail.com>
Cc: buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH 1/1] utils/update-rust: use pathlib with relative paths
Date: Wed, 10 Jul 2024 23:06:16 +0200	[thread overview]
Message-ID: <20240710230616.1f2012ad@windsurf> (raw)
In-Reply-To: <20240623205821.3833321-1-james.hilliard1@gmail.com>

Hello James,

On Sun, 23 Jun 2024 14:58:21 -0600
James Hilliard <james.hilliard1@gmail.com> wrote:

> This avoids the requirement of running update-rust from TOPDIR and
> is slightly cleaner.
> 
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>

Applied after fixing a few flake8 issues:

./utils/update-rust:5:1: F401 'sys' imported but unused
./utils/update-rust:86:18: F541 f-string is missing placeholders
./utils/update-rust:103:18: F541 f-string is missing placeholders

Some comments below.

> +    TOPDIR = pathlib.Path(__file__).parent.parent
> +    update_mk_file(TOPDIR / "package/rust/rust.mk", args.version)
> +    update_mk_file(TOPDIR / "package/rust-bin/rust-bin.mk", args.version)
> +    gen_hash_file_src(TOPDIR / "package/rust/rust.hash", args.version)
> +    gen_hash_file_bin(TOPDIR / "package/rust-bin/rust-bin.hash", args.version)

I really didn't know about pathlib.Path(), so very interesting. My
understanding is that TOPDIR / "package" / "rust-bin" / "rust-bin.hash"
would be more correct, but I find it annoying to read.

We have other Python scripts in Buildroot that also need to get the
TOPDIR, and they do it in different ways.

Two times os.path.dirname():

utils/check-package:        base_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
utils/check-symbols:    base_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))

Or os.path.join() with the path to the root:

support/scripts/pkg-stats:brpath = os.path.normpath(os.path.join(os.path.dirname(__file__), "..", ".."))
support/testing/infra/__init__.py:BASE_DIR = os.path.realpath(os.path.join(os.path.dirname(__file__), "../../.."))

we're not very consistent :-)

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  reply	other threads:[~2024-07-10 21:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-23 20:58 [Buildroot] [PATCH 1/1] utils/update-rust: use pathlib with relative paths James Hilliard
2024-07-10 21:06 ` Thomas Petazzoni via buildroot [this message]
2024-07-10 21:17   ` James Hilliard

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=20240710230616.1f2012ad@windsurf \
    --to=buildroot@buildroot.org \
    --cc=james.hilliard1@gmail.com \
    --cc=thomas.petazzoni@bootlin.com \
    /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