All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony PERARD <anthony.perard@citrix.com>
To: <xen-devel@lists.xenproject.org>
Cc: Anthony PERARD <anthony.perard@citrix.com>,
	Henry Wang <Henry.Wang@arm.com>,
	George Dunlap <george.dunlap@citrix.com>,
	Nick Rosbrook <rosbrookn@gmail.com>, Wei Liu <wl@xen.org>
Subject: [XEN PATCH for-4.17 v5 16/17] tools/golang/xenlight: Rework gengotypes.py and generation of *.gen.go
Date: Thu, 13 Oct 2022 14:05:12 +0100	[thread overview]
Message-ID: <20221013130513.52440-17-anthony.perard@citrix.com> (raw)
In-Reply-To: <20221013130513.52440-1-anthony.perard@citrix.com>

gengotypes.py creates both "types.gen.go" and "helpers.gen.go", but
make can start gengotypes.py twice. Rework the rules so that
gengotypes.py is executed only once.

Also, add the ability to provide a path to tell gengotypes.py where to
put the files. This doesn't matter yet but it will when for example
the script will be run from tools/ to generate the targets.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Release-acked-by: Henry Wang <Henry.Wang@arm.com>
---

Notes:
    v5:
    - released-acked to fix occasional CI build issue
    
    v4:
    - new patch

 tools/golang/xenlight/Makefile      |  6 ++++--
 tools/golang/xenlight/gengotypes.py | 10 +++++++++-
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/tools/golang/xenlight/Makefile b/tools/golang/xenlight/Makefile
index 00e6d17f2b..c5bb6b94a8 100644
--- a/tools/golang/xenlight/Makefile
+++ b/tools/golang/xenlight/Makefile
@@ -15,8 +15,10 @@ all: build
 
 GOXL_GEN_FILES = types.gen.go helpers.gen.go
 
-%.gen.go: gengotypes.py $(LIBXL_SRC_DIR)/libxl_types.idl $(LIBXL_SRC_DIR)/idl.py
-	LIBXL_SRC_DIR=$(LIBXL_SRC_DIR) $(PYTHON) gengotypes.py $(LIBXL_SRC_DIR)/libxl_types.idl
+# This exploits the 'multi-target pattern rule' trick.
+# gentypes.py should be executed only once to make all the targets.
+$(subst .gen.,.%.,$(GOXL_GEN_FILES)): gengotypes.py $(LIBXL_SRC_DIR)/libxl_types.idl $(LIBXL_SRC_DIR)/idl.py
+	LIBXL_SRC_DIR=$(LIBXL_SRC_DIR) $(PYTHON) gengotypes.py $(LIBXL_SRC_DIR)/libxl_types.idl $(@D)/types.gen.go $(@D)/helpers.gen.go
 
 # Go will do its own dependency checking, and not actuall go through
 # with the build if none of the input files have changed.
diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang/xenlight/gengotypes.py
index ac1cf060dd..ff4c2ad216 100644
--- a/tools/golang/xenlight/gengotypes.py
+++ b/tools/golang/xenlight/gengotypes.py
@@ -723,7 +723,13 @@ def xenlight_golang_fmt_name(name, exported = True):
     return words[0] + ''.join(x.title() for x in words[1:])
 
 if __name__ == '__main__':
+    if len(sys.argv) != 4:
+        print("Usage: gengotypes.py <idl> <types.gen.go> <helpers.gen.go>", file=sys.stderr)
+        sys.exit(1)
+
     idlname = sys.argv[1]
+    path_types = sys.argv[2]
+    path_helpers = sys.argv[3]
 
     (builtins, types) = idl.parse(idlname)
 
