NAME

cpppp - Command line tool to process cpppp templates

USAGE

cpppp [OPTIONS] [TEMPLATE_FILE ACTIONS...]... > file.c
cpppp [OPTIONS] [TEMPLATE_FILE ACTIONS...]... --list-sections
cpppp --version

Common Options:  (see --help for more)
  -p --param NAME=VALUE
     --features ENABLE1,ENABLE2,DISABLE=0
Common Actions:
  --call 'TEMPLATE_METHOD(...)'
  --eval 'PERL CODE'
  -o --out [SECTION_LIST=]FILENAME[@MARK]

Transform perl+C source into C. See --help for a list of options.

Warning: this evaluates arbitrary perl from the template files.

OPTIONS

-p
--param NAME=VALUE

Specify a parameter to the template. If NAME includes the Perl sigil, the value will be evaluated as a perl expression. If NAME lacks a sigil, the VALUE will be parsed with a more convenient syntax:

cpppp -p '$type="int"'
cpppp -p type=int
cpppp -p '@types=qw( int float char )'
cpppp -p types=int,float,char
cpppp -p '%typemap={int => "int32",float => "double"}'
cpppp -p typemap=int=int32,float=double
--features LIST

This is a shorthand to specify lots of --param options for parameters whose names start with "feature_". The bare name is equivalent to "=1", which would generally enable some feature.

# (there are no standard features; these would need declared in the template)
cpppp -p feature_debug=1 -p feature_assert=1 -p feature_comments=0
cpppp --features 'debug,assert,comments=0'
--convert-linecomment-to-c89

Convert all '//' comments to '/*' comments.

--dump-pl

Output the generated perl sourcecode for the top-level perl script and don't execute it.

The following "action" options are processed sequentially, like a script, acting on the first template filename to the left of the action on the command line, or the first filename overall if an action option appears first.

--eval 'PERL CODE'

After loading the template, evaluate a string of perl code. The template object is named $tpl and the Cpppp object is $cpppp.

--call 'METHOD(...)'

Shortcut for --eval to call a method of $tpl.

-o
--out [SECTION=]FILENAME[@MARKER]

Write output to FILENAME instead of stdout (unless FILENAME is "-" then do still write stdout ) If FILENAME already exists, a backup will be created, unless you specified a @MARKER.

If a @MARKER is specified, the content will be written within the existing content of the file (without a backup) between lines that match BEGIN marker and END marker. If those lines are not found, the operations aborts.

An equal sign indicates that only specific sections should be sent to this file. The SECTION is either the name of one section, or a comma-delimited list of section names, or a range A..B of section names. All content diverted to this FILENAME will be omitted from further output.

--list-sections

List the sections of output (in order they would be written) and exit without writing any files. The output is TSV. More columns may be added in the future.

eventually it will support many that cpp has, for defining things and parsing headers to discover existing types.

AUTHOR

Michael Conrad <mike@nrdvana.net>

VERSION

version 0.005

COPYRIGHT AND LICENSE

This software is copyright (c) 2024 by Michael Conrad.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.