diff options
author | Nicolas 'Pixel' Noble <nicolas@nobis-crew.org> | 2015-01-24 00:37:10 -0800 |
---|---|---|
committer | Nicolas 'Pixel' Noble <nicolas@nobis-crew.org> | 2015-01-24 01:08:29 -0800 |
commit | 1ea024dbe26420dc3a9f66e5add922dfd91095d1 (patch) | |
tree | 0d1a6f2394caaabf43b8647253c8e6b6e81e981c /templates | |
parent | e2380338bfc9cec2f44877b3551d4e94490c1daa (diff) |
Adding Visual Studio filters.
Diffstat (limited to 'templates')
4 files changed, 70 insertions, 0 deletions
diff --git a/templates/vsprojects/vs2013/gpr.vcxproj.filters.template b/templates/vsprojects/vs2013/gpr.vcxproj.filters.template new file mode 100644 index 0000000000..0ed1ed85d0 --- /dev/null +++ b/templates/vsprojects/vs2013/gpr.vcxproj.filters.template @@ -0,0 +1,2 @@ +<%namespace file="vcxproj.filters_defs.include" import="gen_project"/>\ +${gen_project('gpr', libs, targets)} diff --git a/templates/vsprojects/vs2013/grpc.vcxproj.filters.template b/templates/vsprojects/vs2013/grpc.vcxproj.filters.template new file mode 100644 index 0000000000..0327c9422d --- /dev/null +++ b/templates/vsprojects/vs2013/grpc.vcxproj.filters.template @@ -0,0 +1,2 @@ +<%namespace file="vcxproj.filters_defs.include" import="gen_project"/>\ +${gen_project('grpc', libs, targets)} diff --git a/templates/vsprojects/vs2013/grpc_unsecure.vcxproj.filters.template b/templates/vsprojects/vs2013/grpc_unsecure.vcxproj.filters.template new file mode 100644 index 0000000000..48cbbd30bb --- /dev/null +++ b/templates/vsprojects/vs2013/grpc_unsecure.vcxproj.filters.template @@ -0,0 +1,2 @@ +<%namespace file="vcxproj.filters_defs.include" import="gen_project"/>\ +${gen_project('grpc_unsecure', libs, targets)} diff --git a/templates/vsprojects/vs2013/vcxproj.filters_defs.include b/templates/vsprojects/vs2013/vcxproj.filters_defs.include new file mode 100644 index 0000000000..c25718b802 --- /dev/null +++ b/templates/vsprojects/vs2013/vcxproj.filters_defs.include @@ -0,0 +1,64 @@ +<%! + import re + import hashlib + + def calc_to_filter(path): + return '\\'.join(path.split('/')[:-1]) +%>\ +<%def name="to_windows_path(path)">${path.replace('/','\\')}</%def>\ +<%def name="to_filter(path)">${calc_to_filter(path)}</%def>\ +<%def name="filter_to_guid(proj, filter)">${re.sub('(........)(....)(....)(....)', r'\1-\2-\3-\4-', hashlib.md5(''.join([filter, proj])).hexdigest())}</%def>\ +<%def name="gen_project(name, libs, targets)">\ +% for project in vsprojects: + % if project.name == name: +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + % if project.get('src',[]): + <ItemGroup> + % for src_name in project.src: + <ClCompile Include="..\..\${to_windows_path(src_name)}"> + <Filter>${to_filter(src_name)}</Filter> + </ClCompile> + % endfor + </ItemGroup> + % endif + % if project.get('public_headers',[]): + <ItemGroup> + % for public_header in project.public_headers: + <ClInclude Include="..\..\${to_windows_path(public_header)}"> + <Filter>${to_filter(public_header)}</Filter> + </ClInclude> + % endfor + </ItemGroup> + % endif + % if project.get('headers',[]): + <ItemGroup> + % for header in project.headers: + <ClInclude Include="..\..\${to_windows_path(header)}"> + <Filter>${to_filter(header)}</Filter> + </ClInclude> + % endfor + </ItemGroup> + % 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) +%> + <ItemGroup> + % for filter in filters: + <Filter Include="${filter}"> + <UniqueIdentifier>{${filter_to_guid(project.name, filter)}}</UniqueIdentifier> + </Filter> + % endfor + </ItemGroup> +</Project> + % endif +% endfor +</%def>\
\ No newline at end of file |