Skip to content

Commit 2afbbd0

Browse files
marc-hblgirdwood
authored andcommitted
cmake/git-submodules: don't throw away work in progress at build time
- Add a simple test in cmake to download submodules only when rimage is missing. This stops randomly changing the source code from one build to the next and overwriting any submodule work in progress. - Remove the GIT_SUBMODULE option which is now useless because rimage is not optional for sof - Add a --merge option for safety. It makes zero difference right now but could save work in progress if we ever add more submodules (hopefully not) and someone struggles with submodules and ends up in a partially initialized state. Git submodules are rarely ever the answer; these few changes make them a bit more usable. Signed-off-by: Marc Herbert <marc.herbert@intel.com>
1 parent a10b0ad commit 2afbbd0

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

scripts/cmake/git-submodules.cmake

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22

33
find_package(Git)
4+
set(RIMAGE_CMAKE "${SOF_ROOT_SOURCE_DIRECTORY}/rimage/CMakeLists.txt")
5+
46
if(GIT_FOUND AND EXISTS "${SOF_ROOT_SOURCE_DIRECTORY}/.git")
5-
# Update submodules by default
6-
option(GIT_SUBMODULE "Check submodules during build" ON)
77

8-
if(GIT_SUBMODULE)
9-
message(STATUS "Git submodule update")
8+
if(NOT EXISTS "${RIMAGE_CMAKE}")
9+
message(STATUS "Git submodules update")
1010

11-
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
11+
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --merge --recursive
1212
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
1313
RESULT_VARIABLE GIT_SUBMOD_RESULT)
1414

@@ -18,6 +18,7 @@ if(GIT_FOUND AND EXISTS "${SOF_ROOT_SOURCE_DIRECTORY}/.git")
1818
endif()
1919
endif()
2020

21-
if(NOT EXISTS "${SOF_ROOT_SOURCE_DIRECTORY}/rimage/CMakeLists.txt")
22-
message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
21+
# rimage is not optional, see "git grep include.*rimage"
22+
if(NOT EXISTS "${RIMAGE_CMAKE}")
23+
message(FATAL_ERROR "rimage not found! Please update git submodules and try again.")
2324
endif()

0 commit comments

Comments
 (0)