Skip to content

Commit 8f7ac41

Browse files
authored
[csolution-rpc] Expose evaluated dynamic access sequences
1 parent f090de7 commit 8f7ac41

9 files changed

Lines changed: 32 additions & 13 deletions

tools/projmgr/include/ProjMgrWorker.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ struct VariablesConfiguration {
481481
* layer variables configurations
482482
* unresolved components
483483
* map of available packs for locked packs
484+
* map of sequences to expanded absolute paths
484485
*/
485486
struct ContextItem {
486487
CdefaultItem* cdefault = nullptr;
@@ -555,6 +556,7 @@ struct ContextItem {
555556
std::vector<VariablesConfiguration> variablesConfigurations;
556557
std::set<RteComponentInstance*> unresolvedComponents;
557558
StrMap availablePackVersions;
559+
StrMap absPathSequences;
558560
};
559561

560562
/**
@@ -1272,7 +1274,7 @@ class ProjMgrWorker {
12721274
void SetDefaultLinkerScript(ContextItem& context);
12731275
void CheckAndGenerateRegionsHeader(ContextItem& context);
12741276
bool GenerateRegionsHeader(ContextItem& context, std::string& generatedRegionsFile);
1275-
void ExpandAccessSequence(const ContextItem& context, const ContextItem& refContext, const std::string& sequence, const std::string& outdir, std::string& item, bool withHeadingDot);
1277+
void ExpandAccessSequence(ContextItem& context, const ContextItem& refContext, const std::string& sequence, const std::string& outdir, std::string& item, bool withHeadingDot);
12761278
void ExpandPackDir(ContextItem& context, const std::string& pack, std::string& item);
12771279
bool GetGeneratorDir(const RteGenerator* generator, ContextItem& context, const std::string& layer, std::string& genDir);
12781280
bool GetGeneratorOptions(ContextItem& context, const std::string& layer, GeneratorOptionsItem& options);

tools/projmgr/src/ProjMgrRpcServer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ RpcArgs::ContextInfo RpcHandler::GetContextInfo(const string& context) {
366366

367367
auto& contextItem = GetContext(context);
368368
contextInfo.variables = contextItem.variables;
369+
contextInfo.variables.merge((StrMap)contextItem.absPathSequences);
369370
contextInfo.attributes = contextItem.targetAttributes;
370371
contextInfo.pname = contextItem.deviceItem.pname;
371372

@@ -505,6 +506,7 @@ RpcArgs::VariablesResult RpcHandler::GetVariables(const string& context) {
505506
res.success = false;
506507
auto& contextItem = GetContext(context);
507508
res.variables = contextItem.variables;
509+
res.variables.merge((StrMap)contextItem.absPathSequences);
508510
res.success = true;
509511
return res;
510512
}

tools/projmgr/src/ProjMgrWorker.cpp

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3493,39 +3493,46 @@ bool ProjMgrWorker::ProcessSequencesRelatives(ContextItem & context, bool rerun)
34933493
return true;
34943494
}
34953495

3496-
void ProjMgrWorker::ExpandAccessSequence(const ContextItem& context, const ContextItem& refContext, const string& sequence, const string& outdir, string& item, bool withHeadingDot) {
3497-
const string refContextOutDir = refContext.directories.cprj + "/" + refContext.directories.outdir;
3498-
const string relOutDir = outdir.empty() ? refContextOutDir : RteFsUtils::RelativePath(refContextOutDir, outdir, withHeadingDot);
3496+
void ProjMgrWorker::ExpandAccessSequence(ContextItem& context, const ContextItem& refContext, const string& sequence, const string& outdir, string& item, bool withHeadingDot) {
3497+
string refContextOutDir = refContext.directories.outdir;
3498+
RteFsUtils::NormalizePath(refContextOutDir, refContext.directories.cprj);
34993499
string regExStr = "\\$";
35003500
string replacement;
35013501
if (sequence == RteConstants::AS_SOLUTION_DIR) {
35023502
regExStr += RteConstants::AS_SOLUTION_DIR;
3503-
replacement = outdir.empty() ? refContext.csolution->directory : RteFsUtils::RelativePath(refContext.csolution->directory, outdir, withHeadingDot);
3503+
replacement = refContext.csolution->directory;
35043504
} else if (sequence == RteConstants::AS_PROJECT_DIR) {
35053505
regExStr += RteConstants::AS_PROJECT_DIR;
3506-
replacement = outdir.empty() ? refContext.cproject->directory : RteFsUtils::RelativePath(refContext.cproject->directory, outdir, withHeadingDot);
3506+
replacement = refContext.cproject->directory;
35073507
} else if (sequence == RteConstants::AS_OUT_DIR) {
35083508
regExStr += RteConstants::AS_OUT_DIR;
3509-
replacement = relOutDir;
3509+
replacement = refContextOutDir;
35103510
} else if (sequence == RteConstants::AS_ELF) {
35113511
regExStr += RteConstants::AS_ELF;
3512-
replacement = refContext.outputTypes.elf.on ? relOutDir + "/" + refContext.outputTypes.elf.filename : "";
3512+
replacement = refContext.outputTypes.elf.on ? refContextOutDir + "/" + refContext.outputTypes.elf.filename : "";
35133513
} else if (sequence == RteConstants::AS_BIN) {
35143514
regExStr += RteConstants::AS_BIN;
3515-
replacement = refContext.outputTypes.bin.on ? relOutDir + "/" + refContext.outputTypes.bin.filename : "";
3515+
replacement = refContext.outputTypes.bin.on ? refContextOutDir + "/" + refContext.outputTypes.bin.filename : "";
35163516
} else if (sequence == RteConstants::AS_HEX) {
35173517
regExStr += RteConstants::AS_HEX;
3518-
replacement = refContext.outputTypes.hex.on ? relOutDir + "/" + refContext.outputTypes.hex.filename : "";
3518+
replacement = refContext.outputTypes.hex.on ? refContextOutDir + "/" + refContext.outputTypes.hex.filename : "";
35193519
} else if (sequence == RteConstants::AS_LIB) {
35203520
regExStr += RteConstants::AS_LIB;
3521-
replacement = refContext.outputTypes.lib.on ? relOutDir + "/" + refContext.outputTypes.lib.filename : "";
3521+
replacement = refContext.outputTypes.lib.on ? refContextOutDir + "/" + refContext.outputTypes.lib.filename : "";
35223522
} else if (sequence == RteConstants::AS_CMSE) {
35233523
regExStr += RteConstants::AS_CMSE;
3524-
replacement = refContext.outputTypes.cmse.on ? relOutDir + "/" + refContext.outputTypes.cmse.filename : "";
3524+
replacement = refContext.outputTypes.cmse.on ? refContextOutDir + "/" + refContext.outputTypes.cmse.filename : "";
35253525
} else if (sequence == RteConstants::AS_MAP) {
35263526
regExStr += RteConstants::AS_MAP;
3527-
replacement = refContext.outputTypes.map.on ? relOutDir + "/" + refContext.outputTypes.map.filename : "";
3527+
replacement = refContext.outputTypes.map.on ? refContextOutDir + "/" + refContext.outputTypes.map.filename : "";
35283528
}
3529+
// store sequence and its evaluated absolute path
3530+
context.absPathSequences[item.substr(1, item.size() - 2)] = replacement;
3531+
// get relative path
3532+
if (!replacement.empty() && !outdir.empty()) {
3533+
replacement = RteFsUtils::RelativePath(replacement, outdir, withHeadingDot);
3534+
}
3535+
// replace sequence
35293536
regex regEx = regex(regExStr + "\\(.*\\)\\$");
35303537
item = regex_replace(item, regEx, replacement);
35313538
}

tools/projmgr/test/data/TestLayers/ref/variables/variables.BuildType1+TargetType1.cprj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<output elf="variables.axf" intdir="tmp/variables/TargetType1/BuildType1" name="variables" outdir="out/variables/TargetType1/BuildType1" rtedir="../data/TestLayers/RTE" type="exe"/>
1919
<ldflags compiler="AC6" file="../data/TestLayers/variables/RTE/Device/RteTest_ARMCM0/ARMCM0_ac6.sct"/>
2020
<defines>App-Layer;Build1-Layer;SolutionDir-Layer;Target1-Layer</defines>
21+
<includes>out/variables/TargetType1/BuildType1</includes>
2122
</target>
2223

2324
<components>

tools/projmgr/test/data/TestLayers/ref/variables/variables.BuildType1+TargetType2.cprj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<output elf="variables.axf" intdir="tmp/variables/TargetType2/BuildType1" name="variables" outdir="out/variables/TargetType2/BuildType1" rtedir="../data/TestLayers/RTE" type="exe"/>
1919
<ldflags compiler="AC6" file="../data/TestLayers/variables/RTE/Device/RteTest_ARMCM3/ARMCM3_ac6.sct"/>
2020
<defines>App-Layer;Build1-Layer;SolutionDir-Layer;Target2-Layer</defines>
21+
<includes>out/variables/TargetType2/BuildType1</includes>
2122
</target>
2223

2324
<components>

tools/projmgr/test/data/TestLayers/ref/variables/variables.BuildType2+TargetType1.cprj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<output elf="variables.axf" intdir="tmp/variables/TargetType1/BuildType2" name="variables" outdir="out/variables/TargetType1/BuildType2" rtedir="../data/TestLayers/RTE" type="exe"/>
1919
<ldflags compiler="AC6" file="../data/TestLayers/variables/RTE/Device/RteTest_ARMCM0/ARMCM0_ac6.sct"/>
2020
<defines>App-Layer;Build2-Layer;SolutionDir-Layer;Target1-Layer</defines>
21+
<includes>out/variables/TargetType1/BuildType2</includes>
2122
</target>
2223

2324
<components>

tools/projmgr/test/data/TestLayers/ref/variables/variables.BuildType2+TargetType2.cprj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<output elf="variables.axf" intdir="tmp/variables/TargetType2/BuildType2" name="variables" outdir="out/variables/TargetType2/BuildType2" rtedir="../data/TestLayers/RTE" type="exe"/>
1919
<ldflags compiler="AC6" file="../data/TestLayers/variables/RTE/Device/RteTest_ARMCM3/ARMCM3_ac6.sct"/>
2020
<defines>App-Layer;Build2-Layer;SolutionDir-Layer;Target2-Layer</defines>
21+
<includes>out/variables/TargetType2/BuildType2</includes>
2122
</target>
2223

2324
<components>

tools/projmgr/test/data/TestLayers/variables/solutionDir.clayer.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22

33
layer:
44

5+
add-path:
6+
- $OutDir()$
7+
58
define:
69
- SolutionDir-Layer

tools/projmgr/test/src/ProjMgrRpcTests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,6 +1429,7 @@ TEST_F(ProjMgrRpcTests, RpcGetVariables) {
14291429
EXPECT_EQ(vars["Dpack"], testcmsispack_folder + "/ARM/RteTest_DFP/0.2.0/");
14301430
EXPECT_EQ(vars["Pname"], "");
14311431
EXPECT_EQ(vars["Project"], "variables");
1432+
EXPECT_EQ(vars["OutDir()"], testinput_folder + "/TestLayers/out/variables/TargetType1/BuildType1");
14321433
EXPECT_EQ(vars["Solution"], "variables");
14331434
EXPECT_EQ(vars["TargetType"], "TargetType1");
14341435
EXPECT_EQ(vars["VarBuildLayer"], "./variables/build1.clayer.yml");

0 commit comments

Comments
 (0)