Skip to content

Commit 6b17fec

Browse files
committed
Updated PhysX and Biohazrd. Revamped how the native bits of PhysX are built.
* Updated to latest PhysX SDK * Removed the need to use a modified version of the SDK * Updated to latest Biohazrd * Started rebrand to Mochi.PhysX * Added peliminary Linux support * We now primarily index through PxPhysicsAPI.h (which includes all of the public API surface with a few exceptions we manually account for -- The UnusedFiles.txt report can be used to find new exceptions as needed.) * We no longer attempt to index the "intrinsics" files from any platform. * Added build.cmd/build.sh for automatically configuring+building PhysX and regenerating the bindings * Moved bin/obj folders to a central location at the repository root * Added property for querying the build info (IE: PhysX SDK version, build variant) of the native runtime. * The native PhysX bits are now built down into a single Mochi.PhysX.Native.dll/libMochi.PhysX.Native.so without intrusive modifications to the PhysX build system. Fixes #1 Fixes #4
1 parent f1f62a4 commit 6b17fec

File tree

476 files changed

+8681
-10222
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

476 files changed

+8681
-10222
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Don't attempt end of line normalization on shell scripts
2+
*.sh -text

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
bin/
33
obj/
44
build/
5+
build-*/

Directory.Build.props

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
<Project>
2+
<Import Project="tooling/Common.props" />
23
<Import Project="tooling/Common$(MSBuildProjectExtension).props" Condition="Exists('tooling/Common$(MSBuildProjectExtension).props')"/>
34
</Project>

Directory.Build.rsp

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# This file intentionally left blank.

Directory.Build.targets

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<Project>
2+
<Import Project="tooling/Common.targets" />
3+
<Import Project="tooling/Common$(MSBuildProjectExtension).targets" Condition="Exists('tooling/Common$(MSBuildProjectExtension).targets')" />
4+
</Project>

InfectedPhysX.Generator.sln

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.30615.102
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31815.197
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InfectedPhysX.Generator", "InfectedPhysX.Generator\InfectedPhysX.Generator.csproj", "{AF77B04B-4E36-4EC6-A14C-4A1EF0ED89AA}"
77
EndProject
@@ -16,6 +16,8 @@ EndProject
1616
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tooling", "tooling", "{7021CC28-21DE-4B99-87B1-D1A4FBB74D90}"
1717
ProjectSection(SolutionItems) = preProject
1818
tooling\Common.csproj.props = tooling\Common.csproj.props
19+
tooling\Common.props = tooling\Common.props
20+
tooling\Common.targets = tooling\Common.targets
1921
EndProjectSection
2022
EndProject
2123
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Biohazrd", "external\Biohazrd\Biohazrd\Biohazrd.csproj", "{8BEE1482-5CFB-422D-9500-8A12D1500D11}"
@@ -26,7 +28,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Biohazrd.OutputGeneration",
2628
EndProject
2729
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Biohazrd.CSharp", "external\Biohazrd\Biohazrd.CSharp\Biohazrd.CSharp.csproj", "{C42C433C-EF83-4FAA-AABE-7B3B783313EA}"
2830
EndProject
29-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Biohazrd.Utilities", "external\Biohazrd\Biohazrd.Utilities\Biohazrd.Utilities.csproj", "{E07422E3-877A-4B42-9EA3-D2B5A5406144}"
31+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Biohazrd.Utilities", "external\Biohazrd\Biohazrd.Utilities\Biohazrd.Utilities.csproj", "{E07422E3-877A-4B42-9EA3-D2B5A5406144}"
3032
EndProject
3133
Global
3234
GlobalSection(SolutionConfigurationPlatforms) = preSolution

InfectedPhysX.Generator/#Transformations/PhysXNamespaceFixupTransformation.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,29 @@ public sealed class PhysXNamespaceFixupTransformation : TransformationBase
1111
protected override TransformationResult TransformDeclaration(TransformationContext context, TranslatedDeclaration declaration)
1212
{
1313
const string badCasing = "physx";
14-
const string goodCasing = "PhysX";
14+
const string mochiNamespace = "Mochi.PhysX";
1515

1616
string? newNamespace;
1717

1818
// Put Biohazrd infrastructure types in their own namespace
1919
if (declaration is ConstantArrayTypeDeclaration or NativeBooleanDeclaration or NativeCharDeclaration)
2020
{
2121
Debug.Assert(declaration.Namespace is null);
22-
newNamespace = $"{goodCasing}.Infrastructure";
22+
newNamespace = $"{mochiNamespace}.Infrastructure";
2323
}
2424
else
2525
{
2626
newNamespace = declaration.Namespace switch
2727
{
2828
// PhysX has a lot of global functions in the global namespace for some reason, move them into the PhysX namespace
29-
null => goodCasing,
29+
null => mochiNamespace,
3030
// This is a weird internal detail of how PhysX structures things, a `using namespace` is added for it so you don't normally see it when using it.
31-
"physx.general_PxIOStream2" => goodCasing,
31+
"physx.general_PxIOStream2" => mochiNamespace,
3232

33-
"physx.intrinsics" => $"{goodCasing}.Intrinsics",
34-
"physx.pvdsdk" => $"{goodCasing}.PvdSdk",
35-
"physx.immediate" => $"{goodCasing}.Immediate",
36-
_ => declaration.Namespace.StartsWith(badCasing, StringComparison.Ordinal) ? $"{goodCasing}{declaration.Namespace.Substring(badCasing.Length)}" : declaration.Namespace
33+
"physx.intrinsics" => $"{mochiNamespace}.Intrinsics",
34+
"physx.pvdsdk" => $"{mochiNamespace}.PvdSdk",
35+
"physx.immediate" => $"{mochiNamespace}.Immediate",
36+
_ => declaration.Namespace.StartsWith(badCasing, StringComparison.Ordinal) ? $"{mochiNamespace}{declaration.Namespace.Substring(badCasing.Length)}" : declaration.Namespace
3737
};
3838
}
3939

InfectedPhysX.Generator/#Transformations/PhysxFlagsEnumTransformation.cs

+19-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Biohazrd;
22
using Biohazrd.Transformation;
33
using ClangSharp;
4+
using ClangSharp.Interop;
45
using System.Collections.Generic;
56
using System.Collections.Immutable;
67
using System.Diagnostics;
@@ -44,7 +45,7 @@ protected override TranslatedLibrary PreTransformLibrary(TranslatedLibrary libra
4445
// Get the declaration
4546
if (library.FindClangCursor(templateSpecialization.Handle.Declaration) is not ClassTemplateSpecializationDecl templateSpecializationDeclaration)
4647
{
47-
Debug.Assert(false, "The declaration for a TemplateSpecializationType is expected to be a ClassTemplateSpecializationDecl.");
48+
Debug.Fail("The declaration for a TemplateSpecializationType is expected to be a ClassTemplateSpecializationDecl.");
4849
continue;
4950
}
5051

@@ -55,21 +56,33 @@ protected override TranslatedLibrary PreTransformLibrary(TranslatedLibrary libra
5556
// We expect there to be two template arguments: PxFlags<enumtype, storagetype>
5657
if (templateSpecializationDeclaration.TemplateArgs.Count != 2)
5758
{
58-
Debug.Assert(false, "PxFlags should always have two template arguments.");
59+
Debug.Fail("PxFlags should always have two template arguments.");
5960
continue;
6061
}
6162

6263
// Extract the arguments
63-
ClangType enumArgument = templateSpecializationDeclaration.TemplateArgs[0];
64-
ClangType storageType = templateSpecializationDeclaration.TemplateArgs[1];
64+
TemplateArgument enumArgument = templateSpecializationDeclaration.TemplateArgs[0];
65+
TemplateArgument storageType = templateSpecializationDeclaration.TemplateArgs[1];
66+
67+
if (enumArgument.Kind != CXTemplateArgumentKind.CXTemplateArgumentKind_Type)
68+
{
69+
Debug.Fail("The first template argument to PxFlags should be a type argument");
70+
continue;
71+
}
72+
73+
if (storageType.Kind != CXTemplateArgumentKind.CXTemplateArgumentKind_Type)
74+
{
75+
Debug.Fail("The second template argument to PxFlags should be a type argument");
76+
continue;
77+
}
6578

6679
// The first argument should be an EnumType with a corresponding EnumDecl
67-
if (enumArgument is not EnumType { Decl: EnumDecl enumDecl })
80+
if (enumArgument.AsType is not EnumType { Decl: EnumDecl enumDecl })
6881
{ continue; }
6982

7083
// Record the relevant info needed to perform the transformation
7184
FlagsTypedefs.Add(typedef);
72-
FlagsEnums.Add(enumDecl, (typedef, storageType));
85+
FlagsEnums.Add(enumDecl, (typedef, storageType.AsType));
7386
FlagsCanonicalTypes.Add(templateSpecialization.CanonicalType); //TODO: Is this the same for all PxFlags?
7487
}
7588

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using Biohazrd;
2+
using Biohazrd.Transformation;
3+
4+
namespace InfectedPhysX.Generator
5+
{
6+
internal sealed class __StripPrivateAndProtectedMembersTransformation : TransformationBase
7+
{
8+
protected override TransformationResult TransformFunction(TransformationContext context, TranslatedFunction declaration)
9+
{
10+
// Private/protected functions are always stripped
11+
if (declaration.Accessibility is AccessModifier.Private or AccessModifier.Protected)
12+
{ return null; }
13+
14+
// Check if any parents are private/protected
15+
foreach (TranslatedDeclaration parent in context.Parents)
16+
{
17+
if (parent.Accessibility is AccessModifier.Private or AccessModifier.Protected)
18+
{ return null; }
19+
}
20+
21+
return base.TransformFunction(context, declaration);
22+
}
23+
24+
protected override TransformationResult TransformRecord(TransformationContext context, TranslatedRecord declaration)
25+
{
26+
// Private/protected records are always stripped
27+
if (declaration.Accessibility is AccessModifier.Private or AccessModifier.Protected)
28+
{ return null; }
29+
30+
return base.TransformRecord(context, declaration);
31+
}
32+
33+
protected override TransformationResult TransformUndefinedRecord(TransformationContext context, TranslatedUndefinedRecord declaration)
34+
{
35+
// Private/protected records are always stripped
36+
if (declaration.Accessibility is AccessModifier.Private or AccessModifier.Protected)
37+
{ return null; }
38+
39+
return base.TransformUndefinedRecord(context, declaration);
40+
}
41+
}
42+
}

0 commit comments

Comments
 (0)