summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2016-03-06 16:52:34 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2016-03-06 16:57:30 -0800
commit1ee90a6fe792bce1730bfd3fddb4fa12b4597361 (patch)
treef41d4495efea207cfe16e46c836c1240287b03fc
parent240ada5775c7857932279d86e4305ef001d33717 (diff)
downloadspack-1ee90a6fe792bce1730bfd3fddb4fa12b4597361.tar.gz
spack-1ee90a6fe792bce1730bfd3fddb4fa12b4597361.tar.bz2
spack-1ee90a6fe792bce1730bfd3fddb4fa12b4597361.tar.xz
spack-1ee90a6fe792bce1730bfd3fddb4fa12b4597361.zip
Make spack_cc, spack_cxx, spack_f77, spack_fc available in build env.
- Add for convenience for packages that need to refer to these. - Added an example in the documentation.
-rw-r--r--lib/spack/docs/packaging_guide.rst9
-rw-r--r--lib/spack/spack/build_environment.py7
2 files changed, 16 insertions, 0 deletions
diff --git a/lib/spack/docs/packaging_guide.rst b/lib/spack/docs/packaging_guide.rst
index bae8c34d52..983adb28b0 100644
--- a/lib/spack/docs/packaging_guide.rst
+++ b/lib/spack/docs/packaging_guide.rst
@@ -2137,6 +2137,15 @@ Filtering functions
Examples:
+ #. Filtering a Makefile to force it to use Spack's compiler wrappers:
+
+ .. code-block:: python
+
+ filter_file(r'^CC\s*=.*', spack_cc, 'Makefile')
+ filter_file(r'^CXX\s*=.*', spack_cxx, 'Makefile')
+ filter_file(r'^F77\s*=.*', spack_f77, 'Makefile')
+ filter_file(r'^FC\s*=.*', spack_fc, 'Makefile')
+
#. Replacing ``#!/usr/bin/perl`` with ``#!/usr/bin/env perl`` in ``bib2xhtml``:
.. code-block:: python
diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py
index 1b87778080..e22597a789 100644
--- a/lib/spack/spack/build_environment.py
+++ b/lib/spack/spack/build_environment.py
@@ -214,6 +214,13 @@ def set_module_variables_for_package(pkg, m):
m.std_cmake_args.append('-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=FALSE')
m.std_cmake_args.append('-DCMAKE_INSTALL_RPATH=%s' % ":".join(get_rpaths(pkg)))
+ # Put spack compiler paths in module scope.
+ link_dir = spack.build_env_path
+ m.spack_cc = join_path(link_dir, pkg.compiler.link_paths['cc'])
+ m.spack_cxx = join_path(link_dir, pkg.compiler.link_paths['cxx'])
+ m.spack_f77 = join_path(link_dir, pkg.compiler.link_paths['f77'])
+ m.spack_f90 = join_path(link_dir, pkg.compiler.link_paths['fc'])
+
# Emulate some shell commands for convenience
m.pwd = os.getcwd
m.cd = os.chdir