Skip to content
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 libs/rteutils/include/RteConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class RteConstants
static constexpr const char* AS_COMPILER = "Compiler";
static constexpr const char* AS_BUILD_TYPE = "BuildType";
static constexpr const char* AS_TARGET_TYPE = "TargetType";
static constexpr const char* AS_TARGET_SET = "TargetSet";
static constexpr const char* AS_DNAME = "Dname";
static constexpr const char* AS_PNAME = "Pname";
static constexpr const char* AS_BNAME = "Bname";
Expand Down
6 changes: 3 additions & 3 deletions tools/projmgr/src/ProjMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,6 @@ bool ProjMgr::PopulateContexts(void) {
m_worker.SetOutputDir(m_outputDir);
m_emitter.SetOutputDir(m_outputDir.empty() ? m_rootDir : RteFsUtils::AbsolutePath(m_outputDir).generic_string());

// Update tmp directory
m_worker.UpdateTmpDir();

// Set root directory
m_worker.SetRootDir(m_rootDir);

Expand All @@ -565,6 +562,9 @@ bool ProjMgr::PopulateContexts(void) {
result = false;
}

// Update tmp directory
m_worker.UpdateTmpDir();

// Add image only context
m_worker.AddImageOnlyContext();

Expand Down
3 changes: 2 additions & 1 deletion tools/projmgr/src/ProjMgrCbuildIdx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ bool ProjMgrYamlEmitter::GenerateCbuildIndex(const vector<ContextItem*>& context
rootNode[YAML_BUILD_IDX], contexts, m_parser, m_worker, m_outputDir, m_cbuildRun, failedContexts, executes);

// set rebuild flags
if (NeedRebuild(filename, rootNode)) {
bool defaultTmpdir = RteFsUtils::Equivalent(m_parser->GetCsolution().directories.tmpdir, m_outputDir + "/tmp");
if (defaultTmpdir && NeedRebuild(filename, rootNode)) {
rootNode[YAML_BUILD_IDX][YAML_REBUILD] = true;
}
else {
Expand Down
9 changes: 6 additions & 3 deletions tools/projmgr/src/ProjMgrWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,11 @@ void ProjMgrWorker::UpdateTmpDir() {
auto& tmpdir = m_parser->GetCsolution().directories.tmpdir;
auto& base = m_outputDir.empty() ? m_parser->GetCsolution().directory : m_outputDir;
if (!tmpdir.empty()) {
if (ProjMgrUtils::HasAccessSequence(tmpdir) || !RteFsUtils::IsRelative(tmpdir)) {
ProjMgrLogger::Get().Warn("'tmpdir' does not support access sequences and must be relative to csolution.yml");
tmpdir.clear();
if (!m_activeTargetType.empty()) {
tmpdir = RteUtils::ExpandAccessSequences(tmpdir, {
{ RteConstants::AS_TARGET_TYPE, m_activeTargetType },
{ RteConstants::AS_TARGET_SET, m_activeTargetSet.set.empty() ? "default" : m_activeTargetSet.set } }
);
}
}
tmpdir = base + "/" + (tmpdir.empty() ? "tmp" : tmpdir);
Expand Down Expand Up @@ -204,6 +206,7 @@ void ProjMgrWorker::AddContext(ContextDesc& descriptor, const TypePair& type, Co
context.variables[RteConstants::AS_PROJECT] = context.cproject->name;
context.variables[RteConstants::AS_BUILD_TYPE] = context.type.build;
context.variables[RteConstants::AS_TARGET_TYPE] = context.type.target;
context.variables[RteConstants::AS_TARGET_SET] = context.targetSet.empty() ? "default" : context.targetSet;

// solution and project access sequences with absolute paths
context.absPathSequences[RteConstants::AS_SOLUTION_DIR_BR] = context.csolution->directory;
Expand Down
10 changes: 8 additions & 2 deletions tools/projmgr/test/data/TestSolution/tmpdir-as.csolution.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/main/tools/projmgr/schemas/csolution.schema.json

solution:

compiler: AC6

target-types:
- type: TypeA
target-set:
- set: Set1
images:
- project-context: test1.Debug

build-types:
- type: Debug
compiler: AC6

projects:
- project: ./TestProject1/test1.cproject.yml

output-dirs:
tmpdir: $BuildType$
tmpdir: tmp/$TargetType$/$TargetSet$
13 changes: 7 additions & 6 deletions tools/projmgr/test/src/ProjMgrUnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4164,16 +4164,17 @@ TEST_F(ProjMgrUnitTests, OutputDirs) {
}

TEST_F(ProjMgrUnitTests, OutputDirsTmpdirAccessSequence) {
StdStreamRedirect streamRedirect;
char* argv[4];
char* argv[5];
const string& csolution = testinput_folder + "/TestSolution/tmpdir-as.csolution.yml";
argv[1] = (char*)"convert";
argv[2] = (char*)csolution.c_str();
argv[3] = (char*)"--cbuildgen";
EXPECT_EQ(0, RunProjMgr(4, argv, m_envp));
argv[3] = (char*)"--active";
argv[4] = (char*)"TypeA@Set1";
EXPECT_EQ(0, RunProjMgr(5, argv, m_envp));

auto errStr = streamRedirect.GetErrorString();
EXPECT_TRUE(regex_search(errStr, regex("warning csolution: 'tmpdir' does not support access sequences and must be relative to csolution.yml")));
// Check custom tmp directory
const YAML::Node& cbuild = YAML::LoadFile(testinput_folder + "/TestSolution/tmpdir-as.cbuild-idx.yml");
EXPECT_EQ("tmp/TypeA/Set1", cbuild["build-idx"]["tmpdir"].as<string>());
}

TEST_F(ProjMgrUnitTests, OutputDirsAbsolutePath) {
Expand Down
Loading