Specify C source file in example VC projects

This commit is contained in:
Susko3 2024-10-29 21:19:28 +00:00 committed by Sam Lantinga
parent 415abf2ea2
commit 94d110edd5
24 changed files with 34 additions and 26 deletions

View File

@ -7,7 +7,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ItemGroup>
<None Include="$(SolutionDir)\..\examples\audio\01-simple-playback\README.txt" />
<ClCompile Include="$(SolutionDir)\..\examples\audio\01-simple-playback\*.c" />
<ClCompile Include="$(SolutionDir)\..\examples\audio\01-simple-playback\simple-playback.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>

View File

@ -7,7 +7,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ItemGroup>
<None Include="$(SolutionDir)\..\examples\audio\02-simple-playback-callback\README.txt" />
<ClCompile Include="$(SolutionDir)\..\examples\audio\02-simple-playback-callback\*.c" />
<ClCompile Include="$(SolutionDir)\..\examples\audio\02-simple-playback-callback\simple-playback-callback.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>

View File

@ -7,7 +7,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ItemGroup>
<None Include="$(SolutionDir)\..\examples\audio\03-load-wav\README.txt" />
<ClCompile Include="$(SolutionDir)\..\examples\audio\03-load-wav\*.c" />
<ClCompile Include="$(SolutionDir)\..\examples\audio\03-load-wav\load-wav.c" />
<Content Include="$(SolutionDir)\..\test\sample.wav" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -7,7 +7,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ItemGroup>
<None Include="$(SolutionDir)\..\examples\camera\01-read-and-draw\README.txt" />
<ClCompile Include="$(SolutionDir)\..\examples\camera\01-read-and-draw\*.c" />
<ClCompile Include="$(SolutionDir)\..\examples\camera\01-read-and-draw\read-and-draw.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>

View File

@ -7,7 +7,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ItemGroup>
<None Include="$(SolutionDir)\..\examples\game\01-snake\README.txt" />
<ClCompile Include="$(SolutionDir)\..\examples\game\01-snake\*.c" />
<ClCompile Include="$(SolutionDir)\..\examples\game\01-snake\snake.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>

View File

@ -7,7 +7,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ItemGroup>
<None Include="$(SolutionDir)\..\examples\game\02-woodeneye-008\README.txt" />
<ClCompile Include="$(SolutionDir)\..\examples\game\02-woodeneye-008\*.c" />
<ClCompile Include="$(SolutionDir)\..\examples\game\02-woodeneye-008\woodeneye-008.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>

View File

@ -7,7 +7,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ItemGroup>
<None Include="$(SolutionDir)\..\examples\game\03-infinite-monkeys\README.txt" />
<ClCompile Include="$(SolutionDir)\..\examples\game\03-infinite-monkeys\*.c" />
<ClCompile Include="$(SolutionDir)\..\examples\game\03-infinite-monkeys\infinite-monkeys.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>

View File

