[Bf-usd] Static Linking and Plugin Paths

Sybren A. Stüvel sybren at blender.org
Mon Aug 31 15:35:20 CEST 2020


Hello all,

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.

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.

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.

To get Blender and USD playing nicely together, I had to hack the USD
library to defer the loading of plugins (see
https://developer.blender.org/diffusion/B/browse/master/build_files/build_environment/patches/usd.diff).
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.

This is of course an ugly workaround, and not every Blender developer is
happy with it
(https://lists.blender.org/pipermail/bf-committers/2020-August/050645.html).
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.

Kind regards,
Sybren

-- 
dr. Sybren A. Stüvel

Blender Software Developer

https://blender.org/
https://cloud.blender.org/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-usd/attachments/20200831/39a9d9f4/attachment.htm>


More information about the Bf-usd mailing list