Skip to content

Commit

Permalink
configure uses --with-swig now, if without it will try to reuse previ…
Browse files Browse the repository at this point in the history
…ously generted api
  • Loading branch information
nsimakov committed Jan 11, 2016
1 parent 6cb1858 commit da6539c
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 21 deletions.
48 changes: 35 additions & 13 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -154,23 +154,45 @@ else
fi
AM_CONDITIONAL([WITH_GDAL], test "x$with_gdal" != "xno")


#SWIG
#-------------------------------------------------------------------------------------
AC_ARG_VAR([SWIG],[path to swig, python api generator])
AC_PATH_PROG([SWIG],[swig],[])
if test "x$SWIG" = "x"; then
AC_MSG_ERROR([swig is not found, set SWIG variable!])
fi
SWIG_VERSION=`$SWIG -version|grep ersion|cut -d ' ' -f 3`
SWIG_VERSION_MAJOR=`echo $SWIG_VERSION|cut -d . -f1`
if test "x$SWIG_VERSION_MAJOR" != "x3"; then
AC_MSG_ERROR([swig is too old should be at least 3.0, set SWIG variable for custom location!])
fi
AC_MSG_NOTICE([swig version: $SWIG_VERSION])
AC_ARG_WITH(swig,
AS_HELP_STRING([--with-swig=<path to swig executable>],
[Specify path to SWIG executable. ]
[If set will (re)generate python API, otherwise will try to use previously generated sources. ]
[Note that github repository do not track them.]),)
#only developers/advanced user should call swig
#the public source code releases should come with swig generated files
if test -n "$with_swig"; then
SWIG=$with_swig
AC_PATH_PROG([SWIG],[swig],[])
if test "x$SWIG" = "x"; then
AC_MSG_ERROR([swig is not found, set SWIG variable!])
fi
SWIG_VERSION=`$SWIG -version|grep ersion|cut -d ' ' -f 3`
SWIG_VERSION_MAJOR=`echo $SWIG_VERSION|cut -d . -f1`
if test "x$SWIG_VERSION_MAJOR" != "x3"; then
AC_MSG_ERROR([swig is too old should be at least 3.0, set SWIG variable for custom location!])
fi
AC_MSG_NOTICE([swig: $SWIG])
AC_MSG_NOTICE([swig version: $SWIG_VERSION])
else
#check for swig generated files presence
AC_CHECK_FILE($srcdir/src/main/cxxtitan_wrap.cxx,
AC_MSG_NOTICE([found cxxtitan_wrap.cxx]),
AC_MSG_FAILURE([Couldn't find SWIG generated python API sources.]
[Set --with-swig to SWIG to regenerate interface.])
)
AC_CHECK_FILE($srcdir/src/main/cxxtitan.py,
AC_MSG_NOTICE([found cxxtitan_wrap.cxx]),
AC_MSG_FAILURE([Couldn't find SWIG generated python API sources.]
[Set --with-swig to SWIG to regenerate interface.])
)
fi
AM_CONDITIONAL([WITH_SWIG], test "x$with_swig" != "xno")

#-------------------------------------------------------------------------------------
AC_CHECK_LIB(m,matherr)
AC_CHECK_LIB(nsl, inet_ntoa)

## Checks for header files
#=====================================================================================
Expand Down
3 changes: 1 addition & 2 deletions src/header/hd5calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const int XDMF_NEW = 0;
const int XDMF_OLD = 1;
const int XDMF_CLOSE = 2;

#define __STDC_FORMAT_MACROS
#include <hdf5.h>


Expand Down Expand Up @@ -97,7 +98,6 @@ hid_t GH5_createdataset(hid_t gid, hid_t spcid, const char *dsetname, unsigned t



#ifdef __cplusplus
#include <H5Cpp.h>

#include <iostream>
Expand Down Expand Up @@ -422,5 +422,4 @@ inline void TiH5_readArray2DDataSet__(const H5::Group &group, double *value, con



#endif
#endif
2 changes: 1 addition & 1 deletion src/header/sfc.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ inline SFC_Key sfc_key_read_from_space(const unsigned readspace[],int & pos)
}
#else
#include <stdio.h>
#include <stdint.h>
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
typedef uint64_t SFC_Key;


inline void fprintf_sfc_key(FILE *fout, const SFC_Key& obj)
{
fprintf(fout,"%" PRIu64 "\n",obj);
Expand Down
5 changes: 3 additions & 2 deletions src/main/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ titan_LDADD = ../preproc/libtitan_preprocess.a ../gisapi/libgisapi.a ../adapt/li
../datstr/libdatstr.a ../geoflow/libgeoflow.a ../useful/libuseful.a \
../repartition/librepartition.a ../tecplot/libtecplot.a \
../vectordatapreproc/libvectordatpreproc.a \
-L@PYTHON_ROOT@/lib -lpython@PYTHON_VERSION@ -lutil
-L@PYTHON_ROOT@/lib -lpython@PYTHON_VERSION@

#titan_simulation_CXXFLAGS = -fpic

if WITH_SWIG
cxxtitan_wrap.cxx:cxxtitan.i ../header/properties.h ../header/titan_simulation.h ../preproc/preproc.h
@SWIG@ $(CPPFLAGS) -c++ -v -python -o $(srcdir)/cxxtitan_wrap.cxx -oh $(srcdir)/cxxtitan.py $(srcdir)/cxxtitan.i

endif


pyfilesdir=$(pythondir)/titan
Expand Down
4 changes: 3 additions & 1 deletion src/main/cxxtitan.i
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
*/

%module cxxtitan

%begin %{
#define __STDC_FORMAT_MACROS
%}
%{
#include "../header/constant.h"
#include "../header/properties.h"
Expand Down
25 changes: 24 additions & 1 deletion src/main/titan.C
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#endif

#include <stdio.h>
#include <string.h>
#include <unistd.h>

#include "../header/ticore/omp_mpi.hpp"
Expand All @@ -45,6 +46,7 @@ extern "C" void init_cxxtitan();

int main(int argc, char *argv[])
{
printf("Titan2d\n");
int myid, master, numprocs;
int namelen;

Expand All @@ -55,12 +57,33 @@ int main(int argc, char *argv[])
//set program full name
int i;
char executable[1028];
char python_home[1028];
char buffer[1028];

i = readlink("/proc/self/exe", executable, 1028);
executable[i] = '\0';
Py_SetProgramName(executable);


//#define MAKE_PORTABLE
#ifdef MAKE_PORTABLE
strncpy(python_home,executable,1028);
printf("%s\n",python_home);
int count=0;
for(i=strlen(python_home);i>=0;--i)
{
if(python_home[i]=='/')
{
python_home[i]='\0';
++count;
if(count==2)break;
}
}

printf("%s\n",python_home);
sprintf(python_home+strlen(python_home),"/lib/python");
printf("%s\n",python_home);
Py_SetPythonHome(python_home);
#endif
Py_Initialize();

if(myid == 0)
Expand Down
2 changes: 1 addition & 1 deletion src/main/titan_simulation.C
Original file line number Diff line number Diff line change
Expand Up @@ -612,8 +612,8 @@ void cxxTitanSimulation::save_restart_file()
xmdf<<"\t\t\t\t</DataItem>\n";
}
xmdf<<"\t\t\t</DataItem>\n";
#endif
xmdf<<"\t\t</Topology>\n";
#endif

//Geometry
xmdf<<"\t\t<Geometry Type=\"XYZ\">\n";
Expand Down

0 comments on commit da6539c

Please sign in to comment.