Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify CMakeModules package Packman downloads to include Android, iOS and Mac platforms #59

Closed
moraaar opened this issue Dec 13, 2022 · 3 comments

Comments

@moraaar
Copy link

moraaar commented Dec 13, 2022

The name of the bin folders will be incorrect when building for Android, iOS and Mac-arm64.

To fix this nVidia has to modify the CMakeModules package it's downloaded from packman when building PhysX, since it's not part of the Github repo.

The file that needs to be modified is GetCompilerAndPlatform.cmake, changing the if condition inside GetPlatformBinName function to this:

	ELSEIF(TARGET_BUILD_PLATFORM STREQUAL "mac")
		IF(${PX_OUTPUT_ARCH} STREQUAL "x86")
			SET(RETVAL "mac.x86_${LIBPATH_SUFFIX}")
		ELSEIF(${PX_OUTPUT_ARCH} STREQUAL "arm")
			SET(RETVAL "mac.arm64")
		ENDIF()
	ELSEIF(TARGET_BUILD_PLATFORM STREQUAL "ios")
		SET(RETVAL "ios.arm_${LIBPATH_SUFFIX}")
	ELSEIF(TARGET_BUILD_PLATFORM STREQUAL "android")
		SET(RETVAL "android.${ANDROID_ABI}")

This code modification was tested locally on these PRs: #40 #49 #51

moraaar added a commit to o3de/PhysX that referenced this issue Dec 21, 2022
## What's new?
- Added Android platform support to PhysX 5.1.
- New build preset `android-arm64-v8a` added. Initial support focused on 64-bit arm8 architecture with NEON SIMD instructions.
- Support for generating PhysX as either static or dynamic libraries.
- New android platform readme.
        
## Out of Scope
The following points are considered out of scope, they can be added in the future:
- Support for PhysX Snippets.
- Support for Omniverse Visual Debugger (OmniPVD) .
- Support for other architectures: arm7, x86, x86_64.
- Support for other SIMD instructions set: SSE.
        
## Known Errors/Limitations
- The name of the bin folder for android will appear as `bin\UNKNOWN`. **To fix this nVidia has to modify the CMakeModules package it's downloaded from packman when building PhysX** (NVIDIA-Omniverse#59). The file that needs to be modified is `GetCompilerAndPlatform.cmake`, adding the following lines to the `if` condition inside `GetPlatformBinName` function:
````
	ELSEIF(TARGET_BUILD_PLATFORM STREQUAL "android")
		SET(RETVAL "android.${ANDROID_ABI}")
````
- PhysX Systems that require a CUDA capable GPU are not supported in Android, for example particle system or cloth simulation.
            
