Boost logo

Boost-Build :

Subject: Re: [Boost-build] Help building Maya plugins
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-12-24 20:59:57


AMDG

Justin Walker wrote:
> I'm trying to set up a build system that will allow us to easily build
> and install Maya plugins. I'll start by explaining what I want and
> enumerate each of the steps I'd like help with.
>
> Maya is a 3D software package that provides an API and libraries for
> writing plugins. You typically write your C++ code, include the
> appropriate Maya headers, link against the appropriate Maya libraries,
> then point Maya to the location of your compiled plugins in order to
> load them. Our challenge is that we have many different versions of
> Maya available. Sometimes we want to compile against a single version
> and sometimes against multiple versions. Here is a typical scenario:
>
> Maya is installed in /apps/maya/<version>. So we could have the
> following:
> /apps/maya/1.0.0/include
> /apps/maya/1.0.0/lib
> /apps/maya/1.0.1/include
> /apps/maya/1.0.1/lib
> /apps/maya/1.1.0/include
> /apps/maya/1.1.0/lib
> /mycode/src/plugin.cpp
>
> I want to write a rule that would look something like the following:
>
> lib plugin : plugin.cpp /maya//Maya ;
>
> and it will generate the following:
>
> g++ -o bin/blah/1.0.0/plugin.so -I/apps/maya/1.0.0/include
> -L/apps/maya/1.0.0/lib -lMaya
> g++ -o bin/blah/1.0.1/plugin.so -I/apps/maya/1.0.1/include
> -L/apps/maya/1.0.1/lib -lMaya
> g++ -o bin/blah/1.1.0/plugin.so -I/apps/maya/1.1.0/include
> -L/apps/maya/1.1.0/lib -lMaya
>
> Note that the output binary name is "plugin.so" and not "libplugin.so".
>
> I want the installed libraries to get installed into the following
> locations:
>
> maya/plugins/1.0.0/plugin.so
> maya/plugins/1.0.1/plugin.so
> maya/plugins/1.1.0/plugin.so
>
> I then want to be able to override this when necessary. Something like
> the following:
>
> lib plugin : plugin.cpp /maya//Maya : <maya>1.0.0 ;
>
> This only builds the 1.0.0 version of the plugin.
>
> Finally sometimes the 1.0.1 version is binary compatible with the
> 1.0.0 version. Instead of building a plugin I instead want to create a
> symlink named maya/plugins/1.0.1 that points to maya/plugins/1.0.0.

You can just make the alternative for 1.0.1 create a symlink.

> I'd appreciate any help on how to approach this challenge. Should I
> create a new Maya package? Should I create a new feature and add each
> of the version strings as possible values?

Yes.

> How do I iterate over each of the requested values and modify the
> include and search properties appropriately.

Use alternatives, something like this (completely untested):

feature maya : : propagated ;

path-constant here : . ;

rule plugin-name ( name : type ? : property-set )
{
    if $(type) = SHARED_LIB
    {
        return $(name).so ;
    }
}

.requirements = <link>shared <tag>@maya.plugin-name ;

rule init ( version : path )
{
    feature.extend <maya> : $(version) ;
    lib maya : : <name>Maya <search>$(path) <maya>$(version) ;
   .requirements += <maya>$(version):<include>$(path)/include ;
}

rule maya-plugin ( name : sources * : requirements * :
usage-requirements * : default-build * )
{
    lib $(name) : $(sources) $(here)//maya : $(requirements)
$(.requirements) : $(usage-requirements) : $(default-build) ;
}

> How do I assign the install dir based on the version string?

rule set-location ( properties * ) {
    local version = [ property.select <maya> : $(properties) ] ;
    return <location>maya/plugins/$(version) ;
}

install myplugin : : <conditional>@set-location ;

In Christ,
Steven Watanabe


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk