diff mbox series

[RFC,02/11] decodetree: Add multiple include guard

Message ID 20181111233622.8976-3-f4bug@amsat.org (mailing list archive)
State New, archived
Headers show
Series decodetree: Add tokens to ease checking ISA flags | expand

Commit Message

Philippe Mathieu-Daudé Nov. 11, 2018, 11:36 p.m. UTC
It is necessary when splitting an ISA, or when using multiple ISAs.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
TODO: explain why, use case
TODO: escape full path?
---
 scripts/decodetree.py | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Eduardo Habkost Nov. 12, 2018, 10:30 p.m. UTC | #1
On Mon, Nov 12, 2018 at 12:36:13AM +0100, Philippe Mathieu-Daudé wrote:
> It is necessary when splitting an ISA, or when using multiple ISAs.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> TODO: explain why, use case
> TODO: escape full path?
> ---
>  scripts/decodetree.py | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/scripts/decodetree.py b/scripts/decodetree.py
> index 0bc73b5990..5dea15e7a5 100755
> --- a/scripts/decodetree.py
> +++ b/scripts/decodetree.py
> @@ -1030,7 +1030,11 @@ def main():
>      else:
>          output_fd = sys.stdout
>  
> +    hdr_guard = filename.split(os.path.sep)[-1].upper().replace('.', '_') + "_H"

Isn't
  filename.split(os.path.sep)[-1]
equivalent to
  os.path.basename(filename)
?


> +    hdr_guard = filename.split(os.path.sep)[-1].upper().replace('.', '_') + "_H"
> +
>      output_autogen()
> +    output('#ifndef ' + hdr_guard + '\n')
> +    output('#define ' + hdr_guard + '\n')
>      for n in sorted(arguments.keys()):
>          f = arguments[n]
>          f.output_def()
> @@ -1066,6 +1070,7 @@ def main():
>      t.output_code(4, False, 0, 0)
>  
>      output('}\n')
> +    output('#endif /* ' + hdr_guard + ' */\n')
>  
>      if output_file:
>          output_fd.close()
> -- 
> 2.17.2
>
Philippe Mathieu-Daudé Nov. 12, 2018, 11:30 p.m. UTC | #2
On 12/11/18 23:30, Eduardo Habkost wrote:
> On Mon, Nov 12, 2018 at 12:36:13AM +0100, Philippe Mathieu-Daudé wrote:
>> It is necessary when splitting an ISA, or when using multiple ISAs.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>> TODO: explain why, use case
>> TODO: escape full path?
>> ---
>>   scripts/decodetree.py | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/scripts/decodetree.py b/scripts/decodetree.py
>> index 0bc73b5990..5dea15e7a5 100755
>> --- a/scripts/decodetree.py
>> +++ b/scripts/decodetree.py
>> @@ -1030,7 +1030,11 @@ def main():
>>       else:
>>           output_fd = sys.stdout
>>   
>> +    hdr_guard = filename.split(os.path.sep)[-1].upper().replace('.', '_') + "_H"
> 
> Isn't
>    filename.split(os.path.sep)[-1]
> equivalent to
>    os.path.basename(filename)
> ?

Yes, thanks :)
diff mbox series

Patch

diff --git a/scripts/decodetree.py b/scripts/decodetree.py
index 0bc73b5990..5dea15e7a5 100755
--- a/scripts/decodetree.py
+++ b/scripts/decodetree.py
@@ -1030,7 +1030,11 @@  def main():
     else:
         output_fd = sys.stdout
 
+    hdr_guard = filename.split(os.path.sep)[-1].upper().replace('.', '_') + "_H"
+
     output_autogen()
+    output('#ifndef ' + hdr_guard + '\n')
+    output('#define ' + hdr_guard + '\n')
     for n in sorted(arguments.keys()):
         f = arguments[n]
         f.output_def()
@@ -1066,6 +1070,7 @@  def main():
     t.output_code(4, False, 0, 0)
 
     output('}\n')
+    output('#endif /* ' + hdr_guard + ' */\n')
 
     if output_file:
         output_fd.close()