summaryrefslogtreecommitdiffstats
path: root/Source/cmGhsMultiTargetGenerator.h
blob: 92a1109cbfd080fff3856a0e028e64bca4ba7d90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*============================================================================
  CMake - Cross Platform Makefile Generator
  Copyright 2015 Geoffrey Viola <geoffrey.viola@asirobots.com>

  Distributed under the OSI-approved BSD License (the "License");
  see accompanying file Copyright.txt for details.

  This software is distributed WITHOUT ANY WARRANTY; without even the
  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  See the License for more information.
============================================================================*/
#ifndef cmGhsMultiTargetGenerator_h
#define cmGhsMultiTargetGenerator_h

#include "cmGhsMultiGpj.h"

#include "cmTarget.h"

class cmGeneratedFileStream;
class cmGlobalGhsMultiGenerator;
class cmLocalGhsMultiGenerator;
class cmMakefile;
class cmSourceFile;
class cmGeneratedFileStream;
class cmCustomCommand;

class cmGhsMultiTargetGenerator
{
public:
  cmGhsMultiTargetGenerator(cmGeneratorTarget* target);

  virtual ~cmGhsMultiTargetGenerator();

  virtual void Generate();

  bool IncludeThisTarget();
  std::vector<cmSourceFile*> GetSources() const;
  GhsMultiGpj::Types GetGpjTag() const;
  static GhsMultiGpj::Types GetGpjTag(const cmGeneratorTarget* target);
  const char* GetAbsBuildFilePath() const
  {
    return this->AbsBuildFilePath.c_str();
  }
  const char* GetRelBuildFileName() const
  {
    return this->RelBuildFileName.c_str();
  }
  const char* GetAbsBuildFileName() const
  {
    return this->AbsBuildFileName.c_str();
  }
  const char* GetAbsOutputFileName() const
  {
    return this->AbsOutputFileName.c_str();
  }

  static std::string GetRelBuildFilePath(const cmGeneratorTarget* target);
  static std::string GetAbsPathToRoot(const cmGeneratorTarget* target);
  static std::string GetAbsBuildFilePath(const cmGeneratorTarget* target);
  static std::string GetRelBuildFileName(const cmGeneratorTarget* target);
  static std::string GetBuildFileName(const cmGeneratorTarget* target);
  static std::string AddSlashIfNeededToPath(std::string const& input);

private:
  cmGlobalGhsMultiGenerator* GetGlobalGenerator() const;
  cmGeneratedFileStream* GetFolderBuildStreams()
  {
    return this->FolderBuildStreams[""];
  };
  bool IsTargetGroup() const { return this->TargetGroup; }

  void WriteTypeSpecifics(const std::string& config, bool notKernel);
  void WriteCompilerFlags(const std::string& config,
                          const std::string& language);
  void WriteCompilerDefinitions(const std::string& config,
                                const std::string& language);

  void SetCompilerFlags(std::string const& config, const std::string& language,
                        bool const notKernel);
  std::string GetDefines(const std::string& langugae,
                         std::string const& config);

  void WriteIncludes(const std::string& config, const std::string& language);
  void WriteTargetLinkLibraries(std::string const& config,
                                std::string const& language);
  void WriteCustomCommands();
  void WriteCustomCommandsHelper(
    std::vector<cmCustomCommand> const& commandsSet,
    cmTarget::CustomCommandType commandType);
  void WriteSources(
    std::vector<cmSourceFile*> const& objectSources,
    std::map<const cmSourceFile*, std::string> const& objectNames);
  static std::map<const cmSourceFile*, std::string> GetObjectNames(
    std::vector<cmSourceFile*>* objectSources,
    cmLocalGhsMultiGenerator* localGhsMultiGenerator,
    cmGeneratorTarget* generatorTarget);
  static void WriteObjectLangOverride(cmGeneratedFileStream* fileStream,
                                      cmSourceFile* sourceFile);
  static void WriteObjectDir(cmGeneratedFileStream* fileStream,
                             std::string const& dir);
  std::string GetOutputDirectory(const std::string& config) const;
  std::string GetOutputFilename(const std::string& config) const;
  static std::string ComputeLongestObjectDirectory(
    cmLocalGhsMultiGenerator const* localGhsMultiGenerator,
    cmGeneratorTarget* generatorTarget, cmSourceFile* const sourceFile);

  bool IsNotKernel(std::string const& config, const std::string& language);
  static bool DetermineIfTargetGroup(const cmGeneratorTarget* target);
  bool DetermineIfDynamicDownload(std::string const& config,
                                  const std::string& language);

  cmGeneratorTarget* GeneratorTarget;
  cmLocalGhsMultiGenerator* LocalGenerator;
  cmMakefile* Makefile;
  std::string AbsBuildFilePath;
  std::string RelBuildFilePath;
  std::string AbsBuildFileName;
  std::string RelBuildFileName;
  std::string RelOutputFileName;
  std::string AbsOutputFileName;
  std::map<std::string, cmGeneratedFileStream*> FolderBuildStreams;
  bool TargetGroup;
  bool DynamicDownload;
  static std::string const DDOption;
  std::map<std::string, std::string> FlagsByLanguage;
  std::map<std::string, std::string> DefinesByLanguage;
};

#endif // ! cmGhsMultiTargetGenerator_h