@ -4,7 +4,8 @@ import uuid
REPOSITORY_ROOT = pathlib.Path(__file__).parent.parent.parent
def generate(category, example_name):
def generate(category, example_name, c_source_file):
guid = str(uuid.uuid4()).upper()
text = f"""
<?xml version="1.0" encoding="utf-8"?>
@ -16,7 +17,7 @@ def generate(category, example_name):
<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.props" />
<ItemGroup>
<None Include="$(SolutionDir)\\..\\examples\\{category}\\{example_name}\\README.txt" />
<ClCompile Include="$(SolutionDir)\\..\\examples\\{category}\\{example_name}\\*.c" />
<ClCompile Include="$(SolutionDir)\\..\\examples\\{category}\\{example_name}\\{c_source_file}" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.targets" />
</Project>
@ -34,12 +35,19 @@ def generate(category, example_name):
f.write(text)
def get_c_source_filename(example_dir: pathlib.Path):
"""Gets the one and only C source file name in the directory of the example."""
c_files = [f.name for f in example_dir.iterdir() if f.name.endswith(".c")]
assert len(c_files) == 1
return c_files[0]
def main():
path = REPOSITORY_ROOT / "examples"
for category in path.iterdir():
if category.is_dir():
for example in category.iterdir():
generate(category.name, example.name)
generate(category.name, example.name, get_c_source_filename(example))
if __name__ == "__main__":

View File

@ -7,7 +7,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ItemGroup>
<None Include="$(SolutionDir)\..\examples\pen\01-drawing-lines\README.txt" />
<ClCompile Include="$(SolutionDir)\..\examples\pen\01-drawing-lines\*.c" />
<ClCompile Include="$(SolutionDir)\..\examples\pen\01-drawing-lines\drawing-lines.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>

View File

@ -7,7 +7,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ItemGroup>
<None Include="$(SolutionDir)\..\examples\renderer\01-clear\README.txt" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\01-clear\*.c" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\01-clear\clear.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>

View File

@ -7,7 +7,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ItemGroup>
<None Include="$(SolutionDir)\..\examples\renderer\02-primitives\README.txt" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\02-primitives\*.c" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\02-primitives\primitives.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>

View File

@ -7,7 +7,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ItemGroup>
<None Include="$(SolutionDir)\..\examples\renderer\03-lines\README.txt" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\03-lines\*.c" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\03-lines\lines.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>

View File

@ -7,7 +7,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ItemGroup>
<None Include="$(SolutionDir)\..\examples\renderer\04-points\README.txt" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\04-points\*.c" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\04-points\points.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>

View File

@ -7,7 +7,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ItemGroup>
<None Include="$(SolutionDir)\..\examples\renderer\05-rectangles\README.txt" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\05-rectangles\*.c" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\05-rectangles\rectangles.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>

View File

@ -7,7 +7,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ItemGroup>
<None Include="$(SolutionDir)\..\examples\renderer\06-textures\README.txt" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\06-textures\*.c" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\06-textures\textures.c" />
<Content Include="$(SolutionDir)\..\test\sample.bmp" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -7,7 +7,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ItemGroup>
<None Include="$(SolutionDir)\..\examples\renderer\07-streaming-textures\README.txt" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\07-streaming-textures\*.c" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\07-streaming-textures\streaming-textures.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>

View File

@ -7,7 +7,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ItemGroup>
<None Include="$(SolutionDir)\..\examples\renderer\08-rotating-textures\README.txt" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\08-rotating-textures\*.c" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\08-rotating-textures\rotating-textures.c" />
<Content Include="$(SolutionDir)\..\test\sample.bmp" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -7,7 +7,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ItemGroup>
<None Include="$(SolutionDir)\..\examples\renderer\09-scaling-textures\README.txt" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\09-scaling-textures\*.c" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\09-scaling-textures\scaling-textures.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>

View File

@ -7,7 +7,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ItemGroup>
<None Include="$(SolutionDir)\..\examples\renderer\10-geometry\README.txt" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\10-geometry\*.c" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\10-geometry\geometry.c" />
<Content Include="$(SolutionDir)\..\test\sample.bmp" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -7,7 +7,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ItemGroup>
<None Include="$(SolutionDir)\..\examples\renderer\11-color-mods\README.txt" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\11-color-mods\*.c" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\11-color-mods\color-mods.c" />
<Content Include="$(SolutionDir)\..\test\sample.bmp" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -7,7 +7,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ItemGroup>
<None Include="$(SolutionDir)\..\examples\renderer\14-viewport\README.txt" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\14-viewport\*.c" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\14-viewport\viewport.c" />
<Content Include="$(SolutionDir)\..\test\sample.bmp" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -7,7 +7,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ItemGroup>
<None Include="$(SolutionDir)\..\examples\renderer\15-cliprect\README.txt" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\15-cliprect\*.c" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\15-cliprect\cliprect.c" />
<Content Include="$(SolutionDir)\..\test\sample.bmp" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -7,7 +7,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ItemGroup>
<None Include="$(SolutionDir)\..\examples\renderer\17-read-pixels\README.txt" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\17-read-pixels\*.c" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\17-read-pixels\read-pixels.c" />
<Content Include="$(SolutionDir)\..\test\sample.bmp" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -7,7 +7,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ItemGroup>
<None Include="$(SolutionDir)\..\examples\renderer\18-debug-text\README.txt" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\18-debug-text\*.c" />
<ClCompile Include="$(SolutionDir)\..\examples\renderer\18-debug-text\debug-text.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>