Skip to content

Commit e2141fa

Browse files
committed
Move Toolchain ID script to shared location (arm#170)
This patch makes a few modifications to the CMake script to generate the Arm Toolchain ID: * The script has been moved out of the embedded build folder and into a new shared one, so that it can be used by multiple toolchains. * When run in script mode, the script will print the generated ID. This can then be easily captured by an external script. * The build number is now padded to a minimum of 4 characters. (cherry picked from commit 17138e2)
1 parent 795c60e commit e2141fa

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

arm-software/embedded/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ install(
339339
# Product code 'E' for Embedded.
340340
set(LLVM_TOOLCHAIN_PROJECT_CODE "E")
341341
set(LLVM_TOOLCHAIN_VERSION_SUFFIX "pre")
342-
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/generate_toolchain_id.cmake)
342+
include(${CMAKE_CURRENT_SOURCE_DIR}/../shared/cmake/generate_toolchain_id.cmake)
343343

344344
set(llvmproject_src_dir ${CMAKE_CURRENT_SOURCE_DIR}/../..)
345345
add_subdirectory(

arm-software/embedded/cmake/generate_toolchain_id.cmake renamed to arm-software/shared/cmake/generate_toolchain_id.cmake

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ else()
2222
set(build_number 0)
2323
endif()
2424

25+
# Pad build number
26+
string(LENGTH ${build_number} len_build_number)
27+
if(len_build_number LESS 4)
28+
math(EXPR pad_len "4 - ${len_build_number}")
29+
string(REPEAT "0" ${pad_len} pad_chars)
30+
string(PREPEND build_number ${pad_chars})
31+
endif()
32+
2533
# Version suffix should be optional.
2634
if(DEFINED LLVM_TOOLCHAIN_VERSION_SUFFIX)
2735
set(ID_SUFFIX "-${LLVM_TOOLCHAIN_VERSION_SUFFIX}")
@@ -35,3 +43,9 @@ set(ARM_TOOLCHAIN_ID
3543
"${LLVM_TOOLCHAIN_PROJECT_CODE}${build_number}${ID_SUFFIX} (${builder_name_hash})" CACHE STRING
3644
"Toolchain ID to identify product."
3745
)
46+
47+
# Print the ID in script mode.
48+
get_property(cmake_role GLOBAL PROPERTY CMAKE_ROLE)
49+
if(cmake_role STREQUAL SCRIPT)
50+
execute_process(COMMAND ${CMAKE_COMMAND} -E echo ${ARM_TOOLCHAIN_ID})
51+
endif()

0 commit comments

Comments
 (0)