csp.bat (compile starpack)
The following routine is a work in progress. Things to be done are:
@echo off rem csp.bat - Compile StarPack rem (C) M.Hoffmann, 2003-2005 rem 31.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 --- (evtl. alternativ nack Links schauen, oder anhand Dummyverzeichnissen kopieren) if exist %p%.vfs\lib\import.Done del %p%.vfs\lib\import.Done if exist %p%.vfs\lib\import.Index for /F %%i in (%p%.vfs\lib\import.Index) do ( rem nichts überschreiben! if not exist %p%.vfs\lib\%%~ni ( echo *Import: %%i -^> %%~ni xcopy %r%\%%i %p%.vfs\lib\%%~ni /e /i /h /k /q echo %%~ni >>%p%.vfs\lib\import.Done ) ) 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 rem --- Einkopierte Module wieder entfernen if exist %p%.vfs\lib\import.Done ( for /F %%i in (%p%.vfs\lib\import.Done) do ( rd /s /q %p%.vfs\lib\%%i ) del %p%.vfs\lib\import.Done ) :EOF endlocal
Notes
The script makes certain presumptions:
To use csp, simply call
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
These two little scripts are the successors of various older scripts and programs, which I copied over and over again in the various project dirs, not to say that they needed manual modification afterwords.... Now I get tired of repeating this into eternity. Perhaps it would be better to code the scripts itself in TCL, because Windows batch scripts with more than a few lines tend to be nearly unreadable...
This solution has the following main drawback:
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.