Version 4 of Windows batch script for 'compiling' starpacks

Updated 2005-10-30 22:50:12

csp.bat (compile starpack)

The following routine is work in progress. Things to be done are:

  • temporarily copy common routines, which are needed by the starpack (that is, SOURCEd oder PACKAGE REQUIRED), from a well-known location into the VFS-structure just before the "compile" and delete them afterwords (up until now such routines must be doubled into the VFS and stay there all the time; it would be nixe, if sdx itself would follow Links). Only a fragment of such handling is implemented.
  • Documente everything, translate it to the english language, create some examples
    @echo off
 rem csp.bat - Compile StarPack
 rem (C) M.Hoffmann, 2003-2005
 rem 01.10.2005, 08.10.2005, 13.10.2005, 22.10.2005
 rem v2.0: generische Version (zuvor: individuelle compile.bat`s)
 rem Arg: sh = Textmode-Tclprogramm erzeugen (sonst GUI-Tkprogramm)
 rem Gebrauch:
 rem  im Rootverzeichnis eines mittels CSP oder INITSDX erstellten Projekt-
 rem  Ordners folgendes aufrufen:
 rem  csp [sh]
 rem Spaeter anhand import.Index in /lib etc. unmittelbar vor dem Compilestep die
 rem benoetigten Module einkopieren, anschliessend wieder loeschen (sind ja im VFS!)
     setlocal
     if not %1.==. (if not %1.==sh. (echo falscher Parameter, erlaubt leer oder sh & goto :EOF))
 rem ermitteln lib-Verzeichnis einer Activestate-Installation, wird als Repository-Root angenommen
     for %%i in (tclsh.exe) do set r=%%~dp$PATH:i
     if %r%.==. (echo ActiveStateTcl nicht auffindbar & goto :EOF)
     set r=%r%..\lib
 rem ermitteln Dateispec TCL-Runtime (sh)
     for %%i in (tclkit%1-win32.exe tclkit%1.exe) do if not "%%~$PATH:i"=="" set t=%%~$PATH:i
     if %t%.==. (echo Tclkit[sh]-Runtime nicht auffindbar & goto :EOF)
 rem ermitteln Aufrufverfahren für Starkit-Developer-Extensions (SDX)
     for %%i in (tclkitsh.exe tclkitsh-win32.exe sdx.exe) do if not "%%~$PATH:i"=="" set x=%%~$PATH:i
     if %x%.==. (echo Tclkitsh-Runtime oder sdx.exe nicht auffindbar & goto :EOF)
     if %x:~-7%==sdx.exe goto found!
     for %%i in (sdx.kit) do if not "%%~$PATH:i"=="" (set x=%x% %%~$PATH:i & goto found!)
     echo sdx.kit nicht auffindbar & goto :EOF
 :found!
 rem ermitteln Projektname
     for /d %%i in (.\*.vfs) do set p=%%~ni
     if %p%.==. (echo Ordner "./<project>.vfs" fehlt & goto :EOF)
     echo Projekt='%p%'
 rem --- Einkopieren benoetigter Module anhand import.Index aus dem Repository
 rem --- in Arbeit (nach erfolgreichem Compile wieder loeschen)
     for /F %%i in (%p%.vfs\lib\import.Index) do echo *Import: %%i
 rem --- Einkopieren, Ende
     if exist %p%.exe (attrib -r %p%.exe & del %p%.exe)
     %x% wrap %p% -verbose -runtime %t%
     ren %p% %p%.exe & attrib +r %p%.exe
     if exist %p%.bat del %p%.bat
 :EOF
     endlocal

Notes

The script makes certain presumptions:

  • common routines are expected to be found beneath the lib-path of an tcl-installation (e.g. ActiveState). To found such an installation, tclsh is searched and its path (usually ...bin) is concatenated with ..\lib (for this to work, the bin path of the TCL-installation must be in the system-search-path).
  • one of tclkitsh-win32.exe, tclkitsh.exe, tclkit-win32.exe, tclkit.exe must be found in the system-search-path.
  • one of sdx.kit or sdx.exe (created by me) must be in the system-search-path.
  • when calling csp, the "project"dir must be the current working directory and beneatch the projectdir must contain a project.VFS directory

To use csp, simply call

  • csp to create a starpack for tk-programs (contain the tclkit.exe as a runtime) - or -
  • csp sh to create a starpack for command-line-programs (contain the smaller tclkitsh as a runtime, no Tk available)

To help me generating the neccessary project structure, I'm using a second script which is also subject of changes. I plan to integrate there copying of default-templates and common codeblocks etc. This routine is called isp.bat (init starpack):

    @echo off
 rem isp.bat - Initialize StarPack
 rem (C) M.Hoffmann, 2003-2005
 rem 22.10.2005
 rem v2.0 (zuvor: INITSDX)
 rem Arg: projektname [-new]
 rem Legt im aktuellen Verzeichnis eine Projekt-Ordnerstruktur an und kopiert
 rem  Standard-Module nach dort
 rem (in Arbeit)
 rem (siehe CSP.BAT!!!)
     setlocal
 rem spaeter auch eine Updatemoeglichkeit ermoeglichen (update j/n?)
     if "%1"=="" (echo Fehler: Projektname fehlt! & goto :EOF)
     if exist "%1" if not "%2."=="-new." (echo Ordner "%1" existiert bereits! & goto :EOF) else (rd "%1" /s /q)
     (md %1 & cd %1 & md %1.vfs & cd %1.vfs) || (echo Fehler md/cd "%1(.vfs)" & goto :EOF)
 rem die folgende Ordnerliste noch gemaess Starkit/pack-VFS-Standard anpassen (siehe Doc`s)
 rem keine weiteren Fehlerpruefungen, warum sollte auch nun noch etwas schiefgehen...
     for %%i in (bin doc lib tools) do md %%i
 rem nun Standardmodule/Gerueste einkopieren (von WO? Updates?)
      >lib\import.Index echo # Hier die Namen der benoetigten Packages eintragen.
     >>lib\import.Index echo # Diese Dateien werden beim Umwandeln mittels CSP
     >>lib\import.Index echo # aus einem zentralen Repository temporaer einkopiert.
     echo Projekt %1 wurde angelegt!
 :EOF
     endlocal

RLH I have a batch file (here [L1 ]) that does this on the wiki. It copies everything in and creates the starpack and then deletes everything leaving just the EXE and the original script. This might not be what you are talking about though. MHo: Uff, just had an edit conflict, but thanx to the wiki, nothing's lost! I will look at your routines.