[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] tools/include/xen-foreign: Add SPDX identifier to generated headers



commit c62748312e0adec0cbcf0f8d7d126080e5e43a82
Author:     Anthony PERARD <anthony.perard@xxxxxxxxxx>
AuthorDate: Thu Nov 3 11:52:01 2022 +0000
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Wed Nov 16 16:15:23 2022 +0000

    tools/include/xen-foreign: Add SPDX identifier to generated headers
    
    The headers install in "/usr/include/xen/foreign/" are missing a
    licence header. This patch adds a SPDX identifier to clarify that
    the MIT licence is used.
    
    The script now check that the licence of the input file is also MIT,
    by checking for the presence of the SPDX identifier.
    
    Also add information about which files are used to generate the
    headers.
    
    Reported-by: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
    Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
    Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Release-acked-by: Henry Wang <Henry.Wang@xxxxxxx>
---
 tools/include/xen-foreign/mkheader.py | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/tools/include/xen-foreign/mkheader.py 
b/tools/include/xen-foreign/mkheader.py
index fb268f0dce..081b57f842 100644
--- a/tools/include/xen-foreign/mkheader.py
+++ b/tools/include/xen-foreign/mkheader.py
@@ -1,5 +1,7 @@
 #!/usr/bin/python
 
+from __future__ import print_function
+
 import sys, re;
 from structs import unions, structs, defines;
 
@@ -114,23 +116,39 @@ input  = "";
 output = "";
 fileid = re.sub("[-.]", "_", "__FOREIGN_%s__" % outfile.upper());
 
-# read input header files
 for name in infiles:
     f = open(name, "r");
+
+    # Sanity check the licence of the input file(s)
+    line = f.readline()
+    if line != "/* SPDX-License-Identifier: MIT */\n":
+        print("Error: %s %s Missing or unexpected SPDX tag '%s'" %
+              (sys.argv[0], name, line.strip()), file=sys.stderr)
+        exit(1)
+
     input += f.read();
     f.close();
 
+# replace path in "infiles" by path in '/usr/include' to avoid exposing the
+# build directory path in the generated headers.
+headers_name_list = ""
+public_headers_location = 'xen/include/public/'
+for name in infiles:
+    i = name.rindex(public_headers_location)
+    i += len(public_headers_location)
+    headers_name_list += " xen/%s" % (name[i:])
+
 # add header
-output += """
+output += """/* SPDX-License-Identifier: MIT */
 /*
  * public xen defines and struct for %s
- * generated by %s -- DO NOT EDIT
+ * generated from%s by %s -- DO NOT EDIT
  */
 
 #ifndef %s
 #define %s 1
 
-""" % (arch, sys.argv[0], fileid, fileid)
+""" % (arch, headers_name_list, sys.argv[0], fileid, fileid)
 
 if arch in header:
     output += header[arch];
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.