From 81926f637cf73c4cdbc0bc0d7646ccee602de410 Mon Sep 17 00:00:00 2001
From: Marie Wilmet <marie.willemet@uclouvain.be>
Date: Wed, 8 Dec 2010 11:06:39 +0000
Subject: [PATCH] Cas test BloodFlow 1D (Aorta+Bifurcation) .lua et .py

---
 Solver/function.cpp | 23 +++++++++++------------
 Solver/function.h   |  1 +
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/Solver/function.cpp b/Solver/function.cpp
index 07c7f050a5..8e73c08497 100644
--- a/Solver/function.cpp
+++ b/Solver/function.cpp
@@ -599,27 +599,26 @@ class functionLua : public function {
 #endif
 
 // functionC
-
-void functionC::buildLibrary(std::string code, std::string filename) 
-{
-  //todo use CMAKE_CXX_COMPILER
-  //todo use clean temporary file names
-  //todo work on windows :-)
-  //todo if DG_BUILD_DIR is not defined, use the directory used at compilation time
-  FILE *tmpSrc = fopen("_tmpSrc.cpp","w");
-  fprintf(tmpSrc, "%s\n",code.c_str());
-  fclose(tmpSrc);
+void functionC::buildLibraryFromFile(const std::string cfilename, const std::string libfilename) {
   FILE *tmpMake = fopen("_tmpMake","w");
   fprintf(tmpMake, "include $(DG_BUILD_DIR)/CMakeFiles/dg.dir/flags.make\n"
       "%s : %s\n"
       "\tg++ -fPIC -shared -o $@ $(CXX_FLAGS) $(CXX_DEFINES) $<\n",
-      filename.c_str(), "_tmpSrc.cpp");
+      libfilename.c_str(), cfilename.c_str());
   fclose(tmpMake);
   if(system("make -f _tmpMake"))
     Msg::Error("make command failed\n");
-  UnlinkFile("_tmpSrc.cpp");
   UnlinkFile("_tmpMake.cpp");
 }
+
+void functionC::buildLibrary(std::string code, std::string filename) 
+{
+  FILE *tmpSrc = fopen("_tmpSrc.cpp","w");
+  fprintf(tmpSrc, "%s\n",code.c_str());
+  fclose(tmpSrc);
+	buildLibraryFromFile("_tmpSrc.cpp", filename);
+  UnlinkFile("_tmpSrc.cpp");
+}
 void functionC::call (dataCacheMap *m, fullMatrix<double> &val) 
 {
   switch (args.size()) {
diff --git a/Solver/function.h b/Solver/function.h
index 7321494205..d2946bc029 100644
--- a/Solver/function.h
+++ b/Solver/function.h
@@ -285,6 +285,7 @@ class functionC : public function {
   void (*callback)(void);
   public:
   static void buildLibrary(std::string code, std::string filename) ;
+	static void buildLibraryFromFile(const std::string cfilename, const std::string libfilename);
   void call (dataCacheMap *m, fullMatrix<double> &val) ;
   functionC (std::string file, std::string symbol, int nbCol, 
              std::vector<const function *> dependencies);
-- 
GitLab