aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/ci.yml11
-rwxr-xr-xbuild.sh8
-rwxr-xr-xdocker/build-inner.sh6
-rw-r--r--libs/uibase/src/log.cpp14
4 files changed, 34 insertions, 5 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index d889a05..29b9162 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -42,10 +42,21 @@ jobs:
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max
+ - name: Restore ccache
+ uses: actions/cache@v4
+ with:
+ path: ~/.cache/fluorine-ccache
+ key: ccache-${{ runner.os }}-${{ github.sha }}
+ restore-keys: |
+ ccache-${{ runner.os }}-
+
- name: Build inside container
run: |
+ mkdir -p ~/.cache/fluorine-ccache
docker run --rm \
-v "${{ github.workspace }}:/src:rw" \
+ -v "$HOME/.cache/fluorine-ccache:/ccache:rw" \
+ -e CCACHE_DIR=/ccache \
-w /src \
fluorine-builder:latest \
bash /src/docker/build-inner.sh
diff --git a/build.sh b/build.sh
index 766e8d7..751a916 100755
--- a/build.sh
+++ b/build.sh
@@ -29,10 +29,16 @@ cd "${SCRIPT_DIR}"
echo "=== Ensuring build image is up to date ==="
${DOCKER} build -t "${IMAGE_NAME}" docker/
+# Persistent ccache directory for faster rebuilds.
+CCACHE_DIR="${HOME}/.cache/fluorine-ccache"
+mkdir -p "${CCACHE_DIR}"
+
if [ "${1:-}" = "shell" ]; then
echo "=== Dropping into build container shell ==="
exec ${DOCKER} run --rm -it \
-v "${SCRIPT_DIR}:/src:rw" \
+ -v "${CCACHE_DIR}:/ccache:rw" \
+ -e CCACHE_DIR=/ccache \
-w /src \
--device /dev/fuse \
--cap-add SYS_ADMIN \
@@ -43,6 +49,8 @@ fi
echo "=== Starting build ==="
${DOCKER} run --rm \
-v "${SCRIPT_DIR}:/src:rw" \
+ -v "${CCACHE_DIR}:/ccache:rw" \
+ -e CCACHE_DIR=/ccache \
-w /src \
--device /dev/fuse \
--cap-add SYS_ADMIN \
diff --git a/docker/build-inner.sh b/docker/build-inner.sh
index 8b7ac93..01a644d 100755
--- a/docker/build-inner.sh
+++ b/docker/build-inner.sh
@@ -7,6 +7,12 @@ BUILD_PY="${BUILD_PYTHON:-$(command -v python3)}"
PYBIND11_DIR="$("${BUILD_PY}" -c 'import pybind11; print(pybind11.get_cmake_dir())' 2>/dev/null || true)"
CMAKE_EXTRA_ARGS=()
+
+# Enable ccache if available and not explicitly overridden.
+if [ -z "${CMAKE_C_COMPILER_LAUNCHER:-}" ] && command -v ccache >/dev/null 2>&1; then
+ CMAKE_C_COMPILER_LAUNCHER=ccache
+ CMAKE_CXX_COMPILER_LAUNCHER=ccache
+fi
if [ -n "${CMAKE_C_COMPILER_LAUNCHER:-}" ]; then
CMAKE_EXTRA_ARGS+=("-DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER}")
fi
diff --git a/libs/uibase/src/log.cpp b/libs/uibase/src/log.cpp
index a44c9e3..b7c6a9a 100644
--- a/libs/uibase/src/log.cpp
+++ b/libs/uibase/src/log.cpp
@@ -109,11 +109,15 @@ protected:
spdlog::memory_buf_t formatted;
base_sink::formatter_->format(m, formatted);
- if (formatted.size() >= 2) {
- // remove \r\n
- e.formattedMessage.assign(formatted.begin(), formatted.end() - 2);
- } else {
- e.formattedMessage = std::string(formatted);
+ // Strip trailing newline(s). spdlog appends \r\n on Windows but only
+ // \n on Linux; unconditionally removing 2 chars truncates the real message.
+ {
+ auto end = formatted.end();
+ while (end != formatted.begin() &&
+ (*(end - 1) == '\n' || *(end - 1) == '\r')) {
+ --end;
+ }
+ e.formattedMessage.assign(formatted.begin(), end);
}
(*m_f)(std::move(e));