Pixar USDをmacOS (Apple silicon) でビルドする

手元のMacBook (Apple M1 Max)でPixar USDをビルドしたのでそのメモを残す。

環境

1
2
3
4
5
6
7
8
$ sw_vers
ProductName:	macOS
ProductVersion:	12.6.3
BuildVersion:	21G419

$ xcodebuild -version
Xcode 14.2
Build version 14C18

ビルド手順

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
mkdir workspace && cd workspace

# Pythonのインストール例
# /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Python3 を使ってもいいのかもしれない
pyenv install 3.9.16
pyenv local 3.9.16

# venvを使ってpipでパッケージをインストールする
python -m venv env
source env/bin/activate
python -m pip install --upgrade pip
python -m pip install pyside6 PyOpenGL	  

# USDはv23.02のソースコードを使う
git clone https://github.com/PixarAnimationStudios/USD PixarUSD
git switch -c v23.02

# PYTHONPATHが未定義の場合、build_usd.pyでのビルドに失敗するので宣言する
export PYTHONPATH=path/to/your/python

# ビルド
mkdir buildspace  
python PixarUSD/build_scripts/build_usd.py ./buildspace

ログ

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Building with settings:
  USD source directory          /Users/hiroakit/workspace/PixarUSD
  USD install directory			/Users/hiroakit/workspace/buildspace
  3rd-party source directory	/Users/hiroakit/workspace/buildspace/src
  3rd-party install directory	/Users/hiroakit/workspace/buildspace
  Build directory				/Users/hiroakit/workspace/buildspace/build
  CMake generator               Default
  CMake toolset                 Default
  Downloader                    curl

  Building                      Shared libraries
    Variant                     Release
    Target                      native
    Imaging                     On
      Ptex support:             Off
      OpenVDB support:          Off
      OpenImageIO support:      Off 
      OpenColorIO support:      Off 
      PRMan support:            Off
    UsdImaging                  On
      usdview:                  On
    Python support              On
      Python Debug:             Off
      Python 3:                 On
    Documentation               Off
    Tests                       Off
    Examples                    On
    Tutorials                   On
    Tools                       On
    Alembic Plugin              Off
      HDF5 support:             Off
    Draco Plugin                Off
    MaterialX Plugin            Off

  Dependencies                  zlib, boost, TBB, OpenSubdiv
STATUS: Installing zlib...
STATUS: Installing boost...
STATUS: Installing TBB...
STATUS: Installing OpenSubdiv...
STATUS: Installing USD...

Success! To use USD, please ensure that you have:

    The following in your PYTHONPATH environment variable:
    /Users/hiroakit/workspace/buildspace/lib/python

    The following in your PATH environment variable:
    /Users/hiroakit/workspace/buildspace/bin

USDViewの実行

以下コマンドを実行してUSDViewが起動するか確認する。

1
2
3
4
5
# ビルド後にPYTHONPATHとPATHにパスを追加するように記載があったので  
export PYTHONPATH=/Users/hiroakit/workspace/buildspace/lib/python:$PYTHONPATH
export PATH=/Users/hiroakit/workspace/buildspace/bin:$PATH

usdview ../buildspace/share/usd/tutorials/convertingLayerFormats/Sphere.usd