aboutsummaryrefslogtreecommitdiff
path: root/arnold/mkosx.sh
blob: 78224537393ca42a065b7a3d1c60b4f45d92a634 (plain) (blame)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/sh

# Shave and a Haircut
# (c) 2019 Epic Games
# US Patent 6720962

maya=$1

if [ "${maya}" = "" ]; then
    echo "Usage: $0 mayaVersion" >&2
    echo ""
    exit 1
fi

if [ "${SHAVE_ARNOLD_SDKS}" = "" ]; then
    echo "SHAVE_ARNOLD_SDKS not defined. Shave will be built without Arnold support." >&2
    exit 3
fi

export MAYA_LOCATION=/Applications/Autodesk/maya${maya}

pushd ..
source getosxvars.sh
popd

if [ -d Release/${maya} ]; then
    rm -rf Release/${maya}
fi

grep "^${maya}:" supportedMtoAVersions.txt | while read mayaVer minVer maxVer buildVer garbage; do
    mtoaMin=${minVer/\/*/}
    arnoldMin=${minVer/*\//}

    mtoaMax=${maxVer/\/*/}
    arnoldMax=${maxVer/*\//}

    mtoaBuild=${buildVer/\/*/}
    arnoldBuild=${buildVer/*\//}

    safeMtoABuild=${mtoaBuild//./_}
    safeArnoldBuild=${arnoldBuild//./_}

    # Special case: this version of MtoA is not available on MacOS.
    #
    if [ "${mtoaBuild}" = "1.3.0.0" ]; then
        continue
    fi

    arnoldPath=${SHAVE_ARNOLD_SDKS}/arnold/${arnoldBuild}/osx
    mtoaPath=${SHAVE_ARNOLD_SDKS}/mtoa/${mtoaBuild}/maya${maya}/osx

    ARNOLD_RANGE="-DMIN_ARNOLD_VERSION=${arnoldMin} -DMAX_ARNOLD_VERSION=${arnoldMax}"

    CPPFLAGS="-fvisibility=hidden -Wno-reorder -Wall -Wsign-compare -O3 \
        -funroll-loops -arch x86_64 -fPIC \
        -DENABLE_COLOR_MANAGEMENT -DNDEBUG -DENABLE_XGEN -DENABLE_VP2 \
        -DENABLE_BIFROST -DENABLE_LOOKDEVKIT -DENABLE_RENDERSETUP -D_DARWIN \
        -DOSMac_ \
        -I${arnoldPath}/include"

    PLUGIN_CPPFLAGS="${CPPFLAGS} -D_BOOL -DREQUIRE_IOSTREAM \
        -I../mayaPlug \
        -I${mtoaPath}/include \
        -I/Applications/Autodesk/maya${maya}/include"

    LDFLAGS="-fvisibility=hidden -arch x86_64 -framework Security -dynamiclib \
        -L${arnoldPath}/bin \
        -lai"

    PLUGIN_LDFLAGS="${LDFLAGS} \
        -L${mtoaPath}/lib \
	-L../mayaPlug \
        -L/Applications/Autodesk/maya${maya}/Maya.app/Contents/MacOS \
        -lpthread -lFoundation -lOpenMaya -lOpenMayaRender -lOpenMayaUI \
        -lOpenMayaAnim -lOpenMayaFX \
        -lShaveAPI -lmtoa_api"


    OUTDIR=Release/${maya}/${mtoaBuild}

    mkdir -p ${OUTDIR}

    g++ ${PLUGIN_CPPFLAGS} -o ${OUTDIR}/plugin.o -c plugin/plugin.cpp
    if [ $? -ne 0 ]; then
        exit 1
    fi

    echo "g++ ${PLUGIN_CPPFLAGS} -o ${OUTDIR}/ShaveAndHaircut.o -c plugin/ShaveAndHaircut.cpp"
    g++ ${PLUGIN_CPPFLAGS} -o ${OUTDIR}/ShaveAndHaircut.o -c plugin/ShaveAndHaircut.cpp
    if [ $? -ne 0 ]; then
        exit 1
    fi

    echo "g++ ${PLUGIN_LDFLAGS} -o ${OUTDIR}/shave.dylib ${OUTDIR}/plugin.o ${OUTDIR}/ShaveAndHaircut.o"
    g++ ${PLUGIN_LDFLAGS} -o ${OUTDIR}/shave.dylib ${OUTDIR}/plugin.o ${OUTDIR}/ShaveAndHaircut.o
    if [ $? -ne 0 ]; then
        exit 1
    fi


    g++ ${CPPFLAGS} ${ARNOLD_RANGE} -o ${OUTDIR}/ShaveHair.o -c shaders/ShaveHair.cpp
    if [ $? -ne 0 ]; then
        exit 1
    fi


    # We may have several versions of the shader for a given version of
    # MtoA, so we have to differentiate them.
    #
    g++ ${LDFLAGS} -o ${OUTDIR}/shave_shaders-${safeArnoldBuild}.dylib ${OUTDIR}/ShaveHair.o 
    if [ $? -ne 0 ]; then
        exit 1
    fi
done