mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Added command line option to display the preprocessor output.
Will help identify the source line until preprocessor line tracking is implemented.
This commit is contained in:
parent
7d0ee20058
commit
aad73fb71d
1 changed files with 23 additions and 16 deletions
39
main.py
39
main.py
|
@ -169,6 +169,7 @@ Usage: {progname}
|
||||||
[-P|--prearg=<arg>] add parameter to preprocessor's command line
|
[-P|--prearg=<arg>] add parameter to preprocessor's command line
|
||||||
[--precmd=<cmd>] preprocessor command ('cpp' by default)
|
[--precmd=<cmd>] preprocessor command ('cpp' by default)
|
||||||
[--prenodef] no LSL specific defines (__AGENTKEY__ etc.)
|
[--prenodef] no LSL specific defines (__AGENTKEY__ etc.)
|
||||||
|
[--preshow] show preprocessor output, and stop
|
||||||
[--avid=<UUID>] specify UUID of avatar saving the script
|
[--avid=<UUID>] specify UUID of avatar saving the script
|
||||||
[--avname=<name>] specify name of avatar saving the script
|
[--avname=<name>] specify name of avatar saving the script
|
||||||
[--assetid=<UUID>] specify the asset UUID of the script
|
[--assetid=<UUID>] specify the asset UUID of the script
|
||||||
|
@ -296,7 +297,7 @@ def main():
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.gnu_getopt(sys.argv[1:], 'hO:o:p:P:H',
|
opts, args = getopt.gnu_getopt(sys.argv[1:], 'hO:o:p:P:H',
|
||||||
('optimizer-options=', 'help', 'version', 'output=', 'header',
|
('optimizer-options=', 'help', 'version', 'output=', 'header',
|
||||||
'preproc=', 'precmd=', 'prearg=', 'prenodef',
|
'preproc=', 'precmd=', 'prearg=', 'prenodef', 'preshow',
|
||||||
'avid=', 'avname=', 'assetid=', 'scriptname='))
|
'avid=', 'avname=', 'assetid=', 'scriptname='))
|
||||||
except getopt.GetoptError:
|
except getopt.GetoptError:
|
||||||
Usage()
|
Usage()
|
||||||
|
@ -312,6 +313,7 @@ def main():
|
||||||
predefines = True
|
predefines = True
|
||||||
script_header = ''
|
script_header = ''
|
||||||
mcpp_mode = False
|
mcpp_mode = False
|
||||||
|
preshow = False
|
||||||
|
|
||||||
for opt, arg in opts:
|
for opt, arg in opts:
|
||||||
if type(opt) is unicode:
|
if type(opt) is unicode:
|
||||||
|
@ -386,6 +388,9 @@ def main():
|
||||||
elif opt == '--prenodef':
|
elif opt == '--prenodef':
|
||||||
predefines = False
|
predefines = False
|
||||||
|
|
||||||
|
elif opt == '--preshow':
|
||||||
|
preshow = True
|
||||||
|
|
||||||
elif opt in ('-H', '--header'):
|
elif opt in ('-H', '--header'):
|
||||||
script_header = True
|
script_header = True
|
||||||
|
|
||||||
|
@ -486,23 +491,25 @@ def main():
|
||||||
elif x == 'USE_LAZY_LISTS':
|
elif x == 'USE_LAZY_LISTS':
|
||||||
options.add('lazylists')
|
options.add('lazylists')
|
||||||
|
|
||||||
p = parser()
|
if not preshow:
|
||||||
try:
|
|
||||||
ts = p.parse(script, options)
|
|
||||||
except EParse as e:
|
|
||||||
sys.stderr.write(e.message + '\n')
|
|
||||||
return 1
|
|
||||||
del p
|
|
||||||
|
|
||||||
opt = optimizer()
|
p = parser()
|
||||||
ts = opt.optimize(ts, options)
|
try:
|
||||||
del opt
|
ts = p.parse(script, options)
|
||||||
|
except EParse as e:
|
||||||
|
sys.stderr.write(e.message + '\n')
|
||||||
|
return 1
|
||||||
|
del p
|
||||||
|
|
||||||
outs = outscript()
|
opt = optimizer()
|
||||||
script = script_header + outs.output(ts, options)
|
ts = opt.optimize(ts, options)
|
||||||
del outs
|
del opt
|
||||||
del ts
|
|
||||||
del script_header
|
outs = outscript()
|
||||||
|
script = script_header + outs.output(ts, options)
|
||||||
|
del outs
|
||||||
|
del ts
|
||||||
|
del script_header
|
||||||
|
|
||||||
if outfile == '-':
|
if outfile == '-':
|
||||||
sys.stdout.write(script)
|
sys.stdout.write(script)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue