Snapper - XML Application SourceForge.net Logo  


NAME

snapmake -- Generate XML application file


SYNOPSIS

    snapmake [-f|file=filename] [-d|directory=directory]
             [-c|complile] [-r|readonly] [-m|module=module]
             [-p|pixmap]=directory [-h|help]


OPTIONS

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


DESCRIPTION

Snapmake compiles a directory tree into a Snapper application XML file or standalone perl script. Here is a sample application built in a directory tree:

  pizza/
  pizza/MAIN.module/
  pizza/MAIN.module/scripts
    - 001_main_window.pl
    - 001_table_window.pl
    - 999_startup.pl
  pizza/MAIN.module/widget
    - MAIN.glade

Each child directory ending in ``.module'' represents a module, that can contain perl scripts, and Glade project files. This hierarchy is processed by snapmake to generate the application XML file. The snapmake script is run as follows:

  %snapmake -f pizza.xml -d pizza

This would generate the XML file pizza.xml. The xml file could be activated via the thin client snaprun by command line or from entering the URL in the graphical launcher.

  %snaprun ./pizza.xml

To generate a standalone perl script the ``compile'' option would be used.

  %snapmake -f pizza.pl -d pizza -c
  %perl pizza.pl

This would generate the perl script pizza.pl. The actual code that would acitvate this application is simply (embedded version):

  $SnapRun::xml = Snapper->new();
  if ($SnapRun::xml) {print "ok 2\n";} else {print "not ok 2\n";}
  my $xml_text = join('',<DATA>);
  $SnapRun::xml->build_memory($xml_text);
  undef $xml_text; # free xml data
  $SnapRun::xml->source_scripts("MAIN");


STARTUP SCRIPT

When the compilation option is set snapmake will add some generic bootstrap code to fire off the application. To add your own startup code place a script called start_script.pl in a direcotry called header in the main application directory. For example in the pizza example above the script would be located in pizza/header/. If the thin client is used, i.e. snaprun, then this code is not used. SnapRun has it's own startup code.

There are two types of startup scripts. In the first type snapmake will place the XML text at the end of the file. The last line of the script should be __DATA__. The xml text can then be read using the handle <DATA>.

Example of <DATA> handle startup script:

  #!/usr/local/bin/perl
  #
  # Generic startup script read into XML Compile
  #
  #################
  use Getopt::Long;
  print "snapper bootstrap starting...\n";
  use Snapper;
  print "  loaded library Snapper\n";
  my ($debug);
  GetOptions(
           "debug" => \$debug,
           );
  $Snapper::debug = defined($debug);
  # create new object
  $SnapRun::xml = Snapper->new();
  if ($SnapRun::xml) {
      print "  new Snapper object created\n";
  } else {
      die "  could not create Snapper object\n";
  }
  print "  reading xml embedded data...\n";
  $xml_text = join('',<DATA>);
  print "    --> done.\n";
  print "  building GladeXML object...\n";
  $SnapRun::xml->build_memory($xml_text,'__SNAPPER_PIXMAP__');
  print "    --> done\n";
  $SnapRun::xml->process_oix("s_Dump");
  undef $xml_text;
  print "  jumping in with source scripts...\n\n";
  $SnapRun::xml->source_scripts("s_Dump");
  # snapmake will place the XML text after the DATA line
  __DATA__

The second type uses a function called script_xml that snapmake will populate with the XML text. This type is useful for adding perldoc documentation to the end of the script. The function is identified by the following line #SNAPPER_XML_INSERT.

Example of function startup script:

  #!/usr/local/bin/perl
  #
  # Generic startup script read into XML Compile
  #
  #################
  use Getopt::Long;
  print "snapper bootstrap starting...\n";
  use Snapper;
  print "  loaded library Snapper\n";
  my ($debug);
  GetOptions(
           "debug" => \$debug,
           );
  $Snapper::debug = defined($debug);
  # create new object
  $SnapRUn::xml = Snapper->new();
  if ($SnapRun::xml) {
      print "  new Snapper object created\n";
  } else {
      die "  could not create Snapper object\n";
  }
  print "  building GladeXML object...\n";
  $SnapRun::xml->build_memory(script_xml(),'__SNAPPER_PIXMAP__');
  print "    --> done\n";
  $SnapRun::xml->process_oix("s_Oix");
  print "  jumping in with source scripts...\n\n";
  $SnapRun::xml->source_scripts("s_Oix");
  #
  # Holds the Script Snapper XML application
  # snapmake will place the XML text in
  # the q{} section.
  #
  sub script_xml {
      #SNAPPER_XML_INSERT
      return q{};
  }
  # Autoload methods go after =cut, and are processed by the
  # autosplit program.
  1;
  __END__
  # Below is the stub of documentation for your module. You better edit it!
  =cut


AUTHOR

Bill Walz, bill@landsharklinux.com


SEE ALSO

perl(1).

Gtk.

Gtk::GladeXML.

GTK http://www.gtk.org/

Glade http://glade.pn.org/

LibGlade http://www.daa.com.au/~james/gnome/


COPYRIGHT

You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file, with the exception that it cannot be placed on a CD-ROM or similar media for commercial distribution without the prior approval of the author.

Content owned by Albacore Technology is copyright 1999-2000 Albacore Technology, LLC All rights reserved.