Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ runs:
pip install -r requirements.txt -r requirements_dev.txt
fi

- name: Setup sccache
uses: mozilla/sccache-action@v0.0.9

- name: Set sccache as compiler launcher
shell: bash
run: |
echo "CMAKE_C_COMPILER_LAUNCHER=sccache" >> $GITHUB_ENV
echo "CMAKE_CXX_COMPILER_LAUNCHER=sccache" >> $GITHUB_ENV

- name: Cache Conan
uses: actions/cache@v4
with:
Expand Down
6 changes: 6 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,12 @@ def generate(self):
# tc.cache_variables["CMAKE_OSX_DEPLOYMENT_TARGET"] = "10.13"
tc.parallel = True

# Use sccache as a compiler launcher if available (e.g. in CI via CMAKE_C/CXX_COMPILER_LAUNCHER env vars)
if c_launcher := os.environ.get("CMAKE_C_COMPILER_LAUNCHER"):
tc.cache_variables["CMAKE_C_COMPILER_LAUNCHER"] = c_launcher
if cxx_launcher := os.environ.get("CMAKE_CXX_COMPILER_LAUNCHER"):
tc.cache_variables["CMAKE_CXX_COMPILER_LAUNCHER"] = cxx_launcher

py_limited = resolve_py_limited_api(self.options.get_safe("pyLimitedAPI"))
tc.cache_variables["PY_LIMITED_API"] = py_limited
print(f"{statusColor}PY_LIMITED_API={py_limited}{endColor}")
Expand Down
29 changes: 29 additions & 0 deletions docs/source/Build/installBuild.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,35 @@ similar amount of time to compile the messaging related files. However, after m
only this Basilisk module will need to be compiled and the compile times are drastically reduced.


Speeding Up Builds with ``sccache``
------------------------------------
`sccache <https://github.com/mozilla/sccache>`__ is a compiler cache that caches individual C++ object
files by content hash. When source files have not changed, sccache returns the cached object instead of
invoking the compiler, which can dramatically reduce clean-build times.

Install sccache with your system package manager, for example on macOS::

brew install sccache

Then set the following environment variables before building::

export CMAKE_C_COMPILER_LAUNCHER=sccache
export CMAKE_CXX_COMPILER_LAUNCHER=sccache

With these set, any build invocation (``python3 conanfile.py``, ``pip install -e .``, etc.) will
automatically use sccache. A warm cache reduces a full rebuild to only the linking step plus any
files that actually changed.

To inspect cache statistics after a build::

sccache --show-stats

.. note::

sccache is also enabled automatically in CI via ``CMAKE_C/CXX_COMPILER_LAUNCHER`` environment
variables set by the GitHub Actions build workflow.


Running Project Tests
---------------------

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Added ``sccache`` compiler caching to CI builds to speed up incremental C++ compilation. See :ref:`configureBuild` for how to use ``sccache`` locally.
Loading