Skip to content

Commit

Permalink
usdGenSchema now uses installed schema.usda files
Browse files Browse the repository at this point in the history
Libraries now install their schema.usda files as
resource files. Sublayer asset paths in these files
now use search paths instead of relative paths to
other schema.usda files in the source tree.
usdGenSchema has been modified to set up the
ArDefaultResolver to ensure these paths are
resolved to the correct location in the install.

This allows developers to run usdGenSchema on
schemas that sublayer in other schemas without
having the full USD source tree available. It also
simplifies the sublayer paths authored in a schema
which makes things easier to read.

This change means that opening a schema.usda
on a UsdStage no longer works without setting up
ArDefaultResolver with the necessary search path.
We think this is not a common workflow; if needed in
the future, we could provide a function to make this
easier.

Fixes #158

(Internal change: 1776071)
  • Loading branch information
sunyab authored and pixar-oss committed Aug 19, 2017
1 parent bca839d commit b167e2f
Show file tree
Hide file tree
Showing 20 changed files with 50 additions and 12 deletions.
1 change: 1 addition & 0 deletions extras/usd/examples/usdSchemaExamples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ pxr_plugin(${PXR_PACKAGE}
RESOURCE_FILES
generatedSchema.usda
plugInfo.json
schema.usda:usdSchemaExamples/schema.usda
)

