mirror of
https://github.com/avrdudes/avrdude.git
synced 2026-09-21 00:26:22 +03:00
added script version information
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/* This file was auto-generated by scripts_decoder.py.
|
||||
* Any changes will be overwritten on regeneration
|
||||
* version:001079
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* This file was auto-generated by scripts_decoder.py.
|
||||
* Any changes will be overwritten on regeneration
|
||||
* version:001079
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* This file was auto-generated by scripts_decoder.py.
|
||||
* Any changes will be overwritten on regeneration
|
||||
* version:001079
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* This file was auto-generated by scripts_decoder.py.
|
||||
* Any changes will be overwritten on regeneration
|
||||
* version:001079
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* This file was auto-generated by scripts_decoder.py.
|
||||
* Any changes will be overwritten on regeneration
|
||||
* version:001079
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* This file was auto-generated by scripts_decoder.py.
|
||||
* Any changes will be overwritten on regeneration
|
||||
* version:001079
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* This file was auto-generated by scripts_decoder.py.
|
||||
* Any changes will be overwritten on regeneration
|
||||
* version:001079
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
@@ -100,13 +100,17 @@ cache_dir = os.path.join(work_dir, "scripts_cache")
|
||||
print(work_dir)
|
||||
print(cache_dir)
|
||||
|
||||
version = "000000" # placeholder
|
||||
|
||||
use_older = False # used for version comparison
|
||||
|
||||
# Beginning of C and H Files
|
||||
common_header = \
|
||||
'''\
|
||||
def get_common_header():
|
||||
global version
|
||||
common_header = f'''\
|
||||
/* This file was auto-generated by scripts_decoder.py.
|
||||
* Any changes will be overwritten on regeneration
|
||||
* version:{version}
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -128,6 +132,7 @@ common_header = \
|
||||
*/
|
||||
|
||||
'''
|
||||
return common_header
|
||||
|
||||
# generates the h-file. generates the struct definition
|
||||
def generate_h_file(c_funcs, file_dir):
|
||||
@@ -162,7 +167,6 @@ int get_pickit_tpi_script(SCRIPT *scr, const char *partdesc);
|
||||
|
||||
#endif // pickit5_lut_h
|
||||
'''
|
||||
global common_header
|
||||
if file_dir is None:
|
||||
return
|
||||
|
||||
@@ -171,7 +175,7 @@ int get_pickit_tpi_script(SCRIPT *scr, const char *partdesc);
|
||||
os.remove(h_lut_path)
|
||||
|
||||
with open(h_lut_path, 'w') as h_file:
|
||||
h_file.write(common_header)
|
||||
h_file.write(get_common_header())
|
||||
h_file.write(h_header)
|
||||
for func_name in c_funcs:
|
||||
h_file.write(" const unsigned char *{0};\n unsigned int {0}_len;\n".format(func_name))
|
||||
@@ -180,6 +184,24 @@ int get_pickit_tpi_script(SCRIPT *scr, const char *partdesc);
|
||||
#EOF
|
||||
|
||||
|
||||
# check version numbers, ask if user wants an older version
|
||||
def version_check(file_dir, new_version):
|
||||
old_version_int = 0
|
||||
if file_dir is not None:
|
||||
h_lut_path = os.path.join(file_dir, "pickit5_lut.h")
|
||||
if (os.path.exists(h_lut_path)):
|
||||
with open(h_lut_path, "r") as h_file:
|
||||
for _ in range(5): # read at most the first 5 lines
|
||||
line = h_file.readline()
|
||||
if len(line) == 0: # EOF
|
||||
break
|
||||
if line.startswith(" * version:"):
|
||||
old_version_int = int(line.split(":")[1], 10)
|
||||
if old_version_int > int(new_version, 10):
|
||||
print("WARNING: Overwriting lut files with an older scripts version!")
|
||||
print(f"Old version: {old_version_int:06}\nNew Vesion: {new_version}")
|
||||
return int(new_version, 10) - old_version_int
|
||||
#EOF
|
||||
|
||||
|
||||
# Tries to locate the xml file in a known location
|
||||
@@ -252,10 +274,6 @@ def convert_xml(xml_path, c_funcs):
|
||||
print("Parent Dir: {0}".format(parent_dir))
|
||||
print("Src directory: {0}".format(src_dir))
|
||||
|
||||
|
||||
# create h-File (make sure to provide all function definitions)
|
||||
generate_h_file(c_funcs, src_dir)
|
||||
|
||||
|
||||
with open(xml_path, "r") as xml_script:
|
||||
print ("XML File opened")
|
||||
@@ -332,13 +350,25 @@ def convert_xml(xml_path, c_funcs):
|
||||
# }
|
||||
#}
|
||||
# /if starts with
|
||||
elif line.startswith(" <version>"):
|
||||
global version
|
||||
vers_str = line[11:] # remove " <version>"
|
||||
vers_str = vers_str.split("<", 2)[0] # remove trailing element
|
||||
version = vers_str
|
||||
|
||||
# 0: equal / < 0: current xml older then current lut / > 0: newer, or if old is non-existent
|
||||
ver_diff = version_check(src_dir, version)
|
||||
|
||||
# /while True
|
||||
# /with open
|
||||
|
||||
# create h-File (make sure to provide all function definitions)
|
||||
# create only after processing XML File with version info
|
||||
generate_h_file(c_funcs, src_dir)
|
||||
|
||||
print("XML File processed")
|
||||
|
||||
# create c-File
|
||||
global common_header
|
||||
|
||||
for prog_iface, prog_mcu_list in program_iface.items():
|
||||
lower_prog_iface = prog_iface.lower()
|
||||
@@ -346,7 +376,7 @@ def convert_xml(xml_path, c_funcs):
|
||||
if (os.path.exists(c_lut_path)):
|
||||
os.remove(c_lut_path)
|
||||
with open(c_lut_path, 'w') as c_file:
|
||||
c_file.write(common_header)
|
||||
c_file.write(get_common_header())
|
||||
c_file.write("#include <ac_cfg.h>\n")
|
||||
c_file.write("#include <stddef.h>\n")
|
||||
c_file.write("#include <string.h>\n")
|
||||
|
||||
Reference in New Issue
Block a user