Skip to content

Instantly share code, notes, and snippets.

@jerrymarino
Created September 6, 2018 00:54
Show Gist options
  • Save jerrymarino/77cb52dbf4f8f1d2ba708844a07713e0 to your computer and use it in GitHub Desktop.
Save jerrymarino/77cb52dbf4f8f1d2ba708844a07713e0 to your computer and use it in GitHub Desktop.
Clearing clang's implicit module map for safe, incremental module enabled builds
#!/bin/bash
# This program cleans out the implcit module cache and modulemaps.
# Remove modulemaps to prevent loading lingering invalid modulemaps
# ( Genfiles is not cleared for each incremental build )
set -e
SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
WORKSPACE_DIR="$SCRIPTPATH/../"
EXEC_ROOT=$($WORKSPACE_DIR/tools/bazelwrapper info execution_root)
if [[ ! -d "$EXEC_ROOT" ]]; then
echo "ERROR: invalid WORKSPACE"
exit 1
fi
pushd $EXEC_ROOT
# For all of the module caches which are populated
# - Remove the cache
# - Remove module maps
for MC in $(find bazel-out/ -name '*_objc_module_cache'); do
# Assume we're in `genfiles`.
GENROOT=$(dirname $MC)
for MAP in $(find $GENROOT -name '*.modulemap'); do
echo "INFO: Removing modulemap map $MAP"
rm -rf $MAP
done
echo "INFO: Clear module cache $MC"
rm -rf $MC
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment