<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<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">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">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/">https://blender.org/</a>
<a class="moz-txt-link-freetext" href="https://cloud.blender.org/">https://cloud.blender.org/</a>
</pre>
</body>
</html>