Skip to content

Add build-scope to include/exclude component files#2436

Merged
brondani merged 3 commits intoOpen-CMSIS-Pack:mainfrom
jthuangarm:lib-build
Apr 14, 2026
Merged

Add build-scope to include/exclude component files#2436
brondani merged 3 commits intoOpen-CMSIS-Pack:mainfrom
jthuangarm:lib-build

Conversation

@jthuangarm
Copy link
Copy Markdown
Contributor

@jthuangarm jthuangarm commented Apr 14, 2026

To address: #2216

Introduces support for a new build-scope attribute for components to control whether component source files are included in different build types (library vs. executable). By default, component source files are:

  • included in executable builds
  • excluded from library builds

Changes

  • Added build-scope attribute (include | exclude) to component definitions.
  • Updated schema (common.schema.json) and YAML parsing to support and validate the new attribute.
  • Updated build generation to include/exclude component source files, based on build-scope and build type.
  • Added helper method IsSourceCategory to identify compatible source files.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new build-scope attribute on component definitions to control whether component source files are emitted into generated build files depending on build type (library vs executable), aligning CMSIS-Toolbox behavior with uVision for library generation.

Changes:

  • Extended YAML parsing and JSON schema to accept/validate build-scope: include | exclude on components.
  • Updated cbuild generation to omit component source files by default for library outputs (with per-component overrides via build-scope).
  • Added/updated unit test coverage and reference outputs to verify library behavior and explicit build-scope overrides.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tools/projmgr/src/ProjMgrCbuild.cpp Emits build-scope into generated cbuild YAML and filters component source files for library outputs.
tools/projmgr/src/ProjMgrYamlParser.cpp Parses build-scope from component entries and allows the key during YAML validation.
tools/projmgr/include/ProjMgrYamlParser.h Adds the build-scope YAML key constant.
tools/projmgr/include/ProjMgrParser.h Extends ComponentItem with buildScope.
tools/projmgr/schemas/common.schema.json Defines and wires BuildScope into component schemas (input + resolved).
libs/rtemodel/include/RteFile.h Declares RteFile::IsSourceCategory helper.
libs/rtemodel/src/RteFile.cpp Implements IsSourceCategory used for filtering source categories.
tools/projmgr/test/src/ProjMgrUnitTests.cpp Adds test invocation and reference comparison for build-scope behavior.
tools/projmgr/test/data/TestSolution/ref/outputFiles.Library+Target.cbuild.yml Updates expected output to exclude component source files in library builds.
tools/projmgr/test/data/TestSolution/StandardLibrary/ref/library.Debug+RteTest_ARMCM3.cbuild.yml Updates expected output to exclude startup/system sources for library builds.
tools/projmgr/test/data/TestSolution/StandardLibrary/ref/library_componentBuildScope.Debug+RteTest_ARMCM3.cbuild.yml Adds new reference output verifying build-scope include/exclude behavior.
tools/projmgr/test/data/TestSolution/StandardLibrary/library_componentBuildScope/library_componentBuildScope.cproject.yml Adds a new test project using build-scope overrides.
tools/projmgr/test/data/TestSolution/StandardLibrary/library.csolution.yml Includes the new test project in the standard library solution.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tools/projmgr/src/ProjMgrCbuild.cpp Outdated
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 14, 2026

Test Results

  7 files   53 suites   5m 30s ⏱️
185 tests 168 ✅ 17 💤 0 ❌
692 runs  624 ✅ 68 💤 0 ❌

Results for commit 5127087.

♻️ This comment has been updated with latest results.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@jthuangarm jthuangarm marked this pull request as ready for review April 14, 2026 08:45
@jthuangarm jthuangarm requested a review from brondani April 14, 2026 08:45
@jthuangarm jthuangarm requested a review from brondani April 14, 2026 11:05
Copy link
Copy Markdown
Collaborator

@brondani brondani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@brondani brondani merged commit 265db34 into Open-CMSIS-Pack:main Apr 14, 2026
106 of 107 checks passed
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.75%. Comparing base (b0d01e9) to head (5127087).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2436      +/-   ##
==========================================
+ Coverage   64.73%   64.75%   +0.01%     
==========================================
  Files         145      145              
  Lines       26147    26157      +10     
  Branches    15783    15788       +5     
==========================================
+ Hits        16927    16937      +10     
  Misses       7066     7066              
  Partials     2154     2154              
Flag Coverage Δ
buildmgr-cov 79.87% <ø> (ø)
packchk-cov 69.75% <ø> (ø)
projmgr-cov 87.78% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
tools/projmgr/include/ProjMgrParser.h 100.00% <ø> (ø)
tools/projmgr/src/ProjMgrCbuild.cpp 93.44% <100.00%> (+0.14%) ⬆️
tools/projmgr/src/ProjMgrYamlParser.cpp 84.29% <100.00%> (+0.01%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jthuangarm jthuangarm deleted the lib-build branch April 14, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants