Code generator command line

Starting the code generator from the command line

You can run the code generator from a commandline (console) and have control over a number of important options. But even if you only plan to use the code generator in a windowed environment, you might want to read up on these options because you could create customized shortcuts that pass the arguments that set up your environment perfectly.

The general format of a code generator invocation is:

          jcpp [option-list] [modelfile] 

Let's start with a complete list of code generator command line options
 

Option Description Notes
-addincdir=<file> Adds the directories contained in the file to the list of include directories in the generated project files. This optional argument allows you to generate projects with correctly set up include directory paths. The directories are expected to be represented by their names, one per line.
-addlibdir=<file> Adds the directories contained in the file to the library search path in the generated project files. This optional argument allows you to generate projects with correctly set up library search paths. The directories are expected to be represented by their names, one per line.
-addpre=<file> Adds the preprocessor definitions in the file to the preprocessor directives in the generated project files. This optional argument allows you to generate projects with correctly set up preprocessor definitions (macros). The format of the file is one <name>=<value> pair per line.
-addsrc=<file> Adds the files listed in the specified file to the generatede project files. This optional argument allows you to generate projects with additional source files. The files are expected to be represented by their names, one per line.
-cli Run the code generator in commanline mode (no GUI) This option should usually be used together with the -generatecpp option.
-conf=<conf> Allows you to specify a configuration name that is different from the one that is specified in the model. Configuration names are not nearly as important anymore as they were in earlier versions of JunC++ion. The only reason to still pay attention to them is if you're using legacy file configuration format.
-cp Allows you to specify a classpath that is automatically added to newly created or processed Java models. Specifying a classpath allows you to provide information about the location of jarfiles or classfiles on the commandline.
-classpath Same as -cp None
-D<name=<value> Allows you to specify a system property. None
-generatecpp Start the code generator (with a supplied modelfile) and immediately generate the C++ code for the specified model. This option is usually used together with the -cli option to achieve commandline generation of an already created model.
-gui Start the code generator in GUI mode. This is the default option if -cli is not specified.
-help Display a list of options and some useful examples. None
-jre <dir> Allows you to specify a JRE that is used by the code generator itself. This option is only useful on Windows. A normal user never has to use this options.
-logfilename=<file> Allows you to specify the name of the file to which the code generator logs comments. None
-output=<dir> Allows you to override the target directory of a commandline generation. Normally, you specify the output directory in your modelfile. This option allows you to override this setting.
-version Display code generator version information and exit. None
-we Treat warnings as errors. None
-showversion Display code generator version information and continue. None
-sets=<filelist> Allows you to specify a list of set specification files that were generated by earlier invocations of the code generator. Each time the code generator generates C++ files, it also generates an XML file that contains descriptive information about the files it generated. You can pass this so-called "set specification file" to subsequent code generator sessions to tell the generator that certain types have already been generated and should not be generated again, even if they are marked as generating.
Read more about this feature here.
-Xmxmemm Allows you to specify the heap available to the code generator. You might have to set this option to -Xmx768m or higher if you generate large sets.
-? Same as -help None

In addition to the options specified above, you can also pass any standard Java option.

Now let's look at some examples.

Example 1

This example demonstrates a simple code generator invocation with a classpath. Invoking the code generator with a classpath allows you to import types by name if they are located in any of the classpath roots you specified.

          jcpp -cp ".;c:\temp\myclasses.jar"

Please remember to doublequote the path to avoid problems with spaces in filenames. Without specifying the classpath you can still specify a classpath for your model, but you will have to enter it in the "Create Java Model" dialog.

Example 2

This example demonstrates a simple code generator invocation with an existing modelfile. Invoking the code generator like this quickly puts you back to where you left off without you having to manually opening the modelfile when the code generator GUI is up.

          jcpp c:\temp\mymodel.cmm

Without specifying -cli and -generatecpp, the code generator is going to start in GUI mode and you can make further edits to the modelfile that you opened. By putting th is little snippet into a batch file called "edit_mymodel.bat", you can simply doubleclick the batch file.

Example 3

This example demonstrates a simple code generator invocation with an existing modelfile. Invoking the code generator like this generates C++ proxy classes and exits.

          jcpp -cli -generatecpp c:\temp\mymodel.cmm

This would be the basic invocation used in an automated build or when you have created a batchfile to quickly regenerate your proxy classes after you made changes to your Java classes.

Example 4

This example demonstrates a simple code generator invocation with an existing large modelfile. Invoking the code generator like this generates C++ proxy classes and exits.

          jcpp -Xmx768m -cli -generatecpp c:\temp\mymodel.cmm

Here we give the code generator 768MB of heapspace. Do this (or even more) if the code generator runs out of memory during processing or code generation. An out-of-memory condition might result in weird generation error rather than a formal error condition.

 

 


Copyright 2006-2011 by Codemesh, Inc., ALL RIGHTS RESERVED

:
command line options
home products support customers partners newsroom about us contact us