mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 15:48:21 +00:00
Allow --prenodef to be used anywhere in the command line.
This commit is contained in:
parent
26c4770bab
commit
e2de571f98
1 changed files with 35 additions and 29 deletions
64
main.py
64
main.py
|
@ -398,7 +398,8 @@ def main(argv):
|
||||||
avname = ''
|
avname = ''
|
||||||
shortname = ''
|
shortname = ''
|
||||||
assetid = '00000000-0000-0000-0000-000000000000'
|
assetid = '00000000-0000-0000-0000-000000000000'
|
||||||
preproc_cmdline = ['cpp']
|
preproc_command = 'cpp'
|
||||||
|
preproc_user_args = []
|
||||||
preproc = 'none'
|
preproc = 'none'
|
||||||
predefines = True
|
predefines = True
|
||||||
script_header = ''
|
script_header = ''
|
||||||
|
@ -470,37 +471,17 @@ def main(argv):
|
||||||
% (preproc, u"', '".join(supported)))
|
% (preproc, u"', '".join(supported)))
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
del preproc_cmdline[1:]
|
|
||||||
|
|
||||||
if preproc == 'gcpp':
|
if preproc == 'gcpp':
|
||||||
preproc_cmdline = [
|
preproc_command = 'cpp'
|
||||||
'cpp', '-undef', '-x', 'c', '-std=c99', '-nostdinc',
|
|
||||||
'-trigraphs', '-dN', '-fno-extended-identifiers',
|
|
||||||
]
|
|
||||||
|
|
||||||
elif preproc == 'mcpp':
|
elif preproc == 'mcpp':
|
||||||
preproc_cmdline = [
|
preproc_command = 'mcpp'
|
||||||
'mcpp', '-e', 'UTF-8', '-I-', '-N', '-3', '-j',
|
|
||||||
'-V199901L',
|
|
||||||
]
|
|
||||||
|
|
||||||
if predefines:
|
|
||||||
preproc_cmdline += [
|
|
||||||
'-Dinteger(...)=((integer)(__VA_ARGS__))',
|
|
||||||
'-Dfloat(...)=((float)(__VA_ARGS__))',
|
|
||||||
'-Dstring(...)=((string)(__VA_ARGS__))',
|
|
||||||
'-Dkey(...)=((key)(__VA_ARGS__))',
|
|
||||||
'-Drotation(...)=((rotation)(__VA_ARGS__))',
|
|
||||||
'-Dquaternion(...)=((quaternion)(__VA_ARGS__))',
|
|
||||||
'-Dvector(...)=((vector)(__VA_ARGS__))',
|
|
||||||
'-Dlist(...)=((list)(__VA_ARGS__))',
|
|
||||||
]
|
|
||||||
|
|
||||||
elif opt == '--precmd':
|
elif opt == '--precmd':
|
||||||
preproc_cmdline[0] = arg
|
preproc_command = arg
|
||||||
|
|
||||||
elif opt in ('-P', '--prearg'):
|
elif opt in ('-P', '--prearg'):
|
||||||
preproc_cmdline.append(arg)
|
preproc_user_args.append(arg)
|
||||||
|
|
||||||
elif opt == '--prenodef':
|
elif opt == '--prenodef':
|
||||||
predefines = False
|
predefines = False
|
||||||
|
@ -595,15 +576,40 @@ def main(argv):
|
||||||
if shortname == '':
|
if shortname == '':
|
||||||
shortname = os.path.basename(fname)
|
shortname = os.path.basename(fname)
|
||||||
|
|
||||||
|
# Build preprocessor command line
|
||||||
|
preproc_cmdline = [preproc_command]
|
||||||
if predefines:
|
if predefines:
|
||||||
preproc_cmdline.append('-D__AGENTKEY__="' + avid + '"')
|
if preproc == 'gcpp':
|
||||||
preproc_cmdline.append('-D__AGENTID__="' + avid + '"')
|
preproc_cmdline += [
|
||||||
|
'-undef', '-x', 'c', '-std=c99', '-nostdinc',
|
||||||
|
'-trigraphs', '-dN', '-fno-extended-identifiers',
|
||||||
|
]
|
||||||
|
|
||||||
|
elif preproc == 'mcpp':
|
||||||
|
preproc_cmdline += [
|
||||||
|
'-e', 'UTF-8', '-I-', '-N', '-3', '-j',
|
||||||
|
'-V199901L',
|
||||||
|
]
|
||||||
|
|
||||||
|
preproc_cmdline += [
|
||||||
|
'-Dinteger(...)=((integer)(__VA_ARGS__))',
|
||||||
|
'-Dfloat(...)=((float)(__VA_ARGS__))',
|
||||||
|
'-Dstring(...)=((string)(__VA_ARGS__))',
|
||||||
|
'-Dkey(...)=((key)(__VA_ARGS__))',
|
||||||
|
'-Drotation(...)=((rotation)(__VA_ARGS__))',
|
||||||
|
'-Dquaternion(...)=((quaternion)(__VA_ARGS__))',
|
||||||
|
'-Dvector(...)=((vector)(__VA_ARGS__))',
|
||||||
|
'-Dlist(...)=((list)(__VA_ARGS__))',
|
||||||
|
]
|
||||||
|
preproc_cmdline.append('-D__AGENTKEY__="%s"' % avid)
|
||||||
|
preproc_cmdline.append('-D__AGENTID__="%s"' % avid)
|
||||||
preproc_cmdline.append('-D__AGENTIDRAW__=' + avid)
|
preproc_cmdline.append('-D__AGENTIDRAW__=' + avid)
|
||||||
preproc_cmdline.append('-D__AGENTNAME__="' + avname + '"')
|
preproc_cmdline.append('-D__AGENTNAME__="%s"' % avname)
|
||||||
preproc_cmdline.append('-D__ASSETID__=' + assetid)
|
preproc_cmdline.append('-D__ASSETID__=' + assetid)
|
||||||
preproc_cmdline.append('-D__SHORTFILE__="' + shortname + '"')
|
preproc_cmdline.append('-D__SHORTFILE__="%s"' % shortname)
|
||||||
preproc_cmdline.append('-D__OPTIMIZER__=LSL PyOptimizer')
|
preproc_cmdline.append('-D__OPTIMIZER__=LSL PyOptimizer')
|
||||||
preproc_cmdline.append('-D__OPTIMIZER_VERSION__=' + VERSION)
|
preproc_cmdline.append('-D__OPTIMIZER_VERSION__=' + VERSION)
|
||||||
|
preproc_cmdline += preproc_user_args
|
||||||
|
|
||||||
if type(script) is unicode:
|
if type(script) is unicode:
|
||||||
script = script.encode('utf8')
|
script = script.encode('utf8')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue