Update PhysX building for consoles

This commit is contained in:
Wojtek Figat
2023-03-06 17:39:18 +01:00
parent 7fce25a2e4
commit b7d4758dde
33 changed files with 85 additions and 36 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -104,6 +104,7 @@ public class PhysX : DepsModule
if (useVehicle) if (useVehicle)
{ {
AddLib(options, depsRoot, string.Format("PhysXVehicle_static{0}", archPostFix)); AddLib(options, depsRoot, string.Format("PhysXVehicle_static{0}", archPostFix));
//AddLib(options, depsRoot, string.Format("PhysXVehicle2_static{0}", archPostFix));
} }
} }
} }

View File

@@ -33,7 +33,7 @@
#if PX_WINDOWS_FAMILY #if PX_WINDOWS_FAMILY
#include "foundation/windows/PxWindowsMathIntrinsics.h" #include "foundation/windows/PxWindowsMathIntrinsics.h"
#elif(PX_LINUX || PX_ANDROID || PX_APPLE_FAMILY) #elif (PX_LINUX || PX_ANDROID || PX_PS4 || PX_PS5 || PX_APPLE_FAMILY)
#include "foundation/unix/PxUnixMathIntrinsics.h" #include "foundation/unix/PxUnixMathIntrinsics.h"
#elif PX_SWITCH #elif PX_SWITCH
#include "foundation/switch/PxSwitchMathIntrinsics.h" #include "foundation/switch/PxSwitchMathIntrinsics.h"

View File

@@ -455,7 +455,7 @@ General defines
// check that exactly one of NDEBUG and _DEBUG is defined // check that exactly one of NDEBUG and _DEBUG is defined
#if !defined(NDEBUG) ^ defined(_DEBUG) #if !defined(NDEBUG) ^ defined(_DEBUG)
#error Exactly one of NDEBUG and _DEBUG needs to be defined! #undef _DEBUG
#endif #endif
// make sure PX_CHECKED is defined in all _DEBUG configurations as well // make sure PX_CHECKED is defined in all _DEBUG configurations as well

View File

@@ -32,7 +32,7 @@
#include "foundation/Px.h" #include "foundation/Px.h"
#include "foundation/PxAssert.h" #include "foundation/PxAssert.h"
#if !(PX_LINUX || PX_ANDROID || PX_APPLE_FAMILY) #if !(PX_LINUX || PX_ANDROID || PX_PS4 || PX_PS5 || PX_APPLE_FAMILY)
#error "This file should only be included by Unix builds!!" #error "This file should only be included by Unix builds!!"
#endif #endif

View File

