From nobody Mon Feb 9 13:37:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1587485598; cv=none; d=zohomail.com; s=zohoarc; b=JS6gVtNVu6lu/ZjlOloQwTtIPh9v6MJVy9aR5oQQwo+cyBHAjGFlVIPkHKlCd2cHcqQohvOIz3v06oC7mPKsYl1E4MKpP0+85RrALQWj6cAH4CCyW8DNz5s3zDY359RubAKx3JoiqDvWkB4fGkvWZ+Wt+WXE3udMKtX6Gsv72dY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587485598; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2z9D2yApz3DemqrpuhFDVNosHJGormv3T9hmHFTtNd8=; b=hVVhlc15kfITSIOsvEV5qXI8hav0YeH78K6kjMeFtFJqqnWdcgy/kCT+fiSxDfW0kNp3YIUQtoisB0byOwnrwPLH+gnjlVwSuaHMcYkYX2H3aZtrMOVybdToK5jPoOyD1i3Zo8XH+LktuLaFuY6vLwhjBm8QS0REJH6CJF1IGFI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1587485598870313.5051764779639; Tue, 21 Apr 2020 09:13:18 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jQvWE-0005vm-0T; Tue, 21 Apr 2020 16:13:06 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jQvWC-0005uQ-RP for xen-devel@lists.xenproject.org; Tue, 21 Apr 2020 16:13:04 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f661cd52-83ea-11ea-b58d-bc764e2007e4; Tue, 21 Apr 2020 16:12:57 +0000 (UTC) X-Inumbo-ID: f661cd52-83ea-11ea-b58d-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1587485577; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=K8Lniz6UiDyu3Tb2CuVmdy2kcNZ7QfJlssODBIQJTks=; b=ZYfIZ6ztBpnaDNBkBXD+y/CyDJFuzc5wOXv4sdxHn5GzvRY6UMN0yvA6 4LbFOsae0AbW2Hmwkc8tds0PFWESqOW7+bxCB+ynalO+ysCk4CA94MBR1 DXIwS52ThFnEwu0u1laPGr6eeusMgJJnSPxXL+F4Pf1g0sRHCgg9lmeGo c=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: QJCQGW3Yhu9OQfaPCzcw5RV6uFa+quI1o+tDsWt9gY494v0hluljYK7Ir3bIl3vIWAa6VBnjqp s1VxnAescwFA6Nu8xLymWseN2yOt1eQQld7KAAoGdcSxXq179LoLYo5EFgEZSznKuumfpL5rvN gLB/Dh9FlgO29TfJz2PbEsqsussiUBC2WB2YqX8MyboireG4y5JUwF8qpyldV5FAloPgcVwe7K 4MNOIrKSmcLU9MTmKPqdBDknDzFQBpOvImK8d66nP+l9S/X8iElvDAqAzqziHgx6C66t6Bvyiz dFE= X-SBRS: 2.7 X-MesageID: 16692977 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.72,410,1580792400"; d="scan'208";a="16692977" From: Anthony PERARD To: Subject: [XEN PATCH v5 16/16] build,include: rework compat-build-header.py Date: Tue, 21 Apr 2020 17:12:08 +0100 Message-ID: <20200421161208.2429539-17-anthony.perard@citrix.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200421161208.2429539-1-anthony.perard@citrix.com> References: <20200421161208.2429539-1-anthony.perard@citrix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Julien Grall , Wei Liu , Andrew Cooper , Ian Jackson , George Dunlap , Jan Beulich , Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Replace a mix of shell script and python script by all python script. No change to the final generated headers. Signed-off-by: Anthony PERARD Acked-by: Wei Liu --- Notes: v5: - Removed -P from CPP when generating compat/%.i -> keep removing linemarkers and keep de-duplicating empty lines. So that all the blank line that currently exist in the generated headers stays in place. =20 v4: - new patch xen/include/Makefile | 11 +------ xen/tools/compat-build-header.py | 52 ++++++++++++++++++++++++++++++-- 2 files changed, 51 insertions(+), 12 deletions(-) diff --git a/xen/include/Makefile b/xen/include/Makefile index 537085b82793..12660625119e 100644 --- a/xen/include/Makefile +++ b/xen/include/Makefile @@ -51,16 +51,7 @@ public-$(CONFIG_ARM) :=3D $(wildcard public/arch-arm/*.h= public/arch-arm/*/*.h) all: $(headers-y) =20 compat/%.h: compat/%.i Makefile $(BASEDIR)/tools/compat-build-header.py - set -e; id=3D_$$(echo $@ | tr '[:lower:]-/.' '[:upper:]___'); \ - echo "#ifndef $$id" >$@.new; \ - echo "#define $$id" >>$@.new; \ - echo "#include " >>$@.new; \ - $(if $(filter-out compat/arch-%.h,$@),echo "#include <$(patsubst compat/%= ,public/%,$@)>" >>$@.new;) \ - $(if $(prefix-y),echo "$(prefix-y)" >>$@.new;) \ - grep -v '^# [0-9]' $< | \ - $(PYTHON) $(BASEDIR)/tools/compat-build-header.py | uniq >>$@.new; \ - $(if $(suffix-y),echo "$(suffix-y)" >>$@.new;) \ - echo "#endif /* $$id */" >>$@.new + $(PYTHON) $(BASEDIR)/tools/compat-build-header.py <$< $@ "$(prefix-y)" "$= (suffix-y)" >>$@.new; \ mv -f $@.new $@ =20 compat/%.i: compat/%.c Makefile diff --git a/xen/tools/compat-build-header.py b/xen/tools/compat-build-head= er.py index b85c43f13faf..34d5343c3dd9 100755 --- a/xen/tools/compat-build-header.py +++ b/xen/tools/compat-build-header.py @@ -2,6 +2,12 @@ =20 import re,sys =20 +try: + maketrans =3D str.maketrans +except AttributeError: + # For python2 + from string import maketrans + pats =3D [ [ r"__InClUdE__(.*)", r"#include\1\n#pragma pack(4)" ], [ r"__IfDeF__ (XEN_HAVE.*)", r"#ifdef \1" ], @@ -20,7 +26,49 @@ pats =3D [ [ r"(^|[^\w])long([^\w]|$$)", r"\1int\2" ] ]; =20 +output_filename =3D sys.argv[1] + +# tr '[:lower:]-/.' '[:upper:]___' +header_id =3D '_' + \ + output_filename.upper().translate(maketrans('-/.','___')) + +header =3D """#ifndef {0} +#define {0} +#include """.format(header_id) + +print(header) + +if not re.match("compat/arch-.*.h$", output_filename): + x =3D output_filename.replace("compat/","public/") + print('#include <%s>' % x) + +def print_if_nonempty(s): + if len(s): + print(s) + +print_if_nonempty(sys.argv[2]) + +last_line_empty =3D False for line in sys.stdin.readlines(): + line =3D line.rstrip() + + # Remove linemarkers generated by the preprocessor. + if re.match(r"^# \d", line): + continue + + # De-duplicate empty lines. + if len(line) =3D=3D 0: + if not last_line_empty: + print(line) + last_line_empty =3D True + continue + else: + last_line_empty =3D False + for pat in pats: - line =3D re.subn(pat[0], pat[1], line)[0] - print(line.rstrip()) + line =3D re.sub(pat[0], pat[1], line) + print(line) + +print_if_nonempty(sys.argv[3]) + +print("#endif /* %s */" % header_id) --=20 Anthony PERARD