@@ -280,3 +280,106 @@ together. Within a development environment, ``spack install`` works
280280similar to ``make `` in that it will check file times to rebuild the
281281minimum number of spack packages necessary to reflect the changes to
282282your build.
283+
284+ -------------------
285+ Optional: Tips and Tricks
286+ -------------------
287+
288+ This section will cover some additional features that are useful additions
289+ to the core tutorial above. Many of these items are very useful to specific
290+ projects and developers. A list of the options for the ``spack develop `` can
291+ be viewed below:
292+
293+ .. code-block :: console
294+
295+ $ spack develop --help
296+
297+ Source Code Management
298+ ----------
299+
300+ ``spack develop `` allows users to manipulate the source code locations
301+ The default behavior is to let spack manage its location and cloning operations,
302+ but software developers often want more control over these.
303+
304+ The source directory can be set with the ``--path `` argument when calling ``spack develop ``.
305+ If this directory already exists then ``spack develop `` will not attempt to fetch the code
306+ for you. This allows developers to pre-clone the software or use preferred paths as they wish.
307+
308+ .. code-block :: console
309+
310+ # pre-clone the source code and then point spack develop to it
311+ # note that we can clone into any repo/branch combination desired
312+ $ git clone https://github.com/llnl/scr.git $SPACK_ENV/code
313+ # note that with `--path` the code directory and package name can be different
314+ $ spack develop --path $SPACK_ENV/code scr@3.1.0
315+ $ spack concretize -f
316+
317+ Navigation and the Build Environment
318+ ----------
319+
320+ Diving into the build environment was introduced previously in the packaging section with the
321+ ``spack build-env scr -- bash `` command. This is a helpful function because it allows you
322+ to run commands inside the build environment. In the packages section of the tutorial
323+ this was combined with ``spack cd `` to produce a manual build outside of Spack's automated
324+ Process.
325+ This command is particularly useful in developer environments -- it allows developers a streamlined
326+ workflow when iterating on a single package without the overhead of the ``spack install `` command.
327+ The additional features of the install command are unnecessary when tightly iterating between building
328+ and testing a particular package. For example, the workflow modifying ``scr `` that we just went through
329+ can be simplified to:
330+
331+ .. code-block :: console
332+
333+ $ spack build-env scr -- bash
334+ # Shell wrappers didn't propagate to the subshell
335+ $ source $SPACK_ROOT/share/spack/setup-env.sh
336+ # Let's look at navigation features
337+ $ spack cd --help
338+ $ spack cd -c scr
339+ $ touch src/scr_copy.c
340+ $ spack cd -b scr
341+ # Let's look at what's here
342+ $ ls
343+ # Build and run tests
344+ $ make -j2
345+ $ make test
346+ $ exit
347+
348+ Working with the build environment and along with spack navigation features
349+ provides a nice way to iterate quickly and navigate through the hash heavy
350+ spack directory structures.
351+
352+ Combinatorics
353+ ------------
354+
355+ The final note we will look at in this tutorial will be the power of combinatoric
356+ development builds. There are many instances where developers want to see how
357+ a single set of changes affects multiple builds i.e. ``+cuda `` vs ``~cuda ``,
358+ ``%gcc `` vs ``%clang ``, ``build_type=Release `` vs ``build_type=Debug ``, etc.
359+
360+ Developers can achieve builds of both cases from a single ``spack install `` as
361+ long as the develop spec is generic enough to cover the packages' spec variations
362+
363+ .. code-block :: console
364+
365+ # First we have to allow repeat specs in the environment
366+ $ spack config add concretizer:unify:false
367+ # Next we need to specify the specs we want ('==' propagates the variant to deps)
368+ $ spack change macsio build_type==Release
369+ $ spack add macsio+scr build_type==Debug
370+ # Inspect the graph for multiple dev_path=
371+ $ spack concretize -f
372+
373+ While we won't build out this example it illustrates how the ``dev_path `` for
374+ ``build_type=Release `` and ``build_type=Debug `` points to the same source code.
375+
376+ Now if we want to do most of our incremental builds using the ``Release `` build
377+ and periodically check the results using the ``Debug `` build we can combine the
378+ workflow from the previous example: dive into the ``Release `` versions build
379+ environment using ``spack build-env scr build_type=Release -- bash `` and
380+ navigate with ``spack cd -b scr build_type=Release ``. Note that since there
381+ are two ``scr `` specs in the environment we must distinguish which one we
382+ want for these commands. When we are ready to check our changes for the debug
383+ build we can exit out of the build environment subshell,
384+ rerun ``spack install `` to rebuild everything, and then inspect the debug build
385+ through our method of choice.
0 commit comments