Skip to content

Commit 795c60e

Browse files
committed
[ATfE] Set Arm Toolchain ID (arm#127)
In order to uniquely identify ATfE builds, this patch populates the new Arm Toolchain ID with an auto-generated tag. This tag contains both the product code (E for Embedded), as well as a unique identifier for the build. In a Jenkins environment, this will be based on the build URL and build number. (cherry picked from commit e0066d1)
1 parent 317b598 commit 795c60e

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

arm-software/embedded/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,12 @@ install(
335335
COMPONENT llvm-toolchain-config-files
336336
)
337337

338+
# Generate a toolchain ID.
339+
# Product code 'E' for Embedded.
340+
set(LLVM_TOOLCHAIN_PROJECT_CODE "E")
341+
set(LLVM_TOOLCHAIN_VERSION_SUFFIX "pre")
342+
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/generate_toolchain_id.cmake)
343+
338344
set(llvmproject_src_dir ${CMAKE_CURRENT_SOURCE_DIR}/../..)
339345
add_subdirectory(
340346
${llvmproject_src_dir}/llvm llvm
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Generate a toolchain ID.
2+
# This should identify the product, and where the build came from.
3+
4+
# The ID begins with a product code (e.g. E for Embedded), followed
5+
# by build identifier. The build identifier will depend on the
6+
# build environment: for Jenkins builds, the pipeline and build
7+
# number will be sufficient.
8+
9+
if(NOT DEFINED LLVM_TOOLCHAIN_PROJECT_CODE)
10+
message(FATAL_ERROR "LLVM_TOOLCHAIN_PROJECT_CODE must be set before including generate_toolchain_id.cmake")
11+
endif()
12+
13+
# JENKINS_URL, BUILD_URL and BUILD_NUMBER will be set in a Jenkins environment.
14+
if(DEFINED ENV{JENKINS_URL} AND DEFINED ENV{BUILD_URL} AND DEFINED ENV{BUILD_NUMBER})
15+
set(builder_name $ENV{BUILD_URL})
16+
set(build_number $ENV{BUILD_NUMBER})
17+
# BUILD_URL also contains the build number, which is not needed.
18+
string(REGEX REPLACE "/${build_number}/$" "/" builder_name ${builder_name})
19+
else()
20+
# Use HOSTNAME if nothing else is available.
21+
cmake_host_system_information(RESULT builder_name QUERY HOSTNAME)
22+
set(build_number 0)
23+
endif()
24+
25+
# Version suffix should be optional.
26+
if(DEFINED LLVM_TOOLCHAIN_VERSION_SUFFIX)
27+
set(ID_SUFFIX "-${LLVM_TOOLCHAIN_VERSION_SUFFIX}")
28+
else()
29+
set(ID_SUFFIX "")
30+
endif()
31+
32+
string(SHA256 builder_name_hash ${builder_name})
33+
string(SUBSTRING ${builder_name_hash} 0 8 builder_name_hash)
34+
set(ARM_TOOLCHAIN_ID
35+
"${LLVM_TOOLCHAIN_PROJECT_CODE}${build_number}${ID_SUFFIX} (${builder_name_hash})" CACHE STRING
36+
"Toolchain ID to identify product."
37+
)

0 commit comments

Comments
 (0)