<%! import re import hashlib def calc_to_filter(path): return '\\'.join(path.split('/')[:-1]) %>\ <%def name="get_repo_root(proj)">${'$(SolutionDir)\..'}\ <%def name="to_windows_path(path)">${path.replace('/','\\')}\ <%def name="to_filter(path)">${calc_to_filter(path)}\ <%def name="filter_to_guid(proj, filter)">${re.sub('(........)(....)(....)(....)', r'\1-\2-\3-\4-', hashlib.md5(''.join([filter, proj])).hexdigest())}\ <%def name="gen_filters(name, collection)">\ % for project in vsprojects: % if project.name == name: % if project.get('src',[]): % for src_name in project.src: ${to_filter(src_name)} % endfor % endif % if project.get('public_headers',[]): % for public_header in project.public_headers: ${to_filter(public_header)} % endfor % endif % if project.get('headers',[]): % for header in project.headers: ${to_filter(header)} % endfor % endif <% filters = set() files = project.get('src', []) + project.get('public_headers', []) + project.get('headers', []) for file in files: filter = calc_to_filter(file) paths = filter.split('\\') for i in range(len(paths)): filters.add('\\'.join(paths[:i + 1])) filters = sorted(filters) %> % for filter in filters: {${filter_to_guid(project.name, filter)}} % endfor % endif % endfor \