diff --git a/tools/buildmgr/cbuildgen/src/CMakeListsGenerator.cpp b/tools/buildmgr/cbuildgen/src/CMakeListsGenerator.cpp index 5696647e3..0674c3683 100644 --- a/tools/buildmgr/cbuildgen/src/CMakeListsGenerator.cpp +++ b/tools/buildmgr/cbuildgen/src/CMakeListsGenerator.cpp @@ -65,12 +65,12 @@ bool CMakeListsGenerator::GenBuildCMakeLists(void) { cmakelists << EOL << "set(LD_FLAGS_LIBRARIES \"" << CbuildUtils::EscapeQuotes(m_linkerLibsGlobal) << "\")"; } + const string linkerExt = fs::path(m_linkerScript).extension().generic_string(); if (!m_linkerScript.empty()) { cmakelists << EOL << "set(LD_SCRIPT \"" << m_linkerScript << "\")"; if (!m_linkerRegionsFile.empty()) { cmakelists << EOL << "set(LD_REGIONS \"" << m_linkerRegionsFile << "\")"; } - const string linkerExt = fs::path(m_linkerScript).extension().generic_string(); if ((linkerExt == SRCPPEXT) || !m_linkerRegionsFile.empty() || !m_linkerPreProcessorDefines.empty()) { string absLinkerScript = fs::path(m_linkerScript).filename().generic_string(); RteFsUtils::NormalizePath(absLinkerScript, m_intdir); @@ -508,7 +508,7 @@ bool CMakeListsGenerator::GenBuildCMakeLists(void) { cmakelists << "_LINK_FLAGS \"${LD_CPU}"; if (!m_linkerScript.empty() && !lib_output) { cmakelists << " ${_LS}\\\"${LD_SCRIPT"; - if (!m_linkerRegionsFile.empty() || !m_linkerPreProcessorDefines.empty()) { + if ((linkerExt == SRCPPEXT) || !m_linkerRegionsFile.empty() || !m_linkerPreProcessorDefines.empty()) { cmakelists << "_PP"; } cmakelists << "}\\\""; @@ -706,7 +706,7 @@ bool CMakeListsGenerator::GenBuildCMakeLists(void) { } // Linker script pre-processing - if (!m_linkerScript.empty() && !lib_output && (!m_linkerRegionsFile.empty() || !m_linkerPreProcessorDefines.empty())) { + if (!m_linkerScript.empty() && !lib_output && ((linkerExt == SRCPPEXT) || !m_linkerRegionsFile.empty() || !m_linkerPreProcessorDefines.empty())) { cmakelists << EOL << "# Linker script pre-processing" << EOL << EOL; cmakelists << "add_custom_command(TARGET ${TARGET} PRE_LINK COMMAND ${CPP} ARGS ${CPP_ARGS_LD_SCRIPT} BYPRODUCTS ${LD_SCRIPT_PP})" << EOL; } diff --git a/tools/buildmgr/test/testinput/Examples/GCC/LinkerPreProcessingSrcFile/CMakeLists.txt.ref b/tools/buildmgr/test/testinput/Examples/GCC/LinkerPreProcessingSrcFile/CMakeLists.txt.ref index c1f714b1d..67d4e16ec 100644 --- a/tools/buildmgr/test/testinput/Examples/GCC/LinkerPreProcessingSrcFile/CMakeLists.txt.ref +++ b/tools/buildmgr/test/testinput/Examples/GCC/LinkerPreProcessingSrcFile/CMakeLists.txt.ref @@ -20,11 +20,6 @@ set(LD_FLAGS_GLOBAL "--entry=Reset_Handler --specs=nosys.specs -mcpu=cortex-m3 - set(LD_SCRIPT "C:/sandbox/devtools/build/TestOutput/TestData/Examples/GCC/LinkerPreProcessing/RTE/Device/ARMCM3/gcc_arm.ld.src") set(LD_SCRIPT_PP "C:/sandbox/devtools/build/TestOutput/TestData/Examples/GCC/LinkerPreProcessing/IntDir/gcc_arm.ld") -set(LD_SCRIPT_PP_DEFINES - LD_PP_DEF0 - LD_PP_DEF1=3U -) - set(DEFINES ARMCM3 _RTE_ diff --git a/tools/buildmgr/test/testinput/Examples/GCC/LinkerPreProcessingSrcFile/MyProject.cprj b/tools/buildmgr/test/testinput/Examples/GCC/LinkerPreProcessingSrcFile/MyProject.cprj index 5e9cd1c22..a0a6c3682 100644 --- a/tools/buildmgr/test/testinput/Examples/GCC/LinkerPreProcessingSrcFile/MyProject.cprj +++ b/tools/buildmgr/test/testinput/Examples/GCC/LinkerPreProcessingSrcFile/MyProject.cprj @@ -18,9 +18,7 @@ - - LD_PP_DEF0;LD_PP_DEF1=3U - + diff --git a/tools/buildmgr/test/testinput/Examples/GCC/LinkerPreProcessingSrcFile/RTE/Device/ARMCM3/gcc_arm.ld.src b/tools/buildmgr/test/testinput/Examples/GCC/LinkerPreProcessingSrcFile/RTE/Device/ARMCM3/gcc_arm.ld.src index e17b08d01..ad7cae88f 100644 --- a/tools/buildmgr/test/testinput/Examples/GCC/LinkerPreProcessingSrcFile/RTE/Device/ARMCM3/gcc_arm.ld.src +++ b/tools/buildmgr/test/testinput/Examples/GCC/LinkerPreProcessingSrcFile/RTE/Device/ARMCM3/gcc_arm.ld.src @@ -43,19 +43,6 @@ #define __STACK_SIZE 0x00000200 #define __HEAP_SIZE 0x00000C00 -/* ---------------------------------------------------------------------------- - Test case 'defines' check - *----------------------------------------------------------------------------*/ -#ifndef LD_PP_DEF0 - #error "LD_PP_DEF0 was not defined" -#endif -#ifndef LD_PP_DEF1 - #error "LD_PP_DEF1 was not defined" -#endif -#if (LD_PP_DEF1 != 3U) - #error "LD_PP_DEF1 is not equal to 3U" -#endif - /* ---------------------------------------------------------------------------- Stack seal size definition *----------------------------------------------------------------------------*/ diff --git a/tools/projmgr/src/ProjMgrWorker.cpp b/tools/projmgr/src/ProjMgrWorker.cpp index d12b16d31..d933415ff 100644 --- a/tools/projmgr/src/ProjMgrWorker.cpp +++ b/tools/projmgr/src/ProjMgrWorker.cpp @@ -1869,6 +1869,7 @@ bool ProjMgrWorker::ProcessConfigFiles(ContextItem& context) { if (context.linker.autoGen) { if (!context.linker.script.empty()) { ProjMgrLogger::Warn("conflict: automatic linker script generation overrules specified script '" + context.linker.script + "'"); + context.linker.script.clear(); } } else if (context.linker.script.empty() && context.linker.regions.empty() && context.linker.defines.empty()) { const auto& groups = context.rteActiveTarget->GetProjectGroups();