Re: 4go/4gi format ?
Posted in 1995
Topics: SQL Development & Query Writing, Connectivity: ESQL/C, 4GL & Embedded SQL
How 'bout this:
1) Place all your library *.4go's in a directory.
2) Write a perl script to scan the library source (_4gl_)
files and save the filename in an associative array indexed
by function name. Use the dbm perl functions to create a
dbm file to store the associative array. For example:
dbmopen(%functions, "lib", 0666);
# more code ...
while (<>) {
# code to recognize a function definition ...
if ($functionName = &isFunctionDefinition()) { # Save the name of a file in the associative
# array indexed by function name.
$functions{$functionName} = $ARGV;
}
# more code ...
}
dbmclose(%functions);
4) Write a 4GL linker script in perl to take a list of _4gl_ source
files as arguments.
The script would first save the names of the object files associated
with the _4gl_ files on the command line:
foreach $file ( file_arguments ) {
push(@objects, $file);
}
Next it would scan the _4gl_ files given on the command line for
function references (that aren't builtins) and save them in another
associative array:
$undefined{$functionName} = $ARGV;
If you run into a function definition in these source files, save
the names in a list:
push(@defined, $functionName);
Now remove the defined functions from the undefined associative
array:
foreach $defined (@defined) {
undef $undefined{$defined};
}
%undefined now contains a list of functions in the source files
that are unresolved externals.
Using the dbm database created in step 2, look up the file names
where the unresolved are located:
dbmopen(%functions, "lib", 0444); # read only
# ...
foreach $undefined (keys(%undefined)) {
$fileName = $functions($undefined);
$libraryFiles{$fileName} = 1;
}
# ...
dbmclose(%functions);
Now just concatenate the files together to make the _4gi_:
$cmd = "cat "
. join(' ', @objects) . " "
. join(' ', keys(%libraryFiles))
. " >$outputFileName.4gi";
system($cmd);
Wouldn't that work?
Kevin L. Pauba
In article <3g9mcq$i57@aggedor.rmit.edu.au>,
Li Chuan Dunlop <s925095@minyos.xx.rmit.EDU.AU> wrote:
>Hi all,
>
>Thanks to those that replied to my post concerning my request for info on
>the 4go file format for the purpose of making an smart linker.
>
>Several people replied suggesting that Makefiles were a reasonable way of
>tackling the problem without going to the effort of producing an smart
>linker. Other people went a bit further by recommending I look at the way
>the FourGen CASE tools handle the problem, which seems to be using shell
>scripts to extract function definitions and calls from the source code to
>automatically generate the Makefiles.
>
>I am currently doing this using perl scripts ie. automatically generating
>source depenencies into Makefiles. (Gotta love that perl!). However I would
>still like to be able to use a single (or several) library archive[s]
>instead of specifying every single dependency.
>
>An example of the problem this solution would address is when an existing
>base function calls a new function in a separate module. In this situation,
>currently we need to regenerate all the Makefiles in the system so that
>they can pick up the new dependancy. On the other hand, using library
>archives and an smart linker, nothing at all needs to be done - it
>just works.
>
>Ok, so regenerating the Makefiles isn't a major hassle, but it is a minor
>one - and I'm trying to reduce my workload as much as possible. I'm the
>project overseer/system admin and the 4GL programmers hassle me when anything
>untoward happens. My ultimate goal is to have the system running smoothly and
>the programmers productive and happy without me doing anything at all except
>reading news, drinking coffee, building fun things like smart linkers etc.
>
>There are other considerations also: eg. I'm dreading the day that all the
>modules with pathnames exceed the maximum length of a shell command.
>
>Then there's the aesthetic appreciation - the scripts I have are kind of
>long and complex and would be greatly simplified by the use of a smart linker.
>Come to think of it, this is not only an aesthetic argument but one of
>maintenance also - if I get hit by a tram (we have trams here in Melbourne),
>the next system admin would probably be cursing me for my scripts.
>
>So the request still stands - any info out there on the 4go file format ?
>--
>Li-Chuan Dunlop -- s925095@minyos.xx.rmit.edu.au