Commit ec88f026 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

don't copy {topdir}/COPYING to auto-generated files, following a

suggestion in code review.


git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@986 e5f2f494-b856-4b98-b285-d166d9295462
parent 0189b832
......@@ -36,7 +36,14 @@ class_definitions = ''
classdir_mtime = 0
rdatadef_mtime = 0
rdatahdr_mtime = 0
copyright_file = '@top_srcdir@' + os.sep + 'COPYING'
heading_txt = '''///////////////
///////////////
/////////////// THIS FILE IS AUTOMATICALLY GENERATED BY gen-rdatacode.py.
/////////////// DO NOT EDIT!
///////////////
///////////////
'''
def import_classdef(class_txt, file):
content = ''
......@@ -115,23 +122,6 @@ class MessageRenderer;\n\n'''
rdata_header.close()
return content
def import_copyright():
copyright_txt = ''
f = open(copyright_file, 'r')
for line in f.readlines():
copyright_txt += '// ' + line
f.close()
copyright_txt += '''
///////////////
///////////////
/////////////// THIS FILE IS AUTOMATICALLY GENERATED BY gen-rdatacode.py.
/////////////// DO NOT EDIT!
///////////////
///////////////
'''
return copyright_txt
def import_definitions(classcode2txt, typecode2txt, typeandclass):
global rdata_declarations
global class_definitions
......@@ -189,16 +179,16 @@ def need_generate(file, mtime):
return False
return True
def generate_rdatadef(file, copyright_txt, basemtime):
def generate_rdatadef(file, basemtime):
if not need_generate(file, basemtime):
print('skip generating ' + file);
return
rdata_deffile = open(file, 'w')
rdata_deffile.write(copyright_txt)
rdata_deffile.write(heading_txt)
rdata_deffile.write(class_definitions)
rdata_deffile.close()
def generate_rdatahdr(file, copyright_txt, declarations, basemtime):
def generate_rdatahdr(file, declarations, basemtime):
if not need_generate(file, basemtime):
print('skip generating ' + file);
return
......@@ -208,7 +198,7 @@ def generate_rdatahdr(file, copyright_txt, declarations, basemtime):
// End:
'''
rdata_header = open(file, 'w')
rdata_header.write(copyright_txt)
rdata_header.write(heading_txt)
rdata_header.write(declarations)
rdata_header.close()
......@@ -237,7 +227,7 @@ RR''' + cap_key + '''::''' + codetxt + '''()
'''
header_temp = open(placeholder, 'r')
header_out = open(outputfile, 'w')
header_out.write(copyright_txt)
header_out.write(heading_txt)
for line in header_temp.readlines():
header_out.write(line)
if re.match('\s+// BEGIN_WELL_KNOWN_' + upper_key + '_DECLARATIONS$', line):
......@@ -280,7 +270,7 @@ def generate_rrparam(fileprefix, basemtime):
rrparam_temp = open(placeholder, 'r')
rrparam_out = open(outputfile, 'w')
rrparam_out.write(copyright_txt)
rrparam_out.write(heading_txt)
for line in rrparam_temp.readlines():
rrparam_out.write(line)
if re.match('\s+// BEGIN_WELL_KNOWN_PARAMS', line):
......@@ -290,12 +280,10 @@ def generate_rrparam(fileprefix, basemtime):
if __name__ == "__main__":
try:
copyright_txt = import_copyright()
import_definitions(classcode2txt, typecode2txt, typeandclass)
generate_rdatadef('@srcdir@/rdataclass.cc', copyright_txt,
rdatadef_mtime)
generate_rdatahdr('@srcdir@/rdataclass.h', copyright_txt,
rdata_declarations, rdatahdr_mtime)
generate_rdatadef('@srcdir@/rdataclass.cc', rdatadef_mtime)
generate_rdatahdr('@srcdir@/rdataclass.h', rdata_declarations,
rdatahdr_mtime)
generate_typeclasscode('@srcdir@/rrtype',
max(rdatadef_mtime, rdatahdr_mtime),
typecode2txt, 'Type')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment