cmGhsMultiTargetGenerator.cxx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2015 Geoffrey Viola <[email protected]>
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmGhsMultiTargetGenerator.h"
  11. #include "cmGlobalGhsMultiGenerator.h"
  12. #include "cmLocalGhsMultiGenerator.h"
  13. #include "cmMakefile.h"
  14. #include "cmTarget.h"
  15. #include "cmGeneratedFileStream.h"
  16. #include "cmSourceFile.h"
  17. #include <assert.h>
  18. #include <cmAlgorithms.h>
  19. std::string const cmGhsMultiTargetGenerator::DDOption("-dynamic");
  20. cmGhsMultiTargetGenerator::cmGhsMultiTargetGenerator(cmGeneratorTarget *target)
  21. : GeneratorTarget(target)
  22. , LocalGenerator(static_cast<cmLocalGhsMultiGenerator *>(
  23. target->GetLocalGenerator()))
  24. , Makefile(target->Target->GetMakefile())
  25. , TargetGroup(DetermineIfTargetGroup(target))
  26. , DynamicDownload(false)
  27. {
  28. this->RelBuildFilePath = this->GetRelBuildFilePath(target);
  29. this->RelOutputFileName =
  30. this->RelBuildFilePath + target->GetName() + ".a";
  31. this->RelBuildFileName = this->RelBuildFilePath;
  32. this->RelBuildFileName += this->GetBuildFileName(target);
  33. std::string absPathToRoot = this->GetAbsPathToRoot(target);
  34. absPathToRoot = this->AddSlashIfNeededToPath(absPathToRoot);
  35. this->AbsBuildFilePath = absPathToRoot + this->RelBuildFilePath;
  36. this->AbsBuildFileName = absPathToRoot + this->RelBuildFileName;
  37. this->AbsOutputFileName = absPathToRoot + this->RelOutputFileName;
  38. }
  39. cmGhsMultiTargetGenerator::~cmGhsMultiTargetGenerator()
  40. {
  41. cmDeleteAll(this->FolderBuildStreams);
  42. }
  43. std::string
  44. cmGhsMultiTargetGenerator::GetRelBuildFilePath(
  45. const cmGeneratorTarget *target)
  46. {
  47. std::string output;
  48. char const *folderProp = target->GetProperty("FOLDER");
  49. output = NULL == folderProp ? "" : folderProp;
  50. cmSystemTools::ConvertToUnixSlashes(output);
  51. if (!output.empty())
  52. {
  53. output += "/";
  54. }
  55. output += target->GetName() + "/";
  56. return output;
  57. }
  58. std::string
  59. cmGhsMultiTargetGenerator::GetAbsPathToRoot(const cmGeneratorTarget *target)
  60. {
  61. return target->GetLocalGenerator()->GetBinaryDirectory();
  62. }
  63. std::string
  64. cmGhsMultiTargetGenerator::GetAbsBuildFilePath(const cmGeneratorTarget *target)
  65. {
  66. std::string output;
  67. output = cmGhsMultiTargetGenerator::GetAbsPathToRoot(target);
  68. output = cmGhsMultiTargetGenerator::AddSlashIfNeededToPath(output);
  69. output += cmGhsMultiTargetGenerator::GetRelBuildFilePath(target);
  70. return output;
  71. }
  72. std::string
  73. cmGhsMultiTargetGenerator::GetRelBuildFileName(const cmGeneratorTarget *target)
  74. {
  75. std::string output;
  76. output = cmGhsMultiTargetGenerator::GetRelBuildFilePath(target);
  77. output = cmGhsMultiTargetGenerator::AddSlashIfNeededToPath(output);
  78. output += cmGhsMultiTargetGenerator::GetBuildFileName(target);
  79. return output;
  80. }
  81. std::string
  82. cmGhsMultiTargetGenerator::GetBuildFileName(const cmGeneratorTarget *target)
  83. {
  84. std::string output;
  85. output = target->GetName();
  86. output += cmGlobalGhsMultiGenerator::FILE_EXTENSION;
  87. return output;
  88. }
  89. std::string
  90. cmGhsMultiTargetGenerator::AddSlashIfNeededToPath(std::string const &input)
  91. {
  92. std::string output(input);
  93. if (!cmHasLiteralSuffix(output, "/"))
  94. {
  95. output += "/";
  96. }
  97. return output;
  98. }
  99. void cmGhsMultiTargetGenerator::Generate()
  100. {
  101. const std::vector<cmSourceFile *> objectSources = this->GetSources();
  102. if (!objectSources.empty() && this->IncludeThisTarget())
  103. {
  104. if (!cmSystemTools::FileExists(this->AbsBuildFilePath.c_str()))
  105. {
  106. cmSystemTools::MakeDirectory(this->AbsBuildFilePath.c_str());
  107. }
  108. cmGlobalGhsMultiGenerator::Open(std::string(""), this->AbsBuildFileName,
  109. &this->FolderBuildStreams);
  110. cmGlobalGhsMultiGenerator::OpenBuildFileStream(
  111. this->GetFolderBuildStreams());
  112. std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
  113. if (0 == config.length())
  114. {
  115. config = "RELEASE";
  116. }
  117. const std::string language(
  118. this->GeneratorTarget->GetLinkerLanguage(config));
  119. config = cmSystemTools::UpperCase(config);
  120. this->DynamicDownload = this->DetermineIfDynamicDownload(config, language);
  121. if (this->DynamicDownload)
  122. {
  123. *this->GetFolderBuildStreams() << "#component integrity_dynamic_download"
  124. << std::endl;
  125. }
  126. GhsMultiGpj::WriteGpjTag(this->GetGpjTag(), this->GetFolderBuildStreams());
  127. cmGlobalGhsMultiGenerator::WriteDisclaimer(this->GetFolderBuildStreams());
  128. bool const notKernel = this->IsNotKernel(config, language);
  129. this->WriteTypeSpecifics(config, notKernel);
  130. this->SetCompilerFlags(config, language, notKernel);
  131. this->WriteCompilerFlags(config, language);
  132. this->WriteCompilerDefinitions(config, language);
  133. this->WriteIncludes(config, language);
  134. if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE)
  135. {
  136. this->WriteTargetLinkLibraries(config, language);
  137. }
  138. this->WriteCustomCommands();
  139. this->WriteSources(objectSources);
  140. }
  141. }
  142. bool cmGhsMultiTargetGenerator::IncludeThisTarget()
  143. {
  144. bool output = true;
  145. char const *excludeFromAll =
  146. this->GeneratorTarget->GetProperty("EXCLUDE_FROM_ALL");
  147. if (NULL != excludeFromAll && '1' == excludeFromAll[0] &&
  148. '\0' == excludeFromAll[1])
  149. {
  150. output = false;
  151. }
  152. return output;
  153. }
  154. std::vector<cmSourceFile *> cmGhsMultiTargetGenerator::GetSources() const
  155. {
  156. std::vector<cmSourceFile *> output;
  157. std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
  158. this->GeneratorTarget->GetSourceFiles(output, config);
  159. return output;
  160. }
  161. GhsMultiGpj::Types cmGhsMultiTargetGenerator::GetGpjTag() const
  162. {
  163. return cmGhsMultiTargetGenerator::GetGpjTag(this->GeneratorTarget);
  164. }
  165. GhsMultiGpj::Types cmGhsMultiTargetGenerator::GetGpjTag(
  166. const cmGeneratorTarget *target)
  167. {
  168. GhsMultiGpj::Types output;
  169. if (cmGhsMultiTargetGenerator::DetermineIfTargetGroup(target))
  170. {
  171. output = GhsMultiGpj::INTERGRITY_APPLICATION;
  172. }
  173. else if (target->GetType() == cmState::STATIC_LIBRARY)
  174. {
  175. output = GhsMultiGpj::LIBRARY;
  176. }
  177. else
  178. {
  179. output = GhsMultiGpj::PROGRAM;
  180. }
  181. return output;
  182. }
  183. cmGlobalGhsMultiGenerator*
  184. cmGhsMultiTargetGenerator::GetGlobalGenerator() const
  185. {
  186. return static_cast<cmGlobalGhsMultiGenerator *>(
  187. this->LocalGenerator->GetGlobalGenerator());
  188. }
  189. void cmGhsMultiTargetGenerator::WriteTypeSpecifics(const std::string &config,
  190. bool const notKernel)
  191. {
  192. std::string outputDir(this->GetOutputDirectory(config));
  193. std::string outputFilename(this->GetOutputFilename(config));
  194. if (this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY)
  195. {
  196. std::string const static_library_suffix =
  197. this->Makefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_SUFFIX");
  198. *this->GetFolderBuildStreams() << " -o \""
  199. << outputDir << outputFilename
  200. << static_library_suffix << "\""
  201. << std::endl;
  202. }
  203. else if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE)
  204. {
  205. if (notKernel && !this->IsTargetGroup())
  206. {
  207. *this->GetFolderBuildStreams() << " -relprog" << std::endl;
  208. }
  209. if (this->IsTargetGroup())
  210. {
  211. *this->GetFolderBuildStreams()
  212. << " -o \"" << outputDir
  213. << outputFilename << ".elf\"" << std::endl;
  214. *this->GetFolderBuildStreams() << " :extraOutputFile=\"" << outputDir
  215. << outputFilename << ".elf.ael\""
  216. << std::endl;
  217. }
  218. else
  219. {
  220. std::string const executable_suffix =
  221. this->Makefile->GetSafeDefinition("CMAKE_EXECUTABLE_SUFFIX");
  222. *this->GetFolderBuildStreams() << " -o \""
  223. << outputDir << outputFilename
  224. << executable_suffix << "\""
  225. << std::endl;
  226. }
  227. }
  228. }
  229. void cmGhsMultiTargetGenerator::SetCompilerFlags(std::string const &config,
  230. const std::string &language,
  231. bool const notKernel)
  232. {
  233. std::map<std::string, std::string>::iterator i =
  234. this->FlagsByLanguage.find(language);
  235. if (i == this->FlagsByLanguage.end())
  236. {
  237. std::string flags;
  238. const char *lang = language.c_str();
  239. if (notKernel)
  240. {
  241. this->LocalGenerator->AddLanguageFlags(flags, lang, config);
  242. }
  243. else
  244. {
  245. this->LocalGenerator->AddLanguageFlags(
  246. flags, lang + std::string("_GHS_KERNEL"), config);
  247. }
  248. this->LocalGenerator->AddCMP0018Flags(flags, this->GeneratorTarget,
  249. lang, config);
  250. this->LocalGenerator->AddVisibilityPresetFlags(flags,
  251. this->GeneratorTarget,
  252. lang);
  253. // Append old-style preprocessor definition flags.
  254. if (std::string(" ") != std::string(this->Makefile->GetDefineFlags()))
  255. {
  256. this->LocalGenerator->AppendFlags(flags,
  257. this->Makefile->GetDefineFlags());
  258. }
  259. // Add target-specific flags.
  260. this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget,
  261. lang, config);
  262. std::map<std::string, std::string>::value_type entry(language, flags);
  263. i = this->FlagsByLanguage.insert(entry).first;
  264. }
  265. }
  266. std::string cmGhsMultiTargetGenerator::GetDefines(const std::string &language,
  267. std::string const &config)
  268. {
  269. std::map<std::string, std::string>::iterator i =
  270. this->DefinesByLanguage.find(language);
  271. if (i == this->DefinesByLanguage.end())
  272. {
  273. std::set<std::string> defines;
  274. const char *lang = language.c_str();
  275. // Add the export symbol definition for shared library objects.
  276. if (const char *exportMacro = this->GeneratorTarget->GetExportMacro())
  277. {
  278. this->LocalGenerator->AppendDefines(defines, exportMacro);
  279. }
  280. // Add preprocessor definitions for this target and configuration.
  281. this->LocalGenerator->AddCompileDefinitions(defines,
  282. this->GeneratorTarget, config,
  283. language);
  284. std::string definesString;
  285. this->LocalGenerator->JoinDefines(defines, definesString, lang);
  286. std::map<std::string, std::string>::value_type entry(language,
  287. definesString);
  288. i = this->DefinesByLanguage.insert(entry).first;
  289. }
  290. return i->second;
  291. }
  292. void cmGhsMultiTargetGenerator::WriteCompilerFlags(std::string const &,
  293. const std::string &language)
  294. {
  295. std::map<std::string, std::string>::iterator flagsByLangI =
  296. this->FlagsByLanguage.find(language);
  297. if (flagsByLangI != this->FlagsByLanguage.end())
  298. {
  299. if (!flagsByLangI->second.empty())
  300. {
  301. *this->GetFolderBuildStreams() << " " << flagsByLangI->second
  302. << std::endl;
  303. }
  304. }
  305. }
  306. void cmGhsMultiTargetGenerator::WriteCompilerDefinitions(
  307. const std::string &config, const std::string &language)
  308. {
  309. std::vector<std::string> compileDefinitions;
  310. this->GeneratorTarget->GetCompileDefinitions(compileDefinitions,
  311. config, language);
  312. for (std::vector<std::string>::const_iterator cdI =
  313. compileDefinitions.begin();
  314. cdI != compileDefinitions.end(); ++cdI)
  315. {
  316. *this->GetFolderBuildStreams() << " -D" << (*cdI) << std::endl;
  317. }
  318. }
  319. void cmGhsMultiTargetGenerator::WriteIncludes(const std::string &config,
  320. const std::string &language)
  321. {
  322. std::vector<std::string> includes =
  323. this->GeneratorTarget->GetIncludeDirectories(config, language);
  324. for (std::vector<std::string>::const_iterator includes_i = includes.begin();
  325. includes_i != includes.end(); ++includes_i)
  326. {
  327. *this->GetFolderBuildStreams() << " -I\"" << *includes_i << "\""
  328. << std::endl;
  329. }
  330. }
  331. void cmGhsMultiTargetGenerator::WriteTargetLinkLibraries(
  332. std::string const& config, std::string const& language)
  333. {
  334. // library directories
  335. cmTargetDependSet tds =
  336. this->GetGlobalGenerator()->GetTargetDirectDepends(this->GeneratorTarget);
  337. for (cmTargetDependSet::iterator tdsI = tds.begin(); tdsI != tds.end();
  338. ++tdsI)
  339. {
  340. const cmGeneratorTarget *tg = *tdsI;
  341. *this->GetFolderBuildStreams() << " -L\"" << GetAbsBuildFilePath(tg)
  342. << "\"" << std::endl;
  343. }
  344. // library targets
  345. cmTarget::LinkLibraryVectorType llv =
  346. this->GeneratorTarget->Target->GetOriginalLinkLibraries();
  347. for (cmTarget::LinkLibraryVectorType::const_iterator llvI = llv.begin();
  348. llvI != llv.end(); ++llvI)
  349. {
  350. std::string libName = llvI->first;
  351. // if it is a user defined target get the full path to the lib
  352. cmTarget *tg(GetGlobalGenerator()->FindTarget(libName));
  353. if (NULL != tg)
  354. {
  355. libName = tg->GetName() + ".a";
  356. }
  357. *this->GetFolderBuildStreams() << " -l\"" << libName << "\""
  358. << std::endl;
  359. }
  360. if (!this->TargetGroup)
  361. {
  362. std::string linkLibraries;
  363. std::string flags;
  364. std::string linkFlags;
  365. std::string frameworkPath;
  366. std::string linkPath;
  367. std::string createRule =
  368. this->GeneratorTarget->GetCreateRuleVariable(language, config);
  369. bool useWatcomQuote =
  370. this->Makefile->IsOn(createRule + "_USE_WATCOM_QUOTE");
  371. this->LocalGenerator->GetTargetFlags(
  372. linkLibraries, flags, linkFlags,
  373. frameworkPath, linkPath,
  374. this->GeneratorTarget, useWatcomQuote);
  375. linkFlags = cmSystemTools::TrimWhitespace(linkFlags);
  376. if (!linkPath.empty())
  377. {
  378. linkPath = " " + linkPath.substr(0U, linkPath.size() - 1U);
  379. *this->GetFolderBuildStreams() << linkPath;
  380. }
  381. if (!linkFlags.empty())
  382. {
  383. *this->GetFolderBuildStreams() << " " << linkFlags << std::endl;
  384. }
  385. }
  386. }
  387. void cmGhsMultiTargetGenerator::WriteCustomCommands()
  388. {
  389. WriteCustomCommandsHelper(
  390. this->GeneratorTarget->GetPreBuildCommands(),
  391. cmTarget::PRE_BUILD);
  392. WriteCustomCommandsHelper(
  393. this->GeneratorTarget->GetPostBuildCommands(),
  394. cmTarget::POST_BUILD);
  395. }
  396. void cmGhsMultiTargetGenerator::WriteCustomCommandsHelper(
  397. std::vector<cmCustomCommand> const &commandsSet,
  398. cmTarget::CustomCommandType const commandType)
  399. {
  400. for (std::vector<cmCustomCommand>::const_iterator commandsSetI =
  401. commandsSet.begin();
  402. commandsSetI != commandsSet.end(); ++commandsSetI)
  403. {
  404. cmCustomCommandLines const &commands = commandsSetI->GetCommandLines();
  405. for (cmCustomCommandLines::const_iterator commandI = commands.begin();
  406. commandI != commands.end(); ++commandI)
  407. {
  408. switch (commandType)
  409. {
  410. case cmTarget::PRE_BUILD:
  411. *this->GetFolderBuildStreams() << " :preexecShellSafe=";
  412. break;
  413. case cmTarget::POST_BUILD:
  414. *this->GetFolderBuildStreams() << " :postexecShellSafe=";
  415. break;
  416. default:
  417. assert("Only pre and post are supported");
  418. }
  419. cmCustomCommandLine const &command = *commandI;
  420. for (cmCustomCommandLine::const_iterator commandLineI = command.begin();
  421. commandLineI != command.end(); ++commandLineI)
  422. {
  423. std::string subCommandE =
  424. this->LocalGenerator->EscapeForShell(*commandLineI, true);
  425. if (!command.empty())
  426. {
  427. *this->GetFolderBuildStreams()
  428. << (command.begin() == commandLineI ? "'" : " ");
  429. //Need to double escape backslashes
  430. cmSystemTools::ReplaceString(subCommandE, "\\", "\\\\");
  431. }
  432. *this->GetFolderBuildStreams() << subCommandE;
  433. }
  434. if (!command.empty())
  435. {
  436. *this->GetFolderBuildStreams() << "'" << std::endl;
  437. }
  438. }
  439. }
  440. }
  441. void cmGhsMultiTargetGenerator::WriteSources(
  442. std::vector<cmSourceFile *> const &objectSources)
  443. {
  444. for (std::vector<cmSourceFile *>::const_iterator si = objectSources.begin();
  445. si != objectSources.end(); ++si)
  446. {
  447. std::vector<cmSourceGroup> sourceGroups(this->Makefile->GetSourceGroups());
  448. char const *sourceFullPath = (*si)->GetFullPath().c_str();
  449. cmSourceGroup *sourceGroup =
  450. this->Makefile->FindSourceGroup(sourceFullPath, sourceGroups);
  451. std::string sgPath(sourceGroup->GetFullName());
  452. cmSystemTools::ConvertToUnixSlashes(sgPath);
  453. cmGlobalGhsMultiGenerator::AddFilesUpToPath(
  454. this->GetFolderBuildStreams(), &this->FolderBuildStreams,
  455. this->LocalGenerator->GetBinaryDirectory(), sgPath,
  456. GhsMultiGpj::SUBPROJECT, this->RelBuildFilePath);
  457. std::string fullSourcePath((*si)->GetFullPath());
  458. if ((*si)->GetExtension() == "int" || (*si)->GetExtension() == "bsp")
  459. {
  460. *this->FolderBuildStreams[sgPath] << fullSourcePath << std::endl;
  461. }
  462. else
  463. {
  464. //WORKAROUND: GHS MULTI needs the path to use backslashes without quotes
  465. // to open files in search as of version 6.1.6
  466. cmsys::SystemTools::ReplaceString(fullSourcePath, "/", "\\");
  467. *this->FolderBuildStreams[sgPath] << fullSourcePath << std::endl;
  468. }
  469. if ("ld" != (*si)->GetExtension() && "int" != (*si)->GetExtension() &&
  470. "bsp" != (*si)->GetExtension())
  471. {
  472. this->WriteObjectLangOverride(this->FolderBuildStreams[sgPath], (*si));
  473. this->WriteObjectDir(this->FolderBuildStreams[sgPath],
  474. this->AbsBuildFilePath + sgPath);
  475. }
  476. }
  477. }
  478. void cmGhsMultiTargetGenerator::WriteObjectLangOverride(
  479. cmGeneratedFileStream *fileStream, cmSourceFile *sourceFile)
  480. {
  481. const char *rawLangProp = sourceFile->GetProperty("LANGUAGE");
  482. if (NULL != rawLangProp)
  483. {
  484. std::string sourceLangProp(rawLangProp);
  485. std::string extension(sourceFile->GetExtension());
  486. if ("CXX" == sourceLangProp && ("c" == extension || "C" == extension))
  487. {
  488. *fileStream << " -dotciscxx" << std::endl;
  489. }
  490. }
  491. }
  492. void cmGhsMultiTargetGenerator::WriteObjectDir(
  493. cmGeneratedFileStream *fileStream, std::string const &dir)
  494. {
  495. std::string workingDir(dir);
  496. cmSystemTools::ConvertToUnixSlashes(workingDir);
  497. if (!workingDir.empty())
  498. {
  499. workingDir += "/";
  500. }
  501. workingDir += "Objs";
  502. *fileStream << " -object_dir=\"" << workingDir << "\"" << std::endl;
  503. }
  504. std::string
  505. cmGhsMultiTargetGenerator::GetOutputDirectory(const std::string &config) const
  506. {
  507. std::string outputDir(AbsBuildFilePath);
  508. const char *runtimeOutputProp =
  509. this->GeneratorTarget->GetProperty("RUNTIME_OUTPUT_DIRECTORY");
  510. if (NULL != runtimeOutputProp)
  511. {
  512. outputDir = runtimeOutputProp;
  513. }
  514. std::string configCapped(cmSystemTools::UpperCase(config));
  515. const char *runtimeOutputSProp =
  516. this->GeneratorTarget
  517. ->GetProperty("RUNTIME_OUTPUT_DIRECTORY_" + configCapped);
  518. if (NULL != runtimeOutputSProp)
  519. {
  520. outputDir = runtimeOutputSProp;
  521. }
  522. cmSystemTools::ConvertToUnixSlashes(outputDir);
  523. if (!outputDir.empty())
  524. {
  525. outputDir += "/";
  526. }
  527. return outputDir;
  528. }
  529. std::string
  530. cmGhsMultiTargetGenerator::GetOutputFilename(const std::string &config) const
  531. {
  532. std::string outputFilename(this->GeneratorTarget->GetName());
  533. const char *outputNameProp =
  534. this->GeneratorTarget->GetProperty("OUTPUT_NAME");
  535. if (NULL != outputNameProp)
  536. {
  537. outputFilename = outputNameProp;
  538. }
  539. std::string configCapped(cmSystemTools::UpperCase(config));
  540. const char *outputNameSProp =
  541. this->GeneratorTarget->GetProperty(configCapped + "_OUTPUT_NAME");
  542. if (NULL != outputNameSProp)
  543. {
  544. outputFilename = outputNameSProp;
  545. }
  546. return outputFilename;
  547. }
  548. bool cmGhsMultiTargetGenerator::IsNotKernel(std::string const &config,
  549. const std::string &language)
  550. {
  551. bool output;
  552. std::vector<std::string> options;
  553. this->GeneratorTarget->GetCompileOptions(options, config, language);
  554. output =
  555. options.end() == std::find(options.begin(), options.end(), "-kernel");
  556. return output;
  557. }
  558. bool cmGhsMultiTargetGenerator::DetermineIfTargetGroup(
  559. const cmGeneratorTarget *target)
  560. {
  561. bool output = false;
  562. std::vector<cmSourceFile *> sources;
  563. std::string config =
  564. target->Target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE");
  565. target->GetSourceFiles(sources, config);
  566. for (std::vector<cmSourceFile *>::const_iterator sources_i = sources.begin();
  567. sources.end() != sources_i; ++sources_i)
  568. {
  569. if ("int" == (*sources_i)->GetExtension())
  570. {
  571. output = true;
  572. }
  573. }
  574. return output;
  575. }
  576. bool cmGhsMultiTargetGenerator::DetermineIfDynamicDownload(
  577. std::string const &config, const std::string &language)
  578. {
  579. std::vector<std::string> options;
  580. bool output = false;
  581. this->GeneratorTarget->GetCompileOptions(options, config, language);
  582. for (std::vector<std::string>::const_iterator options_i = options.begin();
  583. options_i != options.end(); ++options_i)
  584. {
  585. std::string option = *options_i;
  586. if (this->DDOption == option)
  587. {
  588. output = true;
  589. }
  590. }
  591. return output;
  592. }