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

[projmgr] add-path: filter out duplicates and tolerate absolute paths (#1142) #1970

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
1 change: 1 addition & 0 deletions tools/projmgr/include/ProjMgrCbuildBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class ProjMgrCbuildBase {
ProjMgrCbuildBase(bool useAbsolutePaths = false) : m_useAbsolutePaths(useAbsolutePaths) {};
void SetNodeValue(YAML::Node node, const std::string& value);
void SetNodeValue(YAML::Node node, const std::vector<std::string>& vec);
void SetNodeValueUniquely(YAML::Node node, const std::string& value);
const std::string FormatPath(const std::string& original, const std::string& directory);

bool m_useAbsolutePaths;
Expand Down
15 changes: 7 additions & 8 deletions tools/projmgr/src/ProjMgrCbuild.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2024 Arm Limited. All rights reserved.
* Copyright (c) 2020-2025 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -91,15 +91,14 @@ void ProjMgrCbuild::SetContextNode(YAML::Node contextNode, const ContextItem* co
}
SetDefineNode(contextNode[YAML_DEFINE], defines);
SetDefineNode(contextNode[YAML_DEFINE_ASM], defines);
vector<string> includes;
if (context->rteActiveTarget != nullptr) {
for (auto include : context->rteActiveTarget->GetIncludePaths(RteFile::Language::LANGUAGE_NONE)) {
RteFsUtils::NormalizePath(include, context->cproject->directory);
CollectionUtils::PushBackUniquely(includes, FormatPath(include, context->directories.cbuild));
include = FormatPath(include, context->directories.cbuild);
SetNodeValueUniquely(contextNode[YAML_ADDPATH], include);
SetNodeValueUniquely(contextNode[YAML_ADDPATH_ASM], include);
}
}
SetNodeValue(contextNode[YAML_ADDPATH], includes);
SetNodeValue(contextNode[YAML_ADDPATH_ASM], includes);
SetOutputDirsNode(contextNode[YAML_OUTPUTDIRS], context);
SetOutputNode(contextNode[YAML_OUTPUT], context);
SetComponentsNode(contextNode[YAML_COMPONENTS], context);
Expand Down Expand Up @@ -447,15 +446,15 @@ void ProjMgrCbuild::SetControlsNode(YAML::Node node, const ContextItem* context,
SetNodeValue(node[YAML_UNDEFINE], controls.undefines);
for (auto addpath : controls.addpaths) {
RteFsUtils::NormalizePath(addpath, context->directories.cprj);
node[YAML_ADDPATH].push_back(FormatPath(addpath, context->directories.cbuild));
SetNodeValueUniquely(node[YAML_ADDPATH], FormatPath(addpath, context->directories.cbuild));
}
for (auto addpath : controls.addpathsAsm) {
RteFsUtils::NormalizePath(addpath, context->directories.cprj);
node[YAML_ADDPATH_ASM].push_back(FormatPath(addpath, context->directories.cbuild));
SetNodeValueUniquely(node[YAML_ADDPATH_ASM], FormatPath(addpath, context->directories.cbuild));
}
for (auto delpath : controls.delpaths) {
RteFsUtils::NormalizePath(delpath, context->directories.cprj);
node[YAML_DELPATH].push_back(FormatPath(delpath, context->directories.cbuild));
SetNodeValueUniquely(node[YAML_DELPATH], FormatPath(delpath, context->directories.cbuild));
}
}

Expand Down
11 changes: 11 additions & 0 deletions tools/projmgr/src/ProjMgrCbuildBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ void ProjMgrCbuildBase::SetNodeValue(YAML::Node node, const vector<string>& vec)
}
}

void ProjMgrCbuildBase::SetNodeValueUniquely(YAML::Node node, const string& value) {
if (!value.empty()) {
for (const auto& item : node) {
if (value == item.as<string>()) {
return;
}
}
node.push_back(value);
}
}

const string ProjMgrCbuildBase::FormatPath(const string& original, const string& directory) {
return ProjMgrUtils::FormatPath(original, directory, m_useAbsolutePaths);
}
7 changes: 5 additions & 2 deletions tools/projmgr/src/ProjMgrWorker.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2024 Arm Limited. All rights reserved.
* Copyright (c) 2020-2025 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -3362,7 +3362,10 @@ bool ProjMgrWorker::ProcessSequenceRelative(ContextItem& context, string& item,
// adjust relative path according to the given reference
if (!fs::equivalent(outDir, ref, ec)) {
const string absPath = RteFsUtils::MakePathCanonical(fs::path(item).is_relative() ? ref + "/" + item : item);
item = RteFsUtils::RelativePath(absPath, outDir, withHeadingDot);
const string relPath = RteFsUtils::RelativePath(absPath, outDir, withHeadingDot);
if (!relPath.empty()) {
item = relPath;
}
}
}
return true;
Expand Down
4 changes: 1 addition & 3 deletions tools/projmgr/src/ProjMgrYamlParser.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2024 Arm Limited. All rights reserved.
* Copyright (c) 2020-2025 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -306,15 +306,13 @@ bool ProjMgrYamlParser::ParseCbuildSet(const string& input, CbuildSetItem& cbuil
}

// EnsurePortability checks the presence of backslash, case inconsistency and absolute path
// It clears the string 'value' when it is an absolute path
void ProjMgrYamlParser::EnsurePortability(const string& file, const YAML::Mark& mark, const string& key, string& value) {
if (value.find('\\') != string::npos) {
ProjMgrLogger::Get().Warn("'" + value + "' contains non-portable backslash, use forward slash instead", "", file, mark.line + 1, mark.column + 1);
}
if (!value.empty()) {
if (fs::path(value).is_absolute()) {
ProjMgrLogger::Get().Warn("absolute path '" + value + "' is not portable, use relative path instead", "", file, mark.line + 1, mark.column + 1);
value.clear();
} else {
const string parentDir = RteFsUtils::ParentPath(file);
const string original = RteFsUtils::LexicallyNormal(fs::path(parentDir).append(value).generic_string());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
build:
generated-by: csolution version 2.8.0
solution: ../data/TestProjectSetup/setup-test.csolution.yml
project: ../data/TestProjectSetup/setup-test.cproject.yml
context: setup-test.AbsolutePath+TEST_TARGET
compiler: GCC
device: ARM::RteTest_ARMCM0
device-pack: ARM::[email protected]
device-books:
- name: http://infocenter.arm.com/help/topic/com.arm.doc.dui0497a/index.html
title: Cortex-M0 Device Generic Users Guide
processor:
fpu: off
trustzone: off
core: Cortex-M0
packs:
- pack: ARM::[email protected]
path: ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0
optimize: size
debug: on
warnings: on
language-C: c11
language-CPP: c++11
misc:
C:
- SETUP_GCC_MISC
- SETUP_COMMON_MISC
define:
- SETUP_GCC
- SETUP_COMMON
- ARMCM0
- _RTE_
define-asm:
- ARMCM0
- _RTE_
add-path:
- ../data/TestProjectSetup/setup/GCC
- ../data/TestProjectSetup/setup/common
- ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Device/ARM/ARMCM0/Include
- C:/Absolute/Path
- ../data/TestProjectSetup/RTE/_AbsolutePath_TEST_TARGET
add-path-asm:
- ../data/TestProjectSetup/RTE/_AbsolutePath_TEST_TARGET
- ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Device/ARM/ARMCM0/Include
output-dirs:
intdir: tmp
outdir: out/setup-test/TEST_TARGET/AbsolutePath
rtedir: ../data/TestProjectSetup/RTE
output:
- type: elf
file: setup-test.elf
components:
- component: ARM::RteTest:[email protected]
condition: Cortex-M Device
from-pack: ARM::[email protected]
selected-by: CORE
implements: RteTest:[email protected]
files:
- file: ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Doc/html/index.html
category: doc
version: 0.1.1
apis:
- api: RteTest:[email protected]
from-pack: ARM::[email protected]
implemented-by: ARM::RteTest:[email protected]
files:
- file: https://arm-software.github.io/CMSIS_5/Pack/html/pdsc_apis_pg.html
category: doc
version: 1.1.2
linker:
script: ../data/TestProjectSetup/RTE/Device/RteTest_ARMCM0/gcc_linker_script.ld.src
regions: ../data/TestProjectSetup/RTE/Device/RteTest_ARMCM0/regions_RteTest_ARMCM0.h
groups:
- group: Generic Group
files:
- file: ../data/TestProjectSetup/gcc.c
category: sourceC
- file: ../data/TestProjectSetup/generic.c
category: sourceC
misc:
C:
- -DMISC-FILE-GCC
constructed-files:
- file: ../data/TestProjectSetup/RTE/_AbsolutePath_TEST_TARGET/RTE_Components.h
category: header
licenses:
- license: <unknown>
license-agreement: ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Doc/license.txt
packs:
- pack: ARM::[email protected]
components:
- component: ARM::RteTest:[email protected]
- component: RteTest:CORE(API)
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
build:
generated-by: csolution version 2.8.0
solution: ../data/TestProjectSetup/setup-test.csolution.yml
project: ../data/TestProjectSetup/setup-test.cproject.yml
context: setup-test.Build_AC6+TEST_TARGET
compiler: AC6
device: ARM::RteTest_ARMCM0
device-pack: ARM::[email protected]
device-books:
- name: http://infocenter.arm.com/help/topic/com.arm.doc.dui0497a/index.html
title: Cortex-M0 Device Generic Users Guide
processor:
fpu: off
core: Cortex-M0
packs:
- pack: ARM::[email protected]
path: ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0
misc:
C:
- SETUP_AC6_MISC
- SETUP_COMMON_MISC
define:
- SETUP_AC6
- SETUP_COMMON
- ARMCM0
- _RTE_
define-asm:
- ARMCM0
- _RTE_
add-path:
- ../data/TestProjectSetup/setup/AC6
- ../data/TestProjectSetup/setup/common
- ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Device/ARM/ARMCM0/Include
- ../data/TestProjectSetup/RTE/_Build_AC6_TEST_TARGET
add-path-asm:
- ../data/TestProjectSetup/RTE/_Build_AC6_TEST_TARGET
- ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Device/ARM/ARMCM0/Include
output-dirs:
intdir: tmp
outdir: out/setup-test/TEST_TARGET/Build_AC6
rtedir: ../data/TestProjectSetup/RTE
output:
- type: elf
file: setup-test.axf
components:
- component: ARM::RteTest:[email protected]
condition: Cortex-M Device
from-pack: ARM::[email protected]
selected-by: CORE
implements: RteTest:[email protected]
files:
- file: ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Doc/html/index.html
category: doc
version: 0.1.1
apis:
- api: RteTest:[email protected]
from-pack: ARM::[email protected]
implemented-by: ARM::RteTest:[email protected]
files:
- file: https://arm-software.github.io/CMSIS_5/Pack/html/pdsc_apis_pg.html
category: doc
version: 1.1.2
linker:
script: ../data/TestProjectSetup/RTE/Device/RteTest_ARMCM0/ac6_linker_script.sct.src
regions: ../data/TestProjectSetup/RTE/Device/RteTest_ARMCM0/regions_RteTest_ARMCM0.h
groups:
- group: Group for AC6
files:
- file: ../data/TestProjectSetup/ac6.c
category: sourceC
- group: Generic Group
files:
- file: ../data/TestProjectSetup/generic.c
category: sourceC
misc:
C:
- -DMISC-FILE-AC6
constructed-files:
- file: ../data/TestProjectSetup/RTE/_Build_AC6_TEST_TARGET/RTE_Components.h
category: header
licenses:
- license: <unknown>
license-agreement: ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Doc/license.txt
packs:
- pack: ARM::[email protected]
components:
- component: ARM::RteTest:[email protected]
- component: RteTest:CORE(API)

This file was deleted.

Loading
Loading