diff options
author | goodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 1999-01-20 08:18:17 +0000 |
---|---|---|
committer | goodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 1999-01-20 08:18:17 +0000 |
commit | 2e473be1b9ea835f367635c770c130252fd835fe (patch) | |
tree | 4b930982412669120b1d95adfdcb242f484e3c69 | |
parent | b49870c673acfff5664d9629c8128aca9e0d2f63 (diff) |
New library - libCactusBindings.a created by make.configuration.
The sources for this are automatically generated by config_parser.pl
and should contain everything needed to bind the flesh and the
thorns.
Specifically have six functions called from the flesh
CCTK_BindingsParametersInitialise
CCTK_BindingsParameterSet
CCTK_BindingsParameterGet
CCTK_BindingsVariablesInitialise
CCTK_BindingsScheduleInitialise
CCTK_BindingsScheduleRegister
All the initialise ones are of type int ()(void)
CCTK_ParameterSet is of type int ()(const char *, const char *)
and takes a parameter specification and a parameter value, as taken
from the parameter file, and sets the parameter accordingly.
CCTK_BindingsParameterGet is of type int()(const char *, void **)
and returns the value of a parameter - the rturn value corresponds to
the type of the parameter.
CCTK_BindingsScheduleRegister is of type int()(const char *)
and will perform registration at, e.g. Startup, or RFR, or
any other point we add in future. Thinking about it, it needs
to also take a void * if it's going to do rfr init stuff - watch this space...
8-)
The c source files for these are put in the $(TOP)/bindings directory by
config.ccl, each subsystem in its own directory.
Tom
git-svn-id: http://svn.cactuscode.org/flesh/trunk@82 17b73243-c579-4c4c-a9d2-2d5706c11dac
-rw-r--r-- | lib/make/make.configuration | 6 | ||||
-rw-r--r-- | lib/sbin/config_parser.pl | 239 |
2 files changed, 195 insertions, 50 deletions
diff --git a/lib/make/make.configuration b/lib/make/make.configuration index 443b1cfe..7d2d1086 100644 --- a/lib/make/make.configuration +++ b/lib/make/make.configuration @@ -13,6 +13,7 @@ # Some configuration variables CONFIG = $(TOP)/config-data +BINDINGS_DIR = $(TOP)/bindings DATESTAMP = $(CCTK_HOME)/src/datestamp.c @@ -31,7 +32,7 @@ include $(CONFIG)/make.config.defn -include $(CONFIG)/make.thornlist # Build the executable -$(EXE): $(CONFIG)/make.thornlist $(patsubst %,$(CCTK_LIBDIR)/lib%.a,$(notdir $(THORNS))) $(CCTK_LIBDIR)/libCactus.a +$(EXE): $(CONFIG)/make.thornlist $(patsubst %,$(CCTK_LIBDIR)/lib%.a,$(notdir $(THORNS))) $(CCTK_LIBDIR)/libCactus.a $(CCTK_LIBDIR)/libCactusBindings.a @echo $(DIVIDER) @echo Creating $(EXE) from $(THORNS) $(CC) -c $(DATESTAMP) -o $(TOP)/datestamp.o @@ -57,7 +58,8 @@ $(CCTK_LIBDIR)/lib%.a: update if [ ! -d $(BUILD_DIR) ]; then $(MKDIR) $(BUILD_DIR) ; fi thorn_name=$(@:$(CCTK_LIBDIR)/lib%.a=%); \ if [ "$$thorn_name" = "Cactus" ] ; then src_dir=$(CCTK_HOME)/src ; \ - else src_dir=$(TOOLKIT_DIR)/$(@:$(CCTK_LIBDIR)/lib%.a=$(filter %/$(@:$(CCTK_LIBDIR)/lib%.a=%), $(THORNS)))/src ; fi ; \ + else if [ "$$thorn_name" = "CactusBindings" ] ; then src_dir=$(BINDINGS_DIR) ; \ + else src_dir=$(TOOLKIT_DIR)/$(@:$(CCTK_LIBDIR)/lib%.a=$(filter %/$(@:$(CCTK_LIBDIR)/lib%.a=%), $(THORNS)))/src ; fi ; fi ;\ if [ ! -d $(BUILD_DIR)/$$thorn_name ]; then $(MKDIR) $(BUILD_DIR)/$$thorn_name ; fi ; \ cd $(BUILD_DIR)/$$thorn_name ; \ if [ -r "$$src_dir/Makefile" ] ; then make_file=$$src_dir/Makefile ; \ diff --git a/lib/sbin/config_parser.pl b/lib/sbin/config_parser.pl index 44f52442..2f70cc7d 100644 --- a/lib/sbin/config_parser.pl +++ b/lib/sbin/config_parser.pl @@ -26,50 +26,35 @@ if(! $cctk_home) $cachome =~ s:/$::g; } +if(! $bindings_dir) +{ + $bindings_dir = "$top/bindings"; +} + $activethorns = shift(@ARGV); if (! $activethorns) { - printf "Usage: config_parser [-top=<TOP>] [-config_dir=<config directory>] [-cctk_home=<CCTK home dir>] ActiveThornList"; + printf "Usage: config_parser [-top=<TOP>] [-config_dir=<config directory>] [-cctk_home=<CCTK home dir>] -bindings_dir=<CCTK bindings directory> ActiveThornList"; exit; } +$sbin_dir = "$cctk_home/lib/sbin"; -#if (!-e "$cctk_home/lib/perl/thorn_utils.pl" ) { -# print <<EOE; -# -#ERROR: Cannot find the cactus perl libraries! -#--------------------------------------------- -#This error usually means that either CACTUS_HOME is -#set incorrectly, or that your distribution is not -#in ~/cactus. Remeber that CACTUS_HOME has -#to point to the directory above cactus. -# -#I was looking in -# -# $cachome/lib/perl -# -#when I failed. -# -# -#EOE -# exit; -#} +if (!-e "$sbin_dir/parameter_parser.pl" ) +{ + die "Unable to find CCTK sbin directory - tried $sbin_dir\n"; +} -require "$cctk_home/lib/sbin/parameter_parser.pl"; -require "$cctk_home/lib/sbin/interface_parser.pl"; -require "$cctk_home/lib/sbin/create_c_stuff.pl"; -require "$cctk_home/lib/sbin/create_fortran_stuff.pl"; -require "$cctk_home/lib/sbin/GridFuncStuff.pl"; -require "$cctk_home/lib/sbin/output_config.pl"; +require "$sbin_dir/parameter_parser.pl"; +require "$sbin_dir/interface_parser.pl"; +require "$sbin_dir/create_c_stuff.pl"; +require "$sbin_dir/create_fortran_stuff.pl"; +require "$sbin_dir/GridFuncStuff.pl"; +require "$sbin_dir/output_config.pl"; %thorns = &create_thorn_list($cctk_home, $activethorns); -foreach $thorn (keys %thorns) -{ - print "$thorn in dir $thorns{$thorn}\n"; -} - %interface_database = &create_interface_database(%thorns); %parameter_database = &create_parameter_database(%thorns); @@ -78,14 +63,6 @@ foreach $thorn (keys %thorns) #&print_interface_database(%interface_database); -@implementations = (keys %thorns); - -@fortran_module_file = &create_fortran_module_file(scalar(@implementations),@implementations,%parameter_database); - -#foreach $line (@fortran_module_file) -#{ -# print "$line\n"; -#} #%public_parameters = &get_public_parameters(%parameter_database); @@ -94,7 +71,7 @@ foreach $thorn (keys %thorns) # print "param $param from " . $public_parameters{"$param"}. "\n"; #} -@c_structures = &create_c_parameter_structures(scalar(@implementations),@implementations,%parameter_database); +#@c_structures = &create_c_parameter_structures(scalar(@implementations),@implementations,%parameter_database); #foreach $line (@c_structures) #{ @@ -118,15 +95,13 @@ foreach $thorn (keys %thorns) # print "$line\n"; #} + +&CreateBindings($bindings_dir, scalar(%parameter_database), %parameter_database, %interface_database); + @make_thornlist = &CreateMakeThornlist(%thorns); -foreach $line (@make_thornlist) -{ - print "$line\n"; -} +&OutputFile($config_dir, "make.thornlist", @make_thornlist); -OutputFile($config_dir, "make.thornlist", @make_thornlist); - sub create_thorn_list { local($cctk_home, $activethorns) = @_; @@ -216,7 +191,175 @@ sub CreateMakeThornlist return ("$thornlist", ""); } - +sub CreateBindings +{ + local($bindings_dir, $n_param_database, @rest) = @_; + local(%parameter_database); + local(%interface_database); + local($start_dir); + + %parameter_database = @rest[0..$n_param_database-1]; + %interface_database = @rest[$n_param_database..$#rest]; + + if(! -d $bindings_dir) + { + mkdir("$bindings_dir", 0755) || die "Unable to create $bindings_dir"; + } + $start_dir = `pwd`; + &CreateParameterBindings($bindings_dir, $n_param_database, @rest); + &CreateVariableBindings($bindings_dir, %interface_database); + &CreateScheduleBindings($bindings_dir); + + chdir $bindings_dir; + + open (OUT, ">make.code.defn") || die "Cannot open make.code.defn"; + + print OUT "SRCS = \n"; + print OUT "SUBDIRS = Parameters Variables Schedule\n"; + + close OUT; + chdir $start_dir; +} + +sub CreateParameterBindings +{ + local($bindings_dir, $n_param_database, @rest) = @_; + local(%parameter_database); + local(%interface_database); + local($start_dir); + + %parameter_database = @rest[0..$n_param_database-1]; + %interface_database = @rest[$n_param_database..$#rest]; + + if(! -d $bindings_dir) + { + mkdir("$bindings_dir", 0755) || die "Unable to create $bindings_dir"; + } + $start_dir = `pwd`; + + chdir $bindings_dir; + + if(! -d "Parameters") + { + mkdir("Parameters", 0755) || die "Unable to create Parameters directory"; + } + chdir "Parameters"; + + open (OUT, ">Bindings.c") || die "Cannot open Bindings.c"; + + print OUT <<EOT; + + int CCTK_BindingsParametersInitialise(void) + { + return 0; + } + + int CCTK_BindingsParameterSet(const char *identifier, const char *value) + { + return 1; + } + + int CCTK_BindingsParameterGet(const char *identifier, void **value) + { + return -1; + } + +EOT + + close OUT; + + open (OUT, ">make.code.defn") || die "Cannot open ake.code.defn"; + + print OUT "SRCS = Bindings.c\n"; + + close OUT; + + chdir $start_dir; +} + + +sub CreateVariableBindings +{ + local($bindings_dir, %inteface_database) = @_; + + if(! -d $bindings_dir) + { + mkdir("$bindings_dir", 0755) || die "Unable to create $bindings_dir"; + } + $start_dir = `pwd`; + chdir $bindings_dir; + + if(! -d "Variables") + { + mkdir("Variables", 0755) || die "Unable to create Variables directory"; + } + chdir "Variables"; + + open (OUT, ">Bindings.c") || die "Cannot open Bindings.c"; + + print OUT <<EOT; + + int CCTK_BindingsVariablesInitialise(void) + { + return 0; + } + +EOT + + close OUT; + + open (OUT, ">make.code.defn") || die "Cannot open make.code.defn"; + + print OUT "SRCS = Bindings.c\n"; + + close OUT; + + chdir $start_dir; +} + +sub CreateScheduleBindings +{ + local($bindings_dir) = @_; + + if(! -d $bindings_dir) + { + mkdir("$bindings_dir", 0755) || die "Unable to create $bindings_dir"; + } + $start_dir = `pwd`; + chdir $bindings_dir; + + if(! -d "Schedule") + { + mkdir("Schedule", 0755) || die "Unable to create Schedule directory"; + } + chdir "Schedule"; + + open (OUT, ">Bindings.c") || die "Cannot open Bindings.c"; + + print OUT <<EOT; + + int CCTK_BindingsScheduleInitialise(void) + { + return 0; + } + + int CCTK_BindingsScheduleRegister(const char *type) + { + return 0; + } + +EOT + + close OUT; + + open (OUT, ">make.code.defn") || die "Cannot open make.code.defn"; + + print OUT "SRCS = Bindings.c\n"; + + close OUT; + + chdir $start_dir; +} |