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 API files to component target sources #237

Merged
merged 2 commits into from
Dec 4, 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
9 changes: 9 additions & 0 deletions pkg/maker/buildcontent.go
Original file line number Diff line number Diff line change
Expand Up @@ -914,3 +914,12 @@ func (m *Maker) ExecutesCommands(executes []Executes) string {
}
return content
}

func (c *Cbuild) GetAPIFiles(id string) []Files {
for _, api := range c.BuildDescType.Apis {
if api.API == id {
return api.Files
}
}
return nil
}
16 changes: 16 additions & 0 deletions pkg/maker/buildcontent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,4 +503,20 @@ add_dependencies(project.debug+target-executes
assert.Equal(expectedData, cbuild.AddRootPrefixes("", testData))
})

t.Run("get api files", func(t *testing.T) {
var cbuild maker.Cbuild
var files = []maker.Files{
{
File: "api_header.h",
},
}
cbuild.BuildDescType.Apis = []maker.Apis{
{
API: "CORE:API",
Files: files,
},
}
assert.Equal(files, cbuild.GetAPIFiles("CORE:API"))
})

}
2 changes: 1 addition & 1 deletion pkg/maker/contextlists.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func (c *Cbuild) CMakeCreateGroupRecursively(parent string, groups []Groups,
func (c *Cbuild) CMakeCreateComponents(contextDir string) error {
content := "# components.cmake\n"
for _, component := range c.BuildDescType.Components {
buildFiles := c.ClassifyFiles(component.Files)
buildFiles := c.ClassifyFiles(append(component.Files, c.GetAPIFiles(component.Implements)...))
name := ReplaceDelimiters(component.Component)
// default scope
scope := "PUBLIC"
Expand Down
8 changes: 8 additions & 0 deletions pkg/maker/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ type Cbuild struct {
OutputDirs OutputDirs `yaml:"output-dirs"`
Output []Output `yaml:"output"`
Components []Components `yaml:"components"`
Apis []Apis `yaml:"apis"`
Linker Linker `yaml:"linker"`
Groups []Groups `yaml:"groups"`
Generators []struct{} `yaml:"generators"`
Expand Down Expand Up @@ -103,10 +104,17 @@ type Cprojects struct {
Clayers []Clayers `yaml:"clayers"`
}

type Apis struct {
API string `yaml:"api"`
Files []Files `yaml:"files"`
FromPack string `yaml:"from-pack"`
}

type Components struct {
Component string `yaml:"component"`
Condition string `yaml:"condition"`
SelectedBy string `yaml:"selected-by"`
Implements string `yaml:"implements"`
Rtedir string `yaml:"rtedir"`
Optimize string `yaml:"optimize"`
Debug string `yaml:"debug"`
Expand Down
4 changes: 4 additions & 0 deletions pkg/maker/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,12 @@ func TestParser(t *testing.T) {
assert.Equal("vendorName::DFP:[email protected]", data.BuildDescType.Components[0].Component)
assert.Equal("Cortex-M Condition", data.BuildDescType.Components[0].Condition)
assert.Equal("vendorName::[email protected]", data.BuildDescType.Components[0].FromPack)
assert.Equal("DFP:[email protected]", data.BuildDescType.Components[0].Implements)
assert.Equal("CORE", data.BuildDescType.Components[0].SelectedBy)

assert.Equal("DFP:[email protected]", data.BuildDescType.Apis[0].API)
assert.Equal("vendorName::[email protected]", data.BuildDescType.Apis[0].FromPack)

assert.Equal("Source", data.BuildDescType.Groups[0].Group)
assert.Equal("./TestSource.c", data.BuildDescType.Groups[0].Files[0].File)
assert.Equal("sourceC", data.BuildDescType.Groups[0].Files[0].Category)
Expand Down
4 changes: 4 additions & 0 deletions test/data/generic/contextName0.cbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ build:
- component: vendorName::DFP:[email protected]
condition: Cortex-M Condition
from-pack: vendorName::[email protected]
implements: DFP:[email protected]
selected-by: CORE
apis:
- api: DFP:[email protected]
from-pack: vendorName::[email protected]
linker:
script: ac6.sct.src
regions: regions_deviceName.h
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
build:
generated-by: csolution version 2.5.0
generated-by: csolution version 2.6.0
solution: ../solution.csolution.yml
project: project.cproject.yml
context: project.AC6+ARMCM0
Expand Down Expand Up @@ -32,7 +32,6 @@ build:
- -Wno-license-management
Link:
- --entry=Reset_Handler
- --map
- --info summarysizes
- --summary_stderr
- --diag_suppress=L6314W
Expand Down Expand Up @@ -91,20 +90,18 @@ build:
- component: ARM::CMSIS:OS Tick:[email protected]
condition: OS Tick SysTick
from-pack: ARM::[email protected]
selected-by: ARM::CMSIS:OS Tick
selected-by: ARM::CMSIS:OS Tick:SysTick
implements: CMSIS:OS [email protected]
files:
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/os_tick.h
category: api
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Source/os_systick.c
category: sourceC
version: 1.0.5
- component: ARM::CMSIS:RTOS2:Keil RTX5&[email protected]
condition: RTX5
from-pack: ARM::[email protected]
selected-by: ARM::CMSIS:RTOS2:Keil RTX5&Library
implements: CMSIS:[email protected]
files:
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/cmsis_os2.h
category: api
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS-RTX/5.9.0/Documentation/index.html
category: doc
version: 5.9.0
Expand Down Expand Up @@ -193,6 +190,27 @@ build:
category: sourceC
attr: config
version: 1.0.0
apis:
- api: CMSIS:[email protected]
from-pack: ARM::[email protected]
implemented-by: ARM::CMSIS:RTOS2:Keil RTX5&[email protected]
files:
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Documentation/html/RTOS2/index.html
category: doc
version: 2.3.0
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/cmsis_os2.h
category: header
version: 2.3.0
- api: CMSIS:OS [email protected]
from-pack: ARM::[email protected]
implemented-by: ARM::CMSIS:OS Tick:[email protected]
files:
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/os_tick.h
category: header
version: 1.0.1
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Documentation/html/RTOS2/index.html
category: doc
version: 1.0.1
linker:
script: RTE/Device/ARMCM0/ARMCM0_ac6.sct
groups:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
build:
generated-by: csolution version 2.5.0
generated-by: csolution version 2.6.0
solution: ../solution.csolution.yml
project: project.cproject.yml
context: project.CLANG+ARMCM0
Expand Down Expand Up @@ -27,9 +27,8 @@ build:
- -ffunction-sections
- -fdata-sections
Link:
- -lcrt0-semihost
- -lsemihost
- -Wl,-Map=../out/project/ARMCM0/CLANG/project.elf.map
- -lcrt0
- -Wl,-print-memory-usage
- -Wl,--gc-sections
define:
- ARMCM0
Expand Down Expand Up @@ -86,20 +85,18 @@ build:
- component: ARM::CMSIS:OS Tick:[email protected]
condition: OS Tick SysTick
from-pack: ARM::[email protected]
selected-by: ARM::CMSIS:OS Tick
selected-by: ARM::CMSIS:OS Tick:SysTick
implements: CMSIS:OS [email protected]
files:
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/os_tick.h
category: api
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Source/os_systick.c
category: sourceC
version: 1.0.5
- component: ARM::CMSIS:RTOS2:Keil RTX5&[email protected]
condition: RTX5
from-pack: ARM::[email protected]
selected-by: ARM::CMSIS:RTOS2:Keil RTX5&Library
implements: CMSIS:[email protected]
files:
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/cmsis_os2.h
category: api
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS-RTX/5.9.0/Documentation/index.html
category: doc
version: 5.9.0
Expand Down Expand Up @@ -184,6 +181,27 @@ build:
category: sourceC
attr: config
version: 1.0.0
apis:
- api: CMSIS:[email protected]
from-pack: ARM::[email protected]
implemented-by: ARM::CMSIS:RTOS2:Keil RTX5&[email protected]
files:
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Documentation/html/RTOS2/index.html
category: doc
version: 2.3.0
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/cmsis_os2.h
category: header
version: 2.3.0
- api: CMSIS:OS [email protected]
from-pack: ARM::[email protected]
implemented-by: ARM::CMSIS:OS Tick:[email protected]
files:
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/os_tick.h
category: header
version: 1.0.1
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Documentation/html/RTOS2/index.html
category: doc
version: 1.0.1
linker:
script: RTE/Device/ARMCM0/clang_linker_script.ld.src
regions: RTE/Device/ARMCM0/regions_ARMCM0.h
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
build:
generated-by: csolution version 2.5.0
generated-by: csolution version 2.6.0
solution: ../solution.csolution.yml
project: project.cproject.yml
context: project.GCC+ARMCM0
Expand Down Expand Up @@ -33,9 +33,10 @@ build:
- -lc
Link:
- --specs=nano.specs
- --specs=rdimon.specs
- -Wl,-Map=../out/project/ARMCM0/GCC/project.elf.map
- --specs=nosys.specs
- -Wl,-print-memory-usage
- -Wl,--gc-sections
- -Wl,--no-warn-rwx-segments
define:
- ARMCM0
- _RTE_
Expand Down Expand Up @@ -91,20 +92,18 @@ build:
- component: ARM::CMSIS:OS Tick:[email protected]
condition: OS Tick SysTick
from-pack: ARM::[email protected]
selected-by: ARM::CMSIS:OS Tick
selected-by: ARM::CMSIS:OS Tick:SysTick
implements: CMSIS:OS [email protected]
files:
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/os_tick.h
category: api
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Source/os_systick.c
category: sourceC
version: 1.0.5
- component: ARM::CMSIS:RTOS2:Keil RTX5&[email protected]
condition: RTX5
from-pack: ARM::[email protected]
selected-by: ARM::CMSIS:RTOS2:Keil RTX5&Library
implements: CMSIS:[email protected]
files:
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/cmsis_os2.h
category: api
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS-RTX/5.9.0/Documentation/index.html
category: doc
version: 5.9.0
Expand Down Expand Up @@ -193,6 +192,27 @@ build:
category: sourceC
attr: config
version: 1.0.0
apis:
- api: CMSIS:[email protected]
from-pack: ARM::[email protected]
implemented-by: ARM::CMSIS:RTOS2:Keil RTX5&[email protected]
files:
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Documentation/html/RTOS2/index.html
category: doc
version: 2.3.0
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/cmsis_os2.h
category: header
version: 2.3.0
- api: CMSIS:OS [email protected]
from-pack: ARM::[email protected]
implemented-by: ARM::CMSIS:OS Tick:[email protected]
files:
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/os_tick.h
category: header
version: 1.0.1
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Documentation/html/RTOS2/index.html
category: doc
version: 1.0.1
linker:
script: RTE/Device/ARMCM0/ARMCM0_gcc.ld
groups:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
build:
generated-by: csolution version 2.5.0
generated-by: csolution version 2.6.0
solution: ../solution.csolution.yml
project: project.cproject.yml
context: project.IAR+ARMCM0
Expand All @@ -21,9 +21,6 @@ build:
- --dlib_config DLib_Config_Full.h
CPP:
- --dlib_config DLib_Config_Full.h
Link:
- --semihosting
- --map=../out/project/ARMCM0/IAR/project.out.map
define:
- ARMCM0
- _RTE_
Expand Down Expand Up @@ -79,20 +76,18 @@ build:
- component: ARM::CMSIS:OS Tick:[email protected]
condition: OS Tick SysTick
from-pack: ARM::[email protected]
selected-by: ARM::CMSIS:OS Tick
selected-by: ARM::CMSIS:OS Tick:SysTick
implements: CMSIS:OS [email protected]
files:
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/os_tick.h
category: api
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Source/os_systick.c
category: sourceC
version: 1.0.5
- component: ARM::CMSIS:RTOS2:Keil RTX5&[email protected]
condition: RTX5
from-pack: ARM::[email protected]
selected-by: ARM::CMSIS:RTOS2:Keil RTX5&Library
implements: CMSIS:[email protected]
files:
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/cmsis_os2.h
category: api
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS-RTX/5.9.0/Documentation/index.html
category: doc
version: 5.9.0
Expand Down Expand Up @@ -177,6 +172,27 @@ build:
category: sourceC
attr: config
version: 1.0.0
apis:
- api: CMSIS:[email protected]
from-pack: ARM::[email protected]
implemented-by: ARM::CMSIS:RTOS2:Keil RTX5&[email protected]
files:
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Documentation/html/RTOS2/index.html
category: doc
version: 2.3.0
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/cmsis_os2.h
category: header
version: 2.3.0
- api: CMSIS:OS [email protected]
from-pack: ARM::[email protected]
implemented-by: ARM::CMSIS:OS Tick:[email protected]
files:
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/RTOS2/Include/os_tick.h
category: header
version: 1.0.1
- file: ${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Documentation/html/RTOS2/index.html
category: doc
version: 1.0.1
linker:
script: RTE/Device/ARMCM0/iar_linker_script.icf.src
regions: RTE/Device/ARMCM0/regions_ARMCM0.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ project:
- component: ARM::CMSIS:CORE
- component: ARM::Device:Startup&C Startup
- component: ARM::CMSIS:RTOS2:Keil RTX5&Library
- component: ARM::CMSIS:OS Tick
- component: ARM::CMSIS:OS Tick:SysTick

groups:
- group: Source
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ target_link_options(${CONTEXT} PUBLIC
"SHELL:${LD_CPU}"
"SHELL:${_LS}\"${LD_SCRIPT_PP}\""
"SHELL:--entry=Reset_Handler"
"SHELL:--map"
"SHELL:--info summarysizes"
"SHELL:--summary_stderr"
"SHELL:--diag_suppress=L6314W"
Expand Down
Loading
Loading