Skip to content

Commit 784569f

Browse files
committed
extract version into into version.cmake
1 parent d1b636c commit 784569f

File tree

4 files changed

+28
-41
lines changed

4 files changed

+28
-41
lines changed

CMakeLists.txt

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@ set(CMAKE_C_FLAGS_RELEASE "-Os")
1919
set(CMAKE_CXX_FLAGS_RELEASE "-Os")
2020
set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s)
2121

22-
# Define the application version
23-
set(APP_VERSION_MAJOR 1)
24-
set(APP_VERSION_MINOR 5)
25-
set(APP_VERSION_PATCH 99) # patch level 99 = work-in-progress for next release
26-
set(APP_VERSION_STRING "${APP_VERSION_MAJOR}.${APP_VERSION_MINOR}.${APP_VERSION_PATCH}")
22+
# Include version definitions
23+
include(version.cmake)
2724

2825
add_compile_options(
2926
${CPU_OPTIONS}
@@ -188,21 +185,6 @@ add_executable(${PROJECT_NAME}
188185

189186
tinyusb_target_add(${PROJECT_NAME})
190187

191-
# Get the GIT SHA
192-
execute_process(
193-
COMMAND git rev-parse --short HEAD
194-
OUTPUT_VARIABLE GIT_SHA
195-
OUTPUT_STRIP_TRAILING_WHITESPACE
196-
)
197-
198-
target_compile_definitions(${PROJECT_NAME} PRIVATE -DGIT_SHA="${GIT_SHA}")
199-
200-
target_compile_definitions(${PROJECT_NAME} PRIVATE -DAPP_VERSION_MAJOR=${APP_VERSION_MAJOR})
201-
target_compile_definitions(${PROJECT_NAME} PRIVATE -DAPP_VERSION_MINOR=${APP_VERSION_MINOR})
202-
target_compile_definitions(${PROJECT_NAME} PRIVATE -DAPP_VERSION_PATCH=${APP_VERSION_PATCH})
203-
target_compile_definitions(${PROJECT_NAME} PRIVATE -DAPP_VERSION="${APP_VERSION_STRING}")
204-
target_compile_definitions(${PROJECT_NAME} PRIVATE -DAPP_VERSION_FULL="${APP_VERSION_STRING}-${GIT_SHA}")
205-
206188
target_link_libraries(${PROJECT_NAME}
207189
${CPU_OPTIONS}
208190
-T${LINKER_SCRIPT}

src/config/tusb_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
#endif
7777

7878
#ifndef CFG_TUSB_DEBUG
79-
#define CFG_TUSB_DEBUG 1
79+
#define CFG_TUSB_DEBUG 0
8080
#endif
8181

8282
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.

test/CMakeLists.txt

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ project(xlat_linux)
44
# Define project root directory
55
set(PROJECT_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/..)
66

7+
# Include version definitions
8+
include(${PROJECT_ROOT}/version.cmake)
9+
710
# Set build type to Debug if not specified
811
if(NOT CMAKE_BUILD_TYPE)
912
set(CMAKE_BUILD_TYPE Debug)
@@ -81,23 +84,3 @@ target_compile_definitions(xlat_linux PRIVATE
8184
LV_CONF_PATH=${LV_CONF_PATH}
8285
LV_DRV_CONF_PATH=${LV_DRV_CONF_PATH}
8386
)
84-
85-
# Add version information
86-
set(APP_VERSION_MAJOR 1)
87-
set(APP_VERSION_MINOR 0)
88-
set(APP_VERSION_PATCH 0)
89-
set(APP_VERSION_STRING "${APP_VERSION_MAJOR}.${APP_VERSION_MINOR}.${APP_VERSION_PATCH}")
90-
91-
# Get the GIT SHA
92-
execute_process(
93-
COMMAND git rev-parse --short HEAD
94-
OUTPUT_VARIABLE GIT_SHA
95-
OUTPUT_STRIP_TRAILING_WHITESPACE
96-
)
97-
98-
target_compile_definitions(xlat_linux PRIVATE
99-
APP_VERSION_MAJOR=${APP_VERSION_MAJOR}
100-
APP_VERSION_MINOR=${APP_VERSION_MINOR}
101-
APP_VERSION_PATCH=${APP_VERSION_PATCH}
102-
APP_VERSION_FULL="${APP_VERSION_STRING}-${GIT_SHA}"
103-
)

version.cmake

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Define the application version
2+
set(APP_VERSION_MAJOR 1)
3+
set(APP_VERSION_MINOR 5)
4+
set(APP_VERSION_PATCH 99) # patch level 99 = work-in-progress for next release
5+
set(APP_VERSION_STRING "${APP_VERSION_MAJOR}.${APP_VERSION_MINOR}.${APP_VERSION_PATCH}")
6+
7+
# Get the GIT SHA
8+
execute_process(
9+
COMMAND git rev-parse --short HEAD
10+
OUTPUT_VARIABLE GIT_SHA
11+
OUTPUT_STRIP_TRAILING_WHITESPACE
12+
)
13+
14+
# Define version-related compile definitions
15+
add_definitions(
16+
-DAPP_VERSION_MAJOR=${APP_VERSION_MAJOR}
17+
-DAPP_VERSION_MINOR=${APP_VERSION_MINOR}
18+
-DAPP_VERSION_PATCH=${APP_VERSION_PATCH}
19+
-DAPP_VERSION="${APP_VERSION_STRING}"
20+
-DAPP_VERSION_FULL="${APP_VERSION_STRING}-${GIT_SHA}"
21+
-DGIT_SHA="${GIT_SHA}"
22+
)

0 commit comments

Comments
 (0)