Skip to content

Commit

Permalink
Code review comments:
Browse files Browse the repository at this point in the history
* My change to 'strategyBase.h' is now gone since it was fixed in dev.
* Added 'uic' to list of pyside executables.
* Added quotes for boost defines.
* Renamed "PXR_DEFINE_BOOST_DEBUG_PYTHON_FLAG" -> "PXR_USE_DEBUG_PYTHON".
* Removed /MP flag.
* Made --build-{debug/release/relwithdebug} mutually exclusive.
* Added documentation for --build-python-info flag.
  • Loading branch information
seando-adsk committed Aug 18, 2021
1 parent 3666cca commit 5bf5247
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 46 deletions.
25 changes: 5 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,16 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
${CMAKE_SOURCE_DIR}/cmake/macros)

include(Options)
# If we were given a python executable, we'll extract the name from that to use in
# the python shebang replacement. This will make these files more portable by not
# having some full path to a python executable which may not exist on another machine.
if (DEFINED PYTHON_EXECUTABLE)
get_filename_component(PYTHON_EXE_BASENAME ${PYTHON_EXECUTABLE} NAME)
endif()

include(ProjectDefaults)
include(Packages)

# This has to be defined after Packages is included, because it relies on the
# discovered path to the python executable.
if (DEFINED PYTHON_EXE_BASENAME)
set(PXR_PYTHON_SHEBANG "${PYTHON_EXE_BASENAME}"
CACHE
STRING
"Replacement path for Python #! line."
)
else()
set(PXR_PYTHON_SHEBANG "${PYTHON_EXECUTABLE}"
CACHE
STRING
"Replacement path for Python #! line."
)
endif()
set(PXR_PYTHON_SHEBANG "${PYTHON_EXECUTABLE}"
CACHE
STRING
"Replacement path for Python #! line."
)

# CXXDefaults will set a variety of variables for the project.
# Consume them here. This is an effort to keep the most common
Expand Down
41 changes: 23 additions & 18 deletions build_scripts/build_usd.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def FormatMultiProcs(numJobs, generator):
tag = "-j"
if generator:
if "Visual Studio" in generator:
tag = "/M:" # This will build multiple projects at once. Also add /MP to CXX_FLAGS (below).
tag = "/M:" # This will build multiple projects at once.
elif "Xcode" in generator:
tag = "-j "

Expand Down Expand Up @@ -363,9 +363,6 @@ def RunCMake(context, force, extraArgs = None):
if IsVisualStudio2019OrGreater():
generator = generator + " -A x64"

if generator and 'Visual Studio' in generator:
generator += ' -DCMAKE_CXX_FLAGS_INIT="/MP{procs}"'.format(procs=context.numJobs)

toolset = context.cmakeToolset
if toolset is not None:
toolset = '-T "{toolset}"'.format(toolset=toolset)
Expand Down Expand Up @@ -1370,9 +1367,9 @@ def InstallUSD(context, force, buildArgs):
# debugging into python land is not what they want which can be done by setting the
# debugPython
if context.buildDebug and context.debugPython:
extraArgs.append('-DPXR_DEFINE_BOOST_DEBUG_PYTHON_FLAG=ON')
extraArgs.append('-DPXR_USE_DEBUG_PYTHON=ON')
else:
extraArgs.append('-DPXR_DEFINE_BOOST_DEBUG_PYTHON_FLAG=OFF')
extraArgs.append('-DPXR_USE_DEBUG_PYTHON=OFF')

# CMake has trouble finding the executable, library, and include
# directories when there are multiple versions of Python installed.
Expand Down Expand Up @@ -1561,6 +1558,11 @@ def InstallUSD(context, force, buildArgs):
built using the DCC's version of Python and not the system version. This can be
done by running %(prog)s using the DCC's version of Python.
The flag --build-python-info allows calling the %(prog)s with any python (such as
system python) but pass in the python that you want USD to use to build the python
bindings with. This flag takes 4 arguments: python executable, python include directory
python library and python version.
For example, to build USD on macOS for use in Maya 2019, run:
/Applications/Autodesk/maya2019/Maya.app/Contents/bin/mayapy %(prog)s --no-usdview ...
Expand Down Expand Up @@ -1598,14 +1600,17 @@ def InstallUSD(context, force, buildArgs):
help=("Build directory for USD and 3rd-party dependencies "
"(default: <install_dir>/build)"))

group.add_argument("--build-debug", dest="build_debug", action="store_true",
help="Build in Debug mode")

group.add_argument("--build-release", dest="build_release", action="store_true",
help="Build in Release mode")

group.add_argument("--build-relwithdebug", dest="build_relwithdebug", action="store_true",
help="Build in RelWithDebInfo mode")
(BUILD_DEBUG, BUILD_RELEASE, BUILD_RELWITHDEBUG) = (0, 1, 2)
subgroup = group.add_mutually_exclusive_group()
subgroup.add_argument("--build-debug", dest="build_variant",
action="store_const", const=BUILD_DEBUG, default=BUILD_RELWITHDEBUG,
help="Build in Debug mode")
subgroup.add_argument("--build-release", dest="build_variant",
action="store_const", const=BUILD_RELEASE,
help="Build in Release mode")
subgroup.add_argument("--build-relwithdebug", dest="build_variant",
action="store_const", const=BUILD_RELWITHDEBUG,
help="Build in RelWithDebInfo mode (default)")