## Testing
- Built PhysX 5.1 successfully on android in debug, checked, profile and release using `PX_GENERATE_STATIC_LIBRARIES` set to both true and false. The right output binaries were generated in `bin/android.arm64-v8a`
- Built cmake `install` target successfully. It generated the correct output for Android under `install/android-29` folder, only including necessary headers for Android.
- Runtime tested using `Open 3D Engine (O3DE)` with an early integration [branch](https://github.com/aws-lumberyard-dev/o3de/tree/PhysX5Support). The following video shows O3DE running PhysX 5.1 on Android.
https://user-images.githubusercontent.com/27999040/203624867-6ed19905-d0dc-4dfe-943a-46e584fd9983.mp4

Signed-off-by: moraaar <moraaar@amazon.com>
moraaar added a commit to o3de/PhysX that referenced this issue Dec 21, 2022
## What's new?
- Added iOS platform support to PhysX 5.1.
- New build preset `ios64` added. Initial support focused on 64-bit arm8 architecture with NEON SIMD instructions.
- Support for generating PhysX as either static libraries or iOS frameworks.
- New iOS platform readme.
        
## Out of Scope
The following points are considered out of scope, they can be added in the future:
- Support for PhysX Snippets.
- Support for Omniverse Visual Debugger (OmniPVD) .
- Support for other architectures: 32-bit arm7
        
## Known Errors/Limitations
- The name of the bin folder for iOS will appear as `bin\UNKNOWN`. **To fix this nVidia has to modify the CMakeModules package it's downloaded from packman when building PhysX** (NVIDIA-Omniverse#59). The file that needs to be modified is `GetCompilerAndPlatform.cmake`, adding the following lines to the `if` condition inside `GetPlatformBinName` function:
````
	ELSEIF(TARGET_BUILD_PLATFORM STREQUAL "ios")
		SET(RETVAL "ios.arm_${LIBPATH_SUFFIX}")
````
- Python package used by packman is based on x86_64 architecture and generates the error `dyld[number]: missing symbol called` when run on an arm-based Mac. **To fix this nVidia has to add an ARM python package for mac into the packman scripts** (NVIDIA-Omniverse#60). As a temporary solution, use your system's python adding the environment variable `PM_PYTHON_EXT` before building (for example by adding `export PM_PYTHON_EXT="python3"` into your `.bash_profile` file).
- PhysX Systems that require a CUDA capable GPU are not supported in iOS, for example particle system or cloth simulation.
            
## Testing
- Built PhysX 5.1 successfully on iOS in debug, checked, profile and release using `PX_GENERATE_STATIC_LIBRARIES` set to both true and false. The right output binaries were generated in `bin/ios.arm_64`
- Built cmake `install` target successfully. It generated the correct output for iOS under `install/ios64` folder, only including necessary headers for iOS.
- Runtime tested using `Open 3D Engine (O3DE)` with an early integration [branch](https://github.com/aws-lumberyard-dev/o3de/tree/PhysX5Support). The following video shows O3DE running PhysX 5.1 on iOS.
https://user-images.githubusercontent.com/27999040/204574141-2e00c7bf-86b5-4e14-981f-6b80665a3ef7.mp4

Signed-off-by: moraaar <moraaar@amazon.com>
moraaar added a commit to o3de/PhysX that referenced this issue Dec 21, 2022
## What's new?
- Added Mac platform support to PhysX 5.1.
- New build preset `mac64` added. It supports 64-bit x86_64 architecture with SSE2 SIMD instructions.
- New build preset `mac-arm64` added. It supports 64-bit arm architecture with NEON SIMD instructions.
- Support for generating PhysX as either static or dynamic libraries.
- New Mac platform readme.
        
## Out of Scope
The following points are considered out of scope, they can be added in the future:
- Support for PhysX Snippets.
- Support for Omniverse Visual Debugger (OmniPVD) .
- Support for other architectures: 32-bit x86
        
## Known Errors/Limitations
- The name of the bin folder for mac-arm64 will appear as `bin\mac.x86_64`. **To fix this nVidia has to modify the CMakeModules package it's downloaded from packman when building PhysX** (NVIDIA-Omniverse#59). The file that needs to be modified is `GetCompilerAndPlatform.cmake`, modifying the mac lines of the `if` condition inside `GetPlatformBinName` function to this:
````
	ELSEIF(TARGET_BUILD_PLATFORM STREQUAL "mac")
		IF(${PX_OUTPUT_ARCH} STREQUAL "x86")
			SET(RETVAL "mac.x86_${LIBPATH_SUFFIX}")
		ELSEIF(${PX_OUTPUT_ARCH} STREQUAL "arm")
			SET(RETVAL "mac.arm64")
		ENDIF()
````
- Python package used by packman is based on x86_64 architecture and generates the error `dyld[number]: missing symbol called` when run on an arm-based Mac. **To fix this nVidia has to add an ARM python package for mac into the packman scripts** (NVIDIA-Omniverse#60). As a temporary solution, use your system's python adding the environment variable `PM_PYTHON_EXT` before building (for example by adding `export PM_PYTHON_EXT="python3"` into your `.bash_profile` file).
- PhysX Systems that require a CUDA capable GPU are not supported in Mac, for example particle system or cloth simulation.
            
## Testing
- Built PhysX 5.1 successfully on mac64 in debug, checked, profile and release using `PX_GENERATE_STATIC_LIBRARIES` set to both true and false. The right output binaries were generated in `bin/mac.x86_64`
- Built PhysX 5.1 successfully on mac-arm64 in debug, checked, profile and release using `PX_GENERATE_STATIC_LIBRARIES` set to both true and false. The right output binaries were generated in `bin/mac.arm64`
- Built cmake `install` target successfully. It generated the correct output for Mac under `install/mac64` and `install/mac-arm64` folders, only including necessary headers for Mac.
- Runtime tested using `Open 3D Engine (O3DE)` with an early integration [branch](https://github.com/aws-lumberyard-dev/o3de/tree/PhysX5Support). The following video shows O3DE running PhysX 5.1 on mac64. 
https://user-images.githubusercontent.com/27999040/204763960-7fe2763e-c3b1-4c73-a6fb-ad3357ef02d3.mov

Signed-off-by: moraaar <moraaar@amazon.com>
@MarkaRagnos0815
Copy link

how is the status here. It would be nice to have this functionality

@preist-nvidia
Copy link
Collaborator

@moraaar - @ayoub-belarbi removed the cmake modules dep with 5.2.1 and they are now included into the repo: https://github.com/NVIDIA-Omniverse/PhysX/tree/main/physx/source/compiler/cmake/modules

@ayoub-belarbi
Copy link
Collaborator

As @preist-nvidia mentioned. The modules are no longer an external Packman dependency. Feel free to fork/modify as you wish.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants