Version 1 of kbs packages

Updated 2007-10-29 21:15:07 by RZ

kbs means Tclkit Kitgen Build System


Package definitions

  • What is a package?

Originally it is a Tcl extension based on the TEA system. but you can use whatever you want.

  • What do I need to build one?

A "Package" definition in the "kbs/kbs/defs.kbs" file and the sources of the package. The "kbs/kbs/defs.kbs" file will be sourced on startup. It contain the available package definitions. If you will add definitions from another file just source the file like:

 catch {source [file join kbs z.kbs]};# project definitions
  • What is the syntax of the definition file?

Some online help is available with:

 ./kbs.tcl kbs

Here are some parts with comments.

Package {name script}

 The "Package" command is available in definition files.
 @arg name   -- unique name of package
 @arg script -- contain definitions in the following order. For a detailed
  description look in the related commands.
 * Require
 * Source
 * Configure
 * Make
 * Install
 * Clean
 * Result

proc Require {args}

 The given "Package"´s in args will be recursively called.
 @arg args - one or more "Package" names

proc Source {type args}

 Procedure to build source tree of current "Package" definition.
 @arg pkg - name of package source dir under "-sourcedir"
 @arg type - describe action to get source tree of "Package"
 Available are:
  cvs path ... - call "cvs -d path ..."
  svn path     - call "svn co path"
  fetch path   - call "http get path", unpack *.tar.gz or *.tgz files
  tgz file     - call "tar xzf file"
  link path      - use sources from "path"

proc Configure {script}

 If [Makedir] not exist create it and eval script.
 @arg script - tcl script to evaluate

proc Make {script}

 Eval script in [Makedir].
 @arg script - tcl script to evaluate

proc Install {script}

 Eval script in [Makedir].
 @arg script - tcl script to evaluate

proc Test {script}

 Eval script in [Makedir].
 @arg script - tcl script to evaluate

proc Clean {script}

 Eval script in [Makedir].
 @arg script - tcl script to evaluate

proc Result {args}

 Copy all in args to "-resultdir". Remove old entries.
 @arg args - list with files/directories in [Builddir]

Here are some usefull helper procedures.

proc Srcdir {type}

 Return fully qualified path to current "Package" source dir.
 The parent dir can be set on the command line with "-sourcedir".
 @par type: one of "tcl" used in tcl commands and "sys" used in system commands

proc Makedir {type}

 Return fully qualified path to current "Package" make dir.
 Path is in dir [Builddir].
 @par type: one of "tcl" used in tcl commands and "sys" used in system commands

proc Builddir {type}

 Return path of current building dir. This dir contain all [Makedir]
 and is used in the "Install" target.
 The dir can be set on the command line with "-builddir".
 @par type: one of "tcl" used in tcl commands and "sys" used in system commands

proc Run {args}

 The procedure call the args as external command with options.
 The procedure is available in all script arguments.

proc tclConfig {varname}

 The procedure return the content of TCL* variables of the tclConfig.sh file.
 The variables are also available in the "_" array.
 The procedure is intended for use in the "Configure" target.

proc tclConfig {varname}

 The procedure return the content of TK* variables of the tkConfig.sh file.
 The variables are also available in the "_" array.
 The procedure is intended for use in the "Configure" target.

proc Kit {mode name args}

 The procedure links the "name.vfs" in to the [Makedir] and create
 foreach name in "args" a link from [Builddir]/lib in to "name.vfs"/lib.
 The names in "args" may subdirectories under [Builddir]/lib. In the
 "name.vfs"/lib the leading directory parts are removed. The same goes for
 "name.vfs".
 @arg mode: make|install|clean|run what to do with kit
  make: link all packages from "args" in "name.vfs"/lib
  install: Wrap kit and move to [Builddir]/bin
  clean: remove all links in "name.vfs"/lib
  run: Run "name.kit" with "args"
 @arg name: name of vfs directory (without extension) to use
 @arg args: additional args
           - list of libraries in "make" and "clean" mode.
           - kit command line arguments in "run" mode.

proc config::Tcl {{package {}}}

 @arg package: install name of package, if missing then build from [Srcdir tcl]

proc config::Patch {file lineoffset oldtext newtext}

 @arg file: name of file to patch
 @arg lineoffset: start point of patch, first line is 1
 @arg oldtext: part of file to replace
 @arg newtext: replacement text

proc config::Proc {name arglist body}

 The 'Proc' command define a procedure the same way as the 'proc' command.
 This procedure is then available in every 'Package' definition.
 @arg name    - name of the procedure
 @arg arglist - argument list of the procedure
 @arg body    - body of the procedure

Commenting the "kbs/kbs/defs.kbs" file

  • Provide default version for Require command:
 Package tcl { Require tcl-8.5 }
  • Clear build area and rebuild some packages:
 Package packages {
  file delete -force [Builddir tcl]/lib
  Require tcl-8.5 tk-8.5 bwidget-1.8.0 img-1.3 itcl-3.3 itk-3.3 iwidgets-4.0.2
 }
  • Checkout with tag and from HEAD
 Source cvs tcllib.cvs.sourceforge.net:/cvsroot/tcllib -r tklib-0-4-1 tklib
 Source cvs tclx.cvs.sourceforge.net:/cvsroot/tclx
  • Get file with http
 Source fetch http://www.sqlite.org/sqlite-3_3_17-tea.tar.gz
  • Use sources from another Package
 Source link itcl-3.3
  • Use different directory names for windows builds
 [Builddir tcl] -- used in tcl commands ("C:/")
 [Builddir sys] -- used in system commands e.g. make ("/c/")

[ Category Tclkit | Category Deployment Category Development ]