mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-16 12:12:57 +00:00
Switch from cheetah to mako and six
This commit is contained in:
parent
343410d73b
commit
ec51b6cca9
@ -74,17 +74,23 @@ SET(CROSSCOMPILE_MULTILIB ${CROSSCOMPILE_MULTILIB} CACHE STRING "Define \"true\"
|
|||||||
|
|
||||||
# Python
|
# Python
|
||||||
include(VolkPython) #sets PYTHON_EXECUTABLE and PYTHON_DASH_B
|
include(VolkPython) #sets PYTHON_EXECUTABLE and PYTHON_DASH_B
|
||||||
VOLK_PYTHON_CHECK_MODULE("python >= 2.5" sys "sys.version.split()[0] >= '2.5'" PYTHON_MIN_VER_FOUND)
|
VOLK_PYTHON_CHECK_MODULE("python >= 2.7" sys "sys.version.split()[0] >= '2.7'" PYTHON_MIN_VER_FOUND)
|
||||||
VOLK_PYTHON_CHECK_MODULE("Cheetah >= 2.0.0" Cheetah "Cheetah.Version >= '2.0.0'" CHEETAH_FOUND)
|
VOLK_PYTHON_CHECK_MODULE("Cheetah >= 2.0.0" Cheetah "Cheetah.Version >= '2.0.0'" CHEETAH_FOUND)
|
||||||
|
VOLK_PYTHON_CHECK_MODULE("six - python 2 and 3 compatibility library" six "True" SIX_FOUND)
|
||||||
|
|
||||||
if(NOT PYTHON_MIN_VER_FOUND)
|
if(NOT PYTHON_MIN_VER_FOUND)
|
||||||
message(FATAL_ERROR "Python 2.5 or greater required to build VOLK_GNSSSDR")
|
message(FATAL_ERROR "Python 2.7 or greater required to build VOLK_GNSSSDR")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Cheetah
|
# Cheetah
|
||||||
if(NOT CHEETAH_FOUND)
|
if(NOT CHEETAH_FOUND)
|
||||||
message(FATAL_ERROR "Cheetah templates required to build VOLK_GNSSSDR")
|
message(FATAL_ERROR "Cheetah templates required to build VOLK_GNSSSDR")
|
||||||
endif()
|
endif()
|
||||||
|
# Six
|
||||||
|
if(NOT SIX_FOUND)
|
||||||
|
message(FATAL_ERROR "six - python 2 and 3 compatibility library required to build VOLK")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
# Boost
|
# Boost
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
|
@ -36,11 +36,12 @@ if(PYTHON_EXECUTABLE)
|
|||||||
else(PYTHON_EXECUTABLE)
|
else(PYTHON_EXECUTABLE)
|
||||||
|
|
||||||
#use the built-in find script
|
#use the built-in find script
|
||||||
|
set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6)
|
||||||
find_package(PythonInterp 2)
|
find_package(PythonInterp 2)
|
||||||
|
|
||||||
#and if that fails use the find program routine
|
#and if that fails use the find program routine
|
||||||
if(NOT PYTHONINTERP_FOUND)
|
if(NOT PYTHONINTERP_FOUND)
|
||||||
find_program(PYTHON_EXECUTABLE NAMES python python2 python2.7 python2.6 python2.5)
|
find_program(PYTHON_EXECUTABLE NAMES python python2 python2.7 python3)
|
||||||
if(PYTHON_EXECUTABLE)
|
if(PYTHON_EXECUTABLE)
|
||||||
set(PYTHONINTERP_FOUND TRUE)
|
set(PYTHONINTERP_FOUND TRUE)
|
||||||
endif(PYTHON_EXECUTABLE)
|
endif(PYTHON_EXECUTABLE)
|
||||||
@ -100,7 +101,7 @@ endmacro(VOLK_PYTHON_CHECK_MODULE)
|
|||||||
if(NOT DEFINED VOLK_PYTHON_DIR)
|
if(NOT DEFINED VOLK_PYTHON_DIR)
|
||||||
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "
|
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "
|
||||||
from distutils import sysconfig
|
from distutils import sysconfig
|
||||||
print sysconfig.get_python_lib(plat_specific=True, prefix='')
|
print(sysconfig.get_python_lib(plat_specific=True, prefix=''))
|
||||||
" OUTPUT_VARIABLE VOLK_PYTHON_DIR OUTPUT_STRIP_TRAILING_WHITESPACE
|
" OUTPUT_VARIABLE VOLK_PYTHON_DIR OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
@ -113,7 +114,7 @@ file(TO_CMAKE_PATH ${VOLK_PYTHON_DIR} VOLK_PYTHON_DIR)
|
|||||||
function(VOLK_UNIQUE_TARGET desc)
|
function(VOLK_UNIQUE_TARGET desc)
|
||||||
file(RELATIVE_PATH reldir ${PROJECT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
file(RELATIVE_PATH reldir ${PROJECT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import re, hashlib
|
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import re, hashlib
|
||||||
unique = hashlib.md5('${reldir}${ARGN}').hexdigest()[:5]
|
unique = hashlib.md5(b'${reldir}${ARGN}').hexdigest()[:5]
|
||||||
print(re.sub('\\W', '_', '${desc} ${reldir} ' + unique))"
|
print(re.sub('\\W', '_', '${desc} ${reldir} ' + unique))"
|
||||||
OUTPUT_VARIABLE _target OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_VARIABLE _target OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
add_custom_target(${_target} ALL DEPENDS ${ARGN})
|
add_custom_target(${_target} ALL DEPENDS ${ARGN})
|
||||||
@ -230,7 +231,7 @@ endfunction(VOLK_PYTHON_INSTALL)
|
|||||||
file(WRITE ${PROJECT_BINARY_DIR}/python_compile_helper.py "
|
file(WRITE ${PROJECT_BINARY_DIR}/python_compile_helper.py "
|
||||||
import sys, py_compile
|
import sys, py_compile
|
||||||
files = sys.argv[1:]
|
files = sys.argv[1:]
|
||||||
srcs, gens = files[:len(files)/2], files[len(files)/2:]
|
srcs, gens = files[:len(files)//2], files[len(files)//2:]
|
||||||
for src, gen in zip(srcs, gens):
|
for src, gen in zip(srcs, gens):
|
||||||
py_compile.compile(file=src, cfile=gen, doraise=True)
|
py_compile.compile(file=src, cfile=gen, doraise=True)
|
||||||
")
|
")
|
||||||
|
@ -18,6 +18,10 @@
|
|||||||
# along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
|
# along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
archs = list()
|
archs = list()
|
||||||
arch_dict = dict()
|
arch_dict = dict()
|
||||||
|
|
||||||
@ -81,8 +85,8 @@ for arch_xml in archs_xml:
|
|||||||
if not flags.has_key(name): flags[name] = list()
|
if not flags.has_key(name): flags[name] = list()
|
||||||
flags[name].append(flag_xml.firstChild.data)
|
flags[name].append(flag_xml.firstChild.data)
|
||||||
#force kwargs keys to be of type str, not unicode for py25
|
#force kwargs keys to be of type str, not unicode for py25
|
||||||
kwargs = dict((str(k), v) for k, v in kwargs.iteritems())
|
kwargs = dict((str(k), v) for k, v in six.iteritems(kwargs))
|
||||||
register_arch(flags=flags, checks=checks, **kwargs)
|
register_arch(flags=flags, checks=checks, **kwargs)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print archs
|
print(archs)
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
# along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
|
# along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import optparse
|
import optparse
|
||||||
import volk_gnsssdr_arch_defs
|
import volk_gnsssdr_arch_defs
|
||||||
import volk_gnsssdr_machine_defs
|
import volk_gnsssdr_machine_defs
|
||||||
@ -28,7 +30,7 @@ def do_arch_flags_list(compiler):
|
|||||||
if not arch.is_supported(compiler): continue
|
if not arch.is_supported(compiler): continue
|
||||||
fields = [arch.name] + arch.get_flags(compiler)
|
fields = [arch.name] + arch.get_flags(compiler)
|
||||||
output.append(','.join(fields))
|
output.append(','.join(fields))
|
||||||
print ';'.join(output)
|
print(';'.join(output))
|
||||||
|
|
||||||
def do_machines_list(arch_names):
|
def do_machines_list(arch_names):
|
||||||
output = list()
|
output = list()
|
||||||
@ -36,14 +38,14 @@ def do_machines_list(arch_names):
|
|||||||
machine_arch_set = set(machine.arch_names)
|
machine_arch_set = set(machine.arch_names)
|
||||||
if set(arch_names).intersection(machine_arch_set) == machine_arch_set:
|
if set(arch_names).intersection(machine_arch_set) == machine_arch_set:
|
||||||
output.append(machine.name)
|
output.append(machine.name)
|
||||||
print ';'.join(output)
|
print(';'.join(output))
|
||||||
|
|
||||||
def do_machine_flags_list(compiler, machine_name):
|
def do_machine_flags_list(compiler, machine_name):
|
||||||
output = list()
|
output = list()
|
||||||
machine = volk_gnsssdr_machine_defs.machine_dict[machine_name]
|
machine = volk_gnsssdr_machine_defs.machine_dict[machine_name]
|
||||||
for arch in machine.archs:
|
for arch in machine.archs:
|
||||||
output.extend(arch.get_flags(compiler))
|
output.extend(arch.get_flags(compiler))
|
||||||
print ' '.join(output)
|
print(' '.join(output))
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = optparse.OptionParser()
|
parser = optparse.OptionParser()
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
@ -98,9 +100,9 @@ def split_into_nested_ifdef_sections(code):
|
|||||||
def print_sections(sections, indent = ' '):
|
def print_sections(sections, indent = ' '):
|
||||||
for header, body in sections:
|
for header, body in sections:
|
||||||
if header == 'text':
|
if header == 'text':
|
||||||
print indent, ('\n'+indent).join(body.splitlines())
|
print(indent, ('\n'+indent).join(body.splitlines()))
|
||||||
continue
|
continue
|
||||||
print indent.replace(' ', '-') + '>', header
|
print(indent.replace(' ', '-') + '>', header)
|
||||||
print_sections(body, indent + ' ')
|
print_sections(body, indent + ' ')
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
@ -136,7 +138,7 @@ class impl_class:
|
|||||||
arg_type, arg_name = m.groups()
|
arg_type, arg_name = m.groups()
|
||||||
self.args.append((arg_type, arg_name))
|
self.args.append((arg_type, arg_name))
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
raise Exception, 'I cant parse the function prototype from: %s in %s\n%s'%(kern_name, body, ex)
|
raise Exception('I cant parse the function prototype from: %s in %s\n%s'%(kern_name, body, ex))
|
||||||
|
|
||||||
assert self.name
|
assert self.name
|
||||||
self.is_aligned = self.name.startswith('a_')
|
self.is_aligned = self.name.startswith('a_')
|
||||||
@ -206,4 +208,4 @@ kernel_files = glob.glob(os.path.join(srcdir, "kernels", "volk_gnsssdr", "*.h"))
|
|||||||
kernels = map(kernel_class, kernel_files)
|
kernels = map(kernel_class, kernel_files)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print kernels
|
print(kernels)
|
||||||
|
@ -17,6 +17,9 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
|
# along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
from volk_gnsssdr_arch_defs import arch_dict
|
from volk_gnsssdr_arch_defs import arch_dict
|
||||||
|
|
||||||
@ -70,8 +73,8 @@ for machine_xml in machines_xml:
|
|||||||
except: pass
|
except: pass
|
||||||
kwargs['archs'] = kwargs['archs'].split()
|
kwargs['archs'] = kwargs['archs'].split()
|
||||||
#force kwargs keys to be of type str, not unicode for py25
|
#force kwargs keys to be of type str, not unicode for py25
|
||||||
kwargs = dict((str(k), v) for k, v in kwargs.iteritems())
|
kwargs = dict((str(k), v) for k, v in six.iteritems(kwargs))
|
||||||
register_machine(**kwargs)
|
register_machine(**kwargs)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print machines
|
print(machines)
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
# along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
|
# along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
@ -67,7 +69,7 @@ def main():
|
|||||||
|
|
||||||
output = __parse_tmpl(open(opts.input).read(), args=args)
|
output = __parse_tmpl(open(opts.input).read(), args=args)
|
||||||
if opts.output: open(opts.output, 'w').write(output)
|
if opts.output: open(opts.output, 'w').write(output)
|
||||||
else: print output
|
else: print(output)
|
||||||
|
|
||||||
if __name__ == '__main__': main()
|
if __name__ == '__main__': main()
|
||||||
|
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
@ -70,7 +72,7 @@ class volk_gnsssdr_modtool_config:
|
|||||||
elif os.path.exists(default):
|
elif os.path.exists(default):
|
||||||
icfg.read(default)
|
icfg.read(default)
|
||||||
else:
|
else:
|
||||||
print "Initializing config file..."
|
print("Initializing config file...")
|
||||||
icfg.add_section(self.config_name)
|
icfg.add_section(self.config_name)
|
||||||
for kn in self.config_defaults:
|
for kn in self.config_defaults:
|
||||||
rv = raw_input("%s: "%(kn))
|
rv = raw_input("%s: "%(kn))
|
||||||
@ -95,9 +97,3 @@ class volk_gnsssdr_modtool_config:
|
|||||||
retval[i[0]] = i[1]
|
retval[i[0]] = i[1]
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
# the Free Software Foundation, Inc., 51 Franklin Street,
|
# the Free Software Foundation, Inc., 51 Franklin Street,
|
||||||
# Boston, MA 02110-1301, USA.
|
# Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
@ -225,14 +226,14 @@ class volk_gnsssdr_modtool:
|
|||||||
|
|
||||||
for kernel in search_kernels:
|
for kernel in search_kernels:
|
||||||
infile = os.path.join(inpath, 'kernels/' + top[:-1] + '/' + top + kernel.pattern + '.h');
|
infile = os.path.join(inpath, 'kernels/' + top[:-1] + '/' + top + kernel.pattern + '.h');
|
||||||
print "Removing kernel %s"%(kernel.pattern)
|
print("Removing kernel %s" % kernel.pattern)
|
||||||
if os.path.exists(infile):
|
if os.path.exists(infile):
|
||||||
os.remove(infile);
|
os.remove(infile);
|
||||||
# remove the orc proto-kernels if they exist. There are no puppets here
|
# remove the orc proto-kernels if they exist. There are no puppets here
|
||||||
# so just need to glob for files matching kernel name
|
# so just need to glob for files matching kernel name
|
||||||
print glob.glob(inpath + '/orc/' + top + name + '*.orc');
|
print(glob.glob(inpath + '/kernel/volk/asm/orc/' + top + name + '*.orc'))
|
||||||
for orcfile in glob.glob(inpath + '/orc/' + top + name + '*.orc'):
|
for orcfile in glob.glob(inpath + '/orc/' + top + name + '*.orc'):
|
||||||
print orcfile
|
print(orcfile)
|
||||||
if(os.path.exists(orcfile)):
|
if(os.path.exists(orcfile)):
|
||||||
os.remove(orcfile);
|
os.remove(orcfile);
|
||||||
|
|
||||||
@ -294,7 +295,7 @@ class volk_gnsssdr_modtool:
|
|||||||
open(dest, 'a').write(otherline);
|
open(dest, 'a').write(otherline);
|
||||||
|
|
||||||
for kernel in search_kernels:
|
for kernel in search_kernels:
|
||||||
print "Adding kernel %s from module %s"%(kernel.pattern,base)
|
print("Adding kernel %s from module %s" % (kernel.pattern, base))
|
||||||
|
|
||||||
infile = open(os.path.join(inpath, 'lib/testqa.cc'));
|
infile = open(os.path.join(inpath, 'lib/testqa.cc'));
|
||||||
otherinfile = open(os.path.join(self.my_dict['destination'], 'volk_gnsssdr_' + self.my_dict['name'], 'lib/testqa.cc'));
|
otherinfile = open(os.path.join(self.my_dict['destination'], 'volk_gnsssdr_' + self.my_dict['name'], 'lib/testqa.cc'));
|
||||||
|
Loading…
Reference in New Issue
Block a user