All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Li Wang <liwang@redhat.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [RFC PATCH 1/3] Makefile: Add C header with generated LTP version
Date: Fri, 14 Jul 2023 06:53:47 +0200	[thread overview]
Message-ID: <20230714045347.GA824361@pevik> (raw)
In-Reply-To: <CAEemH2eE8PUY_at7C-aUX+75ALdM-jjm71L=M-ETYc94RKJFcg@mail.gmail.com>

Hi Cyril, Li,

> On Thu, Jul 13, 2023 at 7:57 PM Cyril Hrubis <chrubis@suse.cz> wrote:

> > Hi!
> > > obviously this is wrong, because $(top_srcdir)/Version (ltp-version.h
> > > dependency) is not specified in the top level Makefile (only Version is
> > > there). But I'm not sure if it should be changed to
> > > $(top_srcdir)/Version.

> > > I suppose ltp-version.h should be in include/

> > Not reall, as long as it's used only in the library it can stay in the
> > lib/

> > > , but here I'm completely lost with dependencies under lib/. My goal
> > > is to type make in lib/ and make sure the header is generated
> > > (dependencies correctly resolved).

> > There is another problem as well, currently the Version file is
> > generated at the end of the LTP build, that means if you do a git pull
> > and make it's not updated until the build has finished.

> > Also we will have to rebuild tst_test.c each time Version file has been
> > rewritten, which actually happens each time make is build in the top
> > level directory, which would cause useless rebuilds.

> > The best I could came up with:

> > ---
> >  lib/.gitignore     |  2 ++
> >  lib/Makefile       | 13 +++++++++++++
> >  lib/gen_version.sh | 16 ++++++++++++++++
> >  3 files changed, 31 insertions(+)
> >  create mode 100644 lib/.gitignore
> >  create mode 100755 lib/gen_version.sh

> > diff --git a/lib/.gitignore b/lib/.gitignore
> > new file mode 100644
> > index 000000000..178867a94
> > --- /dev/null
> > +++ b/lib/.gitignore
> > @@ -0,0 +1,2 @@
> > +ltp-version.h
> > +cached-version
> > diff --git a/lib/Makefile b/lib/Makefile
> > index 9b9906f25..371119ede 100644
> > --- a/lib/Makefile
> > +++ b/lib/Makefile
> > @@ -20,6 +20,19 @@ pc_file                      :=
> > $(DESTDIR)/$(datarootdir)/pkgconfig/ltp.pc

> >  INSTALL_TARGETS                := $(pc_file)

> > +tst_test.o: ltp-version.h
> > +
> > +ltp-version.h: gen_version
> > +
> > +MAKE_TARGETS+=gen_version
> > +
> > +.PHONY: gen_version
> > +gen_version:
> > +       @echo GEN ltp-version.h
> > +       @./gen_version.sh
> > +
> > +CLEAN_TARGETS+=ltp-version.h cached-version
> > +
> >  $(pc_file):
> >         test -d "$(@D)" || mkdir -p "$(@D)"
> >         install -m $(INSTALL_MODE) "$(builddir)/$(@F)" "$@"
> > diff --git a/lib/gen_version.sh b/lib/gen_version.sh
> > new file mode 100755
> > index 000000000..7ecfb9077
> > --- /dev/null
> > +++ b/lib/gen_version.sh
> > @@ -0,0 +1,16 @@
> > +#!/bin/sh
> > +
> > +touch cached-version;
> > +
> > +if git describe >/dev/null 2>&1; then
> > +       VERSION=`git describe`
> > +else
> > +       VERSION=`cat $(top_srcdir)/VERSION`
> > +fi
> > +
> > +CACHED_VERSION=`cat cached-version`
> > +
> > +if [ "$CACHED_VERSION" != "$VERSION" ]; then
> > +       echo "$VERSION" > cached-version
> > +       echo "#define LTP_VERSION \"$VERSION\"" > ltp-version.h

Cyril, thank you for your time! LGTM, I'll test it soon.

> What we are doing in those efforts is to have an available macro
> LTP_VERSION, right?
Yes.

> So why not use the script to append that one line in tst_test.h directly?
We'd have to have tst_test.h.in which would be be kind of skeleton for
tst_test.h. Otherwise tst_test.h would be constantly "modified" by this line.

> The ltp-version.h looks quite redundant and we could even put this script
> into build.sh together, IMHO.

It must be somehow make based, because not everybody uses build.sh.

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2023-07-14  4:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-04  9:19 [LTP] [RFC PATCH 1/3] Makefile: Add C header with generated LTP version Petr Vorel
2023-07-04  9:19 ` Petr Vorel
2023-07-04  9:25   ` Petr Vorel
2023-07-13 11:58     ` Cyril Hrubis
2023-07-14  2:54       ` Li Wang
2023-07-14  4:53         ` Petr Vorel [this message]
2023-07-14  6:46         ` Cyril Hrubis
2023-07-14  9:25           ` Li Wang
2023-07-04  9:19 ` [LTP] [RFC PATCH 2/3] lib/C-API: Add option -V to print " Petr Vorel
2023-07-04 10:33   ` Cyril Hrubis
2023-07-04 11:50     ` Petr Vorel
2023-07-04 12:04       ` Cyril Hrubis
2023-07-04 12:07         ` Petr Vorel
2023-07-04  9:19 ` [LTP] [RFC PATCH 3/3] lib/C-API: Print LTP version at test start Petr Vorel
2023-07-04  9:26 ` [LTP] [RFC PATCH 1/3] Makefile: Add C header with generated LTP version Petr Vorel

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=20230714045347.GA824361@pevik \
    --to=pvorel@suse.cz \
    --cc=liwang@redhat.com \
    --cc=ltp@lists.linux.it \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.