Skip to content

Commit b61fc53

Browse files
authored
[cbuild2cmake] Add output map file handling
1 parent acfd5c7 commit b61fc53

File tree

17 files changed

+234
-208
lines changed

17 files changed

+234
-208
lines changed

pkg/maker/buildcontent.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ func OutputFiles(outputList []Output) (outputByProducts string, outputFile strin
140140
case "bin":
141141
outputByProducts += "\nset(BIN_FILE \"" + output.File + "\")"
142142
customCommands += "\n\n# Bin Conversion\n add_custom_command(TARGET ${CONTEXT} POST_BUILD COMMAND ${CMAKE_OBJCOPY} ${ELF2BIN})"
143+
case "map":
144+
outputByProducts += "\nset(LD_MAP_FILE \"" + output.File + "\")"
143145
case "cmse-lib":
144146
outputByProducts += "\nset(CMSE_LIB \"" + output.File + "\")"
145147
case "elf", "lib":
@@ -150,6 +152,15 @@ func OutputFiles(outputList []Output) (outputByProducts string, outputFile strin
150152
return outputByProducts, outputFile, outputType, customCommands
151153
}
152154

155+
func HasMapFile(outputList []Output) bool {
156+
for _, output := range outputList {
157+
if output.Type == "map" {
158+
return true
159+
}
160+
}
161+
return false
162+
}
163+
153164
func (m *Maker) AddStepSuffix(name string) string {
154165
if slices.Contains(m.Contexts, name) {
155166
name += "-build"
@@ -812,6 +823,9 @@ func (c *Cbuild) LinkerOptions() (linkerVars string, linkerOptions string) {
812823
linkerOptions += "\n# Linker options\ntarget_link_options(${CONTEXT} PUBLIC\n " +
813824
AddShellPrefix("${LD_CPU}") + "\n " +
814825
AddShellPrefix("${_LS}\"${LD_SCRIPT_PP}\"")
826+
if HasMapFile(c.BuildDescType.Output) {
827+
linkerOptions += "\n " + AddShellPrefix("${LD_MAP}")
828+
}
815829
if len(c.BuildDescType.Processor.Trustzone) > 0 {
816830
linkerOptions += "\n " + AddShellPrefix("${LD_SECURE}")
817831
}

pkg/maker/buildcontent_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,18 @@ func TestBuildContent(t *testing.T) {
226226
File: "./secure.lib",
227227
Type: "cmse-lib",
228228
},
229+
{
230+
File: "./project.map",
231+
Type: "map",
232+
},
229233
}
230234
outputByProducts, outputFile, outputType, customCommands := maker.OutputFiles(output)
231235
assert.Equal(outputFile, "./arfifact.elf")
232236
assert.Equal(outputType, "elf")
233237
assert.Contains(outputByProducts, "binary.bin")
234238
assert.Contains(outputByProducts, "hexadecimal.hex")
235239
assert.Contains(outputByProducts, "secure.lib")
240+
assert.Contains(outputByProducts, "project.map")
236241
assert.Contains(customCommands, "${ELF2BIN}")
237242
assert.Contains(customCommands, "${ELF2HEX}")
238243
})
@@ -421,8 +426,15 @@ add_dependencies(project.debug+target-executes
421426
cbuild.BuildDescType.Misc.Link = []string{"--link-flag"}
422427
cbuild.BuildDescType.Misc.LinkC = []string{"--linkC-flag"}
423428
cbuild.BuildDescType.Misc.LinkCPP = []string{"--linkCPP-flag"}
429+
cbuild.BuildDescType.Output = []maker.Output{
430+
{
431+
File: "./project.map",
432+
Type: "map",
433+
},
434+
}
424435
linkerVars, linkerOptions := cbuild.LinkerOptions()
425436
assert.Contains(linkerVars, "set(LD_SCRIPT \"${SOLUTION_ROOT}/path/to/script.ld\")")
437+
assert.Contains(linkerOptions, "${LD_MAP}")
426438
assert.Contains(linkerOptions, "${LD_SECURE}")
427439
assert.Contains(linkerOptions, "--link-flag")
428440
assert.Contains(linkerOptions, "--linkC-flag")
Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
build:
2-
generated-by: csolution version 0.0.0+g447ad5d7
2+
generated-by: csolution version 2.6.0
33
solution: ../solution.csolution.yml
44
project: project.cproject.yml
55
context: project.AC6+ARMCM0
66
compiler: AC6
77
device: ARMCM0
8-
device-pack: ARM::Cortex_DFP@1.0.0
8+
device-pack: ARM::Cortex_DFP@1.1.0
99
processor:
1010
fpu: off
1111
core: Cortex-M0
1212
packs:
13-
- pack: ARM::CMSIS@6.0.0
14-
path: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0
15-
- pack: ARM::Cortex_DFP@1.0.0
16-
path: ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.0.0
13+
- pack: ARM::CMSIS@6.1.0
14+
path: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0
15+
- pack: ARM::Cortex_DFP@1.1.0
16+
path: ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.1.0
1717
misc:
1818
ASM:
1919
- -masm=auto
@@ -29,63 +29,62 @@ build:
2929
- -Wno-parentheses-equality
3030
- -Wno-license-management
3131
Link:
32-
- --info summarysizes
33-
- --info sizes
34-
- --info totals
35-
- --info unused
3632
- --entry=Reset_Handler
37-
- --map
38-
- --summary_stderr
3933
- --diag_suppress=L6314W
4034
define:
4135
- ARMCM0
4236
- _RTE_
37+
define-asm:
38+
- ARMCM0
39+
- _RTE_
4340
add-path:
4441
- RTE/_AC6_ARMCM0
45-
- ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Core/Include
46-
- ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.0.0/Device/ARMCM0/Include
42+
- ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Core/Include
43+
- ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.1.0/Device/ARMCM0/Include
4744
add-path-asm:
4845
- RTE/_AC6_ARMCM0
49-
- ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Core/Include
50-
- ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.0.0/Device/ARMCM0/Include
46+
- ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Core/Include
47+
- ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.1.0/Device/ARMCM0/Include
5148
output-dirs:
52-
intdir: ../tmp/project/ARMCM0/AC6
49+
intdir: ../tmp
5350
outdir: ../out/project/ARMCM0/AC6
5451
rtedir: RTE
5552
output:
5653
- type: elf
5754
file: project.axf
55+
- type: map
56+
file: project.map
5857
components:
59-
- component: ARM::CMSIS:CORE@6.0.0
58+
- component: ARM::CMSIS:CORE@6.1.0
6059
condition: ARMv6_7_8-M Device
61-
from-pack: ARM::CMSIS@6.0.0
60+
from-pack: ARM::CMSIS@6.1.0
6261
selected-by: ARM::CMSIS:CORE
6362
files:
64-
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Core/Include
63+
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Core/Include
6564
category: include
66-
version: 6.0.0
67-
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Core/Include/tz_context.h
65+
version: 6.1.0
66+
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Core/Include/tz_context.h
6867
category: header
69-
version: 6.0.0
70-
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Core/Template/ARMv8-M/main_s.c
68+
version: 6.1.0
69+
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Core/Template/ARMv8-M/main_s.c
7170
category: sourceC
7271
attr: template
7372
version: 1.1.1
7473
select: Secure mode 'main' module for ARMv8-M
75-
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Core/Template/ARMv8-M/tz_context.c
74+
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Core/Template/ARMv8-M/tz_context.c
7675
category: sourceC
7776
attr: template
7877
version: 1.1.1
7978
select: RTOS Context Management (TrustZone for ARMv8-M)
80-
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Documentation/html/Core/index.html
79+
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Documentation/html/Core/index.html
8180
category: doc
82-
version: 6.0.0
81+
version: 6.1.0
8382
- component: ARM::Device:Startup&C [email protected]
8483
condition: ARMCM0 CMSIS
85-
from-pack: ARM::Cortex_DFP@1.0.0
84+
from-pack: ARM::Cortex_DFP@1.1.0
8685
selected-by: ARM::Device:Startup&C Startup
8786
files:
88-
- file: ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.0.0/Device/ARMCM0/Include/ARMCM0.h
87+
- file: ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.1.0/Device/ARMCM0/Include/ARMCM0.h
8988
category: header
9089
version: 2.2.0
9190
- file: RTE/Device/ARMCM0/ARMCM0_ac6.sct
@@ -108,21 +107,16 @@ build:
108107
groups:
109108
- group: Source
110109
files:
111-
- file: ./main.c
110+
- file: main.c
112111
category: sourceC
113112
constructed-files:
114113
- file: RTE/_AC6_ARMCM0/RTE_Components.h
115114
category: header
116115
licenses:
117-
- license: <unknown>
118-
license-agreement: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/LICENSE
119-
packs:
120-
- pack: ARM::[email protected]
121-
components:
122-
- component: ARM::CMSIS:[email protected]
123-
- license: <unknown>
124-
license-agreement: ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.0.0/LICENSE
116+
- license: Apache-2.0
125117
packs:
126-
- pack: ARM::[email protected]
118+
- pack: ARM::[email protected]
119+
- pack: ARM::[email protected]
127120
components:
121+
- component: ARM::CMSIS:[email protected]
128122
- component: ARM::Device:Startup&C [email protected]
Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
build:
2-
generated-by: csolution version 0.0.0+g447ad5d7
2+
generated-by: csolution version 2.6.0
33
solution: ../solution.csolution.yml
44
project: project.cproject.yml
55
context: project.CLANG+ARMCM0
66
compiler: CLANG
77
device: ARMCM0
8-
device-pack: ARM::Cortex_DFP@1.0.0
8+
device-pack: ARM::Cortex_DFP@1.1.0
99
processor:
1010
fpu: off
1111
core: Cortex-M0
1212
packs:
13-
- pack: ARM::CMSIS@6.0.0
14-
path: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0
15-
- pack: ARM::Cortex_DFP@1.0.0
16-
path: ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.0.0
13+
- pack: ARM::CMSIS@6.1.0
14+
path: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0
15+
- pack: ARM::Cortex_DFP@1.1.0
16+
path: ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.1.0
1717
misc:
1818
C:
1919
- -std=gnu11
@@ -25,59 +25,62 @@ build:
2525
- -ffunction-sections
2626
- -fdata-sections
2727
Link:
28-
- -lcrt0-semihost
29-
- -lsemihost
30-
- -Wl,-Map=../out/project/ARMCM0/CLANG/project.elf.map
28+
- -lcrt0
3129
- -Wl,--gc-sections
3230
define:
3331
- ARMCM0
3432
- _RTE_
33+
define-asm:
34+
- ARMCM0
35+
- _RTE_
3536
add-path:
3637
- RTE/_CLANG_ARMCM0
37-
- ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Core/Include
38-
- ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.0.0/Device/ARMCM0/Include
38+
- ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Core/Include
39+
- ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.1.0/Device/ARMCM0/Include
3940
add-path-asm:
4041
- RTE/_CLANG_ARMCM0
41-
- ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Core/Include
42-
- ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.0.0/Device/ARMCM0/Include
42+
- ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Core/Include
43+
- ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.1.0/Device/ARMCM0/Include
4344
output-dirs:
44-
intdir: ../tmp/project/ARMCM0/CLANG
45+
intdir: ../tmp
4546
outdir: ../out/project/ARMCM0/CLANG
4647
rtedir: RTE
4748
output:
4849
- type: elf
4950
file: project.elf
51+
- type: map
52+
file: project.map
5053
components:
51-
- component: ARM::CMSIS:CORE@6.0.0
54+
- component: ARM::CMSIS:CORE@6.1.0
5255
condition: ARMv6_7_8-M Device
53-
from-pack: ARM::CMSIS@6.0.0
56+
from-pack: ARM::CMSIS@6.1.0
5457
selected-by: ARM::CMSIS:CORE
5558
files:
56-
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Core/Include
59+
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Core/Include
5760
category: include
58-
version: 6.0.0
59-
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Core/Include/tz_context.h
61+
version: 6.1.0
62+
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Core/Include/tz_context.h
6063
category: header
61-
version: 6.0.0
62-
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Core/Template/ARMv8-M/main_s.c
64+
version: 6.1.0
65+
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Core/Template/ARMv8-M/main_s.c
6366
category: sourceC
6467
attr: template
6568
version: 1.1.1
6669
select: Secure mode 'main' module for ARMv8-M
67-
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Core/Template/ARMv8-M/tz_context.c
70+
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Core/Template/ARMv8-M/tz_context.c
6871
category: sourceC
6972
attr: template
7073
version: 1.1.1
7174
select: RTOS Context Management (TrustZone for ARMv8-M)
72-
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/CMSIS/Documentation/html/Core/index.html
75+
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Documentation/html/Core/index.html
7376
category: doc
74-
version: 6.0.0
77+
version: 6.1.0
7578
- component: ARM::Device:Startup&C [email protected]
7679
condition: ARMCM0 CMSIS
77-
from-pack: ARM::Cortex_DFP@1.0.0
80+
from-pack: ARM::Cortex_DFP@1.1.0
7881
selected-by: ARM::Device:Startup&C Startup
7982
files:
80-
- file: ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.0.0/Device/ARMCM0/Include/ARMCM0.h
83+
- file: ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.1.0/Device/ARMCM0/Include/ARMCM0.h
8184
category: header
8285
version: 2.2.0
8386
- file: RTE/Device/ARMCM0/startup_ARMCM0.c
@@ -96,21 +99,16 @@ build:
9699
groups:
97100
- group: Source
98101
files:
99-
- file: ./main.c
102+
- file: main.c
100103
category: sourceC
101104
constructed-files:
102105
- file: RTE/_CLANG_ARMCM0/RTE_Components.h
103106
category: header
104107
licenses:
105-
- license: <unknown>
106-
license-agreement: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.0.0/LICENSE
107-
packs:
108-
- pack: ARM::[email protected]
109-
components:
110-
- component: ARM::CMSIS:[email protected]
111-
- license: <unknown>
112-
license-agreement: ${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.0.0/LICENSE
108+
- license: Apache-2.0
113109
packs:
114-
- pack: ARM::[email protected]
110+
- pack: ARM::[email protected]
111+
- pack: ARM::[email protected]
115112
components:
113+
- component: ARM::CMSIS:[email protected]
116114
- component: ARM::Device:Startup&C [email protected]

0 commit comments

Comments
 (0)