summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmake/Modules/GrSwig.cmake20
1 files changed, 11 insertions, 9 deletions
diff --git a/cmake/Modules/GrSwig.cmake b/cmake/Modules/GrSwig.cmake
index d4dcf958a..0d4cce2b3 100644
--- a/cmake/Modules/GrSwig.cmake
+++ b/cmake/Modules/GrSwig.cmake
@@ -102,33 +102,35 @@ MACRO(GR_SWIG_INSTALL)
ENDMACRO(GR_SWIG_INSTALL)
########################################################################
-# Generate a python file that can determine swig dependencies
+# Generate a python file that can determine swig dependencies.
+# Used by the make macro above to determine extra dependencies.
+# When you build C++, CMake figures out the header dependencies.
+# This code essentially performs that logic for swig includes.
########################################################################
FILE(WRITE ${CMAKE_BINARY_DIR}/get_swig_deps.py "
import os, sys, re
-include_matcher = re.compile('(#|%)include\\s*(<(.*)>|\"(.*)\")')
+include_matcher = re.compile('[#|%]include\\s*[<|\"](.*)[>|\"]')
include_dirs = sys.argv[2].split(';')
def get_swig_incs(file_path):
- for line in open(file_path, 'r').readlines():
- m = include_matcher.match(line)
- if not m: continue
- yield m.groups()[2] or m.groups()[3]
+ file_contents = open(file_path, 'r').read()
+ return include_matcher.findall(file_contents, re.MULTILINE)
def get_swig_deps(file_path, level):
- deps = list()
+ deps = [file_path]
+ if level == 0: return deps
for inc_file in get_swig_incs(file_path):
for inc_dir in include_dirs:
inc_path = os.path.join(inc_dir, inc_file)
if not os.path.exists(inc_path): continue
- deps.append(inc_path)
- if level > 1: deps.extend(get_swig_deps(inc_path, level-1))
+ deps.extend(get_swig_deps(inc_path, level-1))
return deps
if __name__ == '__main__':
ifiles = sys.argv[1].split(';')
deps = sum([get_swig_deps(ifile, 3) for ifile in ifiles], [])
+ #sys.stderr.write(';'.join(set(deps)) + '\\n\\n')
print(';'.join(set(deps)))
")