Skip to content

Commit 782657d

Browse files
committed
WIP: restructuring
Signed-off-by: psakiev <psakiev@sandia.gov>
1 parent 73a152c commit 782657d

2 files changed

Lines changed: 41 additions & 16 deletions

File tree

outputs/dev.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ example dev/setup-scr "# for now, disable fortran support in all packages"
2121
example dev/setup-scr 'spack config add "packages:all:variants: ~fortran"'
2222
example dev/setup-scr "spack add macsio+scr"
2323
example dev/setup-scr "spack install"
24+
example dev/setup-scr "spack find -cv scr"
2425

2526
example dev/develop-1 "spack develop scr"
2627
example dev/develop-1 "spack config blame develop"
28+
example dev/develop-1 "spack find -cv scr"
2729

2830
example dev/develop-2 "spack install"
2931

@@ -37,9 +39,16 @@ fake_example dev/develop-4 '$EDITOR scr/src/scr_copy.c' "/bin/true"
3739
sed -i~ s'|\(static char hostname\[256\] = "UNKNOWN_HOST"\)|\1;|' scr/src/scr_copy.c | head -n 70
3840
example dev/develop-4 "spack install"
3941

40-
example dev/develop-5 "# This time let's leave off the version"
41-
example dev/develop-5 "spack develop macsio"
42-
example dev/develop-5 "spack concretize -f"
42+
example dev/develop-5 "spack develop --recursive scr"
43+
example dev/develop-5 "spack find -cv macsio"
44+
45+
example dev/develop-6 "# This time let's add the version"
46+
example dev/develop-6 "spack change macsio@develop"
47+
example dev/develop-6 "spack concretize -f"
48+
example dev/develop-6 "spack develop macsio@develop"
49+
example dev/develop-6 "spack find -cv macsio"
50+
example dev/develop-6 "spack concretize -f"
51+
example dev/develop-6 "spack find -cv macsio"
4352

4453
example dev/otherdevel "cd ~"
4554
cd ~ || exit

tutorial_developer_workflows.rst

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ Development iteration cycles
139139
-----------------------------
140140

141141
Let's assume that ``scr`` has a bug, and we'd like to patch ``scr`` to find out what the problem is.
142-
First, we tell Spack that we'd like to check out the version of ``scr`` that we want to work on.
142+
First, we tell Spack that we'd like to check out the version of ``scr`` in our environment.
143143
In this case, it will be the 3.1.0 release that we want to write a patch for:
144144

145145
.. literalinclude:: outputs/dev/develop-1.out
@@ -188,7 +188,7 @@ If the file times are newer, it will rebuild ``scr`` and any other package that
188188
:language: console
189189

190190
Here, the build failed as expected.
191-
We can look at the output for the build in ``scr/spack-build-out.txt`` to find out why, or we can launch a shell directly with the appropriate environment variables to figure out what went wrong by using ``spack build-env scr@2.0 -- bash``.
191+
We can look at the output for the build in ``scr/spack-build-out.txt`` to find out why, or we can launch a shell directly with the appropriate environment variables to figure out what went wrong by using ``spack build-env scr -- bash``.
192192
If that's too much to remember, then sourcing ``scr/spack-build-env.txt`` will also set all the appropriate environment variables so we can diagnose the build ourselves.
193193
Now let's fix it and rebuild directly.
194194

@@ -205,14 +205,33 @@ If your build system can take advantage of the previously compiled object files
205205
- If your package uses CMake with the typical ``cmake`` / ``build`` / ``install`` build stages, you'll get iterative builds for free with Spack because CMake doesn’t modify the filetime on the ``CMakeCache.txt`` file if your cmake flags haven't changed.
206206
- If your package uses autoconf, then rerunning the typical ``autoreconf`` stage typically modifies the filetime of ``config.h``, which can trigger a cascade of rebuilding.
207207

208-
Multiple packages can also be marked as develop.
209-
If we were co-developing ``macsio``, we could run
208+
Multi-package development
209+
-------------------------
210+
211+
You may have noticed that ``macsio`` is restaged and fully rebuilt each time we call ``spack install``.
212+
This is an unnecessary expense for cross package development.
213+
Luckily, Spack has tools to reduce this expense.
214+
We will use this as an opportunity to introduce another ``spack develop`` feature: the ``--recursive`` option.
210215

211216
.. literalinclude:: outputs/dev/develop-5.out
212217
:language: console
213218

214-
Note that we intentionally gave a different version and in the examples above ``macsio`` never received the ``dev_path`` variant.
215-
This example is to show a few gotchas with the ``spack develop`` command
219+
``spack develop --recursive`` can only be used with a concrete environment.
220+
When called Spack traces the graph from the supplied develop spec to every root in the graph that transitivley depends on the develop package.
221+
Using ``--recursive`` can be very powerful wehn developing applications deep in a graph.
222+
In this case our development point is very close to the root spec so we could have called ``spack develop macsio`` and gotten the same result.
223+
224+
Pre-configuring development environments
225+
----------------------------------------
226+
227+
So far all of our calls to ``spack develop`` have been on a concretized environment, and we have allowed spack to automatically update the build specs for us.
228+
If we don't want Spack to update the concrete environment's specs we can pass the ``---no-modify-concrete-spec``.
229+
This will require you to force concretize an environment to have the develop specs take affect.
230+
231+
.. literalinclude:: outputs/dev/develop-6.out
232+
:language: console
233+
234+
This example is to show a few gotchas with the ``spack develop`` command
216235

217236
* You should ensure a spec for the package you are developing appears in the DAG of at least one of the roots of the environment with the same version that you are developing.
218237
``spack add <package>`` with the matching version you want to develop is a way to ensure the develop spec is satisfied in the ``spack.yaml`` environments file.
@@ -222,13 +241,8 @@ This example is to show a few gotchas with the ``spack develop`` command
222241

223242
If we really wanted to change to developing ``macsio@develop`` we need to change the root spec in the environment and then reconcretize.
224243

225-
In our case the ``1.1`` version is sufficient and we will use this as an opportunity to introduce another ``spack develop`` feature: the ``--recursive`` option.
226-
``spack develop --recursive`` can only be used with a concrete environment.
227-
When called Spack traces the graph from the supplied develop spec to every root in the graph that transitivley depends on the develop package.
228-
This is a nice way to ensure that all specs are skipping restages, and performing incremental builds if their build-system allows for it.
229-
230-
.. literalinclude:: outputs/dev/develop-6.out
231-
:language: console
244+
Sharing development environments
245+
--------------------------------
232246

233247
Using development workflows also lets us ship our whole development process to another developer on the team.
234248
They can simply take our spack.yaml, create a new environment, and use this to replicate our build process.
@@ -244,13 +258,15 @@ When we're done developing, we simply tell Spack that it no longer needs to keep
244258
.. literalinclude:: outputs/dev/wrapup.out
245259
:language: console
246260

261+
----------------
247262
Workflow Summary
248263
----------------
249264

250265
Use the ``spack develop`` command with an environment to make a reproducible build environment for your development workflow.
251266
Spack will set up all the dependencies for you and link all your packages together.
252267
Within a development environment, ``spack install`` works similarly to ``make`` in that it will check file times to rebuild the minimum number of Spack packages necessary to reflect the changes to your build.
253268

269+
-------------------------
254270
Optional: Tips and Tricks
255271
-------------------------
256272

0 commit comments

Comments
 (0)