Skip to content
Draft
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ if (BUILD_USDGENSCHEMA_ARNOLD)
add_subdirectory(tools/usdgenschema)
endif()

if (BUILD_TURNTABLE)
message(STATUS "Building turntable tool")
add_subdirectory(tools/turntable)
endif()

# Building the schemas
if (BUILD_SCHEMAS)
add_subdirectory(schemas)
Expand Down
43 changes: 42 additions & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ vars.AddVariables(
BoolVariable('ENABLE_HYDRA2_RENDERSETTINGS', 'Enable the use of RenderSettings hydra prim', False),
BoolVariable('BUILD_USDGENSCHEMA_ARNOLD', 'Whether or not to build the simplified usdgenschema', False),
BoolVariable('IGNORE_ARCH_FLAGS', 'Ignore the arch flags when compiling usdgenschema', False),
BoolVariable('BUILD_TURNTABLE', 'Whether or not to build the turntable tool', False),
StringVariable('BOOST_LIB_NAME', 'Boost library name pattern', 'boost_%s'),
StringVariable('TBB_LIB_NAME', 'TBB library name pattern', '%s'),
StringVariable('USD_MONOLITHIC_LIBRARY', 'Name of the USD monolithic library', 'usd_ms'),
Expand Down Expand Up @@ -189,6 +190,7 @@ def get_optional_env_path(env_name):
USD_BUILD_MODE = env['USD_BUILD_MODE']

BUILD_USDGENSCHEMA_ARNOLD = env['BUILD_USDGENSCHEMA_ARNOLD']
BUILD_TURNTABLE = env['BUILD_TURNTABLE']
BUILD_RENDER_DELEGATE = env['BUILD_RENDER_DELEGATE'] if USD_BUILD_MODE != 'static' or env['ENABLE_HYDRA_IN_USD_PROCEDURAL'] else False
BUILD_PROCEDURAL = env['BUILD_PROCEDURAL']
BUILD_TESTSUITE = env['BUILD_TESTSUITE']
Expand Down Expand Up @@ -554,6 +556,8 @@ else:
#
usdgenschema_script = os.path.join('tools', 'usdgenschema', 'SConscript')
usdgenschema_build = os.path.join(BUILD_BASE_DIR, 'usdgenschema')
turntable_script = os.path.join('tools', 'turntable', 'SConscript')
turntable_build = os.path.join(BUILD_BASE_DIR, 'turntable')

# common
env.Append(CPPPATH = [os.path.join(env['ROOT_DIR'], 'libs', 'common')])
Expand Down Expand Up @@ -632,9 +636,38 @@ if BUILD_USDGENSCHEMA_ARNOLD:
shutil.copytree(source_dir, target_dir)
# Also copy the plugInfo.
shutil.copy2(os.path.join(USD_LIB, 'usd', 'plugInfo.json'), usd_target_resource_folder)
else:
else:
USDGENSCHEMA_ARNOLD = None

if BUILD_TURNTABLE:
TURNTABLE = env.SConscript(turntable_script, variant_dir = turntable_build, duplicate = 0, exports = 'env')
SConscriptChdir(0)
turntable_hdri_resource_folder = os.path.join(os.path.dirname(os.path.abspath(str(TURNTABLE[0]))), 'hdri')
turntable_hdri_source_folder = os.path.join('tools', 'turntable', 'hdri')
if os.path.exists(turntable_hdri_source_folder) and not os.path.exists(turntable_hdri_resource_folder):
shutil.copytree(turntable_hdri_source_folder, turntable_hdri_resource_folder)
if env['USD_BUILD_MODE'] == 'static':
# For static USD builds, copy the usd plugin config folder next to the binary.
turntable_usd_resource_folder = os.path.join(os.path.dirname(os.path.abspath(str(TURNTABLE[0]))), 'usd')
usd_input_resource_folders = [os.path.join(USD_LIB, 'usd'), os.path.join(turntable_build, 'usd')]
for usd_input_resource_folder in usd_input_resource_folders:
if os.path.exists(usd_input_resource_folder):
for entry in os.listdir(usd_input_resource_folder):
source_dir = os.path.join(usd_input_resource_folder, entry)
target_dir = os.path.join(turntable_usd_resource_folder, entry)
if os.path.isdir(source_dir) and not os.path.exists(target_dir):
shutil.copytree(source_dir, target_dir)
shutil.copy2(os.path.join(USD_LIB, 'usd', 'plugInfo.json'), turntable_usd_resource_folder)
# Also copy USD_PATH/plugin/usd (contains adskAssetResolver and other USD-distribution plugins).
usd_plugin_resource_folder = os.path.join(USD_PATH, 'plugin', 'usd')
if os.path.exists(usd_plugin_resource_folder):
for entry in os.listdir(usd_plugin_resource_folder):
source_dir = os.path.join(usd_plugin_resource_folder, entry)
target_dir = os.path.join(turntable_usd_resource_folder, entry)
if os.path.isdir(source_dir) and not os.path.exists(target_dir):
shutil.copytree(source_dir, target_dir)
else:
TURNTABLE = None

if BUILD_SCHEMAS:
SCHEMAS = env.SConscript(schemas_script,
Expand Down Expand Up @@ -902,6 +935,14 @@ if DOCS:
INSTALL_DOCS = env.Install(PREFIX_DOCS, DOCS)
env.Alias('docs-install', INSTALL_DOCS)

if TURNTABLE:
INSTALL_TURNTABLE = env.Install(PREFIX_BIN, TURNTABLE)
if os.path.exists(turntable_hdri_resource_folder):
INSTALL_TURNTABLE += env.Install(PREFIX_BIN, turntable_hdri_resource_folder)
if env['USD_BUILD_MODE'] == 'static':
INSTALL_TURNTABLE += env.Install(PREFIX_BIN, turntable_usd_resource_folder)
env.Alias('turntable-install', INSTALL_TURNTABLE)

# We don't need to install the license if the prefix is left to its default #553
if PREFIX != '.':
INSTALL_LICENSE = env.Install(PREFIX, 'LICENSE.md')
Expand Down
1 change: 1 addition & 0 deletions cmake/utils/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ option(BUILD_DOCS "Builds the Documentation" OFF)
option(BUILD_TESTSUITE "Builds the testsuite" OFF)
option(BUILD_UNIT_TESTS "Build the unit tests" OFF)
option(BUILD_USDGENSCHEMA_ARNOLD "Build and use a custom usdgenschema" OFF)
option(BUILD_TURNTABLE "Build the turntable tool" OFF)

# Configurations:
option(ENABLE_HYDRA_IN_USD_PROCEDURAL "Enable hydra in the procedural" ON)
Expand Down
63 changes: 63 additions & 0 deletions tools/turntable/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
set(SRC main.cpp)

add_executable(turntable ${SRC})

add_custom_command(TARGET turntable POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${CMAKE_CURRENT_SOURCE_DIR}/hdri"
"$<TARGET_FILE_DIR:turntable>/hdri")

target_include_directories(turntable PRIVATE
"${USD_INCLUDE_DIR}"
"${USD_TRANSITIVE_INCLUDE_DIRS}"
"${TBB_INCLUDE_DIRS}"
"${Boost_INCLUDE_DIRS}"
"${CMAKE_CURRENT_SOURCE_DIR}"
)

# Mirror the static/shared linking pattern used by usdgenschema and the translator.
if (BUILD_WITH_USD_STATIC)
set(_staticlibs ${USD_usd_m_LIBRARY})
list(APPEND _staticlibs ${USD_TRANSITIVE_STATIC_LIBS})
list(REMOVE_DUPLICATES _staticlibs)
if (WIN32)
foreach(USD_M_LIB ${_staticlibs})
if(EXISTS ${USD_M_LIB})
target_link_options(turntable PRIVATE "-WHOLEARCHIVE:${USD_M_LIB}")
else()
target_link_libraries(turntable PRIVATE ${USD_M_LIB})
endif()
endforeach()
else ()
list(JOIN _staticlibs "," _staticlibs)
if (LINUX)
target_link_libraries(turntable PRIVATE dl pthread)
target_link_options(turntable PRIVATE "-Wl,--whole-archive,${_staticlibs},--no-whole-archive")
else () # APPLE
target_link_options(turntable PRIVATE "-Wl,-all_load,${_staticlibs}")
endif ()
endif ()
else () # USD shared lib build
if (USD_MONOLITHIC_BUILD)
target_link_libraries(turntable PRIVATE usd_ms)
else ()
if (LINUX)
target_link_libraries(turntable PRIVATE dl pthread)
endif ()
target_link_libraries(turntable PRIVATE tf;sdf;usd;usdGeom;usdLux;usdRender;usdShade)
endif ()
endif ()

install(TARGETS turntable DESTINATION "${PREFIX_BIN}")
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/hdri"
DESTINATION "${PREFIX_BIN}")

if (BUILD_WITH_USD_STATIC)
install(DIRECTORY "${USD_LIBRARY_DIR}/usd"
DESTINATION "${PREFIX_BIN}")
# Also install USD_LOCATION/plugin/usd (contains adskAssetResolver and other USD-distribution plugins).
if (EXISTS "${USD_LOCATION}/plugin/usd")
install(DIRECTORY "${USD_LOCATION}/plugin/usd"
DESTINATION "${PREFIX_BIN}")
endif ()
endif ()
99 changes: 99 additions & 0 deletions tools/turntable/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
from utils import system, dependencies
from utils.dependencies import get_tbb_lib, add_optional_libs

from utils.build_tools import find_files_recursive, link_usd_libraries
import os
import os.path

Import('env')
local_env = env.Clone()

src_base_dir = os.path.join(local_env['ROOT_DIR'], 'tools/turntable')
source_files = find_files_recursive(src_base_dir, ['.c', '.cpp'])

# Reset inherited include paths: this tool only needs USD, not Arnold.
includePaths = [
'.',
local_env['USD_INCLUDE'],
]
for opt in ['BOOST_INCLUDE', 'TBB_INCLUDE']:
val = local_env.get(opt)
if val:
includePaths.append(val)
local_env['CPPPATH'] = includePaths

usd_deps = None
# Shared monolithic
if local_env['USD_BUILD_MODE'] == 'monolithic':
usd_deps = [
local_env['USD_MONOLITHIC_LIBRARY'],
get_tbb_lib(local_env),
]
if system.is_linux:
usd_deps = usd_deps + ['dl', 'pthread']
usd_deps = add_optional_libs(local_env, usd_deps)

# Static monolithic
elif local_env['USD_BUILD_MODE'] == 'static':
if system.is_windows:
usd_deps = [
'-WHOLEARCHIVE:libusd_m',
'Ws2_32',
'Dbghelp',
'Shlwapi',
'advapi32'
]
if not local_env['TBB_STATIC']:
usd_deps += [get_tbb_lib(local_env)]

extra_static_libs = local_env["EXTRA_STATIC_LIBS"]
if extra_static_libs:
extra_static_libs_list = extra_static_libs.split(';')
for extra_lib in extra_static_libs_list:
usd_deps.append('-WHOLEARCHIVE:{}'.format(extra_lib))
else:
whole_archives = ['%s/libusd_m.a' % local_env.subst(local_env['USD_LIB'])]
if local_env['TBB_STATIC']:
whole_archives.append('%s/libtbb.a' % local_env.subst(local_env['TBB_LIB']))
else:
usd_deps = [get_tbb_lib(local_env)]
whole_archives.extend(local_env["EXTRA_STATIC_LIBS"].split(';'))
if system.is_linux:
local_env.Append(LINKFLAGS=['-Wl,--whole-archive,%s,--no-whole-archive' % ','.join(whole_archives)])
local_env.Append(LIBS = ['dl', 'pthread'])
elif system.is_darwin:
for whole_archive in whole_archives:
local_env.Append(LINKFLAGS=['-Wl,-force_load,{}'.format(whole_archive)])
extra_frameworks = local_env['EXTRA_FRAMEWORKS']
if extra_frameworks:
extra_frameworks = extra_frameworks.split(';')
local_env.Append(FRAMEWORKS = extra_frameworks)

# Shared libs
else:
usd_libs = [
'ar',
'arch',
'plug',
'tf',
'vt',
'sdf',
'usd',
'usdGeom',
'usdLux',
'usdRender',
'usdShade',
]
usd_libs, _ = link_usd_libraries(local_env, usd_libs)
usd_deps = [get_tbb_lib(local_env)]
if system.is_linux:
usd_deps = usd_deps + ['dl']
usd_deps = usd_deps + usd_libs
add_optional_libs(local_env, usd_deps)

if usd_deps:
local_env.Append(LIBS = usd_deps)

TURNTABLE = local_env.Program('turntable', source_files)

Return('TURNTABLE')
Binary file not shown.
Loading