|
@@ -13,6 +13,7 @@ import os
|
|
import re
|
|
import re
|
|
import pathlib
|
|
import pathlib
|
|
from pathlib import Path
|
|
from pathlib import Path
|
|
|
|
+import platform
|
|
import shutil
|
|
import shutil
|
|
import subprocess
|
|
import subprocess
|
|
from tempfile import TemporaryDirectory
|
|
from tempfile import TemporaryDirectory
|
|
@@ -26,6 +27,7 @@ class PhysXBuilder(object):
|
|
self._workingDir = workingDir
|
|
self._workingDir = workingDir
|
|
self._packageSystemDir = basePackageSystemDir
|
|
self._packageSystemDir = basePackageSystemDir
|
|
self._platform = targetPlatform
|
|
self._platform = targetPlatform
|
|
|
|
+ self._hostPlatformLower = platform.system().lower()
|
|
self._env = dict(os.environ)
|
|
self._env = dict(os.environ)
|
|
self._env.update(
|
|
self._env.update(
|
|
GW_DEPS_ROOT=str(workingDir),
|
|
GW_DEPS_ROOT=str(workingDir),
|
|
@@ -90,6 +92,11 @@ class PhysXBuilder(object):
|
|
self.check_call(
|
|
self.check_call(
|
|
['git', 'checkout', lockToCommit,],
|
|
['git', 'checkout', lockToCommit,],
|
|
)
|
|
)
|
|
|
|
+ if self.platform in ['ios', 'mac']:
|
|
|
|
+ self.check_call(
|
|
|
|
+ ['git', 'apply', '--whitespace=fix', (pathlib.Path(__file__).parent / 'build_fix.patch').absolute()]
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
|
|
def preparePreset(self, buildAsStaticLibs, config):
|
|
def preparePreset(self, buildAsStaticLibs, config):
|
|
preset_index = 0
|
|
preset_index = 0
|
|
@@ -109,7 +116,7 @@ class PhysXBuilder(object):
|
|
elif self.platform == 'linux' or self.platform == 'linux-aarch64':
|
|
elif self.platform == 'linux' or self.platform == 'linux-aarch64':
|
|
content = re.sub('name="PX_BUILDSNIPPETS" value="(True|False)"', f'name="PX_BUILDSNIPPETS" value="False"', content, flags = re.M)
|
|
content = re.sub('name="PX_BUILDSNIPPETS" value="(True|False)"', f'name="PX_BUILDSNIPPETS" value="False"', content, flags = re.M)
|
|
content = re.sub('name="PX_BUILDPVDRUNTIME" value="(True|False)"', f'name="PX_BUILDPVDRUNTIME" value="False"', content, flags = re.M)
|
|
content = re.sub('name="PX_BUILDPVDRUNTIME" value="(True|False)"', f'name="PX_BUILDPVDRUNTIME" value="False"', content, flags = re.M)
|
|
-
|
|
|
|
|
|
+
|
|
self.writeFile(preset_file, content)
|
|
self.writeFile(preset_file, content)
|
|
|
|
|
|
# Ignore poison-system-directories warning when building mac/ios caused
|
|
# Ignore poison-system-directories warning when building mac/ios caused
|
|
@@ -124,35 +131,55 @@ class PhysXBuilder(object):
|
|
static_bin_dir = self.workingDir / 'physx' / 'bin' / 'static'
|
|
static_bin_dir = self.workingDir / 'physx' / 'bin' / 'static'
|
|
shared_bin_dir = self.workingDir / 'physx' / 'bin' / 'shared'
|
|
shared_bin_dir = self.workingDir / 'physx' / 'bin' / 'shared'
|
|
|
|
|
|
- # Remove dynamic libraries repeated in static folders to save space.
|
|
|
|
- # Also freeglut is not necessary for PhysX.
|
|
|
|
|
|
+ # Remove dynamic libraries, but copy some missing static libs from
|
|
|
|
+ # the shared builds into the static lib folder. Also freeglut is not
|
|
|
|
+ # necessary for PhysX.
|
|
if self.platform == 'windows':
|
|
if self.platform == 'windows':
|
|
- if buildAsStaticLibs:
|
|
|
|
|
|
+ if not buildAsStaticLibs:
|
|
|
|
+
|
|
|
|
+ for extra_static_lib_filename in ['LowLevel_static_64',
|
|
|
|
+ 'LowLevelAABB_static_64',
|
|
|
|
+ 'LowLevelDynamics_static_64',
|
|
|
|
+ 'PhysXTask_static_64',
|
|
|
|
+ 'SceneQuery_static_64',
|
|
|
|
+ 'SimulationController_static_64']:
|
|
|
|
+
|
|
|
|
+ for extra_static_lib_ext in ['.lib', '.pdb']:
|
|
|
|
+
|
|
|
|
+ for config in ('release', 'profile', 'checked', 'debug'):
|
|
|
|
+
|
|
|
|
+ src_extra_static_lib = shared_bin_dir / config / f'{extra_static_lib_filename}{extra_static_lib_ext}'
|
|
|
|
+ dst_extra_static_lib = static_bin_dir / config / f'{extra_static_lib_filename}{extra_static_lib_ext}'
|
|
|
|
+ print(f"Copying {src_extra_static_lib} -> {dst_extra_static_lib}")
|
|
|
|
+ shutil.copy2(src=src_extra_static_lib, dst=dst_extra_static_lib)
|
|
|
|
+
|
|
for config in ('release', 'profile', 'checked', 'debug'):
|
|
for config in ('release', 'profile', 'checked', 'debug'):
|
|
- os.remove(static_bin_dir / config / 'PhysXDevice64.dll')
|
|
|
|
- os.remove(static_bin_dir / config / 'PhysXGpu_64.dll')
|
|
|
|
if config == 'debug':
|
|
if config == 'debug':
|
|
os.remove(static_bin_dir / config / 'freeglutd.dll')
|
|
os.remove(static_bin_dir / config / 'freeglutd.dll')
|
|
else:
|
|
else:
|
|
os.remove(static_bin_dir / config / 'freeglut.dll')
|
|
os.remove(static_bin_dir / config / 'freeglut.dll')
|
|
- else:
|
|
|
|
- for config in ('release', 'profile', 'checked', 'debug'):
|
|
|
|
- if config == 'debug':
|
|
|
|
- os.remove(shared_bin_dir / config / 'freeglutd.dll')
|
|
|
|
- else:
|
|
|
|
- os.remove(shared_bin_dir / config / 'freeglut.dll')
|
|
|
|
-
|
|
|
|
- elif self.platform == 'linux' or self.platform == 'linux-aarch64':
|
|
|
|
- if buildAsStaticLibs:
|
|
|
|
- for config in ('release', 'profile', 'checked', 'debug'):
|
|
|
|
- os.remove(static_bin_dir / config / 'libPhysXGpu_64.so')
|
|
|
|
|
|
+
|
|
|
|
+ shutil.rmtree(shared_bin_dir)
|
|
|
|
|
|
def build(self, buildAsStaticLibs):
|
|
def build(self, buildAsStaticLibs):
|
|
physx_dir = self.workingDir / 'physx'
|
|
physx_dir = self.workingDir / 'physx'
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ # Update the packman URLs
|
|
|
|
+ packman_dir = physx_dir / 'buildtools' / 'packman'
|
|
|
|
+ check_call_packman_update = functools.partial(subprocess.check_call,
|
|
|
|
+ cwd=packman_dir, # generate_projects script will fail if not called from physx directory
|
|
|
|
+ env=self.env
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ if self._hostPlatformLower == 'windows':
|
|
|
|
+ update_pacman_call = [ str(packman_dir / 'packman.cmd'), 'update', '-y']
|
|
|
|
+ else:
|
|
|
|
+ update_pacman_call = [ str(packman_dir / 'packman'), 'update', '-y']
|
|
|
|
+
|
|
|
|
+ check_call_packman_update(update_pacman_call)
|
|
preset, bin_folder, install_folder, is_multiconfig = self.platform_params[self.platform]
|
|
preset, bin_folder, install_folder, is_multiconfig = self.platform_params[self.platform]
|
|
|
|
|
|
- if self.platform == 'windows' or self.platform == 'android':
|
|
|
|
|
|
+ if self._hostPlatformLower == 'windows':
|
|
generate_projects_cmd = str(physx_dir / 'generate_projects.bat')
|
|
generate_projects_cmd = str(physx_dir / 'generate_projects.bat')
|
|
else:
|
|
else:
|
|
generate_projects_cmd = str(physx_dir / 'generate_projects.sh')
|
|
generate_projects_cmd = str(physx_dir / 'generate_projects.sh')
|
|
@@ -203,20 +230,23 @@ class PhysXBuilder(object):
|
|
|
|
|
|
self.cleanUpLibs(buildAsStaticLibs)
|
|
self.cleanUpLibs(buildAsStaticLibs)
|
|
|
|
|
|
|
|
+ def build_all(self):
|
|
|
|
+
|
|
|
|
+ self.build(buildAsStaticLibs=True)
|
|
|
|
+
|
|
|
|
+ if self.platform == 'windows':
|
|
|
|
+ self.build(buildAsStaticLibs=False)
|
|
|
|
+
|
|
def copyBuildOutputTo(self, packageDir: pathlib.Path):
|
|
def copyBuildOutputTo(self, packageDir: pathlib.Path):
|
|
if packageDir.exists():
|
|
if packageDir.exists():
|
|
shutil.rmtree(packageDir)
|
|
shutil.rmtree(packageDir)
|
|
|
|
|
|
|
|
+
|
|
shutil.copytree(
|
|
shutil.copytree(
|
|
- src=self.workingDir / 'physx' / 'install' / 'shared' / 'PhysX',
|
|
|
|
|
|
+ src=self.workingDir / 'physx' / 'install' / 'static' / 'PhysX',
|
|
dst=packageDir / 'physx',
|
|
dst=packageDir / 'physx',
|
|
symlinks=True,
|
|
symlinks=True,
|
|
)
|
|
)
|
|
- shutil.copytree(
|
|
|
|
- src=self.workingDir / 'physx' / 'bin' / 'shared',
|
|
|
|
- dst=packageDir / 'physx' / 'bin' / 'shared',
|
|
|
|
- symlinks=True,
|
|
|
|
- )
|
|
|
|
shutil.copytree(
|
|
shutil.copytree(
|
|
src=self.workingDir / 'physx' / 'bin' / 'static',
|
|
src=self.workingDir / 'physx' / 'bin' / 'static',
|
|
dst=packageDir / 'physx' / 'bin' / 'static',
|
|
dst=packageDir / 'physx' / 'bin' / 'static',
|
|
@@ -244,7 +274,7 @@ class PhysXBuilder(object):
|
|
json.dump(settings, fh, indent=4)
|
|
json.dump(settings, fh, indent=4)
|
|
|
|
|
|
def writeCMakeFindFile(self, packageDir: pathlib.Path, cmakeFindFile):
|
|
def writeCMakeFindFile(self, packageDir: pathlib.Path, cmakeFindFile):
|
|
- dst = packageDir / 'FindPhysX.cmake'
|
|
|
|
|
|
+ dst = packageDir / 'FindPhysX5.cmake'
|
|
shutil.copy2(
|
|
shutil.copy2(
|
|
src=cmakeFindFile,
|
|
src=cmakeFindFile,
|
|
dst=dst
|
|
dst=dst
|
|
@@ -252,12 +282,12 @@ class PhysXBuilder(object):
|
|
|
|
|
|
extraLibsPerPlatform = {
|
|
extraLibsPerPlatform = {
|
|
'windows': [
|
|
'windows': [
|
|
- ['\${EXTRA_SHARED_LIBS}',
|
|
|
|
|
|
+ ['\\${EXTRA_SHARED_LIBS}',
|
|
''.join(('\n',
|
|
''.join(('\n',
|
|
- '\t${PATH_TO_SHARED_LIBS}/PhysXDevice64.dll\n',
|
|
|
|
- '\t${PATH_TO_SHARED_LIBS}/PhysXGpu_64.dll\n'
|
|
|
|
|
|
+ '\t${PATH_TO_LIBS}/PhysXDevice64.dll\n',
|
|
|
|
+ '\t${PATH_TO_LIBS}/PhysXGpu_64.dll\n'
|
|
))],
|
|
))],
|
|
- ['\${EXTRA_STATIC_LIBS_NON_MONOLITHIC}',
|
|
|
|
|
|
+ ['\\${EXTRA_STATIC_LIBS}',
|
|
''.join(('\n',
|
|
''.join(('\n',
|
|
'\t${PATH_TO_LIBS}/LowLevel_static_64.lib\n',
|
|
'\t${PATH_TO_LIBS}/LowLevel_static_64.lib\n',
|
|
'\t${PATH_TO_LIBS}/LowLevelAABB_static_64.lib\n',
|
|
'\t${PATH_TO_LIBS}/LowLevelAABB_static_64.lib\n',
|
|
@@ -268,23 +298,23 @@ class PhysXBuilder(object):
|
|
))],
|
|
))],
|
|
],
|
|
],
|
|
'linux': [
|
|
'linux': [
|
|
- ['\${EXTRA_SHARED_LIBS}', '${PATH_TO_SHARED_LIBS}/libPhysXGpu_64.so'],
|
|
|
|
- ['\${EXTRA_STATIC_LIBS_NON_MONOLITHIC}', ''],
|
|
|
|
|
|
+ ['\\${EXTRA_SHARED_LIBS}', '${PATH_TO_LIBS}/libPhysXGpu_64.so'],
|
|
|
|
+ ['\\${EXTRA_STATIC_LIBS}', ''],
|
|
],
|
|
],
|
|
'linux-aarch64': [
|
|
'linux-aarch64': [
|
|
- ['\${EXTRA_SHARED_LIBS}', '${PATH_TO_SHARED_LIBS}/libPhysXGpu_64.so'],
|
|
|
|
- ['\${EXTRA_STATIC_LIBS_NON_MONOLITHIC}', ''],
|
|
|
|
|
|
+ ['\\${EXTRA_SHARED_LIBS}', '${PATH_TO_LIBS}/libPhysXGpu_64.so'],
|
|
|
|
+ ['\\${EXTRA_STATIC_LIBS}', ''],
|
|
],
|
|
],
|
|
'mac': [
|
|
'mac': [
|
|
- ['\${EXTRA_SHARED_LIBS}', ''],
|
|
|
|
- ['\${EXTRA_STATIC_LIBS_NON_MONOLITHIC}', ''],
|
|
|
|
|
|
+ ['\\${EXTRA_SHARED_LIBS}', ''],
|
|
|
|
+ ['\\${EXTRA_STATIC_LIBS}', ''],
|
|
],
|
|
],
|
|
# iOS has its own FindPhysX file where it doesn't need to do any adjustments.
|
|
# iOS has its own FindPhysX file where it doesn't need to do any adjustments.
|
|
'ios': [
|
|
'ios': [
|
|
],
|
|
],
|
|
'android': [
|
|
'android': [
|
|
- ['\${EXTRA_SHARED_LIBS}', ''],
|
|
|
|
- ['\${EXTRA_STATIC_LIBS_NON_MONOLITHIC}', ''],
|
|
|
|
|
|
+ ['\\${EXTRA_SHARED_LIBS}', ''],
|
|
|
|
+ ['\\${EXTRA_STATIC_LIBS}', ''],
|
|
],
|
|
],
|
|
}
|
|
}
|
|
|
|
|
|
@@ -295,6 +325,14 @@ class PhysXBuilder(object):
|
|
|
|
|
|
def main():
|
|
def main():
|
|
parser = argparse.ArgumentParser()
|
|
parser = argparse.ArgumentParser()
|
|
|
|
+ parser.add_argument(
|
|
|
|
+ '--package-name',
|
|
|
|
+ required=True
|
|
|
|
+ )
|
|
|
|
+ parser.add_argument(
|
|
|
|
+ '--package-rev',
|
|
|
|
+ required=True
|
|
|
|
+ )
|
|
parser.add_argument(
|
|
parser.add_argument(
|
|
'--platform-name',
|
|
'--platform-name',
|
|
dest='platformName',
|
|
dest='platformName',
|
|
@@ -314,16 +352,13 @@ def main():
|
|
packageSourceDir = packageSystemDir / 'PhysX5'
|
|
packageSourceDir = packageSystemDir / 'PhysX5'
|
|
packageRoot = packageSourceDir / 'temp' / f'PhysX5-{args.platformName}'
|
|
packageRoot = packageSourceDir / 'temp' / f'PhysX5-{args.platformName}'
|
|
|
|
|
|
- cmakeFindFile = packageSourceDir / f'FindPhysX_{args.platformName}.cmake'
|
|
|
|
|
|
+ cmakeFindFile = packageSourceDir / f'FindPhysX5_{args.platformName}.cmake'
|
|
if not cmakeFindFile.exists():
|
|
if not cmakeFindFile.exists():
|
|
- cmakeFindFile = packageSourceDir / 'FindPhysX.cmake'
|
|
|
|
|
|
+ cmakeFindFile = packageSourceDir / 'FindPhysX5.cmake'
|
|
|
|
|
|
with TemporaryDirectory() as tempdir:
|
|
with TemporaryDirectory() as tempdir:
|
|
# Package Name
|
|
# Package Name
|
|
- revision = 'rev1'
|
|
|
|
- if args.platformName == 'windows':
|
|
|
|
- revision = 'rev2'
|
|
|
|
- packageName = f'PhysX-5.1.1-{revision}-{args.platformName}'
|
|
|
|
|
|
+ packageName = f'{args.package_name}-{args.package_rev}-{args.platformName}'
|
|
|
|
|
|
# Version 5.1.1 commits
|
|
# Version 5.1.1 commits
|
|
if args.platformName == 'mac':
|
|
if args.platformName == 'mac':
|
|
@@ -336,11 +371,13 @@ def main():
|
|
commit = '0bbcff3d0c541325f4d14c36ee18f24e22e35e6e' # Commit for 5.1.1 version
|
|
commit = '0bbcff3d0c541325f4d14c36ee18f24e22e35e6e' # Commit for 5.1.1 version
|
|
|
|
|
|
tempdir = Path(tempdir)
|
|
tempdir = Path(tempdir)
|
|
- builder = PhysXBuilder(workingDir=tempdir, basePackageSystemDir=packageSystemDir, targetPlatform=args.platformName)
|
|
|
|
|
|
+ builder = PhysXBuilder(workingDir=tempdir,
|
|
|
|
+ basePackageSystemDir=packageSystemDir,
|
|
|
|
+ targetPlatform=args.platformName)
|
|
builder.clone(lockToCommit=commit)
|
|
builder.clone(lockToCommit=commit)
|
|
|
|
|
|
- builder.build(buildAsStaticLibs=False)
|
|
|
|
- builder.build(buildAsStaticLibs=True)
|
|
|
|
|
|
+ builder.build_all()
|
|
|
|
+
|
|
builder.copyBuildOutputTo(packageRoot/'PhysX')
|
|
builder.copyBuildOutputTo(packageRoot/'PhysX')
|
|
|
|
|
|
builder.writePackageInfoFile(
|
|
builder.writePackageInfoFile(
|