Skip to content

Commit 40e74b0

Browse files
committed
build: Do not overwrite lv_conf.defaults in source path
When a non-default lv_conf.defaults is used it is currenly copied out of the configs/ directory replacing the existing lv_conf.defaults file. This makes changes to source files during build which should be avoided, only modifications should happen in the build directory. There is no need to do this as we can simply update the path used to locate lv_conf.defaults in CMake to the non-default file path and use it just the same. Signed-off-by: Andrew Davis <afd@ti.com>
1 parent 14a5a0c commit 40e74b0

File tree

1 file changed

+6
-25
lines changed

1 file changed

+6
-25
lines changed

CMakeLists.txt

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,16 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wpedantic")
2525
set(CONFIG "default" CACHE STRING "Config name to use. Leave empty for default `lv_conf.defaults`")
2626

2727
set(LV_CONF_DEFAULTS_PATH "${CMAKE_SOURCE_DIR}/lv_conf.defaults")
28-
set(LV_CONF_DEFAULTS_OLD_PATH "${CMAKE_SOURCE_DIR}/lv_conf.defaults.old")
2928

30-
# If CONFIG is not default, copy the selected config to lv_conf.defaults
29+
# If CONFIG is not default, update LV_CONF_DEFAULTS_PATH to the selected config
3130
if(NOT CONFIG STREQUAL "default")
32-
set(CONFIG_FILE "${CMAKE_SOURCE_DIR}/configs/${CONFIG}.defaults")
33-
34-
# Verify the config file exists
35-
if(NOT EXISTS "${CONFIG_FILE}")
36-
message(FATAL_ERROR "Config file not found: ${CONFIG_FILE}")
37-
endif()
38-
39-
# Backup the current lv_conf.defaults to lv_conf.defaults.old
40-
if(EXISTS "${LV_CONF_DEFAULTS_PATH}")
41-
file(RENAME "${LV_CONF_DEFAULTS_PATH}" "${LV_CONF_DEFAULTS_OLD_PATH}")
42-
message(STATUS "Backed up lv_conf.defaults to lv_conf.defaults.old")
43-
endif()
44-
45-
# Copy the config file to lv_conf.defaults
46-
configure_file("${CONFIG_FILE}" "${LV_CONF_DEFAULTS_PATH}" COPYONLY)
47-
message(STATUS "Copied configs/${CONFIG}.defaults to ${LV_CONF_DEFAULTS_PATH}")
48-
message(STATUS "Using config: configs/${CONFIG}.defaults")
49-
else()
50-
if(NOT EXISTS "${LV_CONF_DEFAULTS_PATH}")
51-
message(FATAL_ERROR "Config file not found: ${LV_CONF_DEFAULTS_PATH}")
52-
endif()
53-
message(STATUS "Using default lv_conf.defaults")
54-
message(STATUS "Using config: ${LV_CONF_DEFAULTS_PATH}")
31+
set(LV_CONF_DEFAULTS_PATH "${CMAKE_SOURCE_DIR}/configs/${CONFIG}.defaults")
5532
endif()
5633

34+
if(NOT EXISTS "${LV_CONF_DEFAULTS_PATH}")
35+
message(FATAL_ERROR "Config file not found: ${LV_CONF_DEFAULTS_PATH}")
36+
endif()
37+
message(STATUS "Using config: ${LV_CONF_DEFAULTS_PATH}")
5738

5839
set(LV_BUILD_SET_CONFIG_OPTS ON CACHE BOOL
5940
"create CMAKE variables from lv_conf_internal.h" FORCE)

0 commit comments

Comments
 (0)