mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: "Ulrich Ölmann" <u.oelmann@pengutronix.de>
To: PTXdist Development Mailing List <ptxdist@pengutronix.de>
Cc: "Ulrich Ölmann" <u.oelmann@pengutronix.de>
Subject: [ptxdist] [PATCH 5/5] templates: src-meson-prog: introduce version into template project
Date: Wed,  5 Jun 2019 01:16:55 +0200	[thread overview]
Message-ID: <20190604231655.13949-6-u.oelmann@pengutronix.de> (raw)
In-Reply-To: <20190604231655.13949-1-u.oelmann@pengutronix.de>

Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
---
 rules/templates/src-meson-prog/@name@.c    | 2 +-
 rules/templates/src-meson-prog/config.h.in | 1 +
 rules/templates/src-meson-prog/meson.build | 2 ++
 rules/templates/src-meson-prog/wizard.sh   | 9 ++++++++-
 scripts/lib/ptxd_lib_template.sh           | 2 +-
 5 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/rules/templates/src-meson-prog/@name@.c b/rules/templates/src-meson-prog/@name@.c
index 061debf310bc..1911e620d09d 100644
--- a/rules/templates/src-meson-prog/@name@.c
+++ b/rules/templates/src-meson-prog/@name@.c
@@ -5,7 +5,7 @@
 
 int main(int argc, char *argv[])
 {
-	printf("Hello World, I'm @name@!\n");
+	printf("Hello World, I'm version " VERSION_STR " of @name@!\n");
 	printf("My license is " LICENSE_STR ".\n");
 
 	exit(EXIT_SUCCESS);
diff --git a/rules/templates/src-meson-prog/config.h.in b/rules/templates/src-meson-prog/config.h.in
index b0ee7ec65121..4d90c2e66ea8 100644
--- a/rules/templates/src-meson-prog/config.h.in
+++ b/rules/templates/src-meson-prog/config.h.in
@@ -1 +1,2 @@
+#define VERSION_STR "@version@"
 #define LICENSE_STR "@license@"
diff --git a/rules/templates/src-meson-prog/meson.build b/rules/templates/src-meson-prog/meson.build
index 946e1850cfd5..de559eb72693 100644
--- a/rules/templates/src-meson-prog/meson.build
+++ b/rules/templates/src-meson-prog/meson.build
@@ -1,8 +1,10 @@
 project('@name@', 'c',
+  version : '@version@',
   license : '0BSD',
   default_options : ['warning_level=3'])
 
 conf_data = configuration_data()
+conf_data.set('version', meson.project_version())
 conf_data.set('license', meson.project_license()[0])
 configure_file(input : 'config.h.in',
                output : 'config.h',
diff --git a/rules/templates/src-meson-prog/wizard.sh b/rules/templates/src-meson-prog/wizard.sh
index 305530b654d4..3753d8d0e67d 100644
--- a/rules/templates/src-meson-prog/wizard.sh
+++ b/rules/templates/src-meson-prog/wizard.sh
@@ -6,12 +6,19 @@ if [ -z "$NAME" ]; then
 	read NAME
 fi
 
+VERSION="${3}"
+if [ -z "$VERSION" ]; then
+	echo -n "project version: "
+	read VERSION
+fi
+
 mv "@name@.c" "${NAME}.c"
 
 for i in \
 	meson.build \
 	${NAME}.c \
 ; do
-	sed -i -e "s/\@name\@/${NAME}/g" $i
+	sed -i -e "s/\@name\@/${NAME}/g" \
+	       -e "s/\@version\@/${VERSION}/g" $i
 done
 
diff --git a/scripts/lib/ptxd_lib_template.sh b/scripts/lib/ptxd_lib_template.sh
index 8ac3312dc775..b437c52f24ed 100644
--- a/scripts/lib/ptxd_lib_template.sh
+++ b/scripts/lib/ptxd_lib_template.sh
@@ -211,7 +211,7 @@ ptxd_template_write_src() {
 	return
     fi &&
     template_dir=$(dirname "${template_src}") &&
-    ( cd "${dst}" && bash wizard.sh "${package}" "${template_dir}") &&
+    ( cd "${dst}" && bash wizard.sh "${package}" "${template_dir}" "${VERSION}") &&
     rm -f "${dst}/wizard.sh"
 }
 export -f ptxd_template_write_src
-- 
2.20.1


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

      parent reply	other threads:[~2019-06-04 23:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-04 23:16 [ptxdist] [PATCH 0/5] Clean up templates and add src-meson-prog template Ulrich Ölmann
2019-06-04 23:16 ` [ptxdist] [PATCH 1/5] templates: wizard.sh: remove unused variable Ulrich Ölmann
2019-06-04 23:16 ` [ptxdist] [PATCH 2/5] templates: wizard.sh: use neat parameter expansion and prevent word splitting Ulrich Ölmann
2019-06-04 23:16 ` [ptxdist] [PATCH 3/5] templates: wizard.sh: use only one sed process Ulrich Ölmann
2019-06-04 23:16 ` [ptxdist] [PATCH 4/5] templates: add src-meson-prog template Ulrich Ölmann
2019-06-04 23:16 ` Ulrich Ölmann [this message]

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=20190604231655.13949-6-u.oelmann@pengutronix.de \
    --to=u.oelmann@pengutronix.de \
    --cc=ptxdist@pengutronix.de \
    /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