Skip to content

Commit

Permalink
iar
Browse files Browse the repository at this point in the history
  • Loading branch information
JKorbelRA committed Nov 14, 2022
1 parent 0af19dc commit 6b65ecd
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 12 deletions.
64 changes: 53 additions & 11 deletions Source/cmGlobalIarGenerator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -565,16 +565,30 @@ class IarFsNode : public XmlNode

//----------------------------------------------------------------------------
cmGlobalIarGenerator::cmGlobalIarGenerator(cmake* cm)
: cmGlobalGenerator(cm)
: cmGlobalGenerator(cm)
{
cm->GetState()->SetIarIDE(true);
GLOBALCFG.iarPath = cm->GetCacheDefinition("IAR_INSTALL_DIR");
cm->GetState()->SetIarIDE(true);
std::string iarPath = cm->GetCacheDefinition("IAR_INSTALL_DIR");
if (!iarPath.empty()) {
GLOBALCFG.iarPath = iarPath;
}
}

cmGlobalIarGenerator::~cmGlobalIarGenerator()
{
}

void cmGlobalIarGenerator::AppendDirectoryForConfig(
const std::string& prefix, const std::string& config,
const std::string& suffix, std::string& dir)
{
if (!config.empty()) {
dir += prefix;
dir += config;
dir += suffix;
}
}

std::unique_ptr<cmLocalGenerator> cmGlobalIarGenerator::CreateLocalGenerator(
cmMakefile* mf)
{
Expand Down Expand Up @@ -611,6 +625,11 @@ void cmGlobalIarGenerator::EnableLanguage(
GLOBALCFG.iarArmPath = mf->GetSafeDefinition("IAR_TOOLKIT_DIR");
GLOBALCFG.buildType = mf->GetSafeDefinition("CMAKE_BUILD_TYPE");

// todo: remove eventually, this should be set from the platform file.
mf->AddCacheDefinition("CMAKE_STATIC_LIBRARY_PREFIX", "",
"",
cmStateEnums::CacheEntryType::STRING);

if (GLOBALCFG.iarPath.empty() && wbVer.empty()) {
mf->AddCacheDefinition("IAR_INSTALL_DIR", "",
"IAR Workbench Installation Path",
Expand All @@ -620,6 +639,7 @@ void cmGlobalIarGenerator::EnableLanguage(
cmStateEnums::CacheEntryType::PATH);

cmSystemTools::Message("IAR_INSTALL_DIR neither IAR_WORKBENCH_VERSION (obsolete) is set. Please, pre-set one of those.");
this->cmGlobalGenerator::EnableLanguage(l, mf, optional);
return;
}

Expand Down Expand Up @@ -864,7 +884,7 @@ cmGlobalIarGenerator::GenerateBuildCommand(

std::string buildType = GLOBALCFG.buildType;
if (GLOBALCFG.buildType.empty()) {
buildType = "Debug";
buildType = "empty";
}

makeCommand.Add(buildType);
Expand Down Expand Up @@ -904,14 +924,14 @@ void cmGlobalIarGenerator::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) c
cmStrCat(gt->LocalGenerator->GetCurrentBinaryDirectory(),
'/', gt->LocalGenerator->GetTargetDirectory(gt),
'/', this->GetCMakeCFGIntDir(), '/');

/*
// A nasty haxx. IAR builds binaries into CMAKE_BUILD_TYPE folder. And we need
// to set this early.
if (!gt->Target->GetProperty("OUTPUT_NAME")) {
gt->Target->SetProperty("OUTPUT_NAME",
std::string(this->GetCMakeCFGIntDir()) + "/" +
gt->GetName());
}
}*/

gt->ObjectDirectory = dir;
}
Expand Down Expand Up @@ -1116,7 +1136,24 @@ void cmGlobalIarGenerator::Generate()
GLOBALCFG.tgtArch =
globalMakefile->GetSafeDefinition("IAR_TARGET_ARCHITECTURE");
GLOBALCFG.iarPath = globalMakefile->GetSafeDefinition("IAR_INSTALL_DIR");
if (GLOBALCFG.iarPath.empty()) {
cmSystemTools::Message(
"IAR_INSTALL_DIR not set, using obsolete IAR_EW_ROOT");
GLOBALCFG.iarPath = globalMakefile->GetSafeDefinition("IAR_EW_ROOT");
}
GLOBALCFG.iarArmPath = globalMakefile->GetSafeDefinition("IAR_TOOLKIT_DIR");
if (GLOBALCFG.iarArmPath.empty()) {
cmSystemTools::Message(
"IAR_TOOLKIT_DIR not set, using obsolete IAR_ARM_PATH");
GLOBALCFG.iarArmPath =
globalMakefile->GetSafeDefinition("IAR_ARM_PATH");
}

if (GLOBALCFG.iarPath.empty()) {
cmSystemTools::Message(
"IAR_INSTALL_DIR not set, using obsolete ${IAR_ARM_PATH}/..");
GLOBALCFG.iarPath = GLOBALCFG.iarArmPath + "/..";
}

GLOBALCFG.rtos = globalMakefile->GetSafeDefinition("IAR_TARGET_RTOS");

Expand Down Expand Up @@ -1554,7 +1591,7 @@ void cmGlobalIarGenerator::GetCmdLines(std::vector<cmCustomCommand> const& rTmpC
void cmGlobalIarGenerator::ConvertTargetToProject(const cmTarget& tgt,
cmGeneratorTarget* genTgt)
{
std::string buildType = "Debug";
std::string buildType = "empty";
if (!GLOBALCFG.buildType.empty())
{
buildType = GLOBALCFG.buildType;
Expand Down Expand Up @@ -1611,22 +1648,27 @@ void cmGlobalIarGenerator::ConvertTargetToProject(const cmTarget& tgt,
buildCfg.name = buildType;
buildCfg.isDebug = (buildType == "Debug");
buildCfg.exeDir = buildCfg.name;
if (buildType == "empty") {
buildCfg.exeDir = "";
}

buildCfg.objectDir = buildCfg.exeDir;
buildCfg.listDir = buildCfg.exeDir;

if (!buildCfg.exeDir.empty()) {
buildCfg.objectDir += "/";
buildCfg.listDir += "/";
}
buildCfg.objectDir += "Object";
buildCfg.listDir += "List";
buildCfg.toolchain = GLOBALCFG.tgtArch;
buildCfg.outputFile = genTgt->GetExportName();
buildCfg.outputFile = genTgt->GetName();

buildCfg.preBuildCmd = "";
buildCfg.postBuildCmd = "";

std::string prebuild = project->binaryDir + "/" + buildCfg.exeDir+"/"+project->name+"_prebuild.bat";
std::string postbuild = project->binaryDir + "/" + buildCfg.exeDir+"/"+project->name+"_postbuild.bat";
std::string prebuild = cmStrCat(project->binaryDir, "/", buildCfg.exeDir, "/", project->name, "_prebuild.bat");
std::string postbuild = cmStrCat(project->binaryDir, "/", buildCfg.exeDir, "/", project->name, "_postbuild.bat");

buildCfg.icfPath = GLOBALCFG.linkerIcfFile;

Expand Down Expand Up @@ -2699,7 +2741,7 @@ void cmGlobalIarGenerator::Workspace::CreateWorkspaceFile()
XmlNode rootWsdt = XmlNode("workspace");
XmlNode* wsdt = new XmlNode("CurrentConfigs");

std::string buildType = "Debug";
std::string buildType = "empty";
if (!cmGlobalIarGenerator::GLOBALCFG.buildType.empty())
{
buildType = cmGlobalIarGenerator::GLOBALCFG.buildType;
Expand Down
8 changes: 7 additions & 1 deletion Source/cmGlobalIarGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,16 @@ class cmGlobalIarGenerator : public cmGlobalGenerator
const char* GetCMakeCFGIntDir() const override
{
return cmGlobalIarGenerator::GLOBALCFG.buildType.empty()
? "Debug"
? "empty"
: cmGlobalIarGenerator::GLOBALCFG.buildType.c_str();
}

/** Append the subdirectory for the given configuration. */
void AppendDirectoryForConfig(const std::string& prefix,
const std::string& config,
const std::string& suffix,
std::string& dir) override;

static std::string ToToolkitPath(std::string absolutePath);

static std::string ToWorkbenchPath(std::string absolutePath);
Expand Down

0 comments on commit 6b65ecd

Please sign in to comment.