From 0afaf7b8966af4e86801689e923f886867be6257 Mon Sep 17 00:00:00 2001 From: Luca Scheller Date: Wed, 20 Mar 2024 21:21:26 -0700 Subject: [PATCH] Add Maya SDK Linux and Windows build support --- .github/scripts/houdini.py | 2 +- .github/scripts/houdini_build.bat | 3 +- .github/scripts/houdini_build.sh | 3 +- .github/scripts/maya.py | 503 ++++++++++++++---------------- .github/scripts/maya_build.bat | 8 + .github/scripts/maya_build.sh | 9 + .github/workflows/build_maya.yml | 135 ++++++++ .gitignore | 1 + CMakeLists.txt | 178 +++++++---- build.bat | 4 +- build.sh | 4 +- docs.sh | 0 setup.sh | 32 +- src/CachedResolver/CMakeLists.txt | 6 +- src/FileResolver/CMakeLists.txt | 4 +- 15 files changed, 535 insertions(+), 357 deletions(-) mode change 100755 => 100644 .github/scripts/houdini_build.sh create mode 100644 .github/scripts/maya_build.bat create mode 100755 .github/scripts/maya_build.sh create mode 100644 .github/workflows/build_maya.yml mode change 100755 => 100644 build.sh mode change 100755 => 100644 docs.sh diff --git a/.github/scripts/houdini.py b/.github/scripts/houdini.py index 3821862..d7c9ec4 100644 --- a/.github/scripts/houdini.py +++ b/.github/scripts/houdini.py @@ -81,7 +81,7 @@ def download_sidefx_product_release(dir_path, release): def install_sidefx_product(product, version): - """Install the latest production release of Houdini + """Install a production release of Houdini Args: product (str): The target product name (e.g. houdini, houdini-py39, etc.) version (str|None): The target product version (e.g. 20.0, 19.5, etc.) diff --git a/.github/scripts/houdini_build.bat b/.github/scripts/houdini_build.bat index 983bacf..fcdfdfe 100644 --- a/.github/scripts/houdini_build.bat +++ b/.github/scripts/houdini_build.bat @@ -1,5 +1,6 @@ set HFS=C:\Program Files\Side Effects Software\Houdini -set RESOLVER_NAME=%1 +set AR_DCC_NAME=HOUDINI +set AR_RESOLVER_NAME=%1 cmake . -B build -G "Visual Studio 16 2019" -A x64 -T v142 cmake --build build --clean-first --config Release cmake --install build \ No newline at end of file diff --git a/.github/scripts/houdini_build.sh b/.github/scripts/houdini_build.sh old mode 100755 new mode 100644 index 4147fad..94dd392 --- a/.github/scripts/houdini_build.sh +++ b/.github/scripts/houdini_build.sh @@ -1,5 +1,6 @@ pushd /opt/hfs > /dev/null && source houdini_setup && popd > /dev/null -export RESOLVER_NAME=$1 +export AR_DCC_NAME=HOUDINI +export AR_RESOLVER_NAME=$1 cmake . -B build && cmake --build build --clean-first cmake --install build ctest -VV --test-dir build # Run tests \ No newline at end of file diff --git a/.github/scripts/maya.py b/.github/scripts/maya.py index 86ea0ce..2d62a05 100644 --- a/.github/scripts/maya.py +++ b/.github/scripts/maya.py @@ -1,6 +1,7 @@ import argparse import hashlib import glob +import contextlib import logging import os import pathlib @@ -12,29 +13,51 @@ import subprocess import tarfile import zipfile +from urllib import request +import ssl +import json +MAYA_USD_SDK_URL = "https://api.github.com/repos/Autodesk/maya-usd" +MAYA_USD_SDK_RELEASE_ASSET_ELEMENTS_REGEX = re.compile( + "MayaUSD_([0-9.]+)_Maya([0-9.]+)_(Linux|Windows).(run|exe)" +) +MAYA_PYTHON_VERSION_MAPPING = { + "2024.2": "3.10.11" +} +PYTHON_SOURCE_DOWNLOAD_URL = { + "3.10.11": "https://www.python.org/ftp/python/3.10.11/Python-3.10.11.tgz" +} +PYTHON_WINDOWS_DOWNLOAD_URL = { + "3.10.11": "https://www.python.org/ftp/python/3.10.11/python-3.10.11-amd64.exe" +} +SEVENZIP_WINDOWS_DOWNLOAD_URL = { + "2301": "https://www.7-zip.org/a/7z2401-x64.exe" +} -SIDEFX_CLIENT_ID = os.environ.get("SIDEFX_CLIENT_ID", "") -SIDEFX_CLIENT_SECRET_KEY = os.environ.get("SIDEFX_CLIENT_SECRET_KEY", "") +logging.basicConfig(format="%(asctime)s %(message)s", datefmt="%m/%d/%Y %I:%M:%S %p", level=logging.INFO) -logging.basicConfig(format="%(asctime)s %(message)s", datefmt="%m/%d/%Y %I:%M:%S %p") - -def create_github_service(client_id, client_secret_key): - """Get the GitHub API service +def download_file(download_file_path, download_url): + """Download the release to the directory Args: - client_id (str): The client id - client_secret_key (str): The client secret key + download_file_path (str): The target file + download_url (str): The download url Returns: - sidefx.Service: The service + str: The file path of the downloaded file """ - return sidefx.service( - access_token_url="https://www.sidefx.com/oauth2/application_token", - client_id=client_id, - client_secret_key=client_secret_key, - endpoint_url="https://www.sidefx.com/api/", - ) + # Download file + download_dir_path = os.path.dirname(download_file_path) + if not os.path.exists(download_dir_path): + os.makedirs(download_dir_path) + request = requests.get(download_url, stream=True) + if request.status_code == 200: + with open(download_file_path, "wb") as download_file: + request.raw.decode_content = True + shutil.copyfileobj(request.raw, download_file) + else: + raise Exception("Error downloading file | {}".format(download_url)) + return download_file_path def get_autodesk_platform(): @@ -53,188 +76,189 @@ def get_autodesk_platform(): return "" -def download_sidefx_product_release(dir_path, release): - """Download the release to the directory +def get_autodesk_maya_usd_sdk_releases(platform_name, maya_version): + """Get the GitHub API service Args: - dir_path (str): The target directory - release (dict): The download build release dict + client_id (str): The client id + client_secret_key (str): The client secret key Returns: - str: The file path of the downloaded file + sidefx.Service: The service """ - # Download file - download_file_name = release["filename"] - download_file_path = os.path.join(dir_path, download_file_name) - request = requests.get(release["download_url"], stream=True) - if request.status_code == 200: - with open(download_file_path, "wb") as download_file: - request.raw.decode_content = True - shutil.copyfileobj(request.raw, download_file) - else: - raise Exception("Error downloading file!") - # Verify file checksum - # 10.12.23 -> SideFX Bug, this currently fails on Linux - # download_file_hash = hashlib.md5() - # with open(download_file_path, "rb") as download_file: - # for chunk in iter(lambda: download_file.read(4096), b""): - # download_file_hash.update(chunk) - # if download_file_hash.hexdigest() != release["hash"]: - # raise Exception("Checksum does not match!") - return download_file_path + # Query release data + try: + with contextlib.closing( + request.urlopen( + request.Request(MAYA_USD_SDK_URL + "/releases"), + context=ssl._create_unverified_context(), + ) + ) as response: + data = json.loads(response.read()) + except Exception: + data = [] + + # Extract relevant data + releases = [] + for release in data: + # Skip pre releases + if release["prerelease"]: + continue + for asset in release["assets"]: + if asset["content_type"] not in ("application/x-msdownload", "application/octet-stream"): + continue + asset_name = asset["name"] + asset_name_elements = MAYA_USD_SDK_RELEASE_ASSET_ELEMENTS_REGEX.match(asset_name) + if not asset_name_elements: + continue + ( + asset_usd_sdk_version, + asset_maya_version, + asset_platform, + asset_ext + ) = asset_name_elements.groups() + if asset_platform != platform_name: + continue + elif asset_maya_version != maya_version: + continue + releases.append((asset_usd_sdk_version, asset["browser_download_url"])) + + return releases -def install_autodesk_product(product, version): - """Install the latest production release of Houdini +def install_autodesk_product(product, version, install_dir_path): + """Install a USD SDK release of Maya Args: - product (str): The target product name (e.g. houdini, houdini-py39, etc.) - version (str|None): The target product version (e.g. 20.0, 19.5, etc.) + product (str): The target product name (e.g. maya, etc.) + version (str|None): The target product version (e.g. 2024.4, etc.) + install_dir_path (str): The install dir path. """ - # Connect to SideFX API - logging.info("Connecting to SideFX API") - sidefx_service = create_sidefx_service(SIDEFX_CLIENT_ID, SIDEFX_CLIENT_SECRET_KEY) - sidefx_platform = get_sidefx_platform() - sidefx_product_name = product - sidefx_product_version = version + autodesk_maya_version = version + python_version = MAYA_PYTHON_VERSION_MAPPING[version] - # Get release data - releases_list = sidefx_service.download.get_daily_builds_list( - product=sidefx_product_name, - version=sidefx_product_version, - platform=sidefx_platform, - only_production=True, - ) - target_release = None - if sidefx_platform == "linux": - for release in releases_list: - # Switch to new gcc version starting with H20 - if release["version"] == "20.0": - if not release["platform"].endswith("gcc11.2"): - continue - target_release = release - break - else: - for release in releases_list: - target_release = release - break + # Directories + download_dir_path = os.path.join(install_dir_path, "download") + dependency_dir_path = os.path.join(install_dir_path, "install") + tmp_dir_path = os.path.join(install_dir_path, "tmp") + if os.path.exists(download_dir_path): + shutil.rmtree(download_dir_path) + if os.path.exists(dependency_dir_path): + shutil.rmtree(dependency_dir_path) + if os.path.exists(tmp_dir_path): + shutil.rmtree(tmp_dir_path) + os.makedirs(download_dir_path) + os.makedirs(dependency_dir_path) + os.makedirs(tmp_dir_path) - if not target_release: - raise Exception( - "No Houdini version found for requested version | {}".format( - houdini_version - ) - ) + sevenZip_dir_name = "7zip" + sevenZip_download_dir_path = os.path.join(download_dir_path, sevenZip_dir_name) + sevenZip_install_dir_path = os.path.join(dependency_dir_path, sevenZip_dir_name) - target_release_download = sidefx_service.download.get_daily_build_download( - product="houdini", - version=target_release["version"], - build=target_release["build"], - platform=sidefx_platform, - ) + python_dir_name = "python" + python_download_dir_path = os.path.join(download_dir_path, python_dir_name) + python_extract_dir_path = os.path.join(tmp_dir_path, python_dir_name) + python_install_dir_path = os.path.join(dependency_dir_path, python_dir_name) - # Download latest production release - logging.info( - "Downloading Houdini build {version}.{build}".format( - version=target_release["version"], build=target_release["build"] - ) - ) - downloads_dir_path = os.path.join(os.path.expanduser("~"), "Downloads") - if not os.path.isdir(downloads_dir_path): - os.makedirs(downloads_dir_path) - houdini_installer_file_path = download_sidefx_product_release( - downloads_dir_path, target_release_download - ) - # Install latest production release - logging.info( - "Installing Houdini build {version}.{build}".format( - version=target_release["version"], build=target_release["build"] - ) - ) - hfs_dir_path = "" - if sidefx_platform == "linux": - # Unpack tar file - with tarfile.open(houdini_installer_file_path) as tar_file: - tar_file.extractall(downloads_dir_path) - os.remove(houdini_installer_file_path) - # Get folder name - houdini_installer_dir_name = target_release_download["filename"] - houdini_installer_dir_name = houdini_installer_dir_name.replace(".tar", "") - houdini_installer_dir_name = houdini_installer_dir_name.replace(".gz", "") - houdini_installer_dir_path = os.path.join( - downloads_dir_path, houdini_installer_dir_name - ) - cmd = [ - os.path.join(houdini_installer_dir_path, "houdini.install"), - "--auto-install", - "--accept-EULA", - "2021-10-13", - "--install-houdini", - "--no-install-license", - "--no-install-avahi", - "--no-install-hqueue-server", - "--no-install-hqueue-client", - "--no-install-menus", - "--no-install-bin-symlink", - "--no-install-engine-maya", - "--no-install-engine-unity", - "--no-install-engine-unreal", - "--no-install-sidefxlabs", - ] - status = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - if status.returncode != 0: - raise Exception( - "Failed to install Houdini, ran into the following error:\n {error}".format( - error=status.stderr - ) - ) - hfs_dir_path = os.path.join( - "/opt", - "hfs{}.{}".format(target_release["version"], target_release["build"]), - ) - hfs_symlink_dir_path = os.path.join(os.path.dirname(hfs_dir_path), "hfs") - elif sidefx_platform == "win64": - cmd = [ - houdini_installer_file_path, - "/S", - "/AcceptEULA=2021-10-13", - "/MainApp", - "/LicenseServer=No", - "/StartMenu=No", - "/HQueueServer=No", - "/HQueueClient=No", - "/EngineMaya=No", - "/Engine3dsMax", - "/EngineUnity", - "/EngineUnreal=No", - "/SideFXLabs=No", - ] - status = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - if status.returncode != 0: - raise Exception( - "Failed to install Houdini, ran into the following error:\n {error}".format( - error=status.stderr - ) - ) - hfs_dir_path = os.path.join( - "C:\Program Files\Side Effects Software", - "Houdini {}.{}".format(target_release["version"], target_release["build"]), - ) - hfs_symlink_dir_path = os.path.join( - os.path.dirname(hfs_dir_path), "Houdini" - ) - else: - raise Exception( - "Platform {platform} is currently not" - "supported!".format(platform=platform) - ) - # Create version-less symlink - logging.info( - "Creating symlink Houdini build {src} -> {dst}".format( - src=hfs_dir_path, dst=hfs_symlink_dir_path - ) - ) - os.symlink(hfs_dir_path, hfs_symlink_dir_path) + maya_usd_sdk_dir_name = "maya_usd_sdk" + maya_usd_sdk_download_dir_path = os.path.join(download_dir_path, maya_usd_sdk_dir_name) + maya_usd_sdk_extract_dir_path = os.path.join(tmp_dir_path, maya_usd_sdk_dir_name) + maya_usd_sdk_install_dir_path = os.path.join(dependency_dir_path, maya_usd_sdk_dir_name) + + maya_usd_sdk_devkit_dir_name = "maya_usd_sdk_devkit" + maya_usd_sdk_devkit_install_dir_path = os.path.join(dependency_dir_path, maya_usd_sdk_devkit_dir_name) + + autodesk_platform = get_autodesk_platform() + if autodesk_platform == "Linux": + # Python + python_download_url = PYTHON_SOURCE_DOWNLOAD_URL[python_version] + python_download_file_path = os.path.join(python_download_dir_path, "python.tgz") + logging.info("Downloading Python Build {}".format(python_version)) + download_file(python_download_file_path, python_download_url) + with tarfile.open(python_download_file_path, "r") as python_download_file: + python_download_file.extractall(python_extract_dir_path, filter='data') + python_version_dir_path = os.path.join(python_extract_dir_path, os.listdir(python_extract_dir_path)[0]) + python_configure_file_path = os.path.join(python_version_dir_path, "configure") + os.chmod(python_configure_file_path, 0o777) + logging.info("Configuring Python Build") + command = [python_configure_file_path, "--enable-shared", "--prefix", python_install_dir_path] + process = subprocess.check_call(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=python_version_dir_path) + logging.info("Building Python") + process = subprocess.check_call(["make"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, cwd=python_version_dir_path) + logging.info("Installing Python") + process = subprocess.check_call(["make", "install"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, cwd=python_version_dir_path) + # Maya USD SDK + maya_usd_sdk_releases = get_autodesk_maya_usd_sdk_releases(autodesk_platform, autodesk_maya_version) + maya_usd_sdk_latest_release = maya_usd_sdk_releases[0] + maya_usd_sdk_version = maya_usd_sdk_latest_release[0] + maya_usd_sdk_download_url = maya_usd_sdk_latest_release[1] + maya_usd_sdk_download_file_path = os.path.join(maya_usd_sdk_download_dir_path, "maya_usd_sdk.run") + logging.info("Downloading Maya USD SDK (Release {})".format(maya_usd_sdk_version)) + download_file(maya_usd_sdk_download_file_path, maya_usd_sdk_download_url) + logging.info("Installing Maya USD SDK") + os.chmod(maya_usd_sdk_download_file_path, 777) + os.makedirs(maya_usd_sdk_extract_dir_path) + command = [maya_usd_sdk_download_file_path, "--tar", "xvf", "--directory", maya_usd_sdk_extract_dir_path] + process = subprocess.check_call(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + maya_usd_sdk_extract_rpm_file_name = [f for f in os.listdir(maya_usd_sdk_extract_dir_path) if f.endswith(".rpm")][0] + maya_usd_sdk_extract_rpm_file_path = os.path.join(maya_usd_sdk_extract_dir_path, maya_usd_sdk_extract_rpm_file_name) + command = ["rpm", "-e", maya_usd_sdk_extract_rpm_file_name.replace(".rpm", "")] + process = subprocess.check_call(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + command = ["rpm", "-i", "--prefix", maya_usd_sdk_extract_dir_path, maya_usd_sdk_extract_rpm_file_path] + process = subprocess.check_call(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + maya_usd_sdk_extract_usd_dir_path = glob.glob("**{sep}mayausd{sep}USD".format(sep=os.path.sep), root_dir=maya_usd_sdk_extract_dir_path, recursive=True)[0] + maya_usd_sdk_extract_usd_dir_path = os.path.join(maya_usd_sdk_extract_dir_path, maya_usd_sdk_extract_usd_dir_path) + os.rename(maya_usd_sdk_extract_usd_dir_path, maya_usd_sdk_install_dir_path) + os.chmod(maya_usd_sdk_install_dir_path, 0o777) + # Maya USD SDK devkit + maya_usd_sdk_devkit_zip_file_path = glob.glob("**{}devkit.zip".format(os.path.sep), root_dir=maya_usd_sdk_install_dir_path, recursive=True) + maya_usd_sdk_devkit_zip_file_path = os.path.join(maya_usd_sdk_install_dir_path, maya_usd_sdk_devkit_zip_file_path[0]) + with zipfile.ZipFile(maya_usd_sdk_devkit_zip_file_path, 'r') as zip_file: + zip_file.extractall(maya_usd_sdk_devkit_install_dir_path) + + elif autodesk_platform == "Windows": + # Python + python_download_url = PYTHON_WINDOWS_DOWNLOAD_URL[python_version] + python_download_file_path = os.path.join(python_download_dir_path, "python.exe") + logging.info("Downloading Python Build {}".format(python_version)) + download_file(python_download_file_path, python_download_url) + logging.info("Installing Python") + command = [python_download_file_path, "/passive", "/quiet", "InstallAllUsers=0", + "TargetDir={}".format(python_install_dir_path), "AssociateFiles=0", + "Shortcuts=0", "Include_doc=0", "Include_launcher=0", "Include_test=0"] + process = subprocess.check_call(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + # 7Zip + serverZip_version = "2301" + serverZip_download_url = SEVENZIP_WINDOWS_DOWNLOAD_URL[serverZip_version] + serverZip_download_file_path = os.path.join(sevenZip_download_dir_path, "7zip.exe") + logging.info("Downloading 7zip (Build {})".format(serverZip_version)) + download_file(serverZip_download_file_path, serverZip_download_url) + logging.info("Installing 7zip") + command = [serverZip_download_file_path, "/S", "/D={}".format(sevenZip_install_dir_path)] + process = subprocess.check_call(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + serverZip_exe_file_path = os.path.join(sevenZip_install_dir_path, "7z.exe") + # Maya USD SDK + maya_usd_sdk_releases = get_autodesk_maya_usd_sdk_releases(autodesk_platform, autodesk_maya_version) + maya_usd_sdk_latest_release = maya_usd_sdk_releases[0] + maya_usd_sdk_version = maya_usd_sdk_latest_release[0] + maya_usd_sdk_download_url = maya_usd_sdk_latest_release[1] + maya_usd_sdk_download_file_path = os.path.join(maya_usd_sdk_download_dir_path, "maya_usd_sdk.exe") + logging.info("Downloading Maya USD SDK (Release {})".format(maya_usd_sdk_version)) + download_file(maya_usd_sdk_download_file_path, maya_usd_sdk_download_url) + command = [serverZip_exe_file_path, "x", maya_usd_sdk_download_file_path, "-o{}".format(maya_usd_sdk_extract_dir_path)] + process = subprocess.check_call(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + logging.info("Installing Maya USD SDK") + command = ["msiexec", "/i", os.path.join(maya_usd_sdk_extract_dir_path, "MayaUSD.msi"), "/quiet", "/passive", "INSTALLDIR={}".format(maya_usd_sdk_extract_dir_path)] + process = subprocess.check_call(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + maya_usd_sdk_extract_usd_dir_path = glob.glob("**{sep}mayausd{sep}USD".format(sep=os.path.sep), root_dir=maya_usd_sdk_extract_dir_path, recursive=True)[0] + maya_usd_sdk_extract_usd_dir_path = os.path.join(maya_usd_sdk_extract_dir_path, maya_usd_sdk_extract_usd_dir_path) + os.rename(maya_usd_sdk_extract_usd_dir_path, maya_usd_sdk_install_dir_path) + # Maya USD DevKit + logging.info("Installing Maya USD SDK DevKit") + maya_usd_sdk_devkit_zip_file_path = glob.glob("**{}devkit.zip".format(os.path.sep), root_dir=maya_usd_sdk_install_dir_path, recursive=True) + maya_usd_sdk_devkit_zip_file_path = os.path.join(maya_usd_sdk_install_dir_path, maya_usd_sdk_devkit_zip_file_path[0]) + with zipfile.ZipFile(maya_usd_sdk_devkit_zip_file_path, 'r') as zip_file: + zip_file.extractall(maya_usd_sdk_devkit_install_dir_path) -def create_sidefx_houdini_artifact(artifact_src, artifact_dst, artifact_prefix, artifact_product_name): +def create_autodesk_maya_artifact(artifact_src, artifact_dst, artifact_prefix, artifact_product_name): """Create a .zip artifact based on the source directory content. The output name will have will end in the houdini build name. @@ -248,10 +272,10 @@ def create_sidefx_houdini_artifact(artifact_src, artifact_dst, artifact_prefix, str: The artifact file path """ re_digitdot = re.compile("[^0-9.]") - sidefx_platform = get_sidefx_platform() - if sidefx_platform == "linux": + autodesk_platform = get_autodesk_platform() + if autodesk_platform == "linux": hfs_build_name = os.path.basename(pathlib.Path("/opt/hfs").resolve()) - elif sidefx_platform == "win64": + elif autodesk_platform == "win64": hfs_build_name = os.path.basename( pathlib.Path("C:\Program Files\Side Effects Software\Houdini").resolve() ) @@ -271,93 +295,20 @@ def create_sidefx_houdini_artifact(artifact_src, artifact_dst, artifact_prefix, if __name__ == "__main__": - - - MAYA_PYTHON_VERSION_MAPPING = { - "2022.5": "3.9", - "2023.3": "3.9", - "2024.2": "3.9" - } - - - # Workspace directory - workspace_dir_path = "/home/lucsch/Desktop/Maya" - download_dir_path = os.path.join(workspace_dir_path, "download") - dependency_dir_path = os.path.join(workspace_dir_path, "dependency") - tmp_dir_path = os.path.join(workspace_dir_path, "tmp") - #if os.path.exists(download_dir_path): - # shutil.rmtree(download_dir_path) - #if os.path.exists(tmp_dir_path): - # shutil.rmtree(tmp_dir_path) - if os.path.exists(dependency_dir_path): - shutil.rmtree(dependency_dir_path) - #os.makedirs(download_dir_path) - #os.makedirs(tmp_dir_path) - os.makedirs(dependency_dir_path) - # Download - maya_usd_sdk_source_file_path = os.path.join(download_dir_path, "maya-usd-0.27.0.zip") - maya_usd_sdk_compiled_file_path = os.path.join(download_dir_path, "MayaUSD_0.27.0_Maya2024.2_Linux.run") - - # maya_usd_sdk_source_extracted_dir_path = os.path.join(tmp_dir_path, "usd_sdk_source") - # maya_usd_sdk_source_dependency_dir_path = os.path.join(dependency_dir_path, "usd_sdk_source") - maya_usd_sdk_compiled_extracted_dir_path = os.path.join(tmp_dir_path, "usd_sdk_compiled") - maya_usd_sdk_compiled_dependency_dir_path = os.path.join(dependency_dir_path, "usd_sdk_compiled") - maya_usd_sdk_devkit_dependency_dir_path = os.path.join(dependency_dir_path, "usd_sdk_devkit") - - autodesk_platform = get_autodesk_platform() - if autodesk_platform == "Linux": - # Maya USD SDK source - # with zipfile.ZipFile(maya_usd_sdk_source_file_path, 'r') as zip_file: - # zip_file.extractall(maya_usd_sdk_source_extracted_dir_path) - # maya_usd_sdk_source_extracted_dir_path = os.path.join(maya_usd_sdk_source_extracted_dir_path, os.listdir(maya_usd_sdk_source_extracted_dir_path)[0]) - # os.rename(maya_usd_sdk_source_extracted_dir_path, maya_usd_sdk_source_dependency_dir_path) - # Maya USD SDK compiled - os.chmod(maya_usd_sdk_compiled_file_path, 777) - command = [maya_usd_sdk_compiled_file_path, "--tar", "xvf", "--directory", maya_usd_sdk_compiled_extracted_dir_path] - process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - process.communicate() - maya_usd_sdk_compiled_extracted_rpm_file_name = [f for f in os.listdir(maya_usd_sdk_compiled_extracted_dir_path) if f.endswith(".rpm")][0] - maya_usd_sdk_compiled_extracted_rpm_file_path = os.path.join(maya_usd_sdk_compiled_extracted_dir_path, maya_usd_sdk_compiled_extracted_rpm_file_name) - command = ["rpm", "-e", maya_usd_sdk_compiled_extracted_rpm_file_name.replace(".rpm", "")] - process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - process.communicate() - command = ["rpm", "-i", "--prefix", maya_usd_sdk_compiled_extracted_dir_path, maya_usd_sdk_compiled_extracted_rpm_file_path] - process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - process.communicate() - maya_usd_sdk_compiled_extracted_usd_dir_path = glob.glob("**{sep}mayausd{sep}USD".format(sep=os.path.sep), root_dir=maya_usd_sdk_compiled_extracted_dir_path, recursive=True)[0] - maya_usd_sdk_compiled_extracted_usd_dir_path = os.path.join(maya_usd_sdk_compiled_extracted_dir_path, maya_usd_sdk_compiled_extracted_usd_dir_path) - os.rename(maya_usd_sdk_compiled_extracted_usd_dir_path, maya_usd_sdk_compiled_dependency_dir_path) - os.chmod(dependency_dir_path, 0o777) - for root_dir_path, dir_names, file_names in os.walk(maya_usd_sdk_compiled_dependency_dir_path): - for dir_name in dir_names: - try: - os.chmod(os.path.join(root_dir_path, dir_name), 0o777) - except: - pass - for file_name in file_names: - try: - os.chmod(os.path.join(root_dir_path, file_name), 0o777) - except: - pass - # Maya USD SDK devkit - maya_usd_devkit_zip_file_path = glob.glob("**{}devkit.zip".format(os.path.sep), root_dir=maya_usd_sdk_compiled_dependency_dir_path, recursive=True) - maya_usd_devkit_zip_file_path = os.path.join(maya_usd_sdk_compiled_dependency_dir_path, maya_usd_devkit_zip_file_path[0]) - with zipfile.ZipFile(maya_usd_devkit_zip_file_path, 'r') as zip_file: - zip_file.extractall(maya_usd_sdk_devkit_dependency_dir_path) - # Python - - - ''' # Parse args parser = argparse.ArgumentParser() - parser.add_argument("--install", action="store_true", help="Install Houdini") + parser.add_argument("--install", action="store_true", help="Install Maya USD SDK") parser.add_argument( - "--install_houdini_product_name", - help="Houdini product name to install. If not provided, fallback to the default.", + "--install_maya_product_name", + help="Maya product name to install. If not provided, fallback to the default.", ) parser.add_argument( - "--install_houdini_product_version", - help="Houdini product version to install. If not provided, fallback to the latest version.", + "--install_maya_product_version", + help="Maya product version to install. If not provided, fallback to the latest version.", + ) + parser.add_argument( + "--install_directory", + help="The installation directory.", ) parser.add_argument("--artifact", action="store_true", help="Create artifact") parser.add_argument("--artifact_src", help="Artifact source directory") @@ -366,13 +317,13 @@ def create_sidefx_houdini_artifact(artifact_src, artifact_dst, artifact_prefix, parser.add_argument("--artifact_product_name", help="Artifact product name") args = parser.parse_args() # Execute - # Install Houdini + # Install Maya USD SDK if args.install: - install_sidefx_product(args.install_houdini_product_name, - args.install_houdini_product_version) - # Create artifact tagged with Houdini build name (expects Houdini to be installed via the above install command) + install_autodesk_product(args.install_maya_product_name, + args.install_maya_product_version, + args.install_directory) + # Create artifact tagged with Maya build name (expects Maya USD SDK to be installed via the above install command) if args.artifact: - create_sidefx_houdini_artifact( + create_autodesk_maya_artifact( args.artifact_src, args.artifact_dst, args.artifact_prefix, args.artifact_product_name - ) - ''' \ No newline at end of file + ) \ No newline at end of file diff --git a/.github/scripts/maya_build.bat b/.github/scripts/maya_build.bat new file mode 100644 index 0000000..9694a8a --- /dev/null +++ b/.github/scripts/maya_build.bat @@ -0,0 +1,8 @@ +set MAYA_USD_SDK_ROOT=%cd%\dependency\install\maya_usd_sdk +set MAYA_USD_SDK_DEVKIT_ROOT=%cd%\dependency\install\maya_usd_sdk_devkit +set PYTHON_ROOT=%cd%\dependency\install\python +set AR_DCC_NAME=MAYA +set AR_RESOLVER_NAME=%1 +cmake . -B build -G "Visual Studio 16 2019" -A x64 -T v142 +cmake --build build --clean-first --config Release +cmake --install build \ No newline at end of file diff --git a/.github/scripts/maya_build.sh b/.github/scripts/maya_build.sh new file mode 100755 index 0000000..1203f54 --- /dev/null +++ b/.github/scripts/maya_build.sh @@ -0,0 +1,9 @@ +repo_root=$(cd .; pwd) +export MAYA_USD_SDK_ROOT=$repo_root/dependency/install/maya_usd_sdk +export MAYA_USD_SDK_DEVKIT_ROOT=$repo_root/dependency/install/maya_usd_sdk_devkit +export PYTHON_ROOT=$repo_root/dependency/install/python +export AR_DCC_NAME=MAYA +export AR_RESOLVER_NAME=$1 +cmake . -B build && cmake --build build --clean-first +cmake --install build +ctest -VV --test-dir build # Run tests \ No newline at end of file diff --git a/.github/workflows/build_maya.yml b/.github/workflows/build_maya.yml new file mode 100644 index 0000000..0f8b8e1 --- /dev/null +++ b/.github/workflows/build_maya.yml @@ -0,0 +1,135 @@ +name: Build USD Asset Resolvers against Maya + +on: + release: + types: [released] + schedule: + - cron: '0 12 * * *' + workflow_dispatch: + +concurrency: + group: "build" + cancel-in-progress: false + +jobs: + + build_linux: + runs-on: ubuntu-latest + environment: maya + strategy: + matrix: + maya_product_name: ["maya"] + maya_product_version: ["2024.2"] + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + submodules: recursive + - name: Switch to latest release tag + run: | + git fetch --all --tags --force + latest_release_tag=$(git tag -l --sort=-version:refname v* | head -1) + git checkout tags/$latest_release_tag + - name: Install system packages + run: | + sudo apt-get update + sudo apt-get install -y zip + sudo apt-get install -y build-essential cmake + sudo apt-get install -y python3 python3-pip + sudo pip3 install requests + - name: Install maya + run: | + sudo --preserve-env python3 .github/scripts/maya.py --install --install_maya_product_name ${{ matrix.maya_product_name }} --install_maya_product_version ${{ matrix.maya_product_version }} + - name: Build USD File Resolver + run: | + .github/scripts/maya_build.sh fileResolver + - name: Build USD Python Resolver + run: | + .github/scripts/maya_build.sh pythonResolver + - name: Build USD Cached Resolver + run: | + .github/scripts/maya_build.sh cachedResolver + - name: Build USD Http Resolver + run: | + .github/scripts/maya_build.sh httpResolver + - name: Create single .zip archive + run: | + repo_root=$(cd .; pwd) + python3 .github/scripts/maya.py --artifact --artifact_src=$repo_root/dist --artifact_dst=$repo_root/artifacts --artifact_prefix=UsdAssetResolver --artifact_product_name ${{ matrix.maya_product_name }} + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: UsdAssetResolver-linux-${{ matrix.maya_product_name }}-${{ matrix.maya_product_version }} + path: artifacts/*.zip + + build_windows: + runs-on: windows-2019 + environment: maya + strategy: + matrix: + maya_product_name: ["maya"] + maya_product_version: ["2024.2"] + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + submodules: recursive + - name: Switch to latest release tag + run: | + git fetch --all --tags --force + $latest_release_tag=git tag -l --sort=-version:refname v* | select -first 1 + git checkout tags/$latest_release_tag + - name: Install system packages + run: | + pip3 install requests + - name: Install Maya + run: | + python3 .github\scripts\maya.py --install --install_maya_product_name ${{ matrix.maya_product_name }} --install_maya_product_version ${{ matrix.maya_product_version }} + - name: Build USD File Resolver + run: | + .\.github\scripts\maya_build.bat fileResolver + - name: Build USD Python Resolver + run: | + .\.github\scripts\maya_build.bat pythonResolver + - name: Build USD Cached Resolver + run: | + .\.github\scripts\maya_build.bat cachedResolver + - name: Build USD Http Resolver + run: | + .\.github\scripts\maya_build.bat httpResolver + - name: Create single .zip archive + run: | + & python $pwd\.github\scripts\maya.py --artifact --artifact_src=$pwd\dist --artifact_dst=$pwd\artifacts --artifact_prefix=UsdAssetResolver --artifact_product_name ${{ matrix.maya_product_name }} + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: UsdAssetResolver-windows-${{ matrix.maya_product_name }}-${{ matrix.maya_product_version }} + path: artifacts/*.zip + + deploy: + runs-on: ubuntu-latest + permissions: + contents: write + needs: [build_linux, build_windows] + strategy: + matrix: + os: ["linux", "windows"] + maya_product_name: ["maya"] + maya_product_version: ["2024.2"] + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + submodules: recursive + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: UsdAssetResolver-${{ matrix.os }}-${{ matrix.maya_product_name }}-${{ matrix.maya_product_version }} + path: artifacts + - name: Upload artifacts as release assets + run: | + git fetch --all --tags --force + latest_release_tag=$(git tag -l --sort=-version:refname v* | head -1) + gh release upload $latest_release_tag artifacts/*.zip --clobber + env: + GITHUB_TOKEN: ${{ github.TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 4ccf952..5a169e3 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,6 @@ build dist docs/book temp +dependency venv __pycache__ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index b991fa3..a0696fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ endif() # File Resolver option(AR_FILERESOLVER_BUILD "Build the FileResolver" OFF) -if("$ENV{RESOLVER_NAME}" STREQUAL "fileResolver") +if("$ENV{AR_RESOLVER_NAME}" STREQUAL "fileResolver") set(AR_FILERESOLVER_BUILD ON) endif() set(AR_FILERESOLVER_USD_PLUGIN_NAME fileResolver) @@ -28,7 +28,7 @@ set(AR_FILERESOLVER_TARGET_PYTHON _${AR_FILERESOLVER_TARGET_LIB}) set(AR_FILERESOLVER_INSTALL_PREFIX ${AR_PROJECT_NAME}/${AR_FILERESOLVER_USD_PLUGIN_NAME}) # Python Resolver option(AR_PYTHONRESOLVER_BUILD "Build the PythonResolver" OFF) -if("$ENV{RESOLVER_NAME}" STREQUAL "pythonResolver") +if("$ENV{AR_RESOLVER_NAME}" STREQUAL "pythonResolver") set(AR_PYTHONRESOLVER_BUILD ON) endif() set(AR_PYTHONRESOLVER_USD_PLUGIN_NAME pythonResolver) @@ -41,7 +41,7 @@ set(AR_PYTHONRESOLVER_TARGET_PYTHON _${AR_PYTHONRESOLVER_TARGET_LIB}) set(AR_PYTHONRESOLVER_INSTALL_PREFIX ${AR_PROJECT_NAME}/${AR_PYTHONRESOLVER_USD_PLUGIN_NAME}) # Cached Resolver option(AR_CACHEDRESOLVER_BUILD "Build the CachedResolver" OFF) -if("$ENV{RESOLVER_NAME}" STREQUAL "cachedResolver") +if("$ENV{AR_RESOLVER_NAME}" STREQUAL "cachedResolver") set(AR_CACHEDRESOLVER_BUILD ON) endif() set(AR_CACHEDRESOLVER_USD_PLUGIN_NAME cachedResolver) @@ -56,7 +56,7 @@ set(AR_CACHEDRESOLVER_ENV_EXPOSE_RELATIVE_PATH_IDENTIFIERS "AR_EXPOSE_RELATIVE_P # Http Resolver option(AR_HTTPRESOLVER_BUILD "Build the HttpResolver" OFF) -if("$ENV{RESOLVER_NAME}" STREQUAL "httpResolver") +if("$ENV{AR_RESOLVER_NAME}" STREQUAL "httpResolver") set(AR_HTTPRESOLVER_BUILD ON) endif() set(AR_HTTPRESOLVER_USD_PLUGIN_NAME httpResolver) @@ -67,62 +67,122 @@ set(AR_HTTPRESOLVER_INSTALL_PREFIX ${AR_PROJECT_NAME}/${AR_HTTPRESOLVER_USD_PLUG # Arch if (WIN32) set(AR_ARCH_LIB_SUFFIX "dll") + set(AR_ARCH_PATH_SEP ";") else() set(AR_ARCH_LIB_SUFFIX "so") + set(AR_ARCH_PATH_SEP ":") endif() -# Houdini -set(AR_HOUDINI_ROOT $ENV{HFS} CACHE PATH "Houdini install directory") -if (WIN32) - set(AR_HOUDINI_LIB_DIR ${AR_HOUDINI_ROOT}/custom/houdini/dsolib) -else() - set(AR_HOUDINI_LIB_DIR ${AR_HOUDINI_ROOT}/dsolib) -endif() -set(AR_HOUDINI_INCLUDE_DIR ${AR_HOUDINI_ROOT}/toolkit/include) -# Usd -if (WIN32) - set(AR_PXR_LIB_DIR ${AR_HOUDINI_ROOT}/custom/houdini/dsolib) - set(AR_PXR_LIB_PREFIX "libpxr_") -else() - set(AR_PXR_LIB_DIR ${AR_HOUDINI_ROOT}/dsolib) - set(AR_PXR_LIB_PREFIX "pxr_") -endif() -set(AR_PXR_INCLUDE_DIR ${AR_HOUDINI_INCLUDE_DIR}) -# Python -if (WIN32) - if(EXISTS "${AR_HOUDINI_ROOT}/python310") - set(AR_PYTHON_LIB python3.10) - set(AR_PYTHON_LIB_NUMBER python310) +# DCC +# Per DCC we have to define the following variables: +# USD: AR_PXR_LIB_DIR, AR_PXR_LIB_PREFIX, AR_PXR_INCLUDE_DIR, AR_PXR_PYTHON_LIB_SITEPACKAGES +# Python: AR_PYTHON_LIB, AR_PYTHON_LIB_NUMBER, AR_PYTHON_INCLUDE_DIR, AR_PYTHON_EXECUTABLE +# Boost: AR_BOOST_NAMESPACE, AR_BOOST_PYTHON_LIB, AR_BOOST_INCLUDE_DIR +if("$ENV{AR_DCC_NAME}" STREQUAL "HOUDINI") + # Houdini + set(AR_HOUDINI_ROOT $ENV{HFS} CACHE PATH "Houdini install directory") + if (WIN32) + set(AR_HOUDINI_LIB_DIR ${AR_HOUDINI_ROOT}/custom/houdini/dsolib) else() - set(AR_PYTHON_LIB python3.9) - set(AR_PYTHON_LIB_NUMBER python39) + set(AR_HOUDINI_LIB_DIR ${AR_HOUDINI_ROOT}/dsolib) endif() -else() - if(EXISTS "${AR_HOUDINI_ROOT}/python/bin/python3.10") - set(AR_PYTHON_LIB python3.10) - set(AR_PYTHON_LIB_NUMBER python310) + set(AR_HOUDINI_INCLUDE_DIR ${AR_HOUDINI_ROOT}/toolkit/include) + # Python + if (WIN32) + if(EXISTS "${AR_HOUDINI_ROOT}/python310") + set(AR_PYTHON_LIB python3.10) + set(AR_PYTHON_LIB_NUMBER python310) + else() + set(AR_PYTHON_LIB python3.9) + set(AR_PYTHON_LIB_NUMBER python39) + endif() else() - set(AR_PYTHON_LIB python3.9) - set(AR_PYTHON_LIB_NUMBER python39) + if(EXISTS "${AR_HOUDINI_ROOT}/python/bin/python3.10") + set(AR_PYTHON_LIB python3.10) + set(AR_PYTHON_LIB_NUMBER python310) + else() + set(AR_PYTHON_LIB python3.9) + set(AR_PYTHON_LIB_NUMBER python39) + endif() endif() + if (WIN32) + set(AR_PYTHON_LIB_DIR ${AR_HOUDINI_ROOT}/${AR_PYTHON_LIB_NUMBER}/libs) + else() + set(AR_PYTHON_LIB_DIR ${AR_HOUDINI_ROOT}/python/lib) + endif() + set(AR_PYTHON_INCLUDE_DIR ${AR_HOUDINI_INCLUDE_DIR}/${AR_PYTHON_LIB}) + set(AR_PYTHON_EXECUTABLE ${AR_HOUDINI_ROOT}/python/bin/python) + # Boost + set(AR_BOOST_NAMESPACE hboost) + if (WIN32) + set(AR_BOOST_PYTHON_LIB ${AR_BOOST_NAMESPACE}_${AR_PYTHON_LIB_NUMBER}-mt-x64) + else() + set(AR_BOOST_PYTHON_LIB ${AR_BOOST_NAMESPACE}_${AR_PYTHON_LIB_NUMBER}) + endif() + set(AR_BOOST_INCLUDE_DIR ${AR_HOUDINI_INCLUDE_DIR}/${AR_BOOST_NAMESPACE}) + # Usd + if (WIN32) + set(AR_PXR_LIB_DIR ${AR_HOUDINI_ROOT}/custom/houdini/dsolib) + set(AR_PXR_LIB_PREFIX "libpxr_") + set(AR_PXR_PYTHON_LIB_SITEPACKAGES ${AR_HOUDINI_ROOT}/${AR_PYTHON_LIB_NUMBER}/lib/site-packages) + else() + set(AR_PXR_LIB_DIR ${AR_HOUDINI_ROOT}/dsolib) + set(AR_PXR_LIB_PREFIX "pxr_") + set(AR_PXR_PYTHON_LIB_SITEPACKAGES ${AR_HOUDINI_ROOT}/${AR_PYTHON_LIB_NUMBER}/lib/site-packages) + endif() + set(AR_PXR_INCLUDE_DIR ${AR_HOUDINI_INCLUDE_DIR}) +elseif("$ENV{AR_DCC_NAME}" STREQUAL "MAYA") + # Maya + set(AR_MAYA_USD_SDK_ROOT $ENV{MAYA_USD_SDK_ROOT} CACHE PATH "Maya USD SDK install directory") + set(AR_MAYA_USD_SDK_DEVKIT_ROOT $ENV{MAYA_USD_SDK_DEVKIT_ROOT} CACHE PATH "Maya USD SDK DevKit install directory") + set(AR_MAYA_USD_SDK_LIB_DIR ${AR_MAYA_USD_SDK_ROOT}/lib) + set(AR_MAYA_INCLUDE_DIR ${AR_MAYA_USD_SDK_DEVKIT_ROOT}/include) + # Python + set(AR_PYTHON_ROOT $ENV{PYTHON_ROOT} CACHE PATH "Python install directory") + if (WIN32) + if(EXISTS "${AR_MAYA_USD_SDK_LIB_DIR}/boost_python310-vc142-mt-x64-1_76.dll") + set(AR_PYTHON_LIB python3.10) + set(AR_PYTHON_LIB_NUMBER python310) + else() + message(FATAL_ERROR "Failed to find a compatible Python version.") + endif() + else() + if(EXISTS "${AR_MAYA_USD_SDK_LIB_DIR}/libboost_python310.so") + set(AR_PYTHON_LIB python3.10) + set(AR_PYTHON_LIB_NUMBER python310) + else() + message(FATAL_ERROR "Failed to find a compatible Python version.") + endif() + endif() + set(AR_PYTHON_LIB_DIR ${AR_PYTHON_ROOT}/lib) + if (WIN32) + set(AR_PYTHON_LIB_DIR ${AR_PYTHON_ROOT}/libs) + set(AR_PYTHON_INCLUDE_DIR ${AR_PYTHON_ROOT}/include) + else() + set(AR_PYTHON_LIB_DIR ${AR_PYTHON_ROOT}/lib) + set(AR_PYTHON_INCLUDE_DIR ${AR_PYTHON_ROOT}/include/${AR_PYTHON_LIB}) + endif() + set(AR_PYTHON_EXECUTABLE ${AR_PYTHON_ROOT}/bin/python3) + # Boost + set(AR_BOOST_NAMESPACE boost) + if (WIN32) + set(AR_BOOST_PYTHON_LIB ${AR_BOOST_NAMESPACE}_${AR_PYTHON_LIB_NUMBER}-vc142-mt-x64-1_76) + set(AR_BOOST_INCLUDE_DIR ${AR_MAYA_INCLUDE_DIR}/${AR_BOOST_NAMESPACE}-1_76) + else() + set(AR_BOOST_PYTHON_LIB ${AR_BOOST_NAMESPACE}_${AR_PYTHON_LIB_NUMBER}) + set(AR_BOOST_INCLUDE_DIR ${AR_MAYA_INCLUDE_DIR}/${AR_BOOST_NAMESPACE}) + endif() + # Usd + if (WIN32) + set(AR_PXR_LIB_DIR ${AR_MAYA_USD_SDK_DEVKIT_ROOT}/lib) + set(AR_PXR_LIB_PREFIX "usd_") + else() + set(AR_PXR_LIB_DIR ${AR_MAYA_USD_SDK_ROOT}/lib) + set(AR_PXR_LIB_PREFIX "usd_") + endif() + set(AR_PXR_INCLUDE_DIR ${AR_MAYA_USD_SDK_DEVKIT_ROOT}/include) + set(AR_PXR_PYTHON_LIB_SITEPACKAGES ${AR_MAYA_USD_SDK_ROOT}/lib/python) endif() -if (WIN32) - set(AR_PYTHON_LIB_DIR ${AR_HOUDINI_ROOT}/${AR_PYTHON_LIB_NUMBER}/libs) - set(AR_PYTHON_LIB_SITEPACKAGES ${AR_HOUDINI_ROOT}/${AR_PYTHON_LIB_NUMBER}/lib/site-packages) -else() - set(AR_PYTHON_LIB_DIR ${AR_HOUDINI_ROOT}/python/lib) - set(AR_PYTHON_LIB_SITEPACKAGES ${AR_PYTHON_LIB_DIR}/${AR_PYTHON_LIB}/site-packages) -endif() -set(AR_PYTHON_INCLUDE_DIR ${AR_HOUDINI_INCLUDE_DIR}/${AR_PYTHON_LIB}) -# Boost -set(AR_BOOST_NAMESPACE hboost) -if (WIN32) - set(AR_BOOST_PYTHON_LIB ${AR_BOOST_NAMESPACE}_${AR_PYTHON_LIB_NUMBER}-mt-x64) -else() - set(AR_BOOST_PYTHON_LIB ${AR_BOOST_NAMESPACE}_${AR_PYTHON_LIB_NUMBER}) -endif() -set(AR_BOOST_INCLUDE_DIR ${AR_HOUDINI_INCLUDE_DIR}/${AR_BOOST_NAMESPACE}) - ### Init ### cmake_minimum_required(VERSION 3.19 FATAL_ERROR) project(${AR_PROJECT_NAME} VERSION 1.0.0 LANGUAGES CXX) @@ -137,14 +197,14 @@ else() # Notes: # Houdini 20 - Switched to the new C++11 ABI for Linux https://www.sidefx.com/docs/houdini/news/20/platforms.html # For Houdini versions that use gcc 9.3, please set this to _GLIBCXX_USE_CXX11_ABI=0 - file(REAL_PATH ${AR_HOUDINI_ROOT} AR_HOUDINI_ROOT_RESOLVED) - string(FIND ${AR_HOUDINI_ROOT_RESOLVED} "19.5" AR_HOUDINI_ROOT_IS_H195) - if (${AR_HOUDINI_ROOT_IS_H195} STREQUAL "-1") - add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=1) - else() - message("Houdini 19.5 detected, switching to _GLIBCXX_USE_CXX11_ABI=0") - add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0) - endif() + #file(REAL_PATH ${AR_HOUDINI_ROOT} AR_HOUDINI_ROOT_RESOLVED) + #string(FIND ${AR_HOUDINI_ROOT_RESOLVED} "19.5" AR_HOUDINI_ROOT_IS_H195) + #if (${AR_HOUDINI_ROOT_IS_H195} STREQUAL "-1") + # add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=1) + #else() + # message("Houdini 19.5 detected, switching to _GLIBCXX_USE_CXX11_ABI=0") + # add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0) + #endif() endif() # Compiler Options # This is the same as set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHBOOST_ALL_NO_LIB -D_GLIBCXX_USE_CXX11_ABI=0") diff --git a/build.bat b/build.bat index 363e552..e32afe0 100644 --- a/build.bat +++ b/build.bat @@ -3,7 +3,9 @@ cls REM Source environment (Uncomment lines starting with "set" if you current env does not have these defined.) REM set HFS=C:\Program Files\Side Effects Software\ REM Define Resolver > Has to be one of 'fileResolver'/'pythonResolver'/'cachedResolver'/'httpResolver' -REM set RESOLVER_NAME=fileResolver +REM AR_RESOLVER_NAME=cachedResolver +REM Define App +REM set AR_DCC_NAME=HOUDINI REM Clear existing build data and invoke cmake rmdir /S /Q build rmdir /S /Q dist diff --git a/build.sh b/build.sh old mode 100755 new mode 100644 index e7ff502..b9ce6ee --- a/build.sh +++ b/build.sh @@ -3,7 +3,9 @@ clear # Source environment (Uncomment lines starting with "export" if you current env does not have these defined.) # export HFS=/opt/ # Define Resolver > Has to be one of 'fileResolver'/'pythonResolver'/'cachedResolver'/'httpResolver' -# export RESOLVER_NAME=cachedResolver +# export AR_RESOLVER_NAME=cachedResolver +# Define App +# export AR_DCC_NAME=HOUDINI # Clear existing build data and invoke cmake rm -R build rm -R dist diff --git a/docs.sh b/docs.sh old mode 100755 new mode 100644 diff --git a/setup.sh b/setup.sh index 4e7343b..a5b4690 100644 --- a/setup.sh +++ b/setup.sh @@ -5,27 +5,35 @@ then export REPO_SOURCED=1 export REPO_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && (pwd -W 2> /dev/null || pwd)) # Define Resolver > Has to be one of 'fileResolver'/'pythonResolver'/'cachedResolver'/'httpResolver' - export RESOLVER_NAME=cachedResolver - export RESOLVER_NAME_UPPERCASE=$(echo ${RESOLVER_NAME} | tr '[:lower:]' '[:upper:]') - # Source Houdini (This defines what Houdini version to compile against) - pushd /opt/hfs20.0 > /dev/null - source houdini_setup - popd > /dev/null - export HOUDINI_LMINFO_VERBOSE=1 + export AR_RESOLVER_NAME=cachedResolver + export AR_RESOLVER_NAME_UPPERCASE=$(echo ${AR_RESOLVER_NAME} | tr '[:lower:]' '[:upper:]') + # DCC + export AR_DCC_NAME=HOUDINI + if [ "$AR_DCC_NAME" == "HOUDINI" ]; then + # Source Houdini (This defines what Houdini version to compile against) + pushd /opt/hfs20.0 > /dev/null + source houdini_setup + popd > /dev/null + fi + if [ "$AR_DCC_NAME" == "MAYA" ]; then + export MAYA_USD_SDK_ROOT="/path/to/maya/usd/sdk/root/.../mayausd/USD" + export MAYA_USD_SDK_DEVKIT_ROOT="/path/to/maya/usd/sdk/root/.../content/of/devkit.zip" + export PYTHON_ROOT="/path/to/python/root" + fi # Source env - export PYTHONPATH=${REPO_ROOT}/dist/${RESOLVER_NAME}/lib/python:${PYTHONPATH} - export PXR_PLUGINPATH_NAME=${REPO_ROOT}/dist/${RESOLVER_NAME}/resources:${PXR_PLUGINPATH_NAME} - export LD_LIBRARY_PATH=${REPO_ROOT}/dist/${RESOLVER_NAME}/lib:${LD_LIBRARY_PATH} + export PYTHONPATH=${REPO_ROOT}/dist/${AR_RESOLVER_NAME}/lib/python:${PYTHONPATH} + export PXR_PLUGINPATH_NAME=${REPO_ROOT}/dist/${AR_RESOLVER_NAME}/resources:${PXR_PLUGINPATH_NAME} + export LD_LIBRARY_PATH=${REPO_ROOT}/dist/${AR_RESOLVER_NAME}/lib:${LD_LIBRARY_PATH} alias usdpython="$HFS/python/bin/python $@" # Configure resolver export AR_SEARCH_PATHS=${REPO_ROOT}/files/generic export AR_SEARCH_REGEX_EXPRESSION="(bo)" export AR_SEARCH_REGEX_FORMAT="Bo" # Debug - # export TF_DEBUG=${RESOLVER_NAME_UPPERCASE}_RESOLVER + # export TF_DEBUG=${AR_RESOLVER_NAME_UPPERCASE}_RESOLVER export TF_DEBUG=AR_RESOLVER_INIT # Log - echo "The resolver environment for resolver '${RESOLVER_NAME}' has been initialized." + echo "The resolver environment for resolver '${AR_RESOLVER_NAME}' has been initialized." fi diff --git a/src/CachedResolver/CMakeLists.txt b/src/CachedResolver/CMakeLists.txt index 4d9b774..7202090 100644 --- a/src/CachedResolver/CMakeLists.txt +++ b/src/CachedResolver/CMakeLists.txt @@ -119,12 +119,12 @@ install( DESTINATION ${AR_CACHEDRESOLVER_USD_PLUGIN_NAME}/lib/python/${AR_RESOLVER_USD_PYTHON_MODULE_NAME}/${AR_CACHEDRESOLVER_USD_PYTHON_MODULE_NAME} ) -# ### Tests ### +### Tests ### set(TESTS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/testenv) -set(TESTS_ENV_PYTHONPATH "PYTHONPATH=${CMAKE_INSTALL_PREFIX}/${AR_CACHEDRESOLVER_USD_PLUGIN_NAME}/lib/python") +set(TESTS_ENV_PYTHONPATH "PYTHONPATH=${CMAKE_INSTALL_PREFIX}/${AR_CACHEDRESOLVER_USD_PLUGIN_NAME}/lib/python${AR_ARCH_PATH_SEP}${AR_PXR_PYTHON_LIB_SITEPACKAGES}") set(TESTS_ENV_PXR_PLUGINPATH_NAME "PXR_PLUGINPATH_NAME=${CMAKE_INSTALL_PREFIX}/${AR_CACHEDRESOLVER_USD_PLUGIN_NAME}/resources") set(TESTS_ENV_LD_LIBRARY_PATH "LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/${AR_CACHEDRESOLVER_USD_PLUGIN_NAME}/lib") -set(TESTS_PYTHON_COMMAND $ENV{HFS}/python/bin/python -B -m unittest discover ${TESTS_SOURCE_DIR}) +set(TESTS_PYTHON_COMMAND ${AR_PYTHON_EXECUTABLE} -B -m unittest discover ${TESTS_SOURCE_DIR}) add_test( NAME testCachedResolver diff --git a/src/FileResolver/CMakeLists.txt b/src/FileResolver/CMakeLists.txt index d47e292..c7ece14 100644 --- a/src/FileResolver/CMakeLists.txt +++ b/src/FileResolver/CMakeLists.txt @@ -105,13 +105,13 @@ install( ### Tests ### set(TESTS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/testenv) -set(TESTS_ENV_PYTHONPATH "PYTHONPATH=${CMAKE_INSTALL_PREFIX}/${AR_FILERESOLVER_USD_PLUGIN_NAME}/lib/python") +set(TESTS_ENV_PYTHONPATH "PYTHONPATH=${CMAKE_INSTALL_PREFIX}/${AR_FILERESOLVER_USD_PLUGIN_NAME}/lib/python${AR_ARCH_PATH_SEP}${AR_PXR_PYTHON_LIB_SITEPACKAGES}") set(TESTS_ENV_PXR_PLUGINPATH_NAME "PXR_PLUGINPATH_NAME=${CMAKE_INSTALL_PREFIX}/${AR_FILERESOLVER_USD_PLUGIN_NAME}/resources") set(TESTS_ENV_LD_LIBRARY_PATH "LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/${AR_FILERESOLVER_USD_PLUGIN_NAME}/lib") set(TESTS_ENV_AR_SEARCH_PATHS "AR_SEARCH_PATHS=/env/search/pathA:/env/search/pathB") set(TESTS_ENV_AR_SEARCH_REGEX_EXPRESSION "AR_SEARCH_REGEX_EXPRESSION=(v\\d\\d\\d)") set(TESTS_ENV_AR_SEARCH_REGEX_FORMAT "AR_SEARCH_REGEX_FORMAT=v000") -set(TESTS_PYTHON_COMMAND $ENV{HFS}/python/bin/python -B -m unittest discover ${TESTS_SOURCE_DIR}) +set(TESTS_PYTHON_COMMAND ${AR_PYTHON_EXECUTABLE} -B -m unittest discover ${TESTS_SOURCE_DIR}) add_test( NAME testFileResolver