diff options
author | Martin Braun <martin.braun@ettus.com> | 2018-10-10 21:37:32 -0700 |
---|---|---|
committer | Marcus Müller <marcus.mueller@ettus.com> | 2018-11-01 15:24:48 +0100 |
commit | 08ed1e66f4cc6824fad043621f3b92e534d335e4 (patch) | |
tree | a4815f5460b0d9b7ea2cc37a2a29eaff17b6c2fd /gr-utils/python/modtool/gr-newmod | |
parent | 0bb482acbecb722f227e257606589b0395a32706 (diff) |
modtool: Update cmake/Modules files
This imports various fixes that were already applied to cmake/Modules/*
in GNU Radio itself, but weren't forward-ported to gr-newmod.
These fixes include Py3k compatibility.
Diffstat (limited to 'gr-utils/python/modtool/gr-newmod')
-rw-r--r-- | gr-utils/python/modtool/gr-newmod/cmake/Modules/GrSwig.cmake | 21 | ||||
-rw-r--r-- | gr-utils/python/modtool/gr-newmod/cmake/Modules/UseSWIG.cmake | 3 |
2 files changed, 9 insertions, 15 deletions
diff --git a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrSwig.cmake b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrSwig.cmake index e23c770228..bd9fc8cb62 100644 --- a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrSwig.cmake +++ b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrSwig.cmake @@ -106,17 +106,6 @@ endfunction(GR_SWIG_MAKE_DOCS) macro(GR_SWIG_MAKE name) set(ifiles ${ARGN}) - # Shimming this in here to take care of a SWIG bug with handling - # vector<size_t> and vector<unsigned int> (on 32-bit machines) and - # vector<long unsigned int> (on 64-bit machines). Use this to test - # the size of size_t, then set SIZE_T_32 if it's a 32-bit machine - # or not if it's 64-bit. The logic in gr_type.i handles the rest. - INCLUDE(CheckTypeSize) - CHECK_TYPE_SIZE("size_t" SIZEOF_SIZE_T) - CHECK_TYPE_SIZE("unsigned int" SIZEOF_UINT) - if(${SIZEOF_SIZE_T} EQUAL ${SIZEOF_UINT}) - list(APPEND GR_SWIG_FLAGS -DSIZE_T_32) - endif(${SIZEOF_SIZE_T} EQUAL ${SIZEOF_UINT}) #do swig doc generation if specified if(GR_SWIG_DOC_FILE) @@ -160,8 +149,12 @@ macro(GR_SWIG_MAKE name) include_directories(${GR_SWIG_INCLUDE_DIRS}) list(APPEND SWIG_MODULE_${name}_EXTRA_DEPS ${tag_file}) + if (PYTHON3) + set(py3 "-py3") + endif (PYTHON3) + #setup the swig flags with flags and include directories - set(CMAKE_SWIG_FLAGS -fvirtual -modern -keyword -w511 -module ${name} ${GR_SWIG_FLAGS}) + set(CMAKE_SWIG_FLAGS -fvirtual -modern -keyword -w511 -w314 -relativeimport ${py3} -module ${name} ${GR_SWIG_FLAGS}) foreach(dir ${GR_SWIG_INCLUDE_DIRS}) list(APPEND CMAKE_SWIG_FLAGS "-I${dir}") endforeach(dir) @@ -223,7 +216,7 @@ endmacro(GR_SWIG_INSTALL) ######################################################################## file(WRITE ${CMAKE_BINARY_DIR}/get_swig_deps.py " -import os, sys, re +import os, sys, re, io i_include_matcher = re.compile('%(include|import)\\s*[<|\"](.*)[>|\"]') h_include_matcher = re.compile('#(include)\\s*[<|\"](.*)[>|\"]') @@ -232,7 +225,7 @@ include_dirs = sys.argv[2].split(';') def get_swig_incs(file_path): if file_path.endswith('.i'): matcher = i_include_matcher else: matcher = h_include_matcher - file_contents = open(file_path, 'r').read() + file_contents = io.open(file_path, 'r', encoding='utf-8').read() return matcher.findall(file_contents, re.MULTILINE) def get_swig_deps(file_path, level): diff --git a/gr-utils/python/modtool/gr-newmod/cmake/Modules/UseSWIG.cmake b/gr-utils/python/modtool/gr-newmod/cmake/Modules/UseSWIG.cmake index b7e3e05dc5..a37cc41ae4 100644 --- a/gr-utils/python/modtool/gr-newmod/cmake/Modules/UseSWIG.cmake +++ b/gr-utils/python/modtool/gr-newmod/cmake/Modules/UseSWIG.cmake @@ -155,6 +155,7 @@ macro(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) endif(HAVE_WNO_UNUSED_BUT_SET_VARIABLE) get_directory_property(cmake_include_directories INCLUDE_DIRECTORIES) + list(REMOVE_DUPLICATES cmake_include_directories) set(swig_include_dirs) foreach(it ${cmake_include_directories}) set(swig_include_dirs ${swig_include_dirs} "-I${it}") @@ -175,7 +176,7 @@ macro(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) file(RELATIVE_PATH reldir ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}) 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', '_', '${name} ${reldir} ' + unique))" OUTPUT_VARIABLE _target OUTPUT_STRIP_TRAILING_WHITESPACE ) |