group.add_argument("--build-args", type=str, nargs="*", default=[],
help=("Custom arguments to pass to build system when "
Expand Down Expand Up @@ -1858,9 +1863,9 @@ def __init__(self, args):
self.build_python_info['PYTHON_VERSION'] = args.build_python_info[3]

# Build type
self.buildDebug = args.build_debug;
self.buildRelease = args.build_release;
self.buildRelWithDebug = args.build_relwithdebug;
self.buildDebug = (args.build_variant == BUILD_DEBUG);
self.buildRelease = (args.build_variant == BUILD_RELEASE);
self.buildRelWithDebug = (args.build_variant == BUILD_RELWITHDEBUG);

self.debugPython = args.debug_python

Expand Down Expand Up @@ -2075,7 +2080,7 @@ def _JoinVersion(v):
# The USD build will skip building usdview if pyside2-uic or pyside-uic is
# not found, so check for it here to avoid confusing users. This list of
# PySide executable names comes from cmake/modules/FindPySide.cmake
pyside2Uic = ["pyside2-uic", "python2-pyside2-uic", "pyside2-uic-2.7"]
pyside2Uic = ["pyside2-uic", "python2-pyside2-uic", "pyside2-uic-2.7", "uic"]
found_pyside2Uic = any([which(p) for p in pyside2Uic])
pysideUic = ["pyside-uic", "python2-pyside-uic", "pyside-uic-2.7"]
found_pysideUic = any([which(p) for p in pysideUic])
Expand Down
2 changes: 1 addition & 1 deletion cmake/defaults/Options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ option(PXR_ENABLE_MATERIALX_SUPPORT "Enable MaterialX support" OFF)
option(PXR_BUILD_DOCUMENTATION "Generate doxygen documentation" OFF)
option(PXR_ENABLE_PYTHON_SUPPORT "Enable Python based components for USD" ON)
option(PXR_USE_PYTHON_3 "Build Python bindings for Python 3" OFF)
option(PXR_USE_DEBUG_PYTHON "Build with debug python" OFF)
option(PXR_ENABLE_HDF5_SUPPORT "Enable HDF5 backend in the Alembic plugin for USD" ON)
option(PXR_ENABLE_OSL_SUPPORT "Enable OSL (OpenShadingLanguage) based components" OFF)
option(PXR_ENABLE_PTEX_SUPPORT "Enable Ptex support" ON)
option(PXR_ENABLE_OPENVDB_SUPPORT "Enable OpenVDB support" OFF)
option(PXR_ENABLE_NAMESPACES "Enable C++ namespaces." ON)
option(PXR_DEFINE_BOOST_DEBUG_PYTHON_FLAG "Define BOOST_DEBUG_PYTHON flag." OFF)
option(PXR_PREFER_SAFETY_OVER_SPEED
"Enable certain checks designed to avoid crashes or out-of-bounds memory reads with malformed input files. These checks may negatively impact performance."
ON)
Expand Down
2 changes: 1 addition & 1 deletion cmake/defaults/Packages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ if(PXR_ENABLE_PYTHON_SUPPORT)
find_package(PythonLibs 2.7 REQUIRED)
endif()

if(WIN32 AND PXR_DEFINE_BOOST_DEBUG_PYTHON_FLAG)
if(WIN32 AND PXR_USE_DEBUG_PYTHON)
set(Boost_USE_DEBUG_PYTHON ON)
endif()

Expand Down
6 changes: 3 additions & 3 deletions cmake/defaults/msvcdefaults.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ if (NOT Boost_USE_STATIC_LIBS)
_add_define("BOOST_ALL_DYN_LINK")
endif()

if(${PXR_DEFINE_BOOST_DEBUG_PYTHON_FLAG})
_add_define(BOOST_DEBUG_PYTHON)
_add_define(BOOST_LINKING_PYTHON)
if(${PXR_USE_DEBUG_PYTHON})
_add_define("BOOST_DEBUG_PYTHON")
_add_define("BOOST_LINKING_PYTHON")
endif()

# Need half::_toFloat and half::_eLut.
Expand Down
4 changes: 2 additions & 2 deletions cmake/macros/Private.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function(_get_python_module_name LIBRARY_FILENAME MODULE_NAME)
# or _tf.pyd/_tf_d.pyd for Python module libraries.
# We want to strip off the leading "_" and the trailing "_d".
set(LIBNAME ${LIBRARY_FILENAME})
if (PXR_DEFINE_BOOST_DEBUG_PYTHON_FLAG)
if (PXR_USE_DEBUG_PYTHON)
string(REGEX REPLACE "_d$" "" LIBNAME ${LIBNAME})
endif()
string(REGEX REPLACE "^_" "" LIBNAME ${LIBNAME})
Expand Down Expand Up @@ -900,7 +900,7 @@ function(_pxr_python_module NAME)
return()
endif()

if (WIN32 AND PXR_DEFINE_BOOST_DEBUG_PYTHON_FLAG)
if (WIN32 AND PXR_USE_DEBUG_PYTHON)
# On Windows when compiling with debug python the library must be named with _d.
set(LIBRARY_NAME "_${NAME}_d")
else()
Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/FindPySide.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ execute_process(
)
if (pySideImportResult EQUAL 0)
set(pySideImportResult "PySide2")
set(pySideUIC pyside2-uic python2-pyside2-uic pyside2-uic-2.7)
set(pySideUIC pyside2-uic python2-pyside2-uic pyside2-uic-2.7 uic)
endif()

# PySide2 not found OR PYSIDE explicitly requested
Expand Down

0 comments on commit 5bf5247

Please sign in to comment.