Skip to content

Commit bed7c2c

Browse files
committed
[cbuild2cmake] Add API files to component target sources
1 parent fef52a0 commit bed7c2c

21 files changed

+179
-45
lines changed

pkg/maker/buildcontent.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,3 +914,12 @@ func (m *Maker) ExecutesCommands(executes []Executes) string {
914914
}
915915
return content
916916
}
917+
918+
func (c *Cbuild) GetAPIFiles(id string) []Files {
919+
for _, api := range c.BuildDescType.Apis {
920+
if api.API == id {
921+
return api.Files
922+
}
923+
}
924+
return []Files{}
925+
}

pkg/maker/buildcontent_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,4 +503,20 @@ add_dependencies(project.debug+target-executes
503503
assert.Equal(expectedData, cbuild.AddRootPrefixes("", testData))
504504
})
505505

506+
t.Run("get api files", func(t *testing.T) {
507+
var cbuild maker.Cbuild
508+
var files = []maker.Files{
509+
{
510+
File: "api_header.h",
511+
},
512+
}
513+
cbuild.BuildDescType.Apis = []maker.Apis{
514+
{
515+
API: "CORE:API",
516+
Files: files,
517+
},
518+
}
519+
assert.Equal(files, cbuild.GetAPIFiles("CORE:API"))
520+
})
521+
506522
}

pkg/maker/contextlists.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ func (c *Cbuild) CMakeCreateGroupRecursively(parent string, groups []Groups,
297297
func (c *Cbuild) CMakeCreateComponents(contextDir string) error {
298298
content := "# components.cmake\n"
299299
for _, component := range c.BuildDescType.Components {
300-
buildFiles := c.ClassifyFiles(component.Files)
300+
buildFiles := c.ClassifyFiles(append(component.Files, c.GetAPIFiles(component.Implements)...))
301301
name := ReplaceDelimiters(component.Component)
302302
// default scope
303303
scope := "PUBLIC"

pkg/maker/parser.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ type Cbuild struct {
6565
OutputDirs OutputDirs `yaml:"output-dirs"`
6666
Output []Output `yaml:"output"`
6767
Components []Components `yaml:"components"`
68+
Apis []Apis `yaml:"apis"`
6869
Linker Linker `yaml:"linker"`
6970
Groups []Groups `yaml:"groups"`
7071
Generators []struct{} `yaml:"generators"`
@@ -103,10 +104,17 @@ type Cprojects struct {
103104
Clayers []Clayers `yaml:"clayers"`
104105
}
105106

107+
type Apis struct {
108+
API string `yaml:"api"`
109+
Files []Files `yaml:"files"`
110+
FromPack string `yaml:"from-pack"`
111+
}
112+
106113
type Components struct {
107114
Component string `yaml:"component"`
108115
Condition string `yaml:"condition"`
109116
SelectedBy string `yaml:"selected-by"`
117+
Implements string `yaml:"implements"`
110118
Rtedir string `yaml:"rtedir"`
111119
Optimize string `yaml:"optimize"`
112120
Debug string `yaml:"debug"`

pkg/maker/parser_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,12 @@ func TestParser(t *testing.T) {
8181
assert.Equal("vendorName::DFP:CORE@7.7.7", data.BuildDescType.Components[0].Component)
8282
assert.Equal("Cortex-M Condition", data.BuildDescType.Components[0].Condition)
8383
assert.Equal("vendorName::DFP@8.8.8", data.BuildDescType.Components[0].FromPack)
84+
assert.Equal("DFP:CORE@1.1.1", data.BuildDescType.Components[0].Implements)
8485
assert.Equal("CORE", data.BuildDescType.Components[0].SelectedBy)
8586

87+
assert.Equal("DFP:CORE@1.1.1", data.BuildDescType.Apis[0].API)
88+
assert.Equal("vendorName::DFP@8.8.8", data.BuildDescType.Apis[0].FromPack)
89+
8690
assert.Equal("Source", data.BuildDescType.Groups[0].Group)
8791
assert.Equal("./TestSource.c", data.BuildDescType.Groups[0].Files[0].File)
8892
assert.Equal("sourceC", data.BuildDescType.Groups[0].Files[0].Category)

test/data/generic/contextName0.cbuild.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ build:
3434
- component: vendorName::DFP:CORE@7.7.7
3535
condition: Cortex-M Condition
3636
from-pack: vendorName::DFP@8.8.8
37+
implements: DFP:CORE@1.1.1
3738
selected-by: CORE
39+
apis:
40+
- api: DFP:CORE@1.1.1
41+
from-pack: vendorName::DFP@8.8.8
3842
linker:
3943
script: ac6.sct.src
4044
regions: regions_deviceName.h

test/data/solutions/library-rtos/project/project.AC6+ARMCM0.cbuild.yml

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
build:
2-
generated-by: csolution version 2.5.0
2+
generated-by: csolution version 2.6.0
33
solution: ../solution.csolution.yml
44
project: project.cproject.yml
55
context: project.AC6+ARMCM0
@@ -32,7 +32,6 @@ build:
3232
- -Wno-license-management
3333
Link:
3434
- --entry=Reset_Handler
35-
- --map
3635
- --info summarysizes
3736
- --summary_stderr
3837
- --diag_suppress=L6314W
@@ -91,20 +90,18 @@ build:
9190
- component: ARM::CMSIS:OS Tick:SysTick@1.0.5
9291
condition: OS Tick SysTick
9392
from-pack: ARM::CMSIS@6.1.0
94-
selected-by: ARM::CMSIS:OS Tick
93+
selected-by: ARM::CMSIS:OS Tick:SysTick
94+
implements: CMSIS:OS Tick@1.0.1
9595
files:
96-
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/os_tick.h
97-
category: api
9896
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Source/os_systick.c
9997
category: sourceC
10098
version: 1.0.5
10199
- component: ARM::CMSIS:RTOS2:Keil RTX5&Library@5.9.0
102100
condition: RTX5
103101
from-pack: ARM::CMSIS-RTX@5.9.0
104102
selected-by: ARM::CMSIS:RTOS2:Keil RTX5&Library
103+
implements: CMSIS:RTOS2@2.3.0
105104
files:
106-
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/cmsis_os2.h
107-
category: api
108105
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS-RTX/5.9.0/Documentation/index.html
109106
category: doc
110107
version: 5.9.0
@@ -193,6 +190,27 @@ build:
193190
category: sourceC
194191
attr: config
195192
version: 1.0.0
193+
apis:
194+
- api: CMSIS:RTOS2@2.3.0
195+
from-pack: ARM::CMSIS@6.1.0
196+
implemented-by: ARM::CMSIS:RTOS2:Keil RTX5&Library@5.9.0
197+
files:
198+
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Documentation/html/RTOS2/index.html
199+
category: doc
200+
version: 2.3.0
201+
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/cmsis_os2.h
202+
category: header
203+
version: 2.3.0
204+
- api: CMSIS:OS Tick@1.0.1
205+
from-pack: ARM::CMSIS@6.1.0
206+
implemented-by: ARM::CMSIS:OS Tick:SysTick@1.0.5
207+
files:
208+
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/os_tick.h
209+
category: header
210+
version: 1.0.1
211+
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Documentation/html/RTOS2/index.html
212+
category: doc
213+
version: 1.0.1
196214
linker:
197215
script: RTE/Device/ARMCM0/ARMCM0_ac6.sct
198216
groups:

test/data/solutions/library-rtos/project/project.CLANG+ARMCM0.cbuild.yml

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
build:
2-
generated-by: csolution version 2.5.0
2+
generated-by: csolution version 2.6.0
33
solution: ../solution.csolution.yml
44
project: project.cproject.yml
55
context: project.CLANG+ARMCM0
@@ -27,9 +27,8 @@ build:
2727
- -ffunction-sections
2828
- -fdata-sections
2929
Link:
30-
- -lcrt0-semihost
31-
- -lsemihost
32-
- -Wl,-Map=../out/project/ARMCM0/CLANG/project.elf.map
30+
- -lcrt0
31+
- -Wl,-print-memory-usage
3332
- -Wl,--gc-sections
3433
define:
3534
- ARMCM0
@@ -86,20 +85,18 @@ build:
8685
- component: ARM::CMSIS:OS Tick:SysTick@1.0.5
8786
condition: OS Tick SysTick
8887
from-pack: ARM::CMSIS@6.1.0
89-
selected-by: ARM::CMSIS:OS Tick
88+
selected-by: ARM::CMSIS:OS Tick:SysTick
89+
implements: CMSIS:OS Tick@1.0.1
9090
files:
91-
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/os_tick.h
92-
category: api
9391
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Source/os_systick.c
9492
category: sourceC
9593
version: 1.0.5
9694
- component: ARM::CMSIS:RTOS2:Keil RTX5&Library@5.9.0
9795
condition: RTX5
9896
from-pack: ARM::CMSIS-RTX@5.9.0
9997
selected-by: ARM::CMSIS:RTOS2:Keil RTX5&Library
98+
implements: CMSIS:RTOS2@2.3.0
10099
files:
101-
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/cmsis_os2.h
102-
category: api
103100
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS-RTX/5.9.0/Documentation/index.html
104101
category: doc
105102
version: 5.9.0
@@ -184,6 +181,27 @@ build:
184181
category: sourceC
185182
attr: config
186183
version: 1.0.0
184+
apis:
185+
- api: CMSIS:RTOS2@2.3.0
186+
from-pack: ARM::CMSIS@6.1.0
187+
implemented-by: ARM::CMSIS:RTOS2:Keil RTX5&Library@5.9.0
188+
files:
189+
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Documentation/html/RTOS2/index.html
190+
category: doc
191+
version: 2.3.0
192+
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/cmsis_os2.h
193+
category: header
194+
version: 2.3.0
195+
- api: CMSIS:OS Tick@1.0.1
196+
from-pack: ARM::CMSIS@6.1.0
197+
implemented-by: ARM::CMSIS:OS Tick:SysTick@1.0.5
198+
files:
199+
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/os_tick.h
200+
category: header
201+
version: 1.0.1
202+
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Documentation/html/RTOS2/index.html
203+
category: doc
204+
version: 1.0.1
187205
linker:
188206
script: RTE/Device/ARMCM0/clang_linker_script.ld.src
189207
regions: RTE/Device/ARMCM0/regions_ARMCM0.h

test/data/solutions/library-rtos/project/project.GCC+ARMCM0.cbuild.yml

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
build:
2-
generated-by: csolution version 2.5.0
2+
generated-by: csolution version 2.6.0
33
solution: ../solution.csolution.yml
44
project: project.cproject.yml
55
context: project.GCC+ARMCM0
@@ -33,9 +33,10 @@ build:
3333
- -lc
3434
Link:
3535
- --specs=nano.specs
36-
- --specs=rdimon.specs
37-
- -Wl,-Map=../out/project/ARMCM0/GCC/project.elf.map
36+
- --specs=nosys.specs
37+
- -Wl,-print-memory-usage
3838
- -Wl,--gc-sections
39+
- -Wl,--no-warn-rwx-segments
3940
define:
4041
- ARMCM0
4142
- _RTE_
@@ -91,20 +92,18 @@ build:
9192
- component: ARM::CMSIS:OS Tick:SysTick@1.0.5
9293
condition: OS Tick SysTick
9394
from-pack: ARM::CMSIS@6.1.0
94-
selected-by: ARM::CMSIS:OS Tick
95+
selected-by: ARM::CMSIS:OS Tick:SysTick
96+
implements: CMSIS:OS Tick@1.0.1
9597
files:
96-
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/os_tick.h
97-
category: api
9898
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Source/os_systick.c
9999
category: sourceC
100100
version: 1.0.5
101101
- component: ARM::CMSIS:RTOS2:Keil RTX5&Library@5.9.0
102102
condition: RTX5
103103
from-pack: ARM::CMSIS-RTX@5.9.0
104104
selected-by: ARM::CMSIS:RTOS2:Keil RTX5&Library
105+
implements: CMSIS:RTOS2@2.3.0
105106
files:
106-
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/cmsis_os2.h
107-
category: api
108107
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS-RTX/5.9.0/Documentation/index.html
109108
category: doc
110109
version: 5.9.0
@@ -193,6 +192,27 @@ build:
193192
category: sourceC
194193
attr: config
195194
version: 1.0.0
195+
apis:
196+
- api: CMSIS:RTOS2@2.3.0
197+
from-pack: ARM::CMSIS@6.1.0
198+
implemented-by: ARM::CMSIS:RTOS2:Keil RTX5&Library@5.9.0
199+
files:
200+
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Documentation/html/RTOS2/index.html
201+
category: doc
202+
version: 2.3.0
203+
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/cmsis_os2.h
204+
category: header
205+
version: 2.3.0
206+
- api: CMSIS:OS Tick@1.0.1
207+
from-pack: ARM::CMSIS@6.1.0
208+
implemented-by: ARM::CMSIS:OS Tick:SysTick@1.0.5
209+
files:
210+
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/os_tick.h
211+
category: header
212+
version: 1.0.1
213+
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Documentation/html/RTOS2/index.html
214+
category: doc
215+
version: 1.0.1
196216
linker:
197217
script: RTE/Device/ARMCM0/ARMCM0_gcc.ld
198218
groups:

test/data/solutions/library-rtos/project/project.IAR+ARMCM0.cbuild.yml

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
build:
2-
generated-by: csolution version 2.5.0
2+
generated-by: csolution version 2.6.0
33
solution: ../solution.csolution.yml
44
project: project.cproject.yml
55
context: project.IAR+ARMCM0
@@ -21,9 +21,6 @@ build:
2121
- --dlib_config DLib_Config_Full.h
2222
CPP:
2323
- --dlib_config DLib_Config_Full.h
24-
Link:
25-
- --semihosting
26-
- --map=../out/project/ARMCM0/IAR/project.out.map
2724
define:
2825
- ARMCM0
2926
- _RTE_
@@ -79,20 +76,18 @@ build:
7976
- component: ARM::CMSIS:OS Tick:SysTick@1.0.5
8077
condition: OS Tick SysTick
8178
from-pack: ARM::CMSIS@6.1.0
82-
selected-by: ARM::CMSIS:OS Tick
79+
selected-by: ARM::CMSIS:OS Tick:SysTick
80+
implements: CMSIS:OS Tick@1.0.1
8381
files:
84-
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/os_tick.h
85-
category: api
8682
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Source/os_systick.c
8783
category: sourceC
8884
version: 1.0.5
8985
- component: ARM::CMSIS:RTOS2:Keil RTX5&Library@5.9.0
9086
condition: RTX5
9187
from-pack: ARM::CMSIS-RTX@5.9.0
9288
selected-by: ARM::CMSIS:RTOS2:Keil RTX5&Library
89+
implements: CMSIS:RTOS2@2.3.0
9390
files:
94-
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/cmsis_os2.h
95-
category: api
9691
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS-RTX/5.9.0/Documentation/index.html
9792
category: doc
9893
version: 5.9.0
@@ -177,6 +172,27 @@ build:
177172
category: sourceC
178173
attr: config
179174
version: 1.0.0
175+
apis:
176+
- api: CMSIS:RTOS2@2.3.0
177+
from-pack: ARM::CMSIS@6.1.0
178+
implemented-by: ARM::CMSIS:RTOS2:Keil RTX5&Library@5.9.0
179+
files:
180+
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Documentation/html/RTOS2/index.html
181+
category: doc
182+
version: 2.3.0
183+
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/cmsis_os2.h
184+
category: header
185+
version: 2.3.0
186+
- api: CMSIS:OS Tick@1.0.1
187+
from-pack: ARM::CMSIS@6.1.0
188+
implemented-by: ARM::CMSIS:OS Tick:SysTick@1.0.5
189+
files:
190+
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/os_tick.h
191+
category: header
192+
version: 1.0.1
193+
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Documentation/html/RTOS2/index.html
194+
category: doc
195+
version: 1.0.1
180196
linker:
181197
script: RTE/Device/ARMCM0/iar_linker_script.icf.src
182198
regions: RTE/Device/ARMCM0/regions_ARMCM0.h

0 commit comments

Comments
 (0)