Hi there.  I've developed a module for scripting at Broadcom, and I received 
permissions to publish it to CPAN.    The module is "unifdef+".    It's 
functionality is based on the bash utility unifdef, but it's a bit more 
advanced (it simplifies the precompiler conditionals for example, and has 
support to process dependencies in Kconfig files, and some limited support for 
Makefiles, which still needs work).   It would be good to push upstream, as it 
is very useful for feature tracking.

I was reading through http://engineering.tilt.com/lessons-learned-cpan/ and 
they suggested I email this address to figure out the best name for this 
module.    Currently, it exists as UnifdefPlus.pm, which is invoked from some 
wrappers: unifdef+.pl, unkconfig.pl and unmakefile.pl.     The usage for 
unifdef+ is as follows:



Usage:

  unifdef+ [options] file

  unifdef+ [options] -F file

  unifdef+ [options] [-I file] [-O file]

  unifdef+ --version



Options:

  -D name[=val]     declare name as defined.  All compiler directives related 
to name will be

                    simplified as if name was defined as val.  If val is not 
specified, a value

                    of 'y' will be assumed.  This option may be repeated 
multiple times.

  -U name           declare name as undefined.  All compiler directives related 
to name will be

                    simplified as if name was undefined.  This option may be 
repeated multiple

                    times.

  -I filename       Take input from filename

  -O filename       Send output to filename

  -F filename       Modify filename

  --simplifiedonly  Only output lines within a simplified 
#if/#elif/#else/#endif clause

  --dbg             run with debugging enabled

  --version         outputs the current version of unifdef+





Description:

  The unifdef+ utility is designed to simplify c and cpp files based on 
preprocessor conditionals.

It has the ability to expand and simplify preprocessor conditionals ( #if, 
#ifdef, #elif, #else,

#endif statements) based on the values passed in on the command line.  If a 
preprocessor conditional

contains any of the macros specified on the command line, unifdef+ will 
substitute the known values

and then proceed to simplify the expression.  If the condition resolves to 
either true or false, all

unused code is removed from the output.  Otherwise, the condition is replaced 
with the simplified

version in the output.



Exit Status:

  The exit status will be 0 if the input has not been modified, 1 if there are 
modifications, or

  2 if there is an error processing the input.



Example:

  unifdef+ -U CC_FEATURE1 -D CC_VER=12 -D CC_FEATURE2=y somefile.c
Thanks,

John

Reply via email to