python,scons,mem-ruby: Tag origin of generated files
This will make it easier to backtrack and modify such files when needed. Change-Id: If09b6f848e607fb21a0acf2114ce0b9b0aa4751f Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/47301 Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Maintainer: Jason Lowe-Power <power.jg@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
committed by
Daniel Carvalho
parent
297fa863de
commit
30e770e137
@@ -1149,10 +1149,6 @@ def makeDebugFlagCC(target, source, env):
|
||||
|
||||
# file header
|
||||
code('''
|
||||
/*
|
||||
* DO NOT EDIT THIS FILE! Automatically generated by SCons.
|
||||
*/
|
||||
|
||||
#include "base/debug.hh"
|
||||
|
||||
namespace Debug {
|
||||
@@ -1206,10 +1202,6 @@ def makeDebugFlagHH(target, source, env):
|
||||
|
||||
# file header boilerplate
|
||||
code('''\
|
||||
/*
|
||||
* DO NOT EDIT THIS FILE! Automatically generated by SCons.
|
||||
*/
|
||||
|
||||
#ifndef __DEBUG_${name}_HH__
|
||||
#define __DEBUG_${name}_HH__
|
||||
|
||||
|
||||
@@ -272,11 +272,7 @@ class $py_ident(RubyController):
|
||||
c_ident = "%s_Controller" % self.ident
|
||||
|
||||
code('''
|
||||
/** \\file $c_ident.hh
|
||||
*
|
||||
* Auto generated C++ code started by $__file__:$__line__
|
||||
* Created by slicc definition of Module "${{self.short}}"
|
||||
*/
|
||||
// Created by slicc definition of Module "${{self.short}}"
|
||||
|
||||
#ifndef __${ident}_CONTROLLER_HH__
|
||||
#define __${ident}_CONTROLLER_HH__
|
||||
@@ -492,11 +488,7 @@ void unset_tbe(${{self.TBEType.c_ident}}*& m_tbe_ptr);
|
||||
'''
|
||||
|
||||
code('''
|
||||
/** \\file $c_ident.cc
|
||||
*
|
||||
* Auto generated C++ code started by $__file__:$__line__
|
||||
* Created by slicc definition of Module "${{self.short}}"
|
||||
*/
|
||||
// Created by slicc definition of Module "${{self.short}}"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
@@ -1220,7 +1212,6 @@ $c_ident::functionalReadBuffers(PacketPtr& pkt, WriteMask &mask)
|
||||
outputRequest_types = False
|
||||
|
||||
code('''
|
||||
// Auto generated C++ code started by $__file__:$__line__
|
||||
// ${ident}: ${{self.short}}
|
||||
|
||||
#include <sys/types.h>
|
||||
@@ -1343,7 +1334,6 @@ ${ident}_Controller::wakeup()
|
||||
ident = self.ident
|
||||
|
||||
code('''
|
||||
// Auto generated C++ code started by $__file__:$__line__
|
||||
// ${ident}: ${{self.short}}
|
||||
|
||||
#include <cassert>
|
||||
|
||||
@@ -126,7 +126,6 @@ class SymbolTable(object):
|
||||
makeDir(path)
|
||||
|
||||
code = self.codeFormatter()
|
||||
code('/** Auto generated C++ code started by $__file__:$__line__ */')
|
||||
|
||||
for include_path in includes:
|
||||
code('#include "${{include_path}}"')
|
||||
|
||||
@@ -204,12 +204,6 @@ class Type(Symbol):
|
||||
def printTypeHH(self, path):
|
||||
code = self.symtab.codeFormatter()
|
||||
code('''
|
||||
/** \\file ${{self.c_ident}}.hh
|
||||
*
|
||||
*
|
||||
* Auto generated C++ code started by $__file__:$__line__
|
||||
*/
|
||||
|
||||
#ifndef __${{self.c_ident}}_HH__
|
||||
#define __${{self.c_ident}}_HH__
|
||||
|
||||
@@ -404,11 +398,6 @@ operator<<(std::ostream& out, const ${{self.c_ident}}& obj)
|
||||
code = self.symtab.codeFormatter()
|
||||
|
||||
code('''
|
||||
/** \\file ${{self.c_ident}}.cc
|
||||
*
|
||||
* Auto generated C++ code started by $__file__:$__line__
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
@@ -449,11 +438,6 @@ out << "${{dm.ident}} = " << printAddress(m_${{dm.ident}}) << " ";''')
|
||||
def printEnumHH(self, path):
|
||||
code = self.symtab.codeFormatter()
|
||||
code('''
|
||||
/** \\file ${{self.c_ident}}.hh
|
||||
*
|
||||
* Auto generated C++ code started by $__file__:$__line__
|
||||
*/
|
||||
|
||||
#ifndef __${{self.c_ident}}_HH__
|
||||
#define __${{self.c_ident}}_HH__
|
||||
|
||||
@@ -555,11 +539,6 @@ std::ostream& operator<<(std::ostream& out, const ${{self.c_ident}}& obj);
|
||||
def printEnumCC(self, path):
|
||||
code = self.symtab.codeFormatter()
|
||||
code('''
|
||||
/** \\file ${{self.c_ident}}.hh
|
||||
*
|
||||
* Auto generated C++ code started by $__file__:$__line__
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
@@ -154,6 +154,36 @@ class code_formatter(object, metaclass=code_formatter_meta):
|
||||
|
||||
def write(self, *args):
|
||||
f = open(os.path.join(*args), "w")
|
||||
name, extension = os.path.splitext(f.name)
|
||||
|
||||
# Add a comment to inform which file generated the generated file
|
||||
# to make it easier to backtrack and modify generated code
|
||||
frame = inspect.currentframe().f_back
|
||||
if re.match('\.(cc|hh|c|h)', extension) is not None:
|
||||
f.write(f'''/**
|
||||
* DO NOT EDIT THIS FILE!
|
||||
* File automatically generated by
|
||||
* {frame.f_code.co_filename}:{frame.f_lineno}
|
||||
*/
|
||||
|
||||
''')
|
||||
elif re.match('\.py', extension) is not None:
|
||||
f.write(f'''#
|
||||
# DO NOT EDIT THIS FILE!
|
||||
# File automatically generated by
|
||||
# {frame.f_code.co_filename}:{frame.f_lineno}
|
||||
#
|
||||
|
||||
''')
|
||||
elif re.match('\.html', extension) is not None:
|
||||
f.write(f'''<!--
|
||||
DO NOT EDIT THIS FILE!
|
||||
File automatically generated by
|
||||
{frame.f_code.co_filename}:{frame.f_lineno}
|
||||
-->
|
||||
|
||||
''')
|
||||
|
||||
for data in self._data:
|
||||
f.write(data)
|
||||
f.close()
|
||||
|
||||
Reference in New Issue
Block a user