Skip to content

Commit 7d46457

Browse files
authored
[projmgr] Add support for link: whole-archive feature
1 parent 21e0b30 commit 7d46457

File tree

10 files changed

+60
-7
lines changed

10 files changed

+60
-7
lines changed

tools/projmgr/include/ProjMgrParser.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020-2025 Arm Limited. All rights reserved.
2+
* Copyright (c) 2020-2026 Arm Limited. All rights reserved.
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -439,6 +439,7 @@ struct YamlMark {
439439
* file path,
440440
* for compiler control,
441441
* file category,
442+
* link directives,
442443
* file build settings,
443444
* type filter,
444445
* yaml mark
@@ -447,9 +448,10 @@ struct FileNode {
447448
std::string file;
448449
std::vector<std::string> forCompiler;
449450
std::string category;
451+
std::string link;
450452
BuildType build;
451453
TypeFilter type;
452-
YamlMark mark;
454+
YamlMark mark;;
453455
};
454456

455457
/**

tools/projmgr/include/ProjMgrYamlParser.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020-2025 Arm Limited. All rights reserved.
2+
* Copyright (c) 2020-2026 Arm Limited. All rights reserved.
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -148,6 +148,7 @@ static constexpr const char* YAML_LOAD_OFFSET = "load-offset";
148148
static constexpr const char* YAML_LICENSE = "license";
149149
static constexpr const char* YAML_LICENSES = "licenses";
150150
static constexpr const char* YAML_LICENSE_AGREEMENT = "license-agreement";
151+
static constexpr const char* YAML_LINK = "link";
151152
static constexpr const char* YAML_LINKER = "linker";
152153
static constexpr const char* YAML_LINK_TIME_OPTIMIZE = "link-time-optimize";
153154
static constexpr const char* YAML_MAP = "map";

tools/projmgr/schemas/common.schema.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,11 @@
264264
"type": ["null", "boolean"],
265265
"description": "Enable Link Time Optimization (LTO)"
266266
},
267+
"LinkDirectiveType": {
268+
"title": "link:",
269+
"enum": [ "whole-archive" ],
270+
"description": "Link directive: whole-archive instructs the linker to include the entire library"
271+
},
267272
"DebugType": {
268273
"title": "debug:\nDocumentation: https://open-cmsis-pack.github.io/cmsis-toolbox/YML-Input-Format/#debug",
269274
"enum": [ "on", "off" ],
@@ -864,7 +869,6 @@
864869
"description": "The file attribute defines the special handling in the project when being used as configuration or template file."
865870
},
866871
"FileLanguageType": {
867-
"title": "languange:",
868872
"enum": [ "asm", "c", "cpp", "c-cpp", "link" ],
869873
"description": "File language attribute type defines the language for source, header and include file categories. Based on the language the information is used by language specific build tools."
870874
},
@@ -882,7 +886,7 @@
882886
},
883887
"add-path": { "$ref": "#/definitions/AddpathsType" },
884888
"add-path-asm": { "$ref": "#/definitions/AddAsmPathsType" },
885-
"attr": { "title": "attr:", "$ref": "#/definitions/FileAttributeType" },
889+
"attr": { "$ref": "#/definitions/FileAttributeType" },
886890
"base": {
887891
"title": "base:",
888892
"type": "string",
@@ -904,6 +908,7 @@
904908
"language": { "$ref": "#/definitions/FileLanguageType" },
905909
"language-C": { "$ref": "#/definitions/LanguageCType" },
906910
"language-CPP": { "$ref": "#/definitions/LanguageCppType" },
911+
"link": { "$ref": "#/definitions/LinkDirectiveType" },
907912
"link-time-optimize": { "$ref": "#/definitions/LinkTimeOptimizeType" },
908913
"misc": { "$ref": "#/definitions/MiscTypes" },
909914
"not-for-context": { "$ref": "#/definitions/NotForContext" },

tools/projmgr/src/ProjMgrCbuild.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020-2025 Arm Limited. All rights reserved.
2+
* Copyright (c) 2020-2026 Arm Limited. All rights reserved.
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -362,6 +362,7 @@ void ProjMgrCbuild::SetFilesNode(YAML::Node node, const ContextItem* context, co
362362
RteFsUtils::NormalizePath(fileName, context->directories.cprj);
363363
SetNodeValue(fileNode[YAML_FILE], FormatPath(fileName, context->directories.cbuild));
364364
SetNodeValue(fileNode[YAML_CATEGORY], file.category.empty() ? RteFsUtils::FileCategoryFromExtension(file.file) : file.category);
365+
SetNodeValue(fileNode[YAML_LINK], file.link);
365366
SetControlsNode(fileNode, context, file.build);
366367
node.push_back(fileNode);
367368
}

tools/projmgr/src/ProjMgrYamlParser.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020-2025 Arm Limited. All rights reserved.
2+
* Copyright (c) 2020-2026 Arm Limited. All rights reserved.
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -774,6 +774,7 @@ bool ProjMgrYamlParser::ParseFiles(const YAML::Node& parent, const string& file,
774774
ParsePortablePath(fileEntry, file, YAML_FILE, fileItem.file);
775775
ParseVectorOrString(fileEntry, YAML_FORCOMPILER, fileItem.forCompiler);
776776
ParseString(fileEntry, YAML_CATEGORY, fileItem.category);
777+
ParseString(fileEntry, YAML_LINK, fileItem.link);
777778
if (!ParseBuildType(fileEntry, file, fileItem.build)) {
778779
return false;
779780
}
@@ -1475,6 +1476,7 @@ const set<string> filesKeys = {
14751476
YAML_LANGUAGE_C,
14761477
YAML_LANGUAGE_CPP,
14771478
YAML_LINK_TIME_OPTIMIZE,
1479+
YAML_LINK,
14781480
YAML_DEFINE,
14791481
YAML_DEFINE_ASM,
14801482
YAML_UNDEFINE,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* Dummy */
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* Dummy */
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/main/tools/projmgr/schemas/cproject.schema.json
2+
3+
project:
4+
5+
components:
6+
- component: CORE
7+
- component: Startup
8+
9+
groups:
10+
- group: Source
11+
files:
12+
- file: lib.a
13+
link: whole-archive
14+
- file: main.c
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/main/tools/projmgr/schemas/csolution.schema.json
2+
3+
solution:
4+
5+
compiler: AC6
6+
7+
target-types:
8+
- type: CM0
9+
device: RteTest_ARMCM0
10+
11+
projects:
12+
- project: project.cproject.yml
13+
14+
packs:
15+
- pack: ARM::RteTest_DFP

tools/projmgr/test/src/ProjMgrUnitTests.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7225,6 +7225,17 @@ TEST_F(ProjMgrUnitTests, LinkTimeOptimize) {
72257225
EXPECT_TRUE(cbuild["build"]["groups"][0]["files"][0]["link-time-optimize"].IsDefined());
72267226
}
72277227

7228+
TEST_F(ProjMgrUnitTests, LinkWholeArchive) {
7229+
char* argv[3];
7230+
const string& csolution = testinput_folder + "/TestLinkLib/solution.csolution.yml";
7231+
argv[1] = (char*)"convert";
7232+
argv[2] = (char*)csolution.c_str();
7233+
EXPECT_EQ(0, RunProjMgr(3, argv, m_envp));
7234+
const YAML::Node& cbuild = YAML::LoadFile(testinput_folder + "/TestLinkLib/out/project/CM0/project+CM0.cbuild.yml");
7235+
EXPECT_EQ("library", cbuild["build"]["groups"][0]["files"][0]["category"].as<string>());
7236+
EXPECT_EQ("whole-archive", cbuild["build"]["groups"][0]["files"][0]["link"].as<string>());
7237+
}
7238+
72287239
TEST_F(ProjMgrUnitTests, ImageOnly) {
72297240
char* argv[5];
72307241
const string& csolution = testinput_folder + "/ImageOnly/image-only.csolution.yml";

0 commit comments

Comments
 (0)