2 changes: 1 addition & 1 deletion extras/usd/examples/usdSchemaExamples/schema.usda
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
usdGenSchema.
"""
subLayers = [
@../../../../pxr/usd/lib/usd/schema.usda@
@usd/schema.usda@
]
)

Expand Down
1 change: 1 addition & 0 deletions pxr/usd/lib/usd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ pxr_library(usd
RESOURCE_FILES
plugInfo.json
generatedSchema.usda
schema.usda:usd/schema.usda
codegenTemplates/api.h
codegenTemplates/plugInfo.json
codegenTemplates/schemaClass.cpp
Expand Down
27 changes: 27 additions & 0 deletions pxr/usd/lib/usd/usdGenSchema.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,29 @@ def GenerateRegistry(codeGenPath, filePath, classes, validate, env):
_WriteFile(os.path.join(codeGenPath, 'generatedSchema.usda'), layerSource,
validate)

def InitializeResolver():
"""Initialize the resolver so that search paths pointing to schema.usda
files are resolved to the directories where those files are installed"""

from pxr import Ar, Plug

# Force the use of the ArDefaultResolver so we can take advantage
# of its search path functionality.
Ar.SetPreferredResolver('ArDefaultResolver')

# Figure out where all the plugins that provide schemas are located
# and add their resource directories to the search path prefix list.
resourcePaths = set()
pr = Plug.Registry()
for t in pr.GetAllDerivedTypes('UsdSchemaBase'):
plugin = pr.GetPluginForType(t)
if plugin:
resourcePaths.add(plugin.resourcePath)

# The sorting shouldn't matter here, but we do it for consistency
# across runs.
Ar.DefaultResolver.SetDefaultSearchPath(sorted(list(resourcePaths)))

if __name__ == '__main__':
#
# Parse Command-line
Expand Down Expand Up @@ -835,6 +858,10 @@ def GenerateRegistry(codeGenPath, filePath, classes, validate, env):
sys.exit(1)

try:
#
# Initialize the asset resolver to resolve search paths
#
InitializeResolver()

#
# Gather Schema Class information
Expand Down
1 change: 1 addition & 0 deletions pxr/usd/lib/usdGeom/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ pxr_library(usdGeom
RESOURCE_FILES
plugInfo.json
generatedSchema.usda
schema.usda:usdGeom/schema.usda
)

pxr_test_scripts(
Expand Down
2 changes: 1 addition & 1 deletion pxr/usd/lib/usdGeom/schema.usda
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(
"This file describes the USD Geometric schemata for code generation."
subLayers = [
@../usd/schema.usda@
@usd/schema.usda@
]
)

Expand Down
2 changes: 2 additions & 0 deletions pxr/usd/lib/usdHydra/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ pxr_library(usdHydra
__init__.py

RESOURCE_FILES
generatedSchema.usda
plugInfo.json
schema.usda:usdHydra/schema.usda
)

4 changes: 2 additions & 2 deletions pxr/usd/lib/usdHydra/schema.usda
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#usda 1.0
(
subLayers = [
@../usd/schema.usda@,
@../usdShade/schema.usda@,
@usd/schema.usda@,
@usdShade/schema.usda@,
]
)

Expand Down
1 change: 1 addition & 0 deletions pxr/usd/lib/usdLux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@ pxr_library(usdLux
RESOURCE_FILES
plugInfo.json
generatedSchema.usda
schema.usda:usdLux/schema.usda
)

2 changes: 1 addition & 1 deletion pxr/usd/lib/usdLux/schema.usda
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(
"This file describes the USD Lux light schemata for code generation."
subLayers = [
@../usdGeom/schema.usda@
@usdGeom/schema.usda@
]
)

Expand Down
1 change: 1 addition & 0 deletions pxr/usd/lib/usdRi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ pxr_library(usdRi
RESOURCE_FILES
plugInfo.json
generatedSchema.usda
schema.usda:usdRi/schema.usda
)

pxr_test_scripts(
Expand Down
6 changes: 3 additions & 3 deletions pxr/usd/lib/usdRi/schema.usda
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
(
"This file describes the USD Shader (RSL) schemata for code generation."
subLayers = [
@../usd/schema.usda@,
@../usdShade/schema.usda@,
@../usdLux/schema.usda@,
@usd/schema.usda@,
@usdShade/schema.usda@,
@usdLux/schema.usda@,
]
)

Expand Down
1 change: 1 addition & 0 deletions pxr/usd/lib/usdShade/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pxr_library(usdShade
RESOURCE_FILES
plugInfo.json
generatedSchema.usda
schema.usda:usdShade/schema.usda
)

pxr_test_scripts(
Expand Down
2 changes: 1 addition & 1 deletion pxr/usd/lib/usdShade/schema.usda
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(
"This file describes the USD Shader schemata for code generation."
subLayers = [
@../usd/schema.usda@
@usd/schema.usda@
]
)

Expand Down
1 change: 1 addition & 0 deletions pxr/usd/lib/usdSkel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ pxr_library(usdSkel
RESOURCE_FILES
generatedSchema.usda
plugInfo.json
schema.usda:usdSkel/schema.usda
)

2 changes: 1 addition & 1 deletion pxr/usd/lib/usdSkel/schema.usda
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
""" This file contains a schema for supporting skeletal animation in USD.
"""
subLayers = [
@../usdGeom/schema.usda@
@usdGeom/schema.usda@
]
)

Expand Down
1 change: 1 addition & 0 deletions pxr/usd/lib/usdUI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pxr_library(usdUI
RESOURCE_FILES
plugInfo.json
generatedSchema.usda
schema.usda:usdUI/schema.usda
)

pxr_test_scripts(
Expand Down
2 changes: 1 addition & 1 deletion pxr/usd/lib/usdUI/schema.usda
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(
"This file describes the USD Shader schemata for code generation."
subLayers = [
@../usd/schema.usda@
@usd/schema.usda@
]
)

Expand Down
1 change: 1 addition & 0 deletions third_party/katana/lib/usdKatana/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@ pxr_shared_library(${PXR_PACKAGE}
RESOURCE_FILES
plugInfo.json
generatedSchema.usda
schema.usda:usdKatana/schema.usda
)

2 changes: 1 addition & 1 deletion third_party/katana/lib/usdKatana/schema.usda
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(
"This file describes the USD katana blind object schemata for code generation."
subLayers = [
@../../../../pxr/usd/lib/usd/schema.usda@
@usd/schema.usda@
]

)
Expand Down

0 comments on commit b167e2f

Please sign in to comment.