- The set-paths script specifies the names for the directories
to be used. Change it to reflect your setup. The Mozilla sources need
to be in MOZ_FILES and all the scripts need to be in
BIN_FILES:
#
# use 'source' to include this file into other scripts
#
export MOZ_FILES=/home/rigi-netscape/mozilla/
export BIN_FILES=/home/rigi-netscape/bin
export OUT_FILES=/home/rigi-netscape/out
mkdir $MOZ_FILES $OUT_FILES &> /dev/null
- Some keyword definitions to make cparse parse the Mozilla
source files. Save it as $BIN_FILES/gcckw.h. Depending on
your compiler and OS, you might have to modify it.
/* include file to use for Rigi with Linux & gcc */
/* use RIGICPP="gcc -E -imacros include.linux" */
#define __attribute__(x)
#define __P(x) x
#define __const const
#define __inline
#define __signed__
#define __inline__
#define __asm__(x)
#define __extension__
#define __signed
#define __volatile__
- The makeit Script compiles Mozilla.
If this doesn't work for you, read the
Mozilla documentation.
#!/bin/sh
source `dirname $0`/set-paths
NO_SECURITY=1
MOZ_MEDIUM=1
MOZILLA_CLIENT=1
NO_MDUPDATE=1
export NO_SECURITY MOZ_MEDIUM MOZILLA_CLIENT NO_MDUPDATE
cd $MOZ_FILES
make -k $*
- The parseit Script compiles and parses Mozilla. To get a
complete build, run makeit clean first.
#!/bin/sh
source `dirname $0`/set-paths
NO_SECURITY=1
MOZ_MEDIUM=1
MOZILLA_CLIENT=1
NO_MDUPDATE=1
export NO_SECURITY MOZ_MEDIUM MOZILLA_CLIENT NO_MDUPDATE
export PATH=$PATH:$BINFILES
echo -------------------------------------
echo Starting to compile and parse Mozilla
echo -------------------------------------
cd $MOZ_FILES
make CC=$BIN_FILES/mygcc -k
echo --------------------------------
echo Collecting and sorting RSF files
echo --------------------------------
cd $MOZ_FILES
find -name *.rsf.gz -exec gzip -d -c \{\} \; |
/home/rigi/proj/rigiutils/i586-Linux2.0.33/sortrsf -4 2> $OUT_FILES/sortrsf.errors | gzip -9 > $OUT_FILES/mozilla.rsf.sorted.gz
echo ----------------------------------
echo HTMLifying Mozilla source from RSF
echo ----------------------------------
cd $MOZ_FILES
gzip -d -c $OUT_FILES/mozilla.rsf.sorted.gz | htmlrsf -pxa prototypes,calls,references,declares,tagged -b type > $OUT_FILES/mozilla.rsf.htmld
- Wrapper script for gcc, used by the parseit script.
#!/bin/sh
cmdline=""
for a in $* ; do
if [ "$skip" = "1" ] ; then
skip=0
ofile=$a
elif [ "$a" = "-o" ] ; then
skip=1
else
cmdline="$cmdline $a"
fi
done
export RIGICPP="gcc -E -imacros $BIN_FILES/gcckw.h"
if echo $cmdline | egrep '\.c\>' &> /dev/null; then
echo $cmdline > $ofile.cmdline
$RIGICPP $cmdline | cparse -4 -f$MOZ_FILES 2>> $OUT_FILES/errors | gzip -9 > $ofile.rsf.gz
fi
exec gcc $*
- Various RCL scripts used to work on the graph within RigiEdit:
# load mozilla and perform some preliminary modifications
proc load_mozilla {} {
set_domain cparse 0
rcl_win_set_drawing 0
rcl_load_rsf "/home/rigi-netscape/out/mozilla.rsf.htmld"
puts "Delete standard library nodes..."
c_delete_std
puts "Delete disconnected variables..."
c_delete_disconnected Variable
puts "Delete disconnected prototypes..."
c_delete_disconnected Prototype
puts "Delete disconnected datatypes..."
c_delete_disconnected Datatype
puts "Delete disconnected constants..."
c_delete_disconnected Constant
puts "Delete disconnected functions..."
c_delete_disconnected Function
puts "Delete disconnected unknowns..."
c_delete_disconnected Unknown
puts "Redirecting prototypes..."
c_redirect Prototype prototypes
puts "Redirecting datatypes..."
c_redirect Datatype isTheSameAs
puts "Collapsing function parameters..."
c_collapse2 Function isDefinedIn in
puts "Delete disconnected variables..."
c_delete_disconnected Variable
puts "Delete disconnected prototypes..."
c_delete_disconnected Prototype
puts "Delete disconnected datatypes..."
c_delete_disconnected Datatype
puts "Delete disconnected constants..."
c_delete_disconnected Constant
puts "Delete disconnected functions..."
c_delete_disconnected Unknown
puts "Partitioning subsystems..."
c_partition any
rcl_grid_all
rcl_win_set_drawing 1
rcl_refresh
}
# Delete every nodes that represent artifacts out of the standard library
# (/usr/include/*) and standard data types.
proc c_delete_std { } {
rcl_select_none
rcl_select_grep ".*/usr/include/.*"
rcl_select_name int 1
rcl_select_name char 1
rcl_select_name long 1
rcl_select_name void 1
rcl_select_name float 1
rcl_select_name double 1
set winnodes [rcl_select_get_list]
rcl_select_none
foreach node $winnodes {
rcl_node_delete $node
}
}
# For all nodes of type ntype (winnodes), find a target node
# (destination) for a first (and only) outgoing arc of type atype (arc1).
# Redirect all incoming arcs of nodes belonging to 'winnodes' to enter
# node 'destination'.
# Delete winnodes and their dependencies out of the graph
# an example of usage: c_redirect Prototype prototypes
proc c_redirect {ntype atype} {
rcl_select_none
rcl_select_type $ntype
set winnodes [rcl_select_get_list]
rcl_select_none
foreach node $winnodes {
set arclist [rcl_node_get_arclist $node $atype out 1 1]
if { [llength $arclist] >= 1 } {
set arc1 [lindex $arclist 0]
set enterings [rcl_node_get_arclist_in_window $node any in]
set destination [rcl_get_arc_dst $arc1]
foreach arc2 $enterings {
set type [rcl_get_arc_type $arc2]
if { [rcl_get_arctype level] != $type } {
set source [rcl_get_arc_src $arc2]
rcl_arc_create2 $source $destination $type
}
}
rcl_node_delete $node
}
}
rcl_refresh
}
# For all nodes of type ntype, collapse them and all nodes
# that are connected to them with an arc of type atype
# (the direction of the connection is dir)
# to a single node (the collapsed node is given the same name as
# the original ntype type nodes).
# an exampe of usage: c_collapse Function isDefinedIn in
proc c_collapse {ntype atype dir} {
rcl_select_none
rcl_select_type $ntype
set winnodes [rcl_select_get_list]
rcl_select_none
foreach node $winnodes {
rcl_select_id $node
set name [rcl_get_node_name $node]
select_neighbors $atype $dir 1
if {[rcl_collapse Collapse $name] == 0} { return }
}
}
# For all nodes of type ntype:
# - collapse all nodes that are connected to the node with an arc of
# type atype (the direction of the connection is dir) to a single node.
# - redirect all arcs going to or coming from the node to the
# new collapsed node.
# - give the new collapsed node the name of the original node
# delete the original node
# an exampe of usage: c_collapse Function isDefinedIn in
proc c_collapse2 {ntype atype dir} {
rcl_select_none
rcl_select_type $ntype
set winnodes [rcl_select_get_list]
rcl_select_none
foreach node $winnodes {
rcl_select_id $node
select_neighbors $atype $dir 1
rcl_select_deselect_id $node
if { [ llength [ rcl_select_get_list ] ] >= 1 } {
if { [ rcl_collapse $ntype [ rcl_get_node_name $node ] ] == 0} {
return
}
set id [rcl_select_get_list]
set arclist [ rcl_node_get_arclist $node any out 1 1 ]
foreach arc $arclist {
set type [rcl_get_arc_type $arc]
set dst [rcl_get_arc_dst $arc]
if { $id != $dst } {
rcl_arc_create2 $id $dst $type
}
}
set arclist [ rcl_node_get_arclist $node any in 1 1 ]
foreach arc $arclist {
set type [rcl_get_arc_type $arc]
set src [rcl_get_arc_src $arc]
if { $src != $id } {
rcl_arc_create2 $src $id $type
}
}
rcl_node_delete $node
}
}
}
# Delete disconnected nodes of type 'ntype' from the graph
# an example of usage: c_delete_disconnected Variable
proc c_delete_disconnected {ntype} {
rcl_select_none
rcl_select_type $ntype
set winnodes [rcl_select_get_list]
rcl_select_none
foreach node $winnodes {
set nnodes [rcl_node_get_neighbors_in_window $node any any]
if {[llength $nnodes] < 1} {
rcl_node_delete $node
}
}
rcl_refresh
}
# Find partitions of the graph that are connected with arcs of type atype
# and make them into subsystems.
proc c_partition {atype} {
rcl_set_current_arctype $atype
while { 1 } {
rcl_select_all
set nodes [rcl_select_get_list]
foreach id $nodes {
rcl_select_id $id
set oldnum 0
set newnum 1
while { $newnum > $oldnum } {
rcl_select_forward_tree
rcl_select_reverse_tree
set oldnum $newnum
set newnum [rcl_select_num_nodes]
}
if { $newnum > 1 } {
puts "Collapsing $newnum nodes..."
rcl_collapse Subsystem "Subsystem ($newnum children)"
set id 0
break
}
}
if { $id != 0 } {
break
}
}
}