summaryrefslogtreecommitdiff
path: root/packages/amunits/scripts
diff options
context:
space:
mode:
authormarco <marco@3ad0048d-3df7-0310-abae-a5850022a9f2>2008-01-27 13:16:04 +0000
committermarco <marco@3ad0048d-3df7-0310-abae-a5850022a9f2>2008-01-27 13:16:04 +0000
commit6a03a6eb307706604c64ce32813c8649ed5dd5a4 (patch)
tree133a5e567f177dbb81d4790f55485fd66f5cbeed /packages/amunits/scripts
parentf1536880d78039a3dd589417498f5c59139a6310 (diff)
downloadfpc-6a03a6eb307706604c64ce32813c8649ed5dd5a4.tar.gz
* amunits moved
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@10043 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages/amunits/scripts')
-rw-r--r--packages/amunits/scripts/getrecord.rexx157
-rw-r--r--packages/amunits/scripts/make.rexx148
2 files changed, 305 insertions, 0 deletions
diff --git a/packages/amunits/scripts/getrecord.rexx b/packages/amunits/scripts/getrecord.rexx
new file mode 100644
index 0000000000..b36925c963
--- /dev/null
+++ b/packages/amunits/scripts/getrecord.rexx
@@ -0,0 +1,157 @@
+/* getrecord.rexx
+
+ This is a rexxscript to scan for pascal records.
+
+ I made this one to check my translation of
+ cheaders to fpc units. It will write two
+ files one pascalfile and one cfile.
+
+ The pascalfile you can almost everytime just
+ compile with fpc. In the cfile you have to
+ make some changes, just put in a line that
+ include the cheader for you testprogram.
+
+ So if you translate a cheader to fpc just
+ let this script check it out, if you get
+ the same result from both program you have
+ probably made the translation correct.
+
+ Usage:
+
+ rx getrecord yourunit.pas
+
+ nils.sjoholm@mailbox.swipnet.se
+
+*/
+
+
+SIGNAL ON BREAK_C
+SIGNAL ON SYNTAX
+
+parse arg name
+
+if name = '' then do
+ say 'Input filename to scan for records'
+ parse pull name end
+ if name = '' then do
+ say 'Error no filename'
+ exit 20
+ end
+ end
+
+k = 1
+
+thesource = name
+
+if index(name,'.') > 0 then do
+parse var name thesource '.' extension
+end
+
+pasname = thesource || 'rec1.pas'
+cname = thesource || 'rec2.c'
+
+IF ~Open('textfile',name,'READ') THEN DO
+ say 'File not found'
+ exit 20
+end
+else do
+ say 'Scanning ' || name
+ i = 1
+ DO WHILE ~eof('textfile')
+ line.i = ReadLn('textfile')
+ line.i = Strip(line.i)
+ myproc = Word(line.i,3)
+ myproc = Upper(myproc)
+ IF myproc = "RECORD" THEN DO
+ CALL CheckLine(line.i)
+ SAY "Doing line :" || i
+ END
+ i = i +1
+ END
+ CALL Close('textfile')
+ if k > 1 then do
+ call writepasfile
+ call writecfile
+ say 'Done'
+ end
+ else say 'No records found'
+END
+EXIT
+
+pasheader:
+ writeln('outfile','Program testrecords;')
+ writeln('outfile','')
+ writeln('outfile','uses exec,' || thesource || ';')
+ writeln('outfile','')
+ writeln('outfile','begin')
+return
+
+writepasfile:
+ if ~Open('outfile',pasname,'W') then do
+ say 'Can not create file'
+ exit 20
+ end
+ else do
+ SAY "Working on " || pasname
+ call pasheader
+ do j = 1 to k-1
+ thename = record.j
+ towrite = 'writeln(' || "'" || thename || "',' ':30-length(" || "'" ||thename || "'),"
+ towrite = towrite || "':'"
+ towrite = towrite || ',sizeof(' || thename || '));'
+
+ writeln('outfile',towrite)
+ end j
+ writeln('outfile','end.')
+ writeln('outfile','')
+ CALL Close('outfile')
+
+RETURN
+
+cheader:
+ writeln('outfile','');
+ writeln('outfile','#include ' || '"stdio.h"')
+ writeln('outfile','')
+ writeln('outfile','main()')
+ writeln('outfile','{')
+ return
+
+writecfile:
+ if ~Open('outfile',cname,'W') then do
+ say 'Can not create file'
+ exit 20
+ end
+ else do
+ SAY "Working on " || cname
+ call cheader
+ do j = 1 to k-1
+ thename = record.j
+ towrite = 'printf(' || '"%-30s:%d\n","' || thename || '",'
+ towrite = towrite || 'sizeof(struct ' || right(thename,length(thename)-1) ||'));'
+
+ writeln('outfile',towrite)
+ end j
+ writeln('outfile','}')
+ writeln('outfile','')
+
+ CALL Close('outfile')
+return
+
+CheckLine:
+ PARSE ARG theline
+ parse var theline thename thesep therecord therest
+ if thesep = '=' then do
+ thename = strip(thename)
+ record.k = thename
+ k = k +1
+ end
+RETURN
+
+
+
+BREAK_C:
+SYNTAX:
+SAY "Sorry, error line" SIGL ":" ErrorText(RC) ":-("
+EXIT
+
+
diff --git a/packages/amunits/scripts/make.rexx b/packages/amunits/scripts/make.rexx
new file mode 100644
index 0000000000..d7490ae79c
--- /dev/null
+++ b/packages/amunits/scripts/make.rexx
@@ -0,0 +1,148 @@
+/*
+
+ A simple make script for FPC Pascal.
+
+ For your final release you can use this script
+ to get the smallest possible program.
+
+ If you are using the ms-dos cross compiler you
+ can use this script to assemble and link your
+ programs.
+ This is what I started with, compiled all units
+ on ms-dos and moved them over to my Amiga. There
+ I assembled all to objectfiles. Now I could
+ compile testprograms on ms-dos, move to Amiga
+ and use this script to put it all together.
+
+ Usage:
+
+ rx make testprog.pas exec intuition graphics
+
+ This will compile testprog.pas and link
+ prt0.o, sysamiga.o, exec.o, intuition.o,
+ graphics.o and testprog.o to testprog.
+
+ rx make testprog.asm exec intuition graphics
+
+ The same as above but it just assembles
+ testprog.asm and links it.
+
+ rx make testprog exec intuition graphics
+
+ The same as above, treats testprog as an
+ assembler file.
+
+
+ Don't forget so set the correct paths for
+ the binaries bellow.
+
+ This is just a quick hack but it does work.
+
+ nils.sjoholm@mailbox.swipnet.se
+
+*/
+
+SIGNAL ON BREAK_C
+SIGNAL ON SYNTAX
+
+
+parse arg main list
+
+/*
+ First parse the args and set up a list
+*/
+
+k = 0 œ
+do while list ~= ''
+parse var list keyword.k list
+k=k+1
+end
+
+/*
+ Set the correct path
+*/
+
+ASCOM = 'dh1:fpc/bin/as'
+LDCOM = 'dh1:fpc/bin/ld'
+UNITS = 'dh1:fpc/units/'
+SYSUNITS = 'dh1:fpc/lib/'
+PPCCOM = 'dh1:fpc/bin/ppc'
+STRIPCOM = 'dh1:fpc/bin/strip'
+
+/*
+ Set the system units in the list
+*/
+
+linkline = SYSUNITS || 'prt0.o ' || SYSUNITS || 'sysamiga.o '
+
+/*
+ If there are more args, put in linklist
+*/
+
+do n=0 to k-1
+linkline = linkline || UNITS || keyword.n || '.o'||' '
+end
+
+/*
+ Check if it's a pascal or assembler file
+*/
+
+parse var main head '.' ext
+if upper(ext) = 'PAS' | upper(ext) = 'P' | upper(ext) = 'PP' then do
+ say 'Compiling ' || main
+ address command PPCCOM || ' ' main || ' -Cn'
+ if rc ~=0 then do
+ say 'Problems with compiler'
+ exit
+ end
+end
+else do
+ parse var main head '.' ext
+ say 'Assembling ' || head
+ address command ASCOM || ' ' || head || '.asm' || ' -o ' || head || '.o'
+ if rc ~=0 then do
+ say 'Problems with assembler'
+ exit
+ end
+end
+
+/*
+ If we got here add to linklist
+*/
+
+linkline = linkline || head || '.o' || ' -o ' || head
+
+/*
+ Now link the files
+*/
+
+say 'Linking ' || head
+address command LDCOM || ' ' || linkline
+if rc ~=0 then do
+ say 'Problems with linker'
+ exit
+ end
+
+/*
+ Use strip
+*/
+
+say 'Using Strip on ' || head
+address command STRIPCOM || ' ' || head
+if rc ~=0 then do
+ say 'Problems with strip'
+ exit
+ end
+
+say 'Done with ' || head
+exit
+
+BREAK_C:
+SYNTAX:
+SAY "Sorry, error line" SIGL ":" ErrorText(RC) ":-("
+EXIT
+
+
+
+
+