This page describes how to get started with snapmake.
A Snapper Project or application is contained on a file
system with a specific directory hierarchy.
A project can be created using the
snaputil utility. This
allows for easy development, and for the application to
be stored under version control, i.e. cvs. Snapper
is only interested in directories and files that it
knows about. Any unknown directories or files
that it encounters will be ignored. This is
convenient for adding support files and directories
such as database scripts or makefiles, etc. Here
is the gtk_pizza application from the snapper-contrib
module, note that every application should have a
top-level directory.
[bill@shark contrib]$ ls -lF
gtk_pizza/
pixmaps/
gtk_pizza.rc
|
The directory "gtk_pizza" contains the Snapper
application. The directory "pixmaps"
contains pixmap files used by the application.
Look at the code for "snapoix" for an example
of how to embed pixmaps into the application XML file.
The file "gtk_pizza.rc" is a
GTK Resource file read by the application at startup.
Here is the application structure.
[bill@shark contrib]$ ls -lR gtk_pizza
gtk_pizza:
CVS/
database/
header/
MAIN.module/
gtk_pizza/database:
hotpizza.pg.sql.gz
gtk_pizza/header:
project.options
start_script.pl
gtk_pizza/MAIN.module:
scripts/
widget/
gtk_pizza/MAIN.module/scripts:
001_customer_screen.pl
001_DB.pl
001_display_screen.pl
001_docket_screen.pl
001_login_screen.pl
001_message_box.pl
001_order_screen.pl
001_select_cust_screen.pl
001_select_screen.pl
001_user_utils.pl
001_utils.pl
999_startup.pl
gtk_pizza/MAIN.module/widget:
MAIN.glade
oix.xml
|
The directories in red are
the directories that snapmake
is interested in and will examine. Any scripts,
glade data, or oix data found will be combined into the
application XML file. The directories
"database" and "CVS" are left alone
and are useful for
storing the schema used by the application and cvs data.
They will not be included in the application XML
file.
The directories that end in ".module" contain
two directories, i.e. scripts, and widget
. The name of this directory is the module
name and is used in function calls. Files that end
in ".pl" in the scripts directory
will be read and incorporated into the application XML
file. The widget directory contains the
glade XML file and the oix data XML file. This
data will also be combined into the application XML
file.
The special directory header in the top-level
application directory is used to store the project
options and the startup or bootstrap code.
Sample start scripts can be found in the samples
directory or contrib.
Constucting the Application XML File
|
Building the application XML file can be as simple as
typing the following from the command line:
[bill@shark contrib]$ snapmake -d gtk_pizza -c -f gtk_pizza.pl
|
After some output text, the resulting perl script
gtk_pizza.pl can be executed as follows:
[bill@shark contrib]$ perl gtk_pizza.pl
|
If the -c option is specified then snapmake combines
the various pieces into a single XML schema and will
insert this data into the startup script. There
is more information in the
snapmake manual. Snapmake is used as follows:
snapmake [-f|file=filename] [-d|directory=directory]
[-c|complile] [-r|readonly] [-m|module=module]
[-p|pixmap]=directory [-h|help]
|
f|file |
output file name, default output.xml or output.pl |
d|directory |
directory to scan, default . |
c|compile |
compile application into single perl script |
r|readonly |
do not generate output file |
m|module |
startup module, default MAIN |
p|pixmap |
pixmap directory location, default to
./pixmaps, please note that snapmake will
construct an absolute pathname. If a header
script is used then it will replace the tag
__SNAPPER_PIXMAP__ with the results.
|
h|help |
this message |
If pixmap files are used as opposed to embedding the
pixmap data in the XML application file then a pixmap
directory needs to be passed to snapmake. The
default directory is ./pixmaps. The function
build memory can be passed the location of the pixmap
directory, and snapmake can do this for you by
embedding the tag __SNAPPER_PIXMAP__ in your startup
script. Here is an example from the gtk_pizza
startup script.
$SnapRun::xml->build_memory($xml_text,'__SNAPPER_PIXMAP__');
|
After snapmake runs it will replace the tag with the
absolute path. On my cygwin system it looks like
this:
$SnapRun::xml->build_memory($xml_text,'/home/IBM_USER/wks/snapper-perl/contrib/pixmaps/');
|
|