mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 07:38:21 +00:00
Append --preargs options at the end of the command line
Allows the user to override default defines, for example. Also add docstring to PreparePreproc().
This commit is contained in:
parent
7dcd7aa315
commit
f958b1cdf9
1 changed files with 11 additions and 1 deletions
12
main.py
12
main.py
|
@ -87,6 +87,13 @@ class UniConvScript(object):
|
||||||
return self.script
|
return self.script
|
||||||
|
|
||||||
def PreparePreproc(script):
|
def PreparePreproc(script):
|
||||||
|
"""LSL accepts multiline strings, but the preprocessor doesn't.
|
||||||
|
Fix that by converting newlines to "\n". But in order to report accurate
|
||||||
|
line and column numbers for text past that point, insert blank lines to
|
||||||
|
fill the space previously occupied by the string, and spaces in the last
|
||||||
|
line up to the point where the string was closed. That will place the next
|
||||||
|
token in the same line and column it previously was.
|
||||||
|
"""
|
||||||
s = ''
|
s = ''
|
||||||
nlines = 0
|
nlines = 0
|
||||||
col = 0
|
col = 0
|
||||||
|
@ -589,7 +596,7 @@ def main(argv):
|
||||||
shortname = os.path.basename(fname)
|
shortname = os.path.basename(fname)
|
||||||
|
|
||||||
# Build preprocessor command line
|
# Build preprocessor command line
|
||||||
preproc_cmdline = [preproc_command] + preproc_user_args
|
preproc_cmdline = [preproc_command]
|
||||||
if preproc == 'gcpp':
|
if preproc == 'gcpp':
|
||||||
preproc_cmdline += [
|
preproc_cmdline += [
|
||||||
'-undef', '-x', 'c', '-std=c99', '-nostdinc',
|
'-undef', '-x', 'c', '-std=c99', '-nostdinc',
|
||||||
|
@ -622,6 +629,9 @@ def main(argv):
|
||||||
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)
|
||||||
|
|
||||||
|
# Append user arguments at the end to allow them to override defaults
|
||||||
|
preproc_cmdline += preproc_user_args
|
||||||
|
|
||||||
if type(script) is unicode:
|
if type(script) is unicode:
|
||||||
script = script.encode('utf8')
|
script = script.encode('utf8')
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue