mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-12 11:24:04 +02:00
vsproject.py updates
Add multithreaded compilation flag Fix autogenerated portions being output all on one line Fix irrelevant bug where filters may not be added if there aren't any source files in that directory, but subdirectories do have source files
This commit is contained in:
40
vsproject.py
40
vsproject.py
@@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
from pathlib import Path
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
cl_compile = []
|
cl_compile = []
|
||||||
@@ -7,14 +8,22 @@ source_dirs = set()
|
|||||||
for root, subdirs, files in os.walk('src'):
|
for root, subdirs, files in os.walk('src'):
|
||||||
for file in [os.path.join(root, f) for f in files]:
|
for file in [os.path.join(root, f) for f in files]:
|
||||||
lowerfile = file.lower()
|
lowerfile = file.lower()
|
||||||
|
add_source_dir = False
|
||||||
if lowerfile.endswith('.cpp') or lowerfile.endswith('.c'):
|
if lowerfile.endswith('.cpp') or lowerfile.endswith('.c'):
|
||||||
cl_compile.append(file)
|
cl_compile.append(file)
|
||||||
source_dirs.add(os.path.dirname(file))
|
add_source_dir = True
|
||||||
if lowerfile.endswith('.hpp') or lowerfile.endswith('.h'):
|
if lowerfile.endswith('.hpp') or lowerfile.endswith('.h'):
|
||||||
cl_include.append(file)
|
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))
|
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
|
sln.write(r"""Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 2013
|
# Visual Studio 2013
|
||||||
VisualStudioVersion = 12.0.40629.0
|
VisualStudioVersion = 12.0.40629.0
|
||||||
@@ -42,7 +51,7 @@ EndGlobal
|
|||||||
""")
|
""")
|
||||||
sln.close()
|
sln.close()
|
||||||
|
|
||||||
vcxproj = open('The-Powder-Toy.vcxproj', 'w')
|
vcxproj = open("The-Powder-Toy.vcxproj", 'w')
|
||||||
vcxproj.write(r"""<?xml version="1.0" encoding="utf-8"?>
|
vcxproj.write(r"""<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
@@ -120,6 +129,7 @@ vcxproj.write(r"""<?xml version="1.0" encoding="utf-8"?>
|
|||||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||||
<WarningLevel>Level1</WarningLevel>
|
<WarningLevel>Level1</WarningLevel>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<FloatingPointModel>Fast</FloatingPointModel>
|
<FloatingPointModel>Fast</FloatingPointModel>
|
||||||
<TreatWarningAsError>true</TreatWarningAsError>
|
<TreatWarningAsError>true</TreatWarningAsError>
|
||||||
@@ -137,6 +147,7 @@ vcxproj.write(r"""<?xml version="1.0" encoding="utf-8"?>
|
|||||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||||
<WarningLevel>Level1</WarningLevel>
|
<WarningLevel>Level1</WarningLevel>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<FloatingPointModel>Fast</FloatingPointModel>
|
<FloatingPointModel>Fast</FloatingPointModel>
|
||||||
<TreatWarningAsError>true</TreatWarningAsError>
|
<TreatWarningAsError>true</TreatWarningAsError>
|
||||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||||
@@ -156,6 +167,7 @@ vcxproj.write(r"""<?xml version="1.0" encoding="utf-8"?>
|
|||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
<WarningLevel>Level1</WarningLevel>
|
<WarningLevel>Level1</WarningLevel>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<FloatingPointModel>Fast</FloatingPointModel>
|
<FloatingPointModel>Fast</FloatingPointModel>
|
||||||
<TreatWarningAsError>true</TreatWarningAsError>
|
<TreatWarningAsError>true</TreatWarningAsError>
|
||||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||||
@@ -180,8 +192,8 @@ vcxproj.write(r"""<?xml version="1.0" encoding="utf-8"?>
|
|||||||
<ClCompile Include="data\images.cpp" />
|
<ClCompile Include="data\images.cpp" />
|
||||||
<ClCompile Include="generated\ElementClasses.cpp" />
|
<ClCompile Include="generated\ElementClasses.cpp" />
|
||||||
<ClCompile Include="generated\ToolClasses.cpp" />
|
<ClCompile Include="generated\ToolClasses.cpp" />
|
||||||
""")
|
""")
|
||||||
vcxproj.write(''.join([('<ClCompile Include="' + p + '" />') for p in cl_compile]))
|
vcxproj.write('\n '.join([('<ClCompile Include="' + p + '" />') for p in cl_compile]))
|
||||||
vcxproj.write(r"""
|
vcxproj.write(r"""
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -195,8 +207,8 @@ vcxproj.write(r"""
|
|||||||
<ClInclude Include="generated\ElementClasses.h" />
|
<ClInclude Include="generated\ElementClasses.h" />
|
||||||
<ClInclude Include="generated\ToolClasses.h" />
|
<ClInclude Include="generated\ToolClasses.h" />
|
||||||
<ClInclude Include="resources\resource.h" />
|
<ClInclude Include="resources\resource.h" />
|
||||||
""")
|
""")
|
||||||
vcxproj.write(''.join([('<ClInclude Include="' + p + '" />') for p in cl_include]))
|
vcxproj.write('\n '.join([('<ClInclude Include="' + p + '" />') for p in cl_include]))
|
||||||
vcxproj.write(r"""
|
vcxproj.write(r"""
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -221,7 +233,7 @@ vcxproj.write(r"""
|
|||||||
""")
|
""")
|
||||||
vcxproj.close()
|
vcxproj.close()
|
||||||
|
|
||||||
filters = open('The-Powder-Toy.vcxproj.filters', 'w')
|
filters = open("The-Powder-Toy.vcxproj.filters", 'w')
|
||||||
filters.write(r"""<?xml version="1.0" encoding="utf-8"?>
|
filters.write(r"""<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -239,8 +251,8 @@ filters.write(r"""<?xml version="1.0" encoding="utf-8"?>
|
|||||||
<Filter Include="generated">
|
<Filter Include="generated">
|
||||||
<UniqueIdentifier>{bfb47e29-68f3-48bd-86c2-46b9f63d2597}</UniqueIdentifier>
|
<UniqueIdentifier>{bfb47e29-68f3-48bd-86c2-46b9f63d2597}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
""")
|
""")
|
||||||
filters.write(''.join([('<Filter Include="' + p + '"><UniqueIdentifier>{' + str(uuid.uuid4()) + '}</UniqueIdentifier></Filter>') for p in source_dirs]))
|
filters.write('\n '.join([('<Filter Include="' + p + '">\n <UniqueIdentifier>{' + str(uuid.uuid4()) + '}</UniqueIdentifier>\n </Filter>') for p in source_dirs]))
|
||||||
filters.write(r"""
|
filters.write(r"""
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -250,8 +262,8 @@ filters.write(r"""
|
|||||||
<ClCompile Include="generated\ToolClasses.cpp">
|
<ClCompile Include="generated\ToolClasses.cpp">
|
||||||
<Filter>generated</Filter>
|
<Filter>generated</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
""")
|
""")
|
||||||
filters.write(''.join([('<ClCompile Include="' + p + '"><Filter>' + os.path.dirname(p) + '</Filter></ClCompile>') for p in cl_compile]))
|
filters.write('\n '.join([('<ClCompile Include="' + p + '">\n <Filter>' + os.path.dirname(p) + '</Filter>\n </ClCompile>') for p in cl_compile]))
|
||||||
filters.write(r"""
|
filters.write(r"""
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -285,8 +297,8 @@ filters.write(r"""
|
|||||||
<ClInclude Include="data\Shaders.h">
|
<ClInclude Include="data\Shaders.h">
|
||||||
<Filter>data</Filter>
|
<Filter>data</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
""")
|
""")
|
||||||
filters.write(''.join([('<ClInclude Include="' + p + '"><Filter>' + os.path.dirname(p) + '</Filter></ClInclude>') for p in cl_include]))
|
filters.write('\n '.join([('<ClInclude Include="' + p + '">\n <Filter>' + os.path.dirname(p) + '</Filter>\n </ClInclude>') for p in cl_include]))
|
||||||
filters.write(r"""
|
filters.write(r"""
|
||||||
<ClInclude Include="resources\resource.h">
|
<ClInclude Include="resources\resource.h">
|
||||||
<Filter>resources</Filter>
|
<Filter>resources</Filter>
|
||||||
|
Reference in New Issue
Block a user