Skip to content

Commit fab3ce6

Browse files
committed
Merge commit 'refs/pull/1177/head' of https://github.com/digitalbitbox/bitbox02-firmware
2 parents 7ce04cd + 2887762 commit fab3ce6

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

BUILD.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,12 @@ make coverage # or make -C build-build coverage
179179
```sh
180180
make -C build-build coverage-lcovr
181181
```
182+
183+
### SCCache / CCache
184+
185+
The build systems supports sccache/ccache, you just need to have it available in your path. You can
186+
install it into your dev container with the following commands:
187+
188+
```
189+
docker exec -u 0 -it bitbox02-firmware-dev bash -c 'apt update && apt install -y libssl-dev && CARGO_HOME=/opt/cargo cargo install --locked sccache'
190+
```

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ if(
3636
message(FATAL_ERROR "Invalid CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}")
3737
endif()
3838

39+
find_program(SCCACHE_PROGRAM sccache)
40+
find_program(CCACHE_PROGRAM ccache)
41+
if(SCCACHE_PROGRAM)
42+
set(CMAKE_C_COMPILER_LAUNCHER "${SCCACHE_PROGRAM}")
43+
elseif(CCACHE_PROGRAM)
44+
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
45+
endif()
46+
3947
project(bitbox02 C)
4048

4149
# nosys is set in arm.cmake so that `project(c)` above works. Remove it since it interferes with compile options
@@ -257,6 +265,7 @@ message(STATUS "Processor: ${CMAKE_SYSTEM_PROCESSOR}")
257265
message(STATUS " - Build -")
258266
message(STATUS "Compiler version: ${CMAKE_C_COMPILER_ID} ${C_COMPILER_VERSION}")
259267
message(STATUS "Compiler: ${CMAKE_C_COMPILER}")
268+
message(STATUS "Compiler cache: ${CMAKE_C_COMPILER_LAUNCHER}")
260269
message(STATUS "Linker: ${CMAKE_LINKER}")
261270
message(STATUS "Archiver: ${CMAKE_AR}")
262271
message(STATUS "Default CFLAGS: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}}")

external/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ include(ExternalProject)
22

33
if(CMAKE_CROSSCOMPILING)
44
set(CONFIGURE_FLAGS
5-
--host=${CMAKE_SYSTEM_PROCESSOR}-none-eabi --build=${CMAKE_HOST_SYSTEM_PROCESSOR}-linux-gnu)
5+
--host=${CMAKE_SYSTEM_PROCESSOR}-none-eabi
6+
--build=${CMAKE_HOST_SYSTEM_PROCESSOR}-linux-gnu
7+
"$<$<BOOL:${CMAKE_C_COMPILER_LAUNCHER}>:CC=${CMAKE_C_COMPILER_LAUNCHER} ${CMAKE_C_COMPILER}>"
8+
)
69
endif()
710

811
# Remove parameters to make build identical to older build

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ foreach(type ${RUST_LIBS})
508508
CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}
509509
RUSTFLAGS=${RUSTFLAGS}
510510
FIRMWARE_VERSION_SHORT=${FIRMWARE_VERSION}
511+
$<$<BOOL:${SCCACHE_PROGRAM}>:RUSTC_WRAPPER=${SCCACHE_PROGRAM}>
511512
${CARGO} build $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:-v> --features target-${type} --target-dir ${RUST_BINARY_DIR}/feature-${type} ${RUST_CARGO_FLAG} ${RUST_TARGET_ARCH_ARG}
512513
COMMAND
513514
${CMAKE_COMMAND} -E copy_if_different ${lib} ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/lib${type}_rust_c.a

0 commit comments

Comments
 (0)