Commit: c455e55b5524fdc0e011f17ff2a1a726802453f1 Author: Sybren A. Stüvel Date: Fri Nov 29 11:18:30 2019 +0100 Branches: temp-sybren-usd-patch-02 https://developer.blender.org/rBc455e55b5524fdc0e011f17ff2a1a726802453f1
USD: Check location of USD JSON files in unit tests This commit adds a test to see whether the USD JSON files can be found and loaded. Simply the ability to create a USD Stage for a specific filename means that the extension has been recognised by the USD library, and that a USD plugin has been loaded to write such files. USD has been patched to not only look in `{exe_directory}/lib/usd`, but also in `{exe_directory}/../lib/usd`; the latter is required to resolve the path for test executables in `bin/tests/`. =================================================================== M build_files/build_environment/patches/usd.diff M source/creator/CMakeLists.txt M tests/gtests/usd/CMakeLists.txt A tests/gtests/usd/usd_stage_creation_test.cc =================================================================== diff --git a/build_files/build_environment/patches/usd.diff b/build_files/build_environment/patches/usd.diff index d5a4d286e5e..edc0815f414 100644 --- a/build_files/build_environment/patches/usd.diff +++ b/build_files/build_environment/patches/usd.diff @@ -24,7 +24,7 @@ index 9be215b36..0ce6e6fd5 100644 # --math diff --git a/pxr/base/lib/plug/initConfig.cpp b/pxr/base/lib/plug/initConfig.cpp -index 91d01cadc..8b29aa493 100644 +index 91d01cadc..61bb6de84 100644 --- a/pxr/base/lib/plug/initConfig.cpp +++ b/pxr/base/lib/plug/initConfig.cpp @@ -33,6 +33,7 @@ @@ -35,21 +35,41 @@ index 91d01cadc..8b29aa493 100644 PXR_NAMESPACE_OPEN_SCOPE -@@ -83,6 +84,14 @@ ARCH_CONSTRUCTOR(Plug_InitConfig, 2, void) +@@ -83,6 +84,20 @@ ARCH_CONSTRUCTOR(Plug_InitConfig, 2, void) sharedLibPath = TfGetPathName(sharedLibPath); + // Executable location, which is relevant when using static linking. + boost::filesystem::path executablePath = boost::dll::program_location(); + if (!executablePath.empty()) { ++ boost::filesystem::path pluginPath; ++ + // The path MUST end in a slash, or symlinks will not be treated as directory. -+ boost::filesystem::path pluginPath = executablePath.parent_path() / "usd/"; ++ // Two paths are added, one for relative to Blender, one for relative to unit tests. ++ pluginPath = executablePath.parent_path() / "lib/usd/"; ++ result.push_back(pluginPath.string()); ++ ++ pluginPath = executablePath.parent_path().parent_path() / "lib/usd/"; + result.push_back(pluginPath.string()); + } + // Environment locations. _AppendPathList(&result, TfGetenv(pathEnvVarName), sharedLibPath); +@@ -94,6 +109,13 @@ ARCH_CONSTRUCTOR(Plug_InitConfig, 2, void) + _AppendPathList(&result, installLocation, sharedLibPath); + #endif // PXR_INSTALL_LOCATION + ++ if (!TfGetenv("PXR_PATH_DEBUG").empty()) { ++ printf("USD Plugin paths: (%zu in total):\n", result.size()); ++ for(const std::string &path : result) { ++ printf(" %s\n", path.c_str()); ++ } ++ } ++ + Plug_SetPaths(result); + } + diff --git a/pxr/usd/CMakeLists.txt b/pxr/usd/CMakeLists.txt index c894cca37..df087a418 100644 --- a/pxr/usd/CMakeLists.txt diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 1975eee2ef0..252c66201d3 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -1064,11 +1064,12 @@ setup_liblinks(blender) # ----------------------------------------------------------------------------- # USD registry. # USD requires a set of JSON files that define the standard schemas. These -# files are required at runtime. +# files are required at runtime, and will be installed into 'lib/usd' next +# to the Blender executable. if (WITH_USD) install(DIRECTORY ${LIBDIR}/usd/lib/usd - DESTINATION "." + DESTINATION "lib" ) endif() diff --git a/tests/gtests/usd/CMakeLists.txt b/tests/gtests/usd/CMakeLists.txt index a0416c80b64..60f2f0e6477 100644 --- a/tests/gtests/usd/CMakeLists.txt +++ b/tests/gtests/usd/CMakeLists.txt @@ -18,6 +18,12 @@ # All rights reserved. # ***** END GPL LICENSE BLOCK ***** +# This suppresses the warning "This file includes at least one deprecated or antiquated header which +# may be removed without further notice at a future date", which is caused by the USD library +# including <ext/hash_set>. Nothing we can do about that until they change what +# they include, so this just suppresses it. +add_definitions(-D_GLIBCXX_PERMIT_BACKWARD_HASH) + set(INC . .. @@ -34,8 +40,11 @@ set(INC set(LIB bf_blenloader_test bf_blenloader - bf_intern_opencolorio # Should not be needed but gives windows linker errors if the ocio libs are linked before this - bf_gpu # Should not be needed but gives windows linker errors if the ocio libs are linked before this + + # Should not be needed but gives windows linker errors if the ocio libs are linked before this: + bf_intern_opencolorio + bf_gpu + bf_usd ) @@ -47,6 +56,7 @@ get_property(BLENDER_SORTED_LIBS GLOBAL PROPERTY BLENDER_SORTED_LIBS_PROP) set(SRC abstract_hierarchy_iterator_test.cc hierarchy_context_order_test.cc + usd_stage_creation_test.cc ) if(WITH_BUILDINFO) diff --git a/tests/gtests/usd/usd_stage_creation_test.cc b/tests/gtests/usd/usd_stage_creation_test.cc new file mode 100644 index 00000000000..8c8d0271449 --- /dev/null +++ b/tests/gtests/usd/usd_stage_creation_test.cc @@ -0,0 +1,40 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2019 Blender Foundation. + * All rights reserved. + */ +#include "testing/testing.h" +#include <pxr/usd/usd/stage.h> + +#include <string> + +extern "C" { +#include "BLI_utildefines.h" +} + +class USDStageCreationTest : public testing::Test { +}; + +TEST_F(USDStageCreationTest, JSONFileLoadingTest) +{ + std::string filename = "usd-stage-creation-test.usdc"; + + /* Simply the ability to create a USD Stage for a specific filename means that the extension has + * been recognised by the USD library, and that a USD plugin has been loaded to write such files. + * Practically, this is a test to see whether the USD JSON files can be found and loaded. */ + pxr::UsdStageRefPtr usd_stage = pxr::UsdStage::CreateNew(filename); + EXPECT_TRUE(usd_stage) << "unable to find suitable USD plugin to write " << filename; +} _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs