Skip to content

Commit

Permalink
[buildmgr, projmgr] Update linker pre-processing
Browse files Browse the repository at this point in the history
  • Loading branch information
grasci-arm authored Nov 28, 2023
1 parent afc265d commit 8fd7ddc
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 24 deletions.
6 changes: 3 additions & 3 deletions tools/buildmgr/cbuildgen/src/CMakeListsGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 << "}\\\"";
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

<target Ddsp="NO_DSP" Dendian="Little-endian" Dfpu="NO_FPU" Dmve="NO_MVE" Dname="ARMCM3" Dsecure="Non-secure" Dtz="NO_TZ" Dvendor="ARM:82">
<output name="MyProject"/>
<ldflags add="--entry=Reset_Handler --specs=nosys.specs -mcpu=cortex-m3 -mthumb" compiler="GCC" file="./RTE/Device/ARMCM3/gcc_arm.ld.src">
<defines>LD_PP_DEF0;LD_PP_DEF1=3U</defines>
</ldflags>
<ldflags add="--entry=Reset_Handler --specs=nosys.specs -mcpu=cortex-m3 -mthumb" compiler="GCC" file="./RTE/Device/ARMCM3/gcc_arm.ld.src"/>
<cflags add="-O -Wall -gdwarf-2 -mapcs-frame -mthumb" compiler="GCC"/>
</target>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*----------------------------------------------------------------------------*/
Expand Down
1 change: 1 addition & 0 deletions tools/projmgr/src/ProjMgrWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 8fd7ddc

Please sign in to comment.