@@ -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 }
0 commit comments