diff --git a/vsproject.py b/vsproject.py index 061535c9d..ce4391f9f 100755 --- a/vsproject.py +++ b/vsproject.py @@ -1,4 +1,5 @@ import os +from pathlib import Path import uuid cl_compile = [] @@ -7,14 +8,22 @@ source_dirs = set() for root, subdirs, files in os.walk('src'): for file in [os.path.join(root, f) for f in files]: lowerfile = file.lower() + add_source_dir = False if lowerfile.endswith('.cpp') or lowerfile.endswith('.c'): cl_compile.append(file) - source_dirs.add(os.path.dirname(file)) + add_source_dir = True if lowerfile.endswith('.hpp') or lowerfile.endswith('.h'): cl_include.append(file) + add_source_dir = True + if add_source_dir: + path = Path(root) + for i in range(len(path.parents) - 1): + parent = path.parents[i] + if not str(parent) in source_dirs: + source_dirs.add(str(parent)) source_dirs.add(os.path.dirname(file)) -sln = open('The-Powder-Toy.sln', 'w') +sln = open("The-Powder-Toy.sln", 'w') sln.write(r"""Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 VisualStudioVersion = 12.0.40629.0 @@ -42,7 +51,7 @@ EndGlobal """) sln.close() -vcxproj = open('The-Powder-Toy.vcxproj', 'w') +vcxproj = open("The-Powder-Toy.vcxproj", 'w') vcxproj.write(r""" @@ -120,6 +129,7 @@ vcxproj.write(r""" MultiThreadedDebugDLL Level1 ProgramDatabase + true Disabled Fast true @@ -137,6 +147,7 @@ vcxproj.write(r""" MultiThreadedDLL Level1 ProgramDatabase + true Fast true StreamingSIMDExtensions2 @@ -156,6 +167,7 @@ vcxproj.write(r""" MultiThreaded Level1 ProgramDatabase + true Fast true StreamingSIMDExtensions2 @@ -180,8 +192,8 @@ vcxproj.write(r""" -""") -vcxproj.write(''.join([('') for p in cl_compile])) + """) +vcxproj.write('\n '.join([('') for p in cl_compile])) vcxproj.write(r""" @@ -195,8 +207,8 @@ vcxproj.write(r""" -""") -vcxproj.write(''.join([('') for p in cl_include])) + """) +vcxproj.write('\n '.join([('') for p in cl_include])) vcxproj.write(r""" @@ -221,7 +233,7 @@ vcxproj.write(r""" """) vcxproj.close() -filters = open('The-Powder-Toy.vcxproj.filters', 'w') +filters = open("The-Powder-Toy.vcxproj.filters", 'w') filters.write(r""" @@ -239,8 +251,8 @@ filters.write(r""" {bfb47e29-68f3-48bd-86c2-46b9f63d2597} -""") -filters.write(''.join([('{' + str(uuid.uuid4()) + '}') for p in source_dirs])) + """) +filters.write('\n '.join([('\n {' + str(uuid.uuid4()) + '}\n ') for p in source_dirs])) filters.write(r""" @@ -250,8 +262,8 @@ filters.write(r""" generated -""") -filters.write(''.join([('' + os.path.dirname(p) + '') for p in cl_compile])) + """) +filters.write('\n '.join([('\n ' + os.path.dirname(p) + '\n ') for p in cl_compile])) filters.write(r""" @@ -285,8 +297,8 @@ filters.write(r""" data -""") -filters.write(''.join([('' + os.path.dirname(p) + '') for p in cl_include])) + """) +filters.write('\n '.join([('\n ' + os.path.dirname(p) + '\n ') for p in cl_include])) filters.write(r""" resources