mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-02 03:49:12 +08:00
Header generator: Only get active for no output files or when output older than input
This commit is contained in:
@@ -93,6 +93,29 @@ def convert_dir(inputdir, outputdir, templatedir):
|
|||||||
"""
|
"""
|
||||||
Converts all .msg files in inputdir to uORB header files
|
Converts all .msg files in inputdir to uORB header files
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Find the most recent modification time in input dir
|
||||||
|
maxinputtime = 0
|
||||||
|
for f in os.listdir(inputdir):
|
||||||
|
fni = os.path.join(inputdir, f)
|
||||||
|
if os.path.isfile(fni):
|
||||||
|
it = os.path.getmtime(fni)
|
||||||
|
if it > maxinputtime:
|
||||||
|
maxinputtime = it;
|
||||||
|
|
||||||
|
# Find the most recent modification time in output dir
|
||||||
|
maxouttime = 0
|
||||||
|
for f in os.listdir(outputdir):
|
||||||
|
fni = os.path.join(outputdir, f)
|
||||||
|
if os.path.isfile(fni):
|
||||||
|
it = os.path.getmtime(fni)
|
||||||
|
if it > maxouttime:
|
||||||
|
maxouttime = it;
|
||||||
|
|
||||||
|
# Do not generate if nothing changed on the input
|
||||||
|
if (maxinputtime != 0 and maxouttime != 0 and maxinputtime < maxouttime):
|
||||||
|
return False
|
||||||
|
|
||||||
includepath = incl_default + [':'.join([package, inputdir])]
|
includepath = incl_default + [':'.join([package, inputdir])]
|
||||||
for f in os.listdir(inputdir):
|
for f in os.listdir(inputdir):
|
||||||
fn = os.path.join(inputdir, f)
|
fn = os.path.join(inputdir, f)
|
||||||
@@ -103,6 +126,8 @@ def convert_dir(inputdir, outputdir, templatedir):
|
|||||||
templatedir,
|
templatedir,
|
||||||
includepath)
|
includepath)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def copy_changed(inputdir, outputdir, prefix=''):
|
def copy_changed(inputdir, outputdir, prefix=''):
|
||||||
"""
|
"""
|
||||||
@@ -139,10 +164,11 @@ def convert_dir_save(inputdir, outputdir, templatedir, temporarydir, prefix):
|
|||||||
Unchanged existing files are not overwritten.
|
Unchanged existing files are not overwritten.
|
||||||
"""
|
"""
|
||||||
# Create new headers in temporary output directory
|
# Create new headers in temporary output directory
|
||||||
convert_dir(inputdir, temporarydir, templatedir)
|
if (convert_dir(inputdir, temporarydir, templatedir)):
|
||||||
|
# Copy changed headers from temporary dir to output dir
|
||||||
# Copy changed headers from temporary dir to output dir
|
copy_changed(temporarydir, outputdir, prefix)
|
||||||
copy_changed(temporarydir, outputdir, prefix)
|
else:
|
||||||
|
print('No changes.')
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
|
|||||||
Reference in New Issue
Block a user