Re: parser option handling

Stefan Seefeld <[email protected]> Sat, 05 May 2007 16:26:23 -0400
Newsgroups gmane.comp.documentation.synopsis
Message-ID <[email protected]>
Bernhard Fischer wrote:

> 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'

That's an interesting error. It is caused by you passing 'cppflags'
explicitely (as a string), and then adding to it (where it is assumed
cppflags is a list). I have to think about how to prevent that. I guess
such mixed usage of both 'cppflags' as well as '-D' etc. is rather uncommon.

> cppflags containing -std= is redundant, of course, but how would i pass
> cppflags nowadays, if not via -D, -I etc?

You wouldn't, when using the synopsis applet. (and '-std' is in fact not
a recognized option. I'm not sure it is a good idea to allow unknown options
to be passed through. Where I think it makes sense to pass them through is
in the naming of the 'emulated_compiler' flag. (Logically 'gcc' and 'gcc -std=...'
are two distinct compilers, as far as emulation goes.)

> -U seems to be missing, btw.

You are right. I'll add that.

>> 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.

Understood. The reason I'm suggesting it is because of this '-Dfoo=bar(baz)'
syntax, which needs to be escaped properly. Such things get messy quite easily.

[...]

>> 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?

I mean to use a makefile function like $(subst --include, -include, $(CPPFLAGS)).

Regards,
		Stefan

-- 

      ...ich hab' noch einen Koffer in Berlin...