@@ -735,9 +741,11 @@ if __name__ == '__main__':
 // source: {}
 
 """.format(os.path.basename(sys.argv[0]),
-           ' '.join([os.path.basename(a) for a in sys.argv[1:]]))
+           os.path.basename(sys.argv[1]))
 
     xenlight_golang_generate_types(types=types,
+                                   path=path_types,
                                    comment=header_comment)
     xenlight_golang_generate_helpers(types=types,
+                                     path=path_helpers,
                                      comment=header_comment)
-- 
Anthony PERARD



  parent reply	other threads:[~2022-10-13 13:16 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-13 13:04 [XEN PATCH for-4.17 v5 00/17] Toolstack build system improvement, toward non-recursive makefiles Anthony PERARD
2022-10-13 13:04 ` [XEN PATCH for-4.17 v5 01/17] tools/debugger/gdbsx: Fix and cleanup makefiles Anthony PERARD
2022-10-13 13:04 ` [XEN PATCH for-4.17 v5 02/17] tools/xentrace: rework Makefile Anthony PERARD
2022-10-13 13:04 ` [XEN PATCH for-4.17 v5 03/17] tools: Introduce $(xenlibs-ldflags, ) macro Anthony PERARD
2022-10-13 13:05 ` [XEN PATCH for-4.17 v5 04/17] tools: Add -Werror by default to all tools/ Anthony PERARD
2022-10-13 13:05 ` [XEN PATCH for-4.17 v5 05/17] tools: Remove -Werror everywhere else Anthony PERARD
2022-10-13 15:13   ` Andrew Cooper
2022-10-14 10:16     ` Anthony PERARD
2022-10-14 15:06   ` Anthony PERARD
2022-10-13 13:05 ` [XEN PATCH for-4.17 v5 06/17] tools/hotplug: Generate "hotplugpath.sh" with configure Anthony PERARD
2022-10-14 18:03   ` Andrew Cooper
2022-10-13 13:05 ` [XEN PATCH for-4.17 v5 07/17] libs/light/gentypes.py: allow to generate headers in subdirectory Anthony PERARD
2022-10-13 13:05 ` [XEN PATCH for-4.17 v5 08/17] git-checkout.sh: handle running git-checkout from a different directory Anthony PERARD
2022-10-13 13:05 ` [XEN PATCH for-4.17 v5 09/17] libs: Avoid exposing -Wl,--version-script to other built library Anthony PERARD
2022-10-13 13:05 ` [XEN PATCH for-4.17 v5 10/17] libs: Fix auto-generation of version-script for unstable libs Anthony PERARD
2022-10-14 18:16   ` Andrew Cooper
2022-10-17 14:19     ` Anthony PERARD
2022-10-13 13:05 ` [XEN PATCH for-4.17 v5 11/17] tools/include: Rework Makefile Anthony PERARD
2022-10-13 13:05 ` [XEN PATCH for-4.17 v5 12/17] libs/light: Rework acpi table build targets Anthony PERARD
2022-10-13 13:05 ` [XEN PATCH for-4.17 v5 13/17] libs/light: Rework generation of include/_libxl_*.h Anthony PERARD
2022-10-13 13:05 ` [XEN PATCH for-4.17 v5 14/17] libs/light: Rework targets prerequisites Anthony PERARD
2022-10-14 19:35   ` Andrew Cooper
2022-10-17 14:39     ` Anthony PERARD
2022-10-13 13:05 ` [XEN PATCH for-4.17 v5 15/17] libs/light: Makefile cleanup Anthony PERARD
2022-10-13 13:05 ` Anthony PERARD [this message]
2022-10-13 15:00   ` [XEN PATCH for-4.17 v5 16/17] tools/golang/xenlight: Rework gengotypes.py and generation of *.gen.go Andrew Cooper
2022-10-14 11:24     ` George Dunlap
2022-10-14 11:37       ` Andrew Cooper
2022-10-14 11:42         ` George Dunlap
2022-10-14 11:51           ` Andrew Cooper
2022-10-14 11:25   ` George Dunlap
2022-10-13 13:05 ` [XEN PATCH for-4.17 v5 17/17] tools: Rework linking options for ocaml binding libraries Anthony PERARD
2022-10-13 18:02 ` [XEN PATCH for-4.17 v5 00/17] Toolstack build system improvement, toward non-recursive makefiles Andrew Cooper
2022-10-14  6:26   ` Henry Wang
2022-10-14 10:14     ` Anthony PERARD
2022-10-14 10:28       ` Henry Wang
2022-10-14 10:31       ` Andrew Cooper
2022-10-14 10:39         ` Henry Wang
2022-10-14 12:55 ` Christian Lindig

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=20221013130513.52440-17-anthony.perard@citrix.com \
    --to=anthony.perard@citrix.com \
    --cc=Henry.Wang@arm.com \
    --cc=george.dunlap@citrix.com \
    --cc=rosbrookn@gmail.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.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 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.