Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cbuild2cmake] Add output map file handling #229

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions pkg/maker/buildcontent.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ func OutputFiles(outputList []Output) (outputByProducts string, outputFile strin
case "bin":
outputByProducts += "\nset(BIN_FILE \"" + output.File + "\")"
customCommands += "\n\n# Bin Conversion\n add_custom_command(TARGET ${CONTEXT} POST_BUILD COMMAND ${CMAKE_OBJCOPY} ${ELF2BIN})"
case "map":
outputByProducts += "\nset(LD_MAP_FILE \"" + output.File + "\")"
case "cmse-lib":
outputByProducts += "\nset(CMSE_LIB \"" + output.File + "\")"
case "elf", "lib":
Expand All @@ -150,6 +152,15 @@ func OutputFiles(outputList []Output) (outputByProducts string, outputFile strin
return outputByProducts, outputFile, outputType, customCommands
}

func HasMapFile(outputList []Output) bool {
for _, output := range outputList {
if output.Type == "map" {
return true
}
}
return false
}

func (m *Maker) AddStepSuffix(name string) string {
if slices.Contains(m.Contexts, name) {
name += "-build"
Expand Down Expand Up @@ -809,6 +820,9 @@ func (c *Cbuild) LinkerOptions() (linkerVars string, linkerOptions string) {
linkerOptions += "\n# Linker options\ntarget_link_options(${CONTEXT} PUBLIC\n " +
AddShellPrefix("${LD_CPU}") + "\n " +
AddShellPrefix("${_LS}\"${LD_SCRIPT_PP}\"")
if HasMapFile(c.BuildDescType.Output) {
linkerOptions += "\n " + AddShellPrefix("${LD_MAP}")
}
if len(c.BuildDescType.Processor.Trustzone) > 0 {
linkerOptions += "\n " + AddShellPrefix("${LD_SECURE}")
}
Expand Down
12 changes: 12 additions & 0 deletions pkg/maker/buildcontent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,18 @@ func TestBuildContent(t *testing.T) {
File: "./secure.lib",
Type: "cmse-lib",
},
{
File: "./project.map",
Type: "map",
},
}
outputByProducts, outputFile, outputType, customCommands := maker.OutputFiles(output)
assert.Equal(outputFile, "./arfifact.elf")
assert.Equal(outputType, "elf")
assert.Contains(outputByProducts, "binary.bin")
assert.Contains(outputByProducts, "hexadecimal.hex")
assert.Contains(outputByProducts, "secure.lib")
assert.Contains(outputByProducts, "project.map")
assert.Contains(customCommands, "${ELF2BIN}")
assert.Contains(customCommands, "${ELF2HEX}")
})
Expand Down Expand Up @@ -403,8 +408,15 @@ add_dependencies(project.debug+target-executes
cbuild.BuildDescType.Misc.Link = []string{"--link-flag"}
cbuild.BuildDescType.Misc.LinkC = []string{"--linkC-flag"}
cbuild.BuildDescType.Misc.LinkCPP = []string{"--linkCPP-flag"}
cbuild.BuildDescType.Output = []maker.Output{
{
File: "./project.map",
Type: "map",
},
}
linkerVars, linkerOptions := cbuild.LinkerOptions()
assert.Contains(linkerVars, "set(LD_SCRIPT \"${SOLUTION_ROOT}/path/to/script.ld\")")
assert.Contains(linkerOptions, "${LD_MAP}")
assert.Contains(linkerOptions, "${LD_SECURE}")
assert.Contains(linkerOptions, "--link-flag")
assert.Contains(linkerOptions, "--linkC-flag")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
build:
generated-by: csolution version 0.0.0+g447ad5d7
generated-by: csolution version 2.6.0
solution: ../solution.csolution.yml
project: project.cproject.yml
context: project.AC6+ARMCM0
compiler: AC6
device: ARMCM0
device-pack: ARM::Cortex_DFP@1.0.0
device-pack: ARM::Cortex_DFP@1.1.0
processor:
fpu: off
core: Cortex-M0
packs:
- pack: ARM::CMSIS@6.0.0
path: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0
- pack: ARM::Cortex_DFP@1.0.0
path: ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.0.0
- pack: ARM::CMSIS@6.1.0
path: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0
- pack: ARM::Cortex_DFP@1.1.0
path: ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.1.0
misc:
ASM:
- -masm=auto
Expand All @@ -29,63 +29,62 @@ build:
- -Wno-parentheses-equality
- -Wno-license-management
Link:
- --info summarysizes
- --info sizes
- --info totals
- --info unused
- --entry=Reset_Handler
- --map
- --summary_stderr
- --diag_suppress=L6314W
define:
- ARMCM0
- _RTE_
define-asm:
- ARMCM0
- _RTE_
add-path:
- RTE/_AC6_ARMCM0
- ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Core/Include
- ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.0.0/Device/ARMCM0/Include
- ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Core/Include
- ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.1.0/Device/ARMCM0/Include
add-path-asm:
- RTE/_AC6_ARMCM0
- ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Core/Include
- ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.0.0/Device/ARMCM0/Include
- ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Core/Include
- ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.1.0/Device/ARMCM0/Include
output-dirs:
intdir: ../tmp/project/ARMCM0/AC6
intdir: ../tmp
outdir: ../out/project/ARMCM0/AC6
rtedir: RTE
output:
- type: elf
file: project.axf
- type: map
file: project.map
components:
- component: ARM::CMSIS:CORE@6.0.0
- component: ARM::CMSIS:CORE@6.1.0
condition: ARMv6_7_8-M Device
from-pack: ARM::CMSIS@6.0.0
from-pack: ARM::CMSIS@6.1.0
selected-by: ARM::CMSIS:CORE
files:
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Core/Include
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Core/Include
category: include
version: 6.0.0
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Core/Include/tz_context.h
version: 6.1.0
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Core/Include/tz_context.h
category: header
version: 6.0.0
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Core/Template/ARMv8-M/main_s.c
version: 6.1.0
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Core/Template/ARMv8-M/main_s.c
category: sourceC
attr: template
version: 1.1.1
select: Secure mode 'main' module for ARMv8-M
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Core/Template/ARMv8-M/tz_context.c
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Core/Template/ARMv8-M/tz_context.c
category: sourceC
attr: template
version: 1.1.1
select: RTOS Context Management (TrustZone for ARMv8-M)
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Documentation/html/Core/index.html
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Documentation/html/Core/index.html
category: doc
version: 6.0.0
version: 6.1.0
- component: ARM::Device:Startup&C [email protected]
condition: ARMCM0 CMSIS
from-pack: ARM::Cortex_DFP@1.0.0
from-pack: ARM::Cortex_DFP@1.1.0
selected-by: ARM::Device:Startup&C Startup
files:
- file: ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.0.0/Device/ARMCM0/Include/ARMCM0.h
- file: ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.1.0/Device/ARMCM0/Include/ARMCM0.h
category: header
version: 2.2.0
- file: RTE/Device/ARMCM0/ARMCM0_ac6.sct
Expand All @@ -108,21 +107,16 @@ build:
groups:
- group: Source
files:
- file: ./main.c
- file: main.c
category: sourceC
constructed-files:
- file: RTE/_AC6_ARMCM0/RTE_Components.h
category: header
licenses:
- license: <unknown>
license-agreement: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/LICENSE
packs:
- pack: ARM::[email protected]
components:
- component: ARM::CMSIS:[email protected]
- license: <unknown>
license-agreement: ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.0.0/LICENSE
- license: Apache-2.0
packs:
- pack: ARM::[email protected]
- pack: ARM::[email protected]
- pack: ARM::[email protected]
components:
- component: ARM::CMSIS:[email protected]
- component: ARM::Device:Startup&C [email protected]
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
build:
generated-by: csolution version 0.0.0+g447ad5d7
generated-by: csolution version 2.6.0
solution: ../solution.csolution.yml
project: project.cproject.yml
context: project.CLANG+ARMCM0
compiler: CLANG
device: ARMCM0
device-pack: ARM::Cortex_DFP@1.0.0
device-pack: ARM::Cortex_DFP@1.1.0
processor:
fpu: off
core: Cortex-M0
packs:
- pack: ARM::CMSIS@6.0.0
path: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0
- pack: ARM::Cortex_DFP@1.0.0
path: ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.0.0
- pack: ARM::CMSIS@6.1.0
path: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0
- pack: ARM::Cortex_DFP@1.1.0
path: ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.1.0
misc:
C:
- -std=gnu11
Expand All @@ -25,59 +25,62 @@ build:
- -ffunction-sections
- -fdata-sections
Link:
- -lcrt0-semihost
- -lsemihost
- -Wl,-Map=../out/project/ARMCM0/CLANG/project.elf.map
- -lcrt0
- -Wl,--gc-sections
define:
- ARMCM0
- _RTE_
define-asm:
- ARMCM0
- _RTE_
add-path:
- RTE/_CLANG_ARMCM0
- ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Core/Include
- ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.0.0/Device/ARMCM0/Include
- ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Core/Include
- ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.1.0/Device/ARMCM0/Include
add-path-asm:
- RTE/_CLANG_ARMCM0
- ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Core/Include
- ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.0.0/Device/ARMCM0/Include
- ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Core/Include
- ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.1.0/Device/ARMCM0/Include
output-dirs:
intdir: ../tmp/project/ARMCM0/CLANG
intdir: ../tmp
outdir: ../out/project/ARMCM0/CLANG
rtedir: RTE
output:
- type: elf
file: project.elf
- type: map
file: project.map
components:
- component: ARM::CMSIS:CORE@6.0.0
- component: ARM::CMSIS:CORE@6.1.0
condition: ARMv6_7_8-M Device
from-pack: ARM::CMSIS@6.0.0
from-pack: ARM::CMSIS@6.1.0
selected-by: ARM::CMSIS:CORE
files:
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Core/Include
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Core/Include
category: include
version: 6.0.0
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Core/Include/tz_context.h
version: 6.1.0
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Core/Include/tz_context.h
category: header
version: 6.0.0
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Core/Template/ARMv8-M/main_s.c
version: 6.1.0
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Core/Template/ARMv8-M/main_s.c
category: sourceC
attr: template
version: 1.1.1
select: Secure mode 'main' module for ARMv8-M
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Core/Template/ARMv8-M/tz_context.c
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Core/Template/ARMv8-M/tz_context.c
category: sourceC
attr: template
version: 1.1.1
select: RTOS Context Management (TrustZone for ARMv8-M)
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Documentation/html/Core/index.html
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Documentation/html/Core/index.html
category: doc
version: 6.0.0
version: 6.1.0
- component: ARM::Device:Startup&C [email protected]
condition: ARMCM0 CMSIS
from-pack: ARM::Cortex_DFP@1.0.0
from-pack: ARM::Cortex_DFP@1.1.0
selected-by: ARM::Device:Startup&C Startup
files:
- file: ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.0.0/Device/ARMCM0/Include/ARMCM0.h
- file: ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.1.0/Device/ARMCM0/Include/ARMCM0.h
category: header
version: 2.2.0
- file: RTE/Device/ARMCM0/startup_ARMCM0.c
Expand All @@ -96,21 +99,16 @@ build:
groups:
- group: Source
files:
- file: ./main.c
- file: main.c
category: sourceC
constructed-files:
- file: RTE/_CLANG_ARMCM0/RTE_Components.h
category: header
licenses:
- license: <unknown>
license-agreement: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/LICENSE
packs:
- pack: ARM::[email protected]
components:
- component: ARM::CMSIS:[email protected]
- license: <unknown>
license-agreement: ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.0.0/LICENSE
- license: Apache-2.0
packs:
- pack: ARM::[email protected]
- pack: ARM::[email protected]
- pack: ARM::[email protected]
components:
- component: ARM::CMSIS:[email protected]
- component: ARM::Device:Startup&C [email protected]
Loading
Loading