-
-
Notifications
You must be signed in to change notification settings - Fork 315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DOC] improve description of CPPDEFINES #4235
Conversation
As part of this work, I added another example, intending to show the use of a (list, tuple) of tuples and/or a dictionary to pass multiple values to |
SCons/Defaults.xml
Outdated
|
||
<example_commands> | ||
# SPACED will just get the string 'spaced', arg will be a separate arg | ||
env = Environment(CPPDEFINES={'SPACED': 'spaced arg'}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that the current functionality? Hmm. not what I'd expect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revisited this. At the core, this is not an SCons limitation (although it becomes one because we always invoke a shell to run the compile command), but the fact that the definition is already in a Python string makes it really hard to get right. Here's what the cpp manpage says:
If you are invoking the preprocessor from a shell or shell-like program you may need to use the shell's quoting syntax to protect characters such as spaces that have a meaning in the shell syntax.
As additional fun, GCC's cpp supports function-like macros on the command line, MSVC does not. They have the extra problem of using parens, which matter to the shell also.
On the whole, we'd need to emit options this way:
gcc -D"FOO=thing with strings"
That is, quoting the whole definition rather than the right-hand-side, which I think there is no way to do with current syntax - we'd have to hack on _defines
I assume. Open to suggestions on how to describe this, if we should at all. I'm pushing a new revision which removes the example, because the example (just invented by me, not tested at the time) doesn't actually work - take a look at whether that wording covers the case or if we should just "remain silent" on this topic and figure people will only use simple replacement in CPPDEFINES.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding MSVC's manpage on the function-like macro topic for completeness:
The
/D
option doesn't support function-like macro definitions. To insert definitions that can't be defined on the command line, consider the/FI (Name forced include file)
compiler option.
and cpp's:
If you wish to define a function-like macro on the command line, write its argument list with surrounding parentheses before the equals sign (if any). Parentheses are meaningful to most shells, so you should quote the option. With sh and csh,
-D'name(args...)=definition'
works.
@mwichmann When working on #4174, I ran into docbook issues that were related to a internal lxml global limit that resulted in docbook failures without particularly helpful messages. The root cause took more time that it should have to figure out what was going awry. That particular issue was solved by added the ability to increase the global limit and hard-coding a new constant. As part of #4174, the following snippet was added to #
# lxml etree XSLT global max traversal depth
#
lmxl_xslt_global_max_depth = 3100
if has_lxml and lmxl_xslt_global_max_depth:
def __lxml_xslt_set_global_max_depth(max_depth):
from lxml import etree
etree.XSLT.set_global_max_depth(max_depth)
__lxml_xslt_set_global_max_depth(lmxl_xslt_global_max_depth) At the time, the hard-coded constant Could be worth a try to bump up the global max depth to see if that is the problem. For all I know, there may be more limits hard-coded into lxml as well. EDIT ADDITION: https://lxml.de/api/lxml.etree.XSLT-class.html
|
Thanks! I remember reading about this in your PR now you mention it, and it clearly didn't sink in because I in no way made the connection. Your guess is probably on target - bumping the limit made one build work out, but then something else blew up (in Sphinx, so it's past the phase where lxml is involved). |
ea57bb1
to
19a44a8
Compare
19a44a8
to
418f3ea
Compare
The CPPDEFINES entry and the Append method entry has some additonal clarification added, about ways cpp macros can be specified. Added a couple more examples to illustrate. Signed-off-by: Mats Wichmann <mats@linux.com>
Signed-off-by: Mats Wichmann <mats@linux.com>
At the moment, not sure why including the (new) example blows up the build, so leave it commented out. scons: *** [scons.1] XSLTApplyError : string Traceback (most recent call last): File "/home/mats/github/scons/scripts/../SCons/Action.py", line 1318, in execute result = self.execfunction(target=target, source=rsources, env=env) File "/home/mats/github/scons/build/SCons/Tool/docbook/__init__.py", line 353, in __build_lxml_noresult result = transform(doc) File "src/lxml/xslt.pxi", line 602, in lxml.etree.XSLT.__call__ lxml.etree.XSLTApplyError: string Signed-off-by: Mats Wichmann <mats@linux.com>
In the initial version of PR 4235, an added example was left commented out because it triggered an lxml failure. Thanks to @jcbrill, reminded that there's a global limit for lxml, which SCons can set in the docbook module. This is being bumped a bit, allowing the build to work. Rebased at the same time, so force-pushing. Signed-off-by: Mats Wichmann <mats@linux.com>
Signed-off-by: Mats Wichmann <mats@linux.com>
Signed-off-by: Mats Wichmann <mats@linux.com>
Signed-off-by: Mats Wichmann <mats@linux.com>
Signed-off-by: Mats Wichmann <mats@linux.com>
6695692
to
05ba00d
Compare
Avoid implying (as previous example did) it's a good idea to Append a lone tuple to get the -DFOO=BAR effect, as results will differ beween empty CPPDEFINES and a CPPDEFINES that already contains values - if empty you get: CPPDEFINES will expand to -D('OTHER', 2) Signed-off-by: Mats Wichmann <mats@linux.com>
Closed in favor of #4263 |
The
CPPDEFINES
entry and theAppend
method entry has some additional clarification added, about ways cpp macros can be specified. Added a couple more examples to illustrate.Doc-only change.
Signed-off-by: Mats Wichmann mats@linux.com
Contributor Checklist:
CHANGES.txt
(and read theREADME.rst
)