Skip to content

Commit 53bbd9a

Browse files
authored
[projmgr] Relocate *.cbuild-run.yml and *.cbuild.yml to out directory
1 parent f0df79b commit 53bbd9a

28 files changed

Lines changed: 276 additions & 233 deletions

tools/projmgr/include/ProjMgrParser.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ struct TargetType {
252252
* cbuild directory,
253253
* cprj directory,
254254
* rte directory,
255+
* output base directory
255256
*/
256257
struct DirectoriesItem {
257258
std::string intdir;
@@ -260,6 +261,7 @@ struct DirectoriesItem {
260261
std::string cbuild;
261262
std::string cprj;
262263
std::string rte;
264+
std::string outBaseDir;
263265
};
264266

265267
/**

tools/projmgr/include/ProjMgrRunDebug.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ struct RunDebugType {
162162
std::string solutionName;
163163
std::string targetType;
164164
std::string targetSet;
165+
std::string cbuildRun;
165166
std::string compiler;
166167
std::string board;
167168
std::string boardPack;

tools/projmgr/include/ProjMgrYamlEmitter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class ProjMgrYamlEmitter {
107107
ProjMgrParser* m_parser = nullptr;
108108
ProjMgrWorker* m_worker = nullptr;
109109
std::string m_outputDir;
110+
std::string m_cbuildRun;
110111
bool m_checkSchema;
111112

112113
bool WriteFile(YAML::Node& rootNode, const std::string& filename, const std::string& context = std::string(), bool allowUpdate = true);

tools/projmgr/schemas/common.schema.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,7 @@
12061206
"generated-by": { "type": "string", "description": "Tool name along with version information used to generate this file." },
12071207
"cdefault": { "type": "string", "description": "Path to cdefault.yml file." },
12081208
"csolution": { "type": "string", "description": "Path to csolution.yml file." },
1209+
"cbuild-run": { "type": "string", "description": "Path to cbuild-run.yml file." },
12091210
"tmpdir": { "type": "string", "description": "Specifies the directory for the interim temporary files." },
12101211
"cprojects": { "$ref": "#/definitions/BuildProjectsType" },
12111212
"cbuilds": { "$ref": "#/definitions/BuildContextsType" },

tools/projmgr/src/ProjMgrCbuildIdx.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020-2024 Arm Limited. All rights reserved.
2+
* Copyright (c) 2020-2025 Arm Limited. All rights reserved.
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -18,16 +18,16 @@ class ProjMgrCbuildIdx : public ProjMgrCbuildBase {
1818
public:
1919
ProjMgrCbuildIdx(
2020
YAML::Node node, const vector<ContextItem*>& processedContexts,
21-
ProjMgrParser* parser, ProjMgrWorker* worker, const string& directory, const set<string>& failedContexts,
21+
ProjMgrParser* parser, ProjMgrWorker* worker, const string& directory, const string& cbuildRun, const set<string>& failedContexts,
2222
const map<string, ExecutesItem>& executes);
2323
private:
2424
void SetExecutesNode(YAML::Node node, const map<string, ExecutesItem>& executes, const string& base, const string& ref);
2525
void SetVariablesNode(YAML::Node node, ProjMgrParser* parser, const ContextItem* context, const map<string, map<string, set<const ConnectItem*>>>& layerTypes);
2626
};
2727

2828
ProjMgrCbuildIdx::ProjMgrCbuildIdx(YAML::Node node,
29-
const vector<ContextItem*>& processedContexts, ProjMgrParser* parser, ProjMgrWorker* worker, const string& directory, const set<string>& failedContexts,
30-
const map<string, ExecutesItem>& executes) : ProjMgrCbuildBase(false) {
29+
const vector<ContextItem*>& processedContexts, ProjMgrParser* parser, ProjMgrWorker* worker, const string& directory, const string& cbuildRun,
30+
const set<string>& failedContexts, const map<string, ExecutesItem>& executes) : ProjMgrCbuildBase(false) {
3131
error_code ec;
3232
SetNodeValue(node[YAML_GENERATED_BY], ORIGINAL_FILENAME + string(" version ") + VERSION_STRING);
3333
if (processedContexts.size() > 0) {
@@ -37,6 +37,9 @@ ProjMgrCbuildIdx::ProjMgrCbuildIdx(YAML::Node node,
3737
SetNodeValue(node[YAML_CDEFAULT], FormatPath(parser->GetCdefault().path, directory));
3838
}
3939
SetNodeValue(node[YAML_CSOLUTION], FormatPath(parser->GetCsolution().path, directory));
40+
if (!cbuildRun.empty()) {
41+
SetNodeValue(node[YAML_CBUILD_RUN], FormatPath(cbuildRun, directory));
42+
}
4043
SetNodeValue(node[YAML_OUTPUT_TMPDIR], FormatPath(parser->GetCsolution().directories.tmpdir, directory));
4144

4245
// Generate layer info for each target
@@ -269,7 +272,7 @@ bool ProjMgrYamlEmitter::GenerateCbuildIndex(const vector<ContextItem*>& context
269272

270273
YAML::Node rootNode;
271274
ProjMgrCbuildIdx cbuild(
272-
rootNode[YAML_BUILD_IDX], contexts, m_parser, m_worker, m_outputDir, failedContexts, executes);
275+
rootNode[YAML_BUILD_IDX], contexts, m_parser, m_worker, m_outputDir, m_cbuildRun, failedContexts, executes);
273276

274277
// set rebuild flags
275278
if (NeedRebuild(filename, rootNode)) {

tools/projmgr/src/ProjMgrCbuildRun.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,11 @@ void ProjMgrCbuildRun::SetProcessorsNode(YAML::Node node, const vector<Processor
272272
//-- ProjMgrYamlEmitter::GenerateCbuildRun --------------------------------------------------------
273273
bool ProjMgrYamlEmitter::GenerateCbuildRun(const RunDebugType& debugRun) {
274274
// generate cbuild-run.yml
275-
const string& filename = m_outputDir + "/" + debugRun.solutionName + "+" +
276-
debugRun.targetType + ".cbuild-run.yml";
275+
m_cbuildRun = debugRun.cbuildRun;
276+
RteFsUtils::NormalizePath(m_cbuildRun, m_outputDir);
277+
const auto& cbuildRunDir = RteFsUtils::ParentPath(m_cbuildRun);
278+
277279
YAML::Node rootNode;
278-
ProjMgrCbuildRun cbuildRun(rootNode[YAML_CBUILD_RUN], debugRun, m_outputDir);
279-
return WriteFile(rootNode, filename);
280+
ProjMgrCbuildRun cbuildRun(rootNode[YAML_CBUILD_RUN], debugRun, cbuildRunDir);
281+
return WriteFile(rootNode, m_cbuildRun);
280282
}

tools/projmgr/src/ProjMgrRunDebug.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ bool ProjMgrRunDebug::CollectSettings(const vector<ContextItem*>& contexts, cons
3939
m_runDebug.solution = context0->csolution->path;
4040
m_runDebug.targetType = context0->type.target;
4141
m_runDebug.targetSet = context0->targetSet;
42+
m_runDebug.cbuildRun = context0->directories.cprj + "/" + context0->directories.outBaseDir + "/" +
43+
m_runDebug.solutionName + "+" + m_runDebug.targetType + ".cbuild-run.yml";
44+
4245
m_runDebug.compiler = context0->compiler;
4346
if (!context0->device.empty()) {
4447
m_runDebug.device = context0->deviceItem.vendor + "::" + context0->deviceItem.name;

tools/projmgr/src/ProjMgrWorker.cpp

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,14 @@ void ProjMgrWorker::AddContext(ContextDesc& descriptor, const TypePair& type, Co
122122
context.precedences = false;
123123

124124
// default directories
125-
context.directories.cprj = m_outputDir.empty() ? context.cproject->directory : m_outputDir;
126125
context.directories.intdir = m_cbuild2cmake ? "tmp" :
127-
"tmp/" + context.cproject->name + (type.target.empty() ? "" : "/" + type.target) + (type.build.empty() ? "" : "/" + type.build);
128-
context.directories.outdir = "out/" + context.cproject->name + (type.target.empty() ? "" : "/" + type.target) + (type.build.empty() ? "" : "/" + type.build);
126+
"tmp/" + context.cproject->name + (type.target.empty() ? "" : "/" + type.target) + (type.build.empty() ? "" : "/" + type.build);
127+
context.directories.outBaseDir = "out";
128+
context.directories.outdir = context.directories.outBaseDir +
129+
"/" + context.cproject->name + (type.target.empty() ? "" : "/" + type.target) + (type.build.empty() ? "" : "/" + type.build);
129130
context.directories.rte = "RTE";
130131

131132
// customized directories
132-
if (m_outputDir.empty() && !context.csolution->directories.cprj.empty()) {
133-
context.directories.cprj = context.csolution->directories.cprj;
134-
}
135133
if (!context.csolution->directories.intdir.empty()) {
136134
if (m_cbuild2cmake) {
137135
ProjMgrLogger::Get().Warn("customization of intermediate directory 'intdir' is ignored by the cbuild2cmake backend", context.name);
@@ -141,11 +139,32 @@ void ProjMgrWorker::AddContext(ContextDesc& descriptor, const TypePair& type, Co
141139
}
142140
if (!context.csolution->directories.outdir.empty()) {
143141
context.directories.outdir = context.csolution->directories.outdir;
142+
// https://github.com/Open-CMSIS-Pack/devtools/issues/2057
143+
// specified in csolution.yml with output-dirs, but $Project$, $TargetType$, and $BuildType$ are replaced by empty strings
144+
context.directories.outBaseDir = RteUtils::ExpandAccessSequences(context.csolution->directories.outdir, {
145+
{ RteConstants::AS_PROJECT, RteUtils::EMPTY_STRING },
146+
{ RteConstants::AS_BUILD_TYPE, RteUtils::EMPTY_STRING },
147+
{ RteConstants::AS_TARGET_TYPE, RteUtils::EMPTY_STRING },
148+
});
144149
}
145150
if (!context.cproject->rteBaseDir.empty()) {
146151
context.directories.rte = context.cproject->rteBaseDir;
147152
}
148153

154+
// cbuild.yml / legacy cprj directory
155+
if (m_cbuild2cmake) {
156+
// cprj = cbuild location (outdir)
157+
context.directories.cprj = context.directories.outdir;
158+
RteFsUtils::NormalizePath(context.directories.cprj, m_outputDir);
159+
} else {
160+
// legacy cprj location
161+
context.directories.cprj = m_outputDir.empty() ?
162+
!context.csolution->directories.cprj.empty() ?
163+
context.csolution->directories.cprj : // custom cprj
164+
context.cproject->directory : // cproject directory
165+
m_outputDir; // --output command line option
166+
}
167+
149168
// context variables
150169
context.variables[RteConstants::AS_SOLUTION] = context.csolution->name;
151170
context.variables[RteConstants::AS_PROJECT] = context.cproject->name;
@@ -3277,6 +3296,7 @@ bool ProjMgrWorker::ProcessSequencesRelatives(ContextItem & context, bool rerun)
32773296
}
32783297
if (!ProcessSequenceRelative(context, context.directories.rte, context.cproject->directory) ||
32793298
!ProcessSequenceRelative(context, context.directories.outdir, ref) ||
3299+
!ProcessSequenceRelative(context, context.directories.outBaseDir, ref) ||
32803300
!ProcessSequenceRelative(context, context.directories.intdir, ref)) {
32813301
return false;
32823302
}
@@ -4960,7 +4980,8 @@ bool ProjMgrWorker::GetExtGeneratorOptions(ContextItem& context, const string& l
49604980
if (options.path.empty()) {
49614981
// from global register
49624982
options.path = m_extGenerator->GetGlobalGenDir(options.id);
4963-
if (!ProcessSequenceRelative(context, options.path, layer.empty() ? context.cproject->directory : context.clayers.at(layer)->directory)) {
4983+
if (!options.path.empty() &&
4984+
!ProcessSequenceRelative(context, options.path, layer.empty() ? context.cproject->directory : context.clayers.at(layer)->directory)) {
49644985
return false;
49654986
}
49664987
}

tools/projmgr/test/data/ExternalGenerator/ref/SingleCore/single-core.Debug+Board.cbuild.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
build:
2-
generated-by: csolution version 0.0.0+g1057b313
3-
solution: ../board.csolution.yml
4-
project: single-core.cproject.yml
2+
generated-by: csolution version 0.0.0
3+
solution: ../../../../board.csolution.yml
4+
project: ../../../../single/single-core.cproject.yml
55
context: single-core.Debug+Board
66
compiler: AC6
77
board: Keil::RteTest CM4 board:Rev.C
@@ -19,7 +19,7 @@ build:
1919
- name: http://infocenter.arm.com/help/topic/com.arm.doc.dui0553a/index.html
2020
title: Cortex-M4 Device Generic Users Guide
2121
dbgconf:
22-
- file: ../.cmsis/board+Board.dbgconf
22+
- file: ../../../../.cmsis/board+Board.dbgconf
2323
version: 0.2.1
2424
processor:
2525
fpu: sp
@@ -40,21 +40,21 @@ build:
4040
- ARMCM4_FP
4141
- _RTE_
4242
add-path:
43-
- RTE/_Debug_Board
44-
- generated/RTE/RteTest
43+
- ../../../../single/RTE/_Debug_Board
44+
- ../../../../single/generated/RTE/RteTest
4545
- ${CMSIS_PACK_ROOT}/ARM/RteTest/0.1.0/GlobalLevel
4646
- ${CMSIS_PACK_ROOT}/ARM/RteTest/0.1.0/Include
4747
- ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Device/ARM/ARMCM4/Include
4848
add-path-asm:
49-
- RTE/_Debug_Board
50-
- generated/RTE/RteTest
49+
- ../../../../single/RTE/_Debug_Board
50+
- ../../../../single/generated/RTE/RteTest
5151
- ${CMSIS_PACK_ROOT}/ARM/RteTest/0.1.0/GlobalLevel
5252
- ${CMSIS_PACK_ROOT}/ARM/RteTest/0.1.0/Include
5353
- ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Device/ARM/ARMCM4/Include
5454
output-dirs:
55-
intdir: ../tmp
56-
outdir: ../out/single-core/Board/Debug
57-
rtedir: RTE
55+
intdir: ../../../../tmp
56+
outdir: .
57+
rtedir: ../../../../single/RTE
5858
output:
5959
- type: elf
6060
file: single-core.axf
@@ -75,11 +75,11 @@ build:
7575
- file: ${CMSIS_PACK_ROOT}/ARM/RteTest/0.1.0/Include/Outside/OutsideInclude.h
7676
category: header
7777
version: 0.0.2
78-
- file: generated/RTE/RteTest/Config/ConfigInclude.h
78+
- file: ../../../../single/generated/RTE/RteTest/Config/ConfigInclude.h
7979
category: header
8080
attr: config
8181
version: 0.0.2
82-
- file: generated/RTE/RteTest/GlobalLevelConfig.h
82+
- file: ../../../../single/generated/RTE/RteTest/GlobalLevelConfig.h
8383
category: preIncludeGlobal
8484
attr: config
8585
version: 0.0.2
@@ -88,23 +88,23 @@ build:
8888
selected-by: RteTestGenerator:Check Global Generator
8989
generator:
9090
id: RteTestExternalGenerator
91-
path: generated/single-core.cgen.yml
91+
path: ../../../../single/generated/single-core.cgen.yml
9292
linker:
93-
script: RTE/Device/RteTest_ARMCM4_FP/ac6_linker_script.sct.src
94-
regions: RTE/Device/RteTest_ARMCM4_FP/regions_RteTest_CM4_board.h
93+
script: ../../../../single/RTE/Device/RteTest_ARMCM4_FP/ac6_linker_script.sct.src
94+
regions: ../../../../single/RTE/Device/RteTest_ARMCM4_FP/regions_RteTest_CM4_board.h
9595
groups:
9696
- group: sources
9797
files:
98-
- file: main.c
98+
- file: ../../../../single/main.c
9999
category: sourceC
100100
- group: generated sources
101101
files:
102-
- file: generated/generated.c
102+
- file: ../../../../single/generated/generated.c
103103
category: sourceC
104104
constructed-files:
105-
- file: RTE/_Debug_Board/Pre_Include_Global.h
105+
- file: ../../../../single/RTE/_Debug_Board/Pre_Include_Global.h
106106
category: preIncludeGlobal
107-
- file: RTE/_Debug_Board/RTE_Components.h
107+
- file: ../../../../single/RTE/_Debug_Board/RTE_Components.h
108108
category: header
109109
licenses:
110110
- license: <unknown>

tools/projmgr/test/data/ExternalGenerator/ref/SingleCore/single-core.Debug+CM0.cbuild.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
build:
2-
generated-by: csolution version 0.0.0+gf14e09a4
3-
solution: ../extgen.csolution.yml
4-
project: single-core.cproject.yml
2+
generated-by: csolution version 0.0.0
3+
solution: ../../../../extgen.csolution.yml
4+
project: ../../../../single/single-core.cproject.yml
55
context: single-core.Debug+CM0
66
compiler: AC6
77
device: ARM::RteTestGen_ARMCM0
@@ -18,19 +18,19 @@ build:
1818
define-asm:
1919
- _RTE_
2020
add-path:
21-
- RTE/_Debug_CM0
22-
- generated/RTE/RteTest
21+
- ../../../../single/RTE/_Debug_CM0
22+
- ../../../../single/generated/RTE/RteTest
2323
- ${CMSIS_PACK_ROOT}/ARM/RteTest/0.1.0/GlobalLevel
2424
- ${CMSIS_PACK_ROOT}/ARM/RteTest/0.1.0/Include
2525
add-path-asm:
26-
- RTE/_Debug_CM0
27-
- generated/RTE/RteTest
26+
- ../../../../single/RTE/_Debug_CM0
27+
- ../../../../single/generated/RTE/RteTest
2828
- ${CMSIS_PACK_ROOT}/ARM/RteTest/0.1.0/GlobalLevel
2929
- ${CMSIS_PACK_ROOT}/ARM/RteTest/0.1.0/Include
3030
output-dirs:
31-
intdir: ../tmp
32-
outdir: ../out/single-core/CM0/Debug
33-
rtedir: RTE
31+
intdir: ../../../../tmp
32+
outdir: .
33+
rtedir: ../../../../single/RTE
3434
output:
3535
- type: elf
3636
file: single-core.axf
@@ -51,12 +51,12 @@ build:
5151
- file: ${CMSIS_PACK_ROOT}/ARM/RteTest/0.1.0/Include/Outside/OutsideInclude.h
5252
category: header
5353
version: 0.0.2
54-
- file: generated/RTE/RteTest/Config/ConfigInclude.h
54+
- file: ../../../../single/generated/RTE/RteTest/Config/ConfigInclude.h
5555
category: header
5656
attr: config
5757
version: 0.0.2
5858
status: missing base
59-
- file: generated/RTE/RteTest/GlobalLevelConfig.h
59+
- file: ../../../../single/generated/RTE/RteTest/GlobalLevelConfig.h
6060
category: preIncludeGlobal
6161
attr: config
6262
version: 0.0.2
@@ -65,23 +65,23 @@ build:
6565
selected-by: RteTestGenerator:Check Global Generator
6666
generator:
6767
id: RteTestExternalGenerator
68-
path: generated/single-core.cgen.yml
68+
path: ../../../../single/generated/single-core.cgen.yml
6969
linker:
70-
script: RTE/Device/RteTestGen_ARMCM0/ac6_linker_script.sct.src
71-
regions: RTE/Device/RteTestGen_ARMCM0/regions_RteTestGen_ARMCM0.h
70+
script: ../../../../single/RTE/Device/RteTestGen_ARMCM0/ac6_linker_script.sct.src
71+
regions: ../../../../single/RTE/Device/RteTestGen_ARMCM0/regions_RteTestGen_ARMCM0.h
7272
groups:
7373
- group: sources
7474
files:
75-
- file: main.c
75+
- file: ../../../../single/main.c
7676
category: sourceC
7777
- group: generated sources
7878
files:
79-
- file: generated/generated.c
79+
- file: ../../../../single/generated/generated.c
8080
category: sourceC
8181
constructed-files:
82-
- file: RTE/_Debug_CM0/Pre_Include_Global.h
82+
- file: ../../../../single/RTE/_Debug_CM0/Pre_Include_Global.h
8383
category: preIncludeGlobal
84-
- file: RTE/_Debug_CM0/RTE_Components.h
84+
- file: ../../../../single/RTE/_Debug_CM0/RTE_Components.h
8585
category: header
8686
licenses:
8787
- license: <unknown>

0 commit comments

Comments
 (0)