Skip to content

Commit

Permalink
[buildmgr] Enforce toolchain registration environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
brondani committed Jul 17, 2024
1 parent 299dfc3 commit 2b747bd
Show file tree
Hide file tree
Showing 28 changed files with 58 additions and 31 deletions.
1 change: 1 addition & 0 deletions .github/workflows/buildmgr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ jobs:
CI_CBUILD_INSTALLER: ${{ github.workspace }}/cbuild_install.sh
CMSIS_PACK_ROOT: ${{ github.workspace }}/packs
GCC_TOOLCHAIN_ROOT: ${{ github.workspace }}/${{ matrix.toolchain_root }}
GCC_TOOLCHAIN_10_3_1: ${{ github.workspace }}/${{ matrix.toolchain_root }}
CI_ARCH: ${{ matrix.arch }}
strategy:
#fail-fast: true
Expand Down
7 changes: 3 additions & 4 deletions tools/buildmgr/cbuild/src/CbuildModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,9 @@ bool CbuildModel::GetCompatibleToolchain(const string& name, const string& versi
}

if (selectedVersion.empty()) {
// no compatible registered toolchain was found, search for a suitable config file
if (GetToolchainConfig(toolchainConfigFiles, name, versionRange)) {
return true;
}
// no compatible registered toolchain was found
LogMsg("M616", VAL("NAME", name));
return false;
} else {
// registered toolchain was found
m_toolchainRegisteredVersion = selectedVersion;
Expand Down
1 change: 1 addition & 0 deletions tools/buildmgr/cbuild/src/CbuildMsgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ void InitMessageTable()
table["M613"] = MessageEntry(MsgLevel::LEVEL_ERROR, CRLF_B, "File '%PATH%' has unexpected format!" );
table["M614"] = MessageEntry(MsgLevel::LEVEL_ERROR, CRLF_B, "Missing access sequence delimiter: '%ACCSEQDELIM%'!" );
table["M615"] = MessageEntry(MsgLevel::LEVEL_ERROR, CRLF_B, "%PROP% '%VAL%' was not found in the loaded packs!" );
table["M616"] = MessageEntry(MsgLevel::LEVEL_ERROR, CRLF_B, "compiler registration environment variable missing, format: %NAME%_TOOLCHAIN_<major>_<minor>_<patch>");

table["M630"] = MessageEntry(MsgLevel::LEVEL_WARNING, CRLF_B, "Device '%DEV%' is substituted with variant '%VAR%'." );
table["M631"] = MessageEntry(MsgLevel::LEVEL_WARNING, CRLF_B, "Project must have exactly one target element!" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ set(CXX_FLAGS_C:/Temp/devtools/tools/buildmgr/test/testinput/Examples/GCC/Access

# Toolchain config map

set(REGISTERED_TOOLCHAIN_ROOT "C:/Compilers/GCC/10.3.1/bin")
set(REGISTERED_TOOLCHAIN_VERSION "10.3.1")
set(TOOLCHAIN_VERSION_MIN "9.2.1")
include ("C:/sandbox/cbuild/etc/GCC.10.3.1.cmake")
include ("C:/sandbox/cbuild/etc/CMSIS-Build-Utils.cmake")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ set(AS_FLAGS_C:/sandbox/devtools/build/TestOutput/TestData/Examples/GCC/Asm/GAS.

# Toolchain config map

set(REGISTERED_TOOLCHAIN_ROOT "C:/Compilers/GCC/10.3.1/bin")
set(REGISTERED_TOOLCHAIN_VERSION "10.3.1")
set(TOOLCHAIN_VERSION_MIN "9.2.1")
include ("C:/sandbox/cbuild/etc/GCC.10.3.1.cmake")
include ("C:/sandbox/cbuild/etc/CMSIS-Build-Utils.cmake")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ set(LIB_FILES

# Toolchain config map

set(REGISTERED_TOOLCHAIN_ROOT "C:/Compilers/GCC/10.3.1/bin")
set(REGISTERED_TOOLCHAIN_VERSION "10.3.1")
set(TOOLCHAIN_VERSION_MIN "10.2.1")
include ("C:/sandbox/cbuild/etc/GCC.10.3.1.cmake")
include ("C:/sandbox/cbuild/etc/CMSIS-Build-Utils.cmake")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ set(LIB_FILES

# Toolchain config map

set(REGISTERED_TOOLCHAIN_ROOT "C:/Compilers/GCC/10.3.1/bin")
set(REGISTERED_TOOLCHAIN_VERSION "10.3.1")
set(TOOLCHAIN_VERSION_MIN "9.2.1")
include ("C:/sandbox/cbuild/etc/GCC.10.3.1.cmake")
include ("C:/sandbox/cbuild/etc/CMSIS-Build-Utils.cmake")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ set(LIB_FILES

# Toolchain config map

set(REGISTERED_TOOLCHAIN_ROOT "C:/Compilers/GCC/10.3.1/bin")
set(REGISTERED_TOOLCHAIN_VERSION "10.3.1")
set(TOOLCHAIN_VERSION_MIN "9.2.1")
include ("C:/sandbox/cbuild/etc/GCC.10.3.1.cmake")
include ("C:/sandbox/cbuild/etc/CMSIS-Build-Utils.cmake")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ set(CC_SRC_FILES

# Toolchain config map

set(REGISTERED_TOOLCHAIN_ROOT "C:/Compilers/GCC/10.3.1/bin")
set(REGISTERED_TOOLCHAIN_VERSION "10.3.1")
set(TOOLCHAIN_VERSION_MIN "9.2.1")
include ("C:/sandbox/cbuild/etc/GCC.10.3.1.cmake")
include ("C:/sandbox/cbuild/etc/CMSIS-Build-Utils.cmake")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ set(CC_SRC_FILES

# Toolchain config map

set(REGISTERED_TOOLCHAIN_ROOT "C:/Compilers/GCC/10.3.1/bin")
set(REGISTERED_TOOLCHAIN_VERSION "10.3.1")
set(TOOLCHAIN_VERSION_MIN "9.2.1")
include ("C:/sandbox/cbuild/etc/GCC.10.3.1.cmake")
include ("C:/sandbox/cbuild/etc/CMSIS-Build-Utils.cmake")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ set(CC_FLAGS_C:/Users/Test/AppData/Local/Arm/Packs/ARM/CMSIS/5.8.0/CMSIS/RTOS2/R

# Toolchain config map

set(REGISTERED_TOOLCHAIN_ROOT "C:/Compilers/GCC/10.3.1/bin")
set(REGISTERED_TOOLCHAIN_VERSION "10.3.1")
set(TOOLCHAIN_VERSION_MIN "9.2.1")
include ("C:/sandbox/cbuild/etc/GCC.10.3.1.cmake")
include ("C:/sandbox/cbuild/etc/CMSIS-Build-Utils.cmake")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ set(CXX_SRC_FILES

# Toolchain config map

set(REGISTERED_TOOLCHAIN_ROOT "C:/Compilers/GCC/10.3.1/bin")
set(REGISTERED_TOOLCHAIN_VERSION "10.3.1")
set(TOOLCHAIN_VERSION_MIN "10.2.1")
include ("C:/sandbox/cbuild/etc/GCC.10.2.1.cmake")
include ("C:/sandbox/cbuild/etc/CMSIS-Build-Utils.cmake")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ set(CXX_SRC_FILES

# Toolchain config map

set(REGISTERED_TOOLCHAIN_ROOT "C:/Compilers/GCC/10.3.1/bin")
set(REGISTERED_TOOLCHAIN_VERSION "10.3.1")
set(TOOLCHAIN_VERSION_MIN "10.2.1")
include ("C:/sandbox/cbuild/etc/GCC.10.2.1.cmake")
include ("C:/sandbox/cbuild/etc/CMSIS-Build-Utils.cmake")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ set(CC_SRC_FILES

# Toolchain config map

set(REGISTERED_TOOLCHAIN_ROOT "C:/Compilers/GCC/10.3.1/bin")
set(REGISTERED_TOOLCHAIN_VERSION "10.3.1")
set(TOOLCHAIN_VERSION_MIN "9.2.1")
include ("C:/sandbox/cbuild/etc/GCC.10.3.1.cmake")
include ("C:/sandbox/cbuild/etc/CMSIS-Build-Utils.cmake")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ set(CC_SRC_FILES

# Toolchain config map

set(REGISTERED_TOOLCHAIN_ROOT "C:/Compilers/GCC/10.3.1/bin")
set(REGISTERED_TOOLCHAIN_VERSION "10.3.1")
set(TOOLCHAIN_VERSION_MIN "9.2.1")
include ("C:/sandbox/cbuild/etc/GCC.10.3.1.cmake")
include ("C:/sandbox/cbuild/etc/CMSIS-Build-Utils.cmake")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ set(CC_SRC_FILES

# Toolchain config map

set(REGISTERED_TOOLCHAIN_ROOT "C:/Compilers/GCC/10.3.1/bin")
set(REGISTERED_TOOLCHAIN_VERSION "10.3.1")
set(TOOLCHAIN_VERSION_MIN "9.2.1")
include ("C:/sandbox/cbuild/etc/GCC.10.3.1.cmake")
include ("C:/sandbox/cbuild/etc/CMSIS-Build-Utils.cmake")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ set(CC_SRC_FILES

# Toolchain config map

set(REGISTERED_TOOLCHAIN_ROOT "C:/Compilers/GCC/10.3.1/bin")
set(REGISTERED_TOOLCHAIN_VERSION "10.3.1")
set(TOOLCHAIN_VERSION_MIN "9.2.1")
include ("C:/sandbox/cbuild/etc/GCC.10.3.1.cmake")
include ("C:/sandbox/cbuild/etc/CMSIS-Build-Utils.cmake")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ set(CC_FLAGS_C:/sandbox/devtools/build/TestOutput/TestData/Examples/GCC/NestedGr

# Toolchain config map

set(REGISTERED_TOOLCHAIN_ROOT "C:/Compilers/GCC/10.3.1/bin")
set(REGISTERED_TOOLCHAIN_VERSION "10.3.1")
set(TOOLCHAIN_VERSION_MIN "9.2.1")
include ("C:/sandbox/cbuild/etc/GCC.10.3.1.cmake")
include ("C:/sandbox/cbuild/etc/CMSIS-Build-Utils.cmake")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ set(PRE_INC_LOCAL_C:/Users/Test/AppData/Local/Arm/Packs/Keil/PreIncludeTestPack/

# Toolchain config map

set(REGISTERED_TOOLCHAIN_ROOT "C:/Compilers/GCC/10.3.1/bin")
set(REGISTERED_TOOLCHAIN_VERSION "10.3.1")
set(TOOLCHAIN_VERSION_MIN "9.2.1")
include ("C:/sandbox/cbuild/etc/GCC.10.3.1.cmake")
include ("C:/sandbox/cbuild/etc/CMSIS-Build-Utils.cmake")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ set(CC_SRC_FILES

# Toolchain config map

set(REGISTERED_TOOLCHAIN_ROOT "C:/Compilers/GCC/10.3.1/bin")
set(REGISTERED_TOOLCHAIN_VERSION "10.3.1")
set(TOOLCHAIN_VERSION_MIN "9.2.1")
include ("C:/sandbox/cbuild/etc/GCC.10.3.1.cmake")
include ("C:/sandbox/cbuild/etc/CMSIS-Build-Utils.cmake")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ set(CC_SRC_FILES

# Toolchain config map

set(REGISTERED_TOOLCHAIN_ROOT "C:/Compilers/GCC/10.3.1/bin")
set(REGISTERED_TOOLCHAIN_VERSION "10.3.1")
set(TOOLCHAIN_VERSION_MIN "9.2.1")
include ("C:/sandbox/devtools/tools/buildmgr/cbuildgen/config/GCC.10.3.1.cmake")
include ("C:/sandbox/devtools/tools/buildmgr/cbuildgen/config/CMSIS-Build-Utils.cmake")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ set(CXX_FLAGS_C:/Sandbox/devtools-external/build/testoutput/GCC/TranslationContr

# Toolchain config map

set(REGISTERED_TOOLCHAIN_ROOT "C:/Compilers/GCC/10.3.1/bin")
set(REGISTERED_TOOLCHAIN_VERSION "10.3.1")
set(TOOLCHAIN_VERSION_MIN "9.2.1")
include ("C:/sandbox/cbuild/etc/GCC.10.2.1.cmake")
include ("C:/sandbox/cbuild/etc/CMSIS-Build-Utils.cmake")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ set(CXX_FLAGS_C:/Sandbox/devtools-external/build/testoutput/GCC/TranslationContr

# Toolchain config map

set(REGISTERED_TOOLCHAIN_ROOT "C:/Compilers/GCC/10.3.1/bin")
set(REGISTERED_TOOLCHAIN_VERSION "10.3.1")
set(TOOLCHAIN_VERSION_MIN "9.2.1")
include ("C:/sandbox/cbuild/etc/GCC.10.2.1.cmake")
include ("C:/sandbox/cbuild/etc/CMSIS-Build-Utils.cmake")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ set(CXX_SRC_FILES

# Toolchain config map

set(REGISTERED_TOOLCHAIN_ROOT "C:/Compilers/GCC/10.3.1/bin")
set(REGISTERED_TOOLCHAIN_VERSION "10.3.1")
set(TOOLCHAIN_VERSION_MIN "10.2.1")
include ("C:/sandbox/cbuild/etc/GCC.10.2.1.cmake")
include ("C:/sandbox/cbuild/etc/CMSIS-Build-Utils.cmake")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ set(LIB_FILES

# Toolchain config map

set(REGISTERED_TOOLCHAIN_ROOT "C:/Compilers/GCC/10.3.1/bin")
set(REGISTERED_TOOLCHAIN_VERSION "10.3.1")
set(TOOLCHAIN_VERSION_MIN "9.2.1")
include ("C:/sandbox/cbuild/etc/GCC.10.2.1.cmake")
include ("C:/sandbox/cbuild/etc/CMSIS-Build-Utils.cmake")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ set(CC_SRC_FILES

# Toolchain config map

set(REGISTERED_TOOLCHAIN_ROOT "C:/Compilers/GCC/10.3.1/bin")
set(REGISTERED_TOOLCHAIN_VERSION "10.3.1")
set(TOOLCHAIN_VERSION_MIN "10.2.1")
include ("C:/sandbox/cbuild/etc/GCC.10.2.1.cmake")
include ("C:/sandbox/cbuild/etc/CMSIS-Build-Utils.cmake")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ set(LIB_FILES

# Toolchain config map

set(REGISTERED_TOOLCHAIN_ROOT "C:/Compilers/GCC/10.3.1/bin")
set(REGISTERED_TOOLCHAIN_VERSION "10.3.1")
set(TOOLCHAIN_VERSION_MIN "10.2.1")
include ("C:/sandbox/cbuild/etc/GCC.10.2.1.cmake")
include ("C:/sandbox/cbuild/etc/CMSIS-Build-Utils.cmake")
Expand Down
32 changes: 5 additions & 27 deletions tools/buildmgr/test/unittests/src/CbuildModelTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,19 @@ class CbuildModelTests : public CbuildModel, public ::testing::Test {
};


TEST_F(CbuildModelTests, GetCompatibleToolchain_Select_Latest) {
TEST_F(CbuildModelTests, GetCompatibleToolchain_NotRegistered) {
string name = "AC6", versionRange = "6.5.0:6.18.0", dir;
string toolchainDir = testinput_folder + "/toolchain";
string expectedToolchainVersion = "6.16.0";
string expectedToolchainConfig = toolchainDir + "/AC6.6.16.0.cmake";
RteFsUtils::NormalizePath(expectedToolchainConfig);
vector<string> envVars;

// Select latest compatible toolchain
// Check not registered toolchains
ASSERT_TRUE(RteFsUtils::CreateDirectories(toolchainDir));
ASSERT_TRUE(RteFsUtils::CreateTextFile(toolchainDir + "/AC6.6.6.4.cmake", ""));
ASSERT_TRUE(RteFsUtils::CreateTextFile(toolchainDir + "/AC6.6.16.0.cmake", ""));
ASSERT_TRUE(RteFsUtils::CreateTextFile(toolchainDir + "/GCC.6.19.0.cmake", ""));
EXPECT_TRUE(GetCompatibleToolchain(name, versionRange, toolchainDir, envVars));
EXPECT_EQ(m_toolchainConfigVersion, expectedToolchainVersion);
EXPECT_EQ(m_toolchainConfig, expectedToolchainConfig);
EXPECT_FALSE(GetCompatibleToolchain(name, versionRange, toolchainDir, envVars));
EXPECT_TRUE(m_toolchainConfigVersion.empty());
EXPECT_TRUE(m_toolchainConfig.empty());
ASSERT_TRUE(RteFsUtils::RemoveDir(toolchainDir));
}

Expand Down Expand Up @@ -61,25 +58,6 @@ TEST_F(CbuildModelTests, GetCompatibleToolchain_Invalid_Files) {
ASSERT_TRUE(RteFsUtils::RemoveDir(toolchainDir));
}

TEST_F(CbuildModelTests, GetCompatibleToolchain_Select_Latest_recursively) {
string name = "AC6", versionRange = "6.5.0:6.18.0", dir;
string toolchainDir = testinput_folder + "/toolchain";
string expectedToolchainVersion = "6.16.0";
string expectedToolchainConfig = toolchainDir + "/Test/AC6.6.16.0.cmake";
RteFsUtils::NormalizePath(expectedToolchainConfig);
vector<string> envVars;

// Select latest compatible toolchain
ASSERT_TRUE(RteFsUtils::CreateDirectories(toolchainDir+"/Test"));
ASSERT_TRUE(RteFsUtils::CreateTextFile(toolchainDir + "/Test/AC6.6.6.4.cmake", ""));
ASSERT_TRUE(RteFsUtils::CreateTextFile(toolchainDir + "/Test/AC6.6.16.0.cmake", ""));
ASSERT_TRUE(RteFsUtils::CreateTextFile(toolchainDir + "/Test/GCC.6.19.0.cmake", ""));
EXPECT_TRUE(GetCompatibleToolchain(name, versionRange, toolchainDir, envVars));
EXPECT_EQ(m_toolchainConfigVersion, expectedToolchainVersion);
EXPECT_EQ(m_toolchainConfig, expectedToolchainConfig);
ASSERT_TRUE(RteFsUtils::RemoveDir(toolchainDir));
}

TEST_F(CbuildModelTests, GetCompatibleToolchain_Registered) {
string name = "AC6", versionRange = "6.17.0:6.18.0", dir;
string toolchainDir = testinput_folder + "/toolchain";
Expand Down

0 comments on commit 2b747bd

Please sign in to comment.