[gt-users] skeleton code generator script

Giorgio Gonnella ggonnell at yahoo.it
Sun Jan 24 16:14:02 CET 2010


Hi gt users,

this morning, I was having a look to the scripts I wrote during the last months
and I found one that may eventually be interesting for someone else too.

Personally I hate VisualStudio-like code generators, but it is often boring to
copy-paste the same stuff and do repetitive tasks by creating new code files.

Therefore I wrote some months ago a ruby script that uses erb to create
header files (the license with your name and email, the current year,
and the ifndef wrapper part), then over the time I extended it to create
header plus c file including the header ("module"), to create gt "class"
c/h files and to create tools based on the tools/gt_template files.
I never had time to understand and try all scripts in the gt/scripts directory,
so I don't know if anything similar was actually already there.

So, if anyone is interested or curious, I checked it now in a git repository
against the current master in my fork of genometools in Github, branch "codegen";
the scripts resides in scripts/codegen.rb

You are welcome to give me any feedback (just I will not have time to fix
or change anything in it for the next 3 weeks or so).

http://github.com/ggonnella/genometools/tree/codegen
or git://github.com/ggonnella/genometools.git in branch codegen

bye bye,
Giorgio

---
PS:
Here is the help message of the script:

> scripts/codegen.rb help

Code generator for:
- header file (license, ifndef/def/endif)
- module files (header file and c file including the header)
- class files (h and c files, basic skeleton)
- tool files (based on tools/gt_template.[ch])

It requires name and email of the user, that are expected
to be found in the [user] section of the user-specific git
configuration file (~/.gitconfig). You may specify another file
using the env variable GT_CODEGEN_CONFIG.

Usage:

  scripts/codegen.rb header|module|class|tool <subdir> <basename>

where <subdir> is the directory under src where the files are written
and <basename> has no gt_ prefix and is written in lower case,
and if it consists in multiple words they are connected_with_underscores
e.g.
  scripts/codegen.rb tool tools xyz
  scripts/codegen.rb header core abc_def

There is absolutely no guarantee that the results are correct.
Existing files are not overwritten or modified.
Report bugs to <ggonnell at yahoo.it>.


      


More information about the gt-users mailing list