Skip to content

Commit

Permalink
Clarify when the commands block is executed during rez-build (#1391)
Browse files Browse the repository at this point in the history
* Clarity around when the commands block when building

Signed-off-by: Jason Scott <[email protected]>
  • Loading branch information
jasoncscott authored Nov 15, 2022
1 parent 7abf303 commit 8c87993
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
12 changes: 9 additions & 3 deletions wiki/pages/Building-Packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ build environment, but the details of the build itself are left open for the use
Having said that, *cmake* has been supported by rez for some time, and rez comes with a
decent amount of utility code to manage cmake builds.

When a rez environment is configured, each package's [commands](Package-Definition-Guide#commands)
section configures the environment. When a build is occurring, a special variable
[building](Package-Commands#building) is set to *True*. Your packages should use this
When a rez environment is configured, each required package's
[commands](Package-Definition-Guide#commands) section configures the environment for the building
package to use. When a build is occurring, a special variable
[building](Package-Commands#building) is set to *True*. Your required packages should use this
variable to communicate build information to the package being built.

For example, our *boost* package's commands might look like so:
Expand All @@ -88,6 +89,11 @@ For example, our *boost* package's commands might look like so:
# there is a 'FindBoost.cmake' file in this dir..
env.CMAKE_MODULE_PATH.append("{root}/cmake")

> [[media/icons/warning.png]] Note that _commands_ is never executed for the package actually
being built -
> if you want to run commands in that case, you can use
[pre_build_commands](Package-Commands#pre-build-commands) instead.

A (very simple) *FindBoost.cmake* file might look like this:

set(Boost_INCLUDE_DIRS $ENV{REZ_BOOST_ROOT}/include)
Expand Down
6 changes: 4 additions & 2 deletions wiki/pages/Package-Commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,10 @@ Do not check this variable to detect if an installation is occurring - see `buil
env.FOO_INCLUDE_PATH = "{root}/include"

This boolean variable is *True* if a build is occurring (typically done via the *rez-build* tool),
and *False* otherwise. Typically a package will use this variable to set environment variables that
are only useful during a build - C++ header include paths are a good example.
and *False* otherwise, however, the `commands` block is only executed when the package is brought
into a resolved environment, so this is not used when the package itself is building. Typically a
package will use this variable to set environment variables that are only useful during when other
packages are being built - C++ header include paths are a good example.

### command
*Function*
Expand Down
7 changes: 4 additions & 3 deletions wiki/pages/Package-Definition-Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -546,9 +546,10 @@ enabled. If not provided, this is determined from the global config setting [def
env.PYTHONPATH.append("{root}/python")
env.PATH.append("{root}/bin")

This is a block of python code which tells rez how to update an environment so that this package can
be used. There is a python API provided (see [here](Package-Commands) for more details) that lets
you do things such as:
This is a block of python code which tells rez how to update an environment so that this package
can be used. It is executed when the package is brought into a rez environment, either by explicit
request or by another package's requirements. There is a python API provided (see
[here](Package-Commands) for more details) that lets you do things such as:

* set, unset, prepend and append environment variables;
* create aliases;
Expand Down

0 comments on commit 8c87993

Please sign in to comment.