@@ -230,9 +230,11 @@ namespace Flax.Deploy
/// <param name="buildConfig">Configuration to build.</param> /// <param name="buildConfig">Configuration to build.</param>
/// <param name="buildPlatform">Platform to build.</param> /// <param name="buildPlatform">Platform to build.</param>
/// <param name="props">Custom build properties mapping (property=value).</param> /// <param name="props">Custom build properties mapping (property=value).</param>
public static void BuildSolution(string solutionFile, string buildConfig, string buildPlatform, Dictionary<string, string> props = null) /// <param name="msBuild">Custom MSBuild executable path.</param>
public static void BuildSolution(string solutionFile, string buildConfig, string buildPlatform, Dictionary<string, string> props = null, string msBuild = null)
{ {
var msBuild = MSBuildPath; if (msBuild == null)
msBuild = MSBuildPath;
if (string.IsNullOrEmpty(msBuild)) if (string.IsNullOrEmpty(msBuild))
{ {
throw new Exception(string.Format("Unable to find msbuild.exe at: \"{0}\"", msBuild)); throw new Exception(string.Format("Unable to find msbuild.exe at: \"{0}\"", msBuild));

View File

@@ -7,6 +7,7 @@ using System.Linq;
using System.Xml; using System.Xml;
using Flax.Build; using Flax.Build;
using Flax.Build.Platforms; using Flax.Build.Platforms;
using Flax.Build.Projects.VisualStudio;
using Flax.Deploy; using Flax.Deploy;
namespace Flax.Deps.Dependencies namespace Flax.Deps.Dependencies
@@ -134,7 +135,6 @@ namespace Flax.Deps.Dependencies
break; break;
default: throw new InvalidArchitectureException(architecture); default: throw new InvalidArchitectureException(architecture);
} }
switch (architecture) switch (architecture)
{ {
case TargetArchitecture.x86: case TargetArchitecture.x86:
@@ -144,7 +144,7 @@ namespace Flax.Deps.Dependencies
buildPlatform = architecture.ToString(); buildPlatform = architecture.ToString();
break; break;
} }
var msBuildProps = new Dictionary<string, string>();
switch (targetPlatform) switch (targetPlatform)
{ {
case TargetPlatform.Windows: case TargetPlatform.Windows:
@@ -185,6 +185,8 @@ namespace Flax.Deps.Dependencies
buildPlatform = "NX64"; buildPlatform = "NX64";
suppressBitsPostfix = true; suppressBitsPostfix = true;
binariesPrefix = "lib"; binariesPrefix = "lib";
envVars.Add("NintendoSdkRoot", Sdk.Get("SwitchSdk").RootPath + '\\');
msBuildProps.Add("NintendoSdkRoot", envVars["NintendoSdkRoot"]);
break; break;
case TargetPlatform.Mac: case TargetPlatform.Mac:
switch (architecture) switch (architecture)
@@ -205,11 +207,44 @@ namespace Flax.Deps.Dependencies
} }
// Setup build environment variables for PhysX build system // Setup build environment variables for PhysX build system
string msBuild = null;
switch (BuildPlatform) switch (BuildPlatform)
{ {
case TargetPlatform.Windows: case TargetPlatform.Windows:
{ {
var msBuild = VCEnvironment.MSBuildPath; msBuild = VCEnvironment.MSBuildPath;
// Some consoles don't support the latest Visual Studio 2022
var vsVersion = VisualStudioVersion.VisualStudio2022;
switch (targetPlatform)
{
case TargetPlatform.PS4:
vsVersion = VisualStudioVersion.VisualStudio2017;
break;
case TargetPlatform.PS5:
case TargetPlatform.Switch:
vsVersion = VisualStudioVersion.VisualStudio2019;
break;
}
if (vsVersion != VisualStudioVersion.VisualStudio2022)
{
// TODO: override VS version in cmake_generate_projects.py too
var visualStudioInstances = VisualStudioInstance.GetInstances();
foreach (var visualStudioInstance in visualStudioInstances)
{
if (visualStudioInstance.Version <= vsVersion)
{
var toolPath = Path.Combine(visualStudioInstance.Path, "MSBuild\\Current\\Bin\\MSBuild.exe");
if (!File.Exists(toolPath))
toolPath = Path.Combine(visualStudioInstance.Path, "MSBuild\\15.0\\Bin\\MSBuild.exe");
if (File.Exists(toolPath))
{
msBuild = toolPath;
break;
}
}
}
}
if (File.Exists(msBuild)) if (File.Exists(msBuild))
{ {
envVars.Add("PATH", Path.GetDirectoryName(msBuild)); envVars.Add("PATH", Path.GetDirectoryName(msBuild));
@@ -233,13 +268,14 @@ namespace Flax.Deps.Dependencies
Log.Info("Building PhysX version " + File.ReadAllText(Path.Combine(root, "physx", "version.txt")) + " to " + binariesSubDir); Log.Info("Building PhysX version " + File.ReadAllText(Path.Combine(root, "physx", "version.txt")) + " to " + binariesSubDir);
// Generate project files // Generate project files
Utilities.Run(projectGenPath, preset, null, projectGenDir, Utilities.RunOptions.Default, envVars); Utilities.Run(projectGenPath, preset, null, projectGenDir, Utilities.RunOptions.ThrowExceptionOnError, envVars);
switch (targetPlatform) switch (targetPlatform)
{ {
case TargetPlatform.PS4: case TargetPlatform.PS4:
case TargetPlatform.PS5: case TargetPlatform.PS5:
// Hack: PS4 uses .o extension for compiler output files but CMake uses .obj even if CMAKE_CXX_OUTPUT_EXTENSION/CMAKE_C_OUTPUT_EXTENSION are specified case TargetPlatform.Switch:
// Hack: Platform compiler uses .o extension for compiler output files but CMake uses .obj even if CMAKE_CXX_OUTPUT_EXTENSION/CMAKE_C_OUTPUT_EXTENSION are specified
Utilities.ReplaceInFiles(Path.Combine(root, "physx\\compiler\\" + binariesSubDir), "*.vcxproj", SearchOption.AllDirectories, ".obj", ".o"); Utilities.ReplaceInFiles(Path.Combine(root, "physx\\compiler\\" + binariesSubDir), "*.vcxproj", SearchOption.AllDirectories, ".obj", ".o");
break; break;
case TargetPlatform.XboxOne: case TargetPlatform.XboxOne:
@@ -260,6 +296,7 @@ namespace Flax.Deps.Dependencies
"PhysXFoundation", "PhysXFoundation",
"PhysXPvdSDK", "PhysXPvdSDK",
"PhysXVehicle", "PhysXVehicle",
"PhysXVehicle2",
}; };
var dstBinaries = GetThirdPartyFolder(options, targetPlatform, architecture); var dstBinaries = GetThirdPartyFolder(options, targetPlatform, architecture);
var srcBinaries = Path.Combine(root, "physx", "bin", binariesSubDir, configuration); var srcBinaries = Path.Combine(root, "physx", "bin", binariesSubDir, configuration);
@@ -269,10 +306,10 @@ namespace Flax.Deps.Dependencies
switch (targetPlatform) switch (targetPlatform)
{ {
case TargetPlatform.Android: case TargetPlatform.Android:
Utilities.Run("cmake", "--build .", null, Path.Combine(root, "physx\\compiler\\android-release"), Utilities.RunOptions.None, envVars); Utilities.Run("cmake", "--build .", null, Path.Combine(root, "physx\\compiler\\android-" + configuration), Utilities.RunOptions.None, envVars);
break; break;
default: default:
VCEnvironment.BuildSolution(Path.Combine(solutionFilesRoot, preset, "PhysXSDK.sln"), configuration, buildPlatform); VCEnvironment.BuildSolution(Path.Combine(solutionFilesRoot, preset, "PhysXSDK.sln"), configuration, buildPlatform, msBuildProps, msBuild);
break; break;
} }
break; break;