Commit 6908cde8 authored by Berk Onat's avatar Berk Onat

Silence all plugins' messagaes at stdout of C level to be compatibale with NOMAD parsers.

parent 7d08ba55
......@@ -14,7 +14,7 @@ message("GIT_EXECUTABLE='${GIT_EXECUTABLE}'")
ExternalProject_Add(tng
PREFIX ${TNG_PREFIX}
GIT_REPOSITORY https://github.com/gromacs/tng.git
GIT_TAG v1.7.6
#GIT_TAG v1.7.6
INSTALL_DIR ${TNG_INSTALL_DIR}
CMAKE_ARGS ${TNG_CMAKE_ARGS}
CMAKE_COMMAND CFLAGS=-fPIC CXXFLAGS=-fPIC ${CMAKE_COMMAND}
......
......@@ -172,6 +172,7 @@ if(UNIX)
message(MAKE_COMMAND= "make dynlibs staticlibs bins \"ARCH = ${TARGET_ARCH}\" \"COPTO = ${TARGET_COPT} \" \"LOPTO = ${TARGET_LOPT} \" \"CC = ${CMAKE_C_COMPILER} \" \"CXX = ${CMAKE_CXX_COMPILER} \" \"DEF = ${TARGET_DEF}\" \"CCFLAGS = ${TARGET_CFLAGS} \" \"CXXFLAGS = ${TARGET_CXXFLG} \" \"AR = ${TARGET_AR}\" \"NM = ${TARGET_NM}\" \"RANLIB = ${TARGET_RANLIB}\" \"LIBTOOL = ${TARGET_LIBTOOL} \" ${TARGET_MOL_LIBS}")
add_custom_command(
OUTPUT ${LIB_MOLFILE_FILES}
COMMAND ${CMAKE_SOURCE_DIR}/molfile_plugins/compile/silence_plugins.sh
COMMAND make dynlibs staticlibs bins \"ARCH = ${TARGET_ARCH}\" \"COPTO = ${TARGET_COPT} \" \"LOPTO = ${TARGET_LOPT} \" \"CC = ${CMAKE_C_COMPILER} \" \"CXX = ${CMAKE_CXX_COMPILER} \" \"DEF = ${TARGET_DEF}\" \"CCFLAGS = ${TARGET_CFLAGS} \" \"CXXFLAGS = ${TARGET_CXXFLG} \" \"AR = ${TARGET_AR}\" \"NM = ${TARGET_NM}\" \"RANLIB = ${TARGET_RANLIB}\" \"LIBTOOL = ${TARGET_LIBTOOL} \" ${TARGET_MOL_LIBS}
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/molfile_plugins/compile/lib ${CMAKE_CURRENT_BINARY_DIR}/lib
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_SOURCE_DIR}/molfile_plugins/compile/lib
......@@ -201,6 +202,7 @@ if(WINCOMP)
endif()
add_custom_command(
OUTPUT ${LIB_MOLFILE_FILES}
COMMAND ${CMAKE_SOURCE_DIR}/molfile_plugins/compile/silence_plugins.sh
COMMAND ${MYMAKE} dynlibs win32staticlibs "\" ARCH = ${TARGET_ARCH} \"" "\" COPTO = /Fo \"" "\" LOPTO = /OUT: \"" "\" ${TARGET_MOL_SETTINGS} \"" "\" DEF = ${TARGET_DEF} \"" "\" AR = ${TARGET_AR} \"" "\" NM = ${TARGET_NM} \"" "\" RANLIB = ${TARGET_RANLIB} \"" "\" SHLDFLAGS = ${TARGET_SHLDFLAGS} \"" "\"${TARGET_MOL_LIBS}\""
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/molfile_plugins/compile/lib ${CMAKE_CURRENT_BINARY_DIR}/molfile_plugins/compile/lib
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_SOURCE_DIR}/molfile_plugins/compile/lib
......
#!/bin/bash
fpath="../molfile_plugin/src/"
#ipath="../include/"
#incfile="silence_plugins.h"
allpattern="printf"
pattern1=" printf("
pattern2=" fprintf(stderr"
pattern3=" fprintf(stdout"
addstr1=" sprintf(msgstr"
addstr2=" sprintf(msgerr"
addstr3=" sprintf(msgout"
adddef1="#ifndef SILENCEMESSAGES "
adddef2="char msgstr[512], msgout[512], msgerr[512];"
adddef3="#endif"
alsomatch=");"
ignore1="/*"
ignore2="//"
exclude="("
files=`find -E ${fpath}* -regex '.*\.(c|h|cxx|hxx|C|H)' -type f -exec grep -l -e "$allpattern" {} \; | grep -v "periodic_table"`
echo "Changing lines with $pattern1 $pattern2 and $pattern3 in following files:"
#echo "Copying $incfile to $ipath"
#cp $incfile $ipath
fcount=1
for file in $files
do
if [ -f $file.bak ]; then
cp $file.bak $file
fi
echo "Processing file $file ..."
#incline=` cat $file | grep -n -e "#" | head -n 1 | awk -F":" '{print $1}'`
#sed -i.bak $incline'a\'$'\n''#include "silence_plugins.h"'$'\n' $file
#sed -i.bak $incline'a\'$'\n''#endif'$'\n' $file
#firstline=`cat $file | head -n 1`
#sed -i.bak '1a\'$'\n'${firstline}$'\n' $file
sed -i.bak '1i\'$'\n''#endif'$'\n' $file
sed -i.bak '1i\'$'\n''char msgstr'${fcount}'[512], msgout'${fcount}'[512], msgerr'${fcount}'[512];'$'\n' $file
sed -i.bak '1i\'$'\n''#define SILENCE_'${fcount}'_PLUGIN 1'$'\n' $file
sed -i.bak '1i\'$'\n''#ifndef SILENCE_'${fcount}'_PLUGIN'$'\n' $file
#sed -i.bak $incline'a\'$'\n''#define SILENCE_PLUGINS_'${fcount}' 1'$'\n' $file
#sed -i.bak $incline'a\'$'\n''#ifndef SILENCE_PLUGINS_'${fcount}''$'\n' $file
singlelines1=`cat $file | grep -n -e "$pattern1" | grep -v "^--" | awk -F":" '{print $1}'`
singlelines2=`cat $file | grep -n -e "$pattern2" | grep -v "^--" | awk -F":" '{print $1}'`
singlelines3=`cat $file | grep -n -e "$pattern3" | grep -v "^--" | awk -F":" '{print $1}'`
for line in $singlelines1
do
sed -i "" $line's|'"$pattern1"'|'"${addstr1}${fcount},"'|' $file
done
for line in $singlelines2
do
sed -i "" $line's|'"$pattern2"'|'"${addstr2}${fcount}"'|' $file
done
for line in $singlelines3
do
sed -i "" $line's|'"$pattern3"'|'"${addstr3}${fcount}"'|' $file
done
#if [ -f $file.bak2 ]; then
# rm $file.bak2
#fi
let fcount="$fcount + 1"
done
......@@ -90,6 +90,14 @@ class BuildExtWithoutPlatformSuffix(build_ext):
filename = super().get_ext_filename(ext_name)
return get_ext_filename_without_platform_suffix(filename)
def check_tcl_version():
output = subprocess.check_output("echo \"puts \$tcl_version;exit 0\" | tclsh", shell=True)
try:
val = float(output)
except (TypeError,ValueError):
val = None
return val
VERSION = "0.0.1"
CLASSIFIERS = [
"Development Status :: 1 - Alpha",
......@@ -110,7 +118,6 @@ CLASSIFIERS = [
"Operating System :: Microsoft :: Windows",
]
# from MDAnalysis setup.py (http://www.mdanalysis.org/)
class NumpyExtension(Extension, object):
"""Derived class to cleanly handle setup-time (numpy) dependencies.
......@@ -169,22 +176,33 @@ def get_numpy_include():
return numpy_include
# from SimpleTraj setup.py (https://github.com/arose/simpletraj)
if __name__ == '__main__':
tcl_version = None
tcl_version = check_tcl_version()
if tcl_version is None:
library_defs=['netcdf', 'expat']
else:
library_defs=['netcdf', 'expat', 'tcl']
# if sys.version_info < (3, 0):
# swig_opt_defs=['-Wall', '-c++']
# else:
# swig_opt_defs=['-py3', '-Wall', '-c++']
swig_opt_defs=['-py3', '-Wall', '-c++']
libpymolfile_module = Extension(
'pymolfile/molfile/_libpymolfile',
sources=[
'pymolfile/molfile/libpymolfile.i' ,
'pymolfile/molfile/pymolfile.cxx',
],
swig_opts=['-py3', '-Wall', '-c++'],
swig_opts=swig_opt_defs,
library_dirs=[
'build/external/tng/lib',
'build/molfile_plugins/compile/lib/'
],
#libraries=['netcdf','expat','tcl'],
libraries=['netcdf','expat'],
libraries=library_defs,
include_dirs = [
get_numpy_include(),
'pymolfile/molfile',
......@@ -210,7 +228,7 @@ if __name__ == '__main__':
version = VERSION,
classifiers = CLASSIFIERS,
license = "UIUC",
url = "https://gitlab.mpcdf.mpg.de/berko/pymolfile",
url = "https://gitlab.mpcdf.mpg.de/nomad-lab/pymolfile",
zip_safe = False,
packages = find_packages(),
libraries = [('molfile_plugin', { 'sources' : ['build/molfile_plugins/compile/lib/libmolfile_plugin.a']})],
......@@ -228,3 +246,5 @@ if __name__ == '__main__':
install_requires = [ "numpy" ],
extras_require = {}
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment