Skip to content

Commit 33fac87

Browse files
authored
[projmgr] Set target-set specific tmpdir as default
1 parent 5c2482f commit 33fac87

5 files changed

Lines changed: 40 additions & 7 deletions

File tree

tools/projmgr/src/ProjMgrWorker.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,14 @@ bool ProjMgrWorker::AddContexts(ProjMgrParser& parser, ContextDesc& descriptor,
157157
void ProjMgrWorker::UpdateTmpDir() {
158158
auto& tmpdir = m_parser->GetCsolution().directories.tmpdir;
159159
auto& base = m_outputDir.empty() ? m_parser->GetCsolution().directory : m_outputDir;
160-
if (!tmpdir.empty()) {
161-
if (!m_activeTargetType.empty()) {
162-
tmpdir = RteUtils::ExpandAccessSequences(tmpdir, {
160+
if (!m_activeTargetType.empty()) {
161+
const auto& targetSet = m_activeTargetSet.set.empty() ? "default" : m_activeTargetSet.set;
162+
// default tmpdir: tmp/$TargetType$/$TargetSet$
163+
tmpdir = tmpdir.empty() ? "tmp/" + m_activeTargetType + "/" + targetSet :
164+
RteUtils::ExpandAccessSequences(tmpdir, {
163165
{ RteConstants::AS_TARGET_TYPE, m_activeTargetType },
164-
{ RteConstants::AS_TARGET_SET, m_activeTargetSet.set.empty() ? "default" : m_activeTargetSet.set } }
166+
{ RteConstants::AS_TARGET_SET, targetSet } }
165167
);
166-
}
167168
}
168169
tmpdir = base + "/" + (tmpdir.empty() ? "tmp" : tmpdir);
169170
}

tools/projmgr/test/data/ImageOnly/ref/image-only.cbuild-idx.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ build-idx:
22
generated-by: csolution version 0.0.0
33
csolution: image-only.csolution.yml
44
cbuild-run: out/image-only+CM0.cbuild-run.yml
5-
tmpdir: tmp
5+
tmpdir: tmp/CM0/default
66
image-only: true
77
cbuilds:
88
- cbuild: out/image-only/CM0/image-only+CM0.cbuild.yml
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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: TypeA
9+
target-set:
10+
- set: Set1
11+
images:
12+
- project-context: test1.Debug
13+
14+
build-types:
15+
- type: Debug
16+
17+
projects:
18+
- project: ./TestProject1/test1.cproject.yml

tools/projmgr/test/data/WestSupport/ref/solution.cbuild-idx.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ build-idx:
22
generated-by: csolution version 0.0.0
33
csolution: solution.csolution.yml
44
cbuild-run: out/solution+CM0.cbuild-run.yml
5-
tmpdir: tmp
5+
tmpdir: tmp/CM0/default
66
cbuilds:
77
- cbuild: out/core0/CM0/Debug/core0.Debug+CM0.cbuild.yml
88
west: true

tools/projmgr/test/src/ProjMgrUnitTests.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4388,6 +4388,20 @@ TEST_F(ProjMgrUnitTests, OutputDirsTmpdirAccessSequence) {
43884388
EXPECT_EQ("tmp/TypeA/Set1", cbuild["build-idx"]["tmpdir"].as<string>());
43894389
}
43904390

4391+
TEST_F(ProjMgrUnitTests, OutputDirsTmpdirDefault) {
4392+
char* argv[5];
4393+
const string& csolution = testinput_folder + "/TestSolution/tmpdir-default-active.csolution.yml";
4394+
argv[1] = (char*)"convert";
4395+
argv[2] = (char*)csolution.c_str();
4396+
argv[3] = (char*)"--active";
4397+
argv[4] = (char*)"TypeA@Set1";
4398+
EXPECT_EQ(0, RunProjMgr(5, argv, m_envp));
4399+
4400+
// Check default tmp directory for active target type and target set
4401+
const YAML::Node& cbuild = YAML::LoadFile(testinput_folder + "/TestSolution/tmpdir-default-active.cbuild-idx.yml");
4402+
EXPECT_EQ("tmp/TypeA/Set1", cbuild["build-idx"]["tmpdir"].as<string>());
4403+
}
4404+
43914405
TEST_F(ProjMgrUnitTests, OutputDirsAbsolutePath) {
43924406
StdStreamRedirect streamRedirect;
43934407
char* argv[5];

0 commit comments

Comments
 (0)