make-plugin-reg: Update modification time to plugin.c
Let the build system handle the dependencies. Make sure to update the file even if nothing has changed to avoid re-running the script every time. Change-Id: I2229c13578a6278a04152825c98d8b889081dcb7 Reviewed-on: https://code.wireshark.org/review/24597 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: João Valverde <j@v6e.pt>
This commit is contained in:
parent
d865871627
commit
944a3c3a58
@ -7,8 +7,6 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import hashlib
|
|
||||||
from stat import *
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# The first argument is the directory in which the source files live.
|
# The first argument is the directory in which the source files live.
|
||||||
@ -72,7 +70,6 @@ patterns = [
|
|||||||
# Grep
|
# Grep
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
file = open(filename)
|
file = open(filename)
|
||||||
cur_mtime = os.fstat(file.fileno())[ST_MTIME]
|
|
||||||
# Read the whole file into memory
|
# Read the whole file into memory
|
||||||
contents = file.read()
|
contents = file.read()
|
||||||
for action in patterns:
|
for action in patterns:
|
||||||
@ -157,30 +154,11 @@ register_wtap_module(void)
|
|||||||
reg_code += " {extern void %s (void); %s ();}\n" % (symbol, symbol)
|
reg_code += " {extern void %s (void); %s ();}\n" % (symbol, symbol)
|
||||||
reg_code += "}"
|
reg_code += "}"
|
||||||
|
|
||||||
# Compare current and new content and update the file if anything has changed.
|
|
||||||
|
|
||||||
try: # Python >= 2.6, >= 3.0
|
|
||||||
reg_code_bytes = bytes(reg_code.encode('utf-8'))
|
|
||||||
except:
|
|
||||||
reg_code_bytes = reg_code
|
|
||||||
|
|
||||||
new_hash = hashlib.sha1(reg_code_bytes).hexdigest()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
fh = open(final_filename, 'rb')
|
|
||||||
cur_hash = hashlib.sha1(fh.read()).hexdigest()
|
|
||||||
fh.close()
|
|
||||||
except:
|
|
||||||
cur_hash = ''
|
|
||||||
|
|
||||||
try:
|
|
||||||
if new_hash != cur_hash:
|
|
||||||
print(('Updating ' + final_filename))
|
print(('Updating ' + final_filename))
|
||||||
fh = open(final_filename, 'w')
|
fh = open(final_filename, 'w')
|
||||||
fh.write(reg_code)
|
fh.write(reg_code)
|
||||||
fh.close()
|
fh.close()
|
||||||
else:
|
|
||||||
print((final_filename + ' unchanged.'))
|
|
||||||
except OSError:
|
except OSError:
|
||||||
sys.exit('Unable to write ' + final_filename + '.\n')
|
sys.exit('Unable to write ' + final_filename + '.\n')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user