<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p><font face="Noto Sans">Hello all,</font></p>
<p><font face="Noto Sans">In the USD Interest group I got two
responses, one of which from Mark Tucker who helped me solve
this isssue:</font></p>
<p><font face="Noto Sans">
<blockquote type="cite">I'm not sure if this helps, but Houdini
also has a need to explicitly scan the HOUDINI_PATH for USD
plugins. We do this by scanning the HOUDINI_PATH after
initializing USD, and calling
`PlugRegistry::GetInstance().RegisterPlugins(pluginpaths);`,
where `pluginpaths` is a vector of all the USD plugin paths we
find within the HOUDINI_PATH. This results in a different
initialization order than if we used environment variables or
modified the USD library to change its plugin loading, but it
works for us, and did not require any changes to the USD
library.
<div><br>
</div>
Mark</blockquote>
This approach seems to work for Blender as well, so I'll be
phasing out the our patch of the USD library.<br>
</font></p>
<p><font face="Noto Sans">Kind regards,</font></p>
<p><font face="Noto Sans">Sybren</font><br>
</p>
<div class="moz-cite-prefix">On 31-08-2020 15:35, Sybren A. Stüvel
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:7bde8fb5-1f53-bb4d-74ab-6b28def4c6a2@blender.org">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<p><font face="Noto Sans">Hello all,</font></p>
I have just sent the below mail to the USD Interest google group.
Since that group is not public, I send that email here as well.
That way everybody knows what's being discussed.<br>
<p><font face="Noto Sans">Blender is statically linking most
libraries, including USD. It's also built in such a way that
it can be moved to (or an archive unpacked into) an arbitrary
directory. This means that at build time, there is no way to
know what the path of the USD Plugin files will be. Because of
the static linking in combination with USD's static
initialisers, it's also not possible for Blender to set any
environment variables, or to run any code before the static
initialisers run.<br>
<br>
The USD library has some code to find files relative to the
executable, but it doesn't search in our Blender-specific
location. This would require knowing the version of Blender
that's running, so it would put Blender-specific code into the
USD library, which is of course not desirable.<br>
<br>
To get Blender and USD playing nicely together, I had to hack
the USD library to defer the loading of plugins (see
<a class="moz-txt-link-freetext"
href="https://developer.blender.org/diffusion/B/browse/master/build_files/build_environment/patches/usd.diff"
moz-do-not-send="true">https://developer.blender.org/diffusion/B/browse/master/build_files/build_environment/patches/usd.diff</a>).
With this hack, the static initialiser is still there, but is
a no-op, and the plugin loading is moved to a function that
can be called from Blender itself. That function gets the
plugin path from Blender.<br>
<br>
This is of course an ugly workaround, and not every Blender
developer is happy with it
(<a class="moz-txt-link-freetext"
href="https://lists.blender.org/pipermail/bf-committers/2020-August/050645.html"
moz-do-not-send="true">https://lists.blender.org/pipermail/bf-committers/2020-August/050645.html</a>).
Is there anything that can be changed in the USD library to
support Blender's use case? I could clean up my patch and make
its behaviour optional via some build-time option that's off
by default. That way the default behaviour of the USD library
doesn't change, but the ability for a program to determine the
plugin path at runtime remains.<br>
<br>
Kind regards,<br>
Sybren</font><br>
</p>
<pre class="moz-signature" cols="72">--
dr. Sybren A. Stüvel
Blender Software Developer
<a class="moz-txt-link-freetext" href="https://blender.org/" moz-do-not-send="true">https://blender.org/</a>
<a class="moz-txt-link-freetext" href="https://cloud.blender.org/" moz-do-not-send="true">https://cloud.blender.org/</a>
</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
</blockquote>
<pre class="moz-signature" cols="72">--
dr. Sybren A. Stüvel
Blender Software Developer
<a class="moz-txt-link-freetext" href="https://blender.org/">https://blender.org/</a>
<a class="moz-txt-link-freetext" href="https://cloud.blender.org/">https://cloud.blender.org/</a>
</pre>
</body>
</html>