[gtkada] Gate on 98
Jeff Creem
jeff at thecreems.com
Fri Jan 19 19:01:42 CET 2001
I almost hestiate to post this since it is not robust and does not include
the normal error
checking of the real gate, but while on travel last week away from my normal
machine, I was
stuck with my Windows 98 laptop and no ability to run gate..Looking at the
situation it at first
appeared that the problem was mostly caused by the way 95/98 handles return
values / arguments
v.s. the way NT does.. After fixing that a little, I found that for some
reason, when gnatchop is called
from the sh.exe that is included in the GtkAda for win32 it seems to be
unable to parse the file.
So, to solve these to issues, I have a really poorly written program to fix
the argument parsing issue and
a new gate script that runs as a tcsh script.
All of this is released under the same GPL license conditions as the rest of
the GtkAda components.
Note that I was running gate from the command line not from Glade (it might
work there too)....
I am releasing this now as is since I do not think I will be working on it
anymore (Installed Linux on
the laptop instead)...
So, first you need to get tcsh for win 32 from
ftp://ftp.blarg.net/users/amol/tcsh/
I just installed it in by bin area for GtkAda (probably a bad idea).
Then, save you old gate.bat script and replace it with a file that contains
@C:\GtkAda-1.3.10\bin\tcsh.exe "C:/GtkAda-1.3.10/bin"/gate.csh %1
Next, save this source in a file called parseargs.adb compile/link it and
stick the
executable with your tcsh executable
with Text_IO;
with Ada.Command_Line;
procedure ParseArgs is
Last : INteger;
Item : String (1 .. 1024);
Current_Word : Integer := 0;
type State_Type is
(Await_Word_Start,
Word_Started);
State : State_Type := Await_Word_Start;
THis_Is_The_WOrd : Boolean := False;
begin
Text_IO.Get_Line(
Item => Item,
Last => Last);
for I in 1 .. Last loop
case State is
when Await_Word_Start =>
if Item(I) /= ' ' then
State := Word_Started;
Current_Word := Current_Word + 1;
This_Is_The_Word := Current_Word = Integer'Value(Ada.
Command_Line.Argument(1));
if This_Is_The_Word then
Text_IO.Put(Item(I));
end if;
end if;
when Word_Started =>
if Item(I) = ' ' then
State := Await_Word_Start;
elsif This_Is_The_Word then
Text_IO.Put(Item(I));
end if;
end case;
end loop;
end ParseArgs;
Finally, here is a partially finished gate.csh script that sort of works (at
least you can get source
code out)..Save this a gate.csh
#
# This script is a front end to the gate executable that build
# the Ada source code from the GLADE XML. The script handles all
# error handling processing as well as the reconciliation of the
# newly generated files with any hand edited files that already exist.
#
#
# Check that at least one parameter has been specified and
# pop-up an error dialog if not.
#
if ( $# == 0) then
echo "Usage: gate project-file" | gdialog error justify_left
exit 1
endif
#
# Determine the directory that contains the project file.
#
set dir=`dirname $1|sed -e 's$\\\\$/$g'`
#
# Strip off the portion that contains just the filename of
# the XML file.
#
set file=`cd $dir; `$cwd/`basename $1`
cd $dir
set dir=$cwd
#
# Call the Gate executable and ask it to specify the
# names for the main program (based on the input file) and
# the directory for source code and pixmaps.
#
set info=`gate-in.exe -p -s -x $file`
echo "Info is:" $info
echo "File is:" $file
#
# Check that the return code from gate did not say that it
# could not parse the file.
#if [ $? != 0 ]; then
# echo "Couldn't parse $file. Exiting." | gdialog error justify_left
# exit 1
#fi
#
# Now, check the returned parameters from the call to the gate
# executable program and set the project directory, source
# directory and pixmap directory variables.
#
set prj=`echo $info | parseargs 1`
if ("$prj" == "<no_name>") then
set prj=default
endif
set srcdir=`echo $info | parseargs 2`
set psrcdir=$srcdir
if ( "$srcdir" == "<no_name>" ) then
set srcdir=.
set psrcdir="the current directory"
endif
set pixdir=`echo $info | parseargs 3`
echo $pixdir
# Copy any pixmap files from pixdir to srcdir
mkdir -p $dir/$srcdir
if ( "$pixdir" != "<no_name>" ) then
cp $dir/$pixdir/*xpm $dir/$srcdir
endif
set owd=$cwd
cd $dir/$srcdir
set gt=".gate/$prj"
mkdir -p .gate > /dev/null
mkdir -p $gt > /dev/null
set tmp=$gt/tmp
rm -rf $tmp
mkdir -p $tmp
set wd=`pwd`
set out=$gt/output.txt
echo "Now File is :"$file
gate-in.exe $file | grep -v Gtk-WARNING > .gate/$prj/tmp/gate.ada
cd $tmp
gnatchop gate.ada
rm -f gate.ada
set files=`echo *`
cd $wd
rm -f $gt/gate.difs
foreach j ($files)
diff -u $gt/$j $j >> $gt/gate.difs
end
cp -f $tmp/* .
rm -f *.rej *.orig
echo "Got Here"
echo "Gt is " $gt
cat $gt/gate.difs | patch -f > $gt/patch.out
cp -f $tmp/* $gt
More information about the gtkada
mailing list