summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>2001-05-21 10:38:44 +0000
committergoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>2001-05-21 10:38:44 +0000
commit9e9ae09fdf13b595c4053e803e6a396d7f843c95 (patch)
tree1d9bf55cd6d4f4045aecb5087c3ebd7ac96eeb9f
parent9291fe92c464ba411050fa1758937af49906d805 (diff)
Several inter-twined changes: -
Make system now looks in bindings/build/$(THORN)/make.code.defn for additional objects to be built and linked into a library. The CST puts a file cctk_ThornBindings.c into this directory. This should solve the empty library problem - PR 638. The interface to the internal routine CCTKi_RegisterThorn has changed. The new file created by the CST uses the correct new syntax, ands passes information about ancestors and friends into the flesh. Hence the commit of two separate things in one commit, as the both changes require a -rebuild. Please do a make <config>-rebuild or your code will not compile. Tom git-svn-id: http://svn.cactuscode.org/flesh/trunk@2199 17b73243-c579-4c4c-a9d2-2d5706c11dac
-rw-r--r--lib/make/make.subdir4
-rw-r--r--lib/make/make.thornlib41
-rw-r--r--lib/sbin/CreateImplementationBindings.pl89
-rw-r--r--src/include/cctki_ActiveThorns.h24
-rw-r--r--src/main/ActiveThorns.c65
5 files changed, 191 insertions, 32 deletions
diff --git a/lib/make/make.subdir b/lib/make/make.subdir
index c70ea2df..2003ac16 100644
--- a/lib/make/make.subdir
+++ b/lib/make/make.subdir
@@ -20,14 +20,14 @@ INC_DIRS += $(SRCDIR) $(SRCDIR)/include
EXTRA_DEFINES += THORN_IS_$(THORN)
# Include the subdirectory's local include data
-include $(SRCDIR)/make.code.defn
+-include $(SRCDIR)/make.code.defn
# Turn source file names into object file names
OBJS = $(SRCS:%=%.o)
# Build all the object files
-make.checked: $(OBJS)
+$(TARGET): $(OBJS)
touch make.checked
# Rules to make the object files
diff --git a/lib/make/make.thornlib b/lib/make/make.thornlib
index 87195beb..005557b9 100644
--- a/lib/make/make.thornlib
+++ b/lib/make/make.thornlib
@@ -24,6 +24,8 @@ INC_DIRS = $(SYS_INC_DIRS) $(SRCDIR) $(SRCDIR)/include $(CONFIG) $(TOP)/bindings
# Allow subdirectories to inherit these include directories
export INC_DIRS
+BINDINGS_DIR=$(TOP)/bindings
+
EXTRA_DEFINES += THORN_IS_$(THORN)
# Define some make variables
@@ -40,8 +42,6 @@ include $(SRCDIR)/make.code.defn
LOCAL_SUBDIRS := . $(SUBDIRS)
-SRCS =
-
# Include all the make.code.defn files for the subdirectories
# These have to be wrapped to allow us to concatanate all the
# SRCS definitions, complete with subdirectory names.
@@ -51,6 +51,13 @@ ifneq ($(strip $(LOCAL_SUBDIRS)),)
-include $(foreach DIR,$(LOCAL_SUBDIRS), $(DIR)/make.identity $(MAKE_DIR)/$(PRE_WRAPPER) $(SRCDIR)/$(DIR)/make.code.defn $(MAKE_DIR)/$(POST_WRAPPER))
endif
+# The CactusBindings pseudo-thorn doesn't need to define its own bindings 8-)
+
+ifneq ($(THORN), CactusBindings)
+THORNBINDINGS=cctk_Bindings
+-include cctk_Bindings/make.identity $(MAKE_DIR)/$(PRE_WRAPPER) $(BINDINGS_DIR)/build/$(THORN)/make.code.defn $(MAKE_DIR)/$(POST_WRAPPER)
+endif
+
# Restore the value of SRCS and SUBDIRS of this directory
SRCS = $(CCTK_SRCS)
@@ -59,21 +66,13 @@ SUBDIRS = $(LOCAL_SUBDIRS)
# Turn source file names into object file names
OBJS = $(SRCS:%=%.o)
-$(NAME): $(addsuffix /make.checked, $(SUBDIRS))
+$(NAME): $(addsuffix /make.checked, $(SUBDIRS) $(THORNBINDINGS))
@echo $(DIVIDER)
if [ -r $(NAME) ] ; then echo Updating $(NAME) ; else echo Creating $(NAME) ; fi
if [ -r $@ ] ; then rm $@ ; fi
$(AR) $(ARFLAGS) $@ $(OBJS)
if test "x$(USE_RANLIB)" = "xyes" ; then $(RANLIB) $(RANLIBFLAGS) $@ ; fi
-# Rules to make the object files
-include $(CONFIG)/make.config.rules
-
-# Extra thorn-specific dependencies
-# This file isn't strictly necessary, so use -include to prevent
-# warnings if it is missing.
--include $(SRCDIR)/make.code.deps
-
# Extra stuff for allowing make to recurse into directories
# This one makes the object files in the subdirectory
@@ -81,15 +80,23 @@ include $(CONFIG)/make.config.rules
$(addsuffix /make.checked, $(SUBDIRS)) : FORCE
if [ ! -d $(dir $@) ] ; then $(MKDIR) $(MKDIRFLAGS) $(dir $@) ; fi
- cd $(dir $@) ; $(MAKE) TOP=$(TOP) CONFIG=$(CONFIG) SRCDIR=$(subst /./,,$(SRCDIR)/$(dir $@)) THORN=$(THORN) -f $(MAKE_DIR)/make.subdir
+ cd $(dir $@) ; $(MAKE) TARGET=make.checked TOP=$(TOP) CONFIG=$(CONFIG) SRCDIR=$(subst /./,,$(SRCDIR)/$(dir $@)) THORN=$(THORN) -f $(MAKE_DIR)/make.subdir
+
+cctk_Bindings/make.checked: FORCE
+ cd cctk_Bindings; $(MAKE) TARGET=make.checked TOP=$(TOP) CONFIG=$(CONFIG) SRCDIR=$(BINDINGS_DIR)/build/$(THORN) THORN=$(THORN) -f $(MAKE_DIR)/make.subdir
# This one puts a file containing identity info into the build subdirectory
-$(addsuffix /make.identity, $(SUBDIRS)):
+$(addsuffix /make.identity, $(SUBDIRS) $(THORNBINDINGS)):
if [ ! -d $(dir $@) ] ; then $(MKDIR) $(MKDIRFLAGS) $(dir $@) ; fi
echo CCTK_THIS_SUBDIR := $(dir $@) > $@
-# Dependency stuff
-ifneq ($(strip $(LOCAL_SRCS)),)
--include $(LOCAL_SRCS:%=%.d)
-endif
+# Catch people who have not done a -rebuild. Remove in beta 12
+$(BINDINGS_DIR)/build/$(THORN)/make.code.defn:
+ @echo $(DIVIDER)
+ @echo "************************************************************************"
+ @echo " Major changes to CST and bindings system."
+ @echo " Please $(MAKE) $(notdir $(TOP))-rebuild "
+ @echo "************************************************************************"
+ @echo $(DIVIDER)
+ @exit 1 \ No newline at end of file
diff --git a/lib/sbin/CreateImplementationBindings.pl b/lib/sbin/CreateImplementationBindings.pl
index 38dd25b5..7ee96263 100644
--- a/lib/sbin/CreateImplementationBindings.pl
+++ b/lib/sbin/CreateImplementationBindings.pl
@@ -14,6 +14,11 @@ sub CreateImplementationBindings
my($thorn);
my(@data);
+ if(! $build_dir)
+ {
+ $build_dir = "$bindings_dir/build";
+ }
+
if(! -d $bindings_dir)
{
mkdir("$bindings_dir", 0755) || die "Unable to create $bindings_dir";
@@ -36,18 +41,16 @@ sub CreateImplementationBindings
@data = ();
- push(@data, "#include <stdio.h>\n");
- push(@data, "/* FIXME - remove when ActiveThorns does not need this */\n");
- push(@data, "#include \"SKBinTree.h\"\n\n");
- push(@data, "#include \"cctk_ActiveThorns.h\"\n\n");
- push(@data, "#include \"cctki_ActiveThorns.h\"\n\n");
+ foreach $thorn (sort split(" ", $rhinterface_db->{"THORNS"}))
+ {
+ push(@data, "int CCTKi_BindingsThorn_$thorn(void);\n")
+ }
push(@data, "int CCTKi_BindingsImplementationsInitialise(void)\n{\n");
foreach $thorn (sort split(" ", $rhinterface_db->{"THORNS"}))
{
- push(@data, " CCTKi_RegisterThorn(\"$thorn\",\"" .
- $rhinterface_db->{"\U$thorn\E IMPLEMENTS"} ."\");\n");
+ push(@data, " CCTKi_BindingsThorn_$thorn();\n")
}
push(@data, "\n return 0;\n}\n");
@@ -61,8 +64,78 @@ sub CreateImplementationBindings
&WriteFile("make.code.defn",\$dataout);
+ if(! -d "$build_dir")
+ {
+ mkdir("$build_dir", 0755) || die "Unable to create $build_dir";
+ }
+
+ chdir "$build_dir";
+
+ foreach $thorn (sort split(" ", $rhinterface_db->{"THORNS"}))
+ {
+
+ if(! -d "$thorn")
+ {
+ mkdir("$thorn", 0755) || die "Unable to create $build_dir/$thorn";
+ }
+
+ chdir "$thorn";
+
+ $myimp = $rhinterface_db->{"\U$thorn\E IMPLEMENTS"};
+
+ @data = ();
- chdir $start_dir;
+ push(@data, "#include <stdio.h>\n");
+ push(@data, "#include \"cctki_ActiveThorns.h\"\n\n");
+
+ push(@data, "int CCTKi_BindingsThorn_${thorn}(void)\n{\n");
+
+ push(@data, " int retval;\n");
+
+ push(@data, " const char *name[] = {\"$thorn\",0};");
+ push(@data, " const char *implementation[]={\"$myimp\",0};");
+
+ push(@data, " const char *ancestors[]=\n {");
+ foreach $ancestor (split(" ",$rhinterface_db->{"IMPLEMENTATION \U$myimp\E ANCESTORS"}))
+ {
+ push(@data, " \"$ancestor\",");
+ }
+ push(@data, " 0,");
+ push(@data, " };\n");
+
+ push(@data, " const char *friends[]=\n {");
+ foreach $friend (split(" ",$rhinterface_db->{"IMPLEMENTATION \U$myimp\E FRIENDS"}))
+ {
+ push(@data, " \"$friend\",");
+ }
+ push(@data, " 0,");
+ push(@data, " };\n");
+
+ push(@data, "\n struct iAttributeList attributes[] =");
+ push(@data, " {");
+ push(@data, " {\"name\", {name}},");
+ push(@data, " {\"implementation\",{implementation}},");
+ push(@data, " {\"ancestors\",{ancestors}},");
+ push(@data, " {\"friends\",{friends}},");
+ push(@data, " {0,{0}},");
+ push(@data, " };\n");
+
+ push(@data, " retval = CCTKi_RegisterThorn(attributes);");
+
+ push(@data, "\n return retval;\n}\n");
+
+ &OutputFile(".", "cctk_ThornBindings.c", @data);
+
+
+ $dataout = "";
+ $dataout .= "\n";
+ $dataout .= "SRCS = cctk_ThornBindings.c\n\n";
+
+ &WriteFile("make.code.defn",\$dataout);
+
+ chdir "..";
+ }
+
}
1;
diff --git a/src/include/cctki_ActiveThorns.h b/src/include/cctki_ActiveThorns.h
index 13568a79..a72fe854 100644
--- a/src/include/cctki_ActiveThorns.h
+++ b/src/include/cctki_ActiveThorns.h
@@ -11,14 +11,30 @@
#ifndef __CCTKI_ACTIVETHORNS_H_
#define __CCTKI_ACTIVETHORNS_H_
-#include <stdio.h>
-#include "SKBinTree.h"
-
#ifdef __cplusplus
extern "C" {
#endif
-int CCTKi_RegisterThorn(const char *name, const char *imp);
+struct iFuncList
+{
+ const char *keyword;
+ const char *signature;
+ void (*func)(void);
+};
+
+union iAttributeData
+{
+ const char **StringList;
+ const struct iFuncList *FuncList;
+};
+
+struct iAttributeList
+{
+ const char *attribute;
+ union iAttributeData AttributeData;
+};
+
+int CCTKi_RegisterThorn(const struct iAttributeList *attributes);
int CCTKi_ActivateThorn(const char *name);
int CCTKi_PrintThorns(FILE *file, const char *format, int active);
int CCTKi_PrintImps(FILE *file, const char *format, int active);
diff --git a/src/main/ActiveThorns.c b/src/main/ActiveThorns.c
index 82707906..08eab08a 100644
--- a/src/main/ActiveThorns.c
+++ b/src/main/ActiveThorns.c
@@ -17,6 +17,7 @@
#include "cctk_Flesh.h"
#include "cctk_Config.h"
#include "cctk_ActiveThorns.h"
+#include "cctki_ActiveThorns.h"
#include "cctk_FortranString.h"
static const char *rcsid = "$Header$";
@@ -100,14 +101,76 @@ static int n_imps = 0;
-4 - failed to store thorn in tree
@endreturndesc
@@*/
-int CCTKi_RegisterThorn(const char *name, const char *imp)
+int CCTKi_RegisterThorn(const struct iAttributeList *attributes)
{
int retval;
+ int i,j;
+
t_sktree *node;
t_sktree *temp;
struct THORN *thorn;
+ const char *name;
+ const char *imp;
+
+#if 0
+ for(i=0; attributes[i].attribute; i++)
+ {
+ if(!strcmp(attributes[i].attribute, "functions"))
+ {
+ printf("Functions: \n");
+ for(j=0; attributes[i].AttributeData.FuncList[j].keyword; j++)
+ {
+ printf("keyword is %s\n", attributes[i].AttributeData.FuncList[j].keyword);
+ printf("signature is %s\n", attributes[i].AttributeData.FuncList[j].signature);
+ printf("pointer is %p\n", attributes[i].AttributeData.FuncList[j].func);
+ }
+ }
+ else
+ {
+ printf("attribute is %s\n", attributes[i].attribute);
+ if(attributes[i].AttributeData.StringList)
+ {
+ for(j=0; attributes[i].AttributeData.StringList[j]; j++)
+ {
+ printf(" datapoint %s\n", attributes[i].AttributeData.StringList[j]);
+ }
+ }
+ }
+ }
+#endif /* 0 */
+
+ for(i=0; attributes[i].attribute; i++)
+ {
+ if(!strcmp(attributes[i].attribute, "name"))
+ {
+ if(attributes[i].AttributeData.StringList)
+ {
+ name = attributes[i].AttributeData.StringList[0];
+ }
+ }
+ else if(!strcmp(attributes[i].attribute, "implementation"))
+ {
+ if(attributes[i].AttributeData.StringList)
+ {
+ imp = attributes[i].AttributeData.StringList[0];
+ }
+ }
+ else if(!strcmp(attributes[i].attribute, "ancestors"))
+ {
+ ;
+ }
+ else if(!strcmp(attributes[i].attribute, "friends"))
+ {
+ ;
+ }
+ else
+ {
+ fprintf(stderr, "Unknown/unimplemented thorn attribute %s\n", attributes[i].attribute);
+ }
+ }
+
/* printf("Registering thorn %s, which provides %s\n", name, imp);*/
/* Does the thorn already exist ? */