Re: parser option handling
Bernhard Fischer <[email protected]> Sat, 5 May 2007 20:49:27 +0200
| Newsgroups | gmane.comp.documentation.synopsis |
|---|---|
| Message-ID | <[email protected]> |
On Sat, May 05, 2007 at 11:02:18AM -0400, Stefan Seefeld wrote:
>Hi Bernhard,
>
>Bernhard Fischer wrote:
>
>> %.syn: %.c
>> synopsis -p C -l Comments.SSDFilter,Comments.Previous \
>> -Wp,preprocess=True,cppflags="'$(SYN_CPPFLAGS)'" -o $@ $<
>
>(Note that 'preprocess=True' by default.)
>Starting with the 0.9 release the comment processing is expressed differently:
>Use --cprocessor, --cfilter, and --translator with the 'synopsis' tool.
For synopsis trunk, i'm using the new syntax, as you mention:
$ make html
synopsis -p C --cprocessor=previous --cfilter=ssd
-Wp,cppflags="'-std=gnu99'",emulate_compiler="'gcc-mine -std=gnu99'"
-Iinclude -Ilibbb -I/home/cow/src/busybox_trunk/libbb --include
include/autoconf.h -D_GNU_SOURCE -DNDEBUG -D_LARGEFILE_SOURCE
-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
-D"BB_VER=KBUILD_STR\(1.6.0.svn\)" -DBB_BT=AUTOCONF_TIMESTAMP -o
applets/applets.syn applets/applets.c
Traceback (most recent call last):
File "/opt/synopsis-trunk/bin/synopsis", line 216, in ?
main()
File "/opt/synopsis-trunk/bin/synopsis", line 210, in main
processor = make_processor(sys.argv[1:])
File "/opt/synopsis-trunk/bin/synopsis", line 147, in make_processor
parser_opts['cppflags'].append('-I%s'%a)
AttributeError: 'str' object has no attribute 'append'
cppflags containing -std= is redundant, of course, but how would i pass
cppflags nowadays, if not via -D, -I etc?
-U seems to be missing, btw.
>
>However, note that the whole idea behind the 'synopsis' applet is to make the
>most common options available conveniently. It sounds as if you are on the
>borderline to more complex needs. You may consider using a synopsis script
>(http://synopsis.fresco.org/docs/Tutorial/script.html)
>
>That may be particularly practical if you use an autotools-based build system,
>as then you can write a 'synopsis.py.in' template and let configure substitute
>variables such as CPPFLAGS etc., so you don't need to deal with shell escaping.
This particular cross-reference is IMO simple enough not to require a
script. I want to keep it as simple as possible for a start.
>> 1) -std=gnu99
>> is currently not accepted but would influence the Cpp behaviour.
>
>Right, and I'm not sure what the best way to handle that is. Synopsis
>provides a mechanism to emulate a particular compiler, in particular
>in its preprocessing. It may make sense to consider to pass 'gcc -std=gnu99'
>as the 'emulate_compiler' option to the Cpp processor, and then let
>this sort out what CPP flags that maps to.
I'm doing that now, thanks.
>
>> 2) -include
>> is currently rejected, only --include is accepted.
>> This is, from the looks, merely a getopt-imposed misfeature.
>
>Heh. I wouldn't call it a misfeature. Synopsis unifies the handling of
>flags / options in POSIX style, i.e. '--' options are 'long options',
>while '-' options are one-letter (short) options. If anything it is
>gcc that is broken :-). (I recognize that this may be a matter of compatibility.)
>
>However, knowing this mismatch, it is easy enough to map '-include'
>to '--include' prior to passing it to Synopsis.
You mean me to map -include to --include for the command line or rewrite
a given '-include' to '--include' before parsing the options?