CMake/Source/cmGhsMultiTargetGenerator.h
Fred Baksik 83c47ef5b8 GHS: Update project layout to accommodate gbuild inconsistencies
-- Do not use reference projects, use build hierarchy instead.
   gbuild has three parallel levels:
   * low -- Parallelizes compiling source files within a single project (.gpj)
     file when safe to do so.
   * medium -- Parallelizes processing files within a single linked output when
     safe to do so.
   * high [default] -- Parallelizes processing files whenever safe to do so,
     including linking task.

   Testing showed that for some combinations of gbuild / MULTI there are issues
   with building a project that uses references to target project files along with
   using {nobuild} option.

   Sometimes the archiving of a library and linking of an executable were
   happening in parallel and the build would fail when linking because the
   archive wasn't complete.

   This behavior was also inconsistent when running the build from MULTI and
   from the command line with gbuild. In some cases MULTI did not parallelize
   archiving and linking, but gbuild performed these actions in parallel.

   The parallel build issue was not seen when using a build hierarchy where the
   project listed the project files normally instead of using a reference link.

   The other option was to add the -parallel_level=medium to the command line
   when using "cmake --build" but this wouldn't fix the issue if gbuild itself
   was used to and the user might not be aware of the extra option used by cmake.
2019-04-11 13:15:51 -04:00

87 lines
3.2 KiB
C++

/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#ifndef cmGhsMultiTargetGenerator_h
#define cmGhsMultiTargetGenerator_h
#include "cmGhsMultiGpj.h"
#include <iosfwd>
#include <map>
#include <set>
#include <string>
#include <vector>
class cmCustomCommand;
class cmCustomCommandGenerator;
class cmGeneratorTarget;
class cmGlobalGhsMultiGenerator;
class cmLocalGhsMultiGenerator;
class cmMakefile;
class cmSourceFile;
class cmGhsMultiTargetGenerator
{
public:
cmGhsMultiTargetGenerator(cmGeneratorTarget* target);
virtual ~cmGhsMultiTargetGenerator();
virtual void Generate();
private:
cmGlobalGhsMultiGenerator* GetGlobalGenerator() const;
void GenerateTarget();
void WriteTargetSpecifics(std::ostream& fout, const std::string& config);
void WriteCompilerFlags(std::ostream& fout, const std::string& config,
const std::string& language);
void WriteCompilerDefinitions(std::ostream& fout, const std::string& config,
const std::string& language);
void SetCompilerFlags(std::string const& config,
const std::string& language);
std::string GetDefines(const std::string& langugae,
std::string const& config);
void WriteIncludes(std::ostream& fout, const std::string& config,
const std::string& language);
void WriteTargetLinkLine(std::ostream& fout, std::string const& config);
void WriteBuildEvents(std::ostream& fout);
void WriteBuildEventsHelper(std::ostream& fout,
const std::vector<cmCustomCommand>& ccv,
std::string const& name, std::string const& cmd);
void WriteCustomCommandsHelper(std::ostream& fout,
cmCustomCommandGenerator const& ccg);
void WriteCustomCommandLine(std::ostream& fout, std::string& fname,
cmCustomCommandGenerator const& ccg);
bool ComputeCustomCommandOrder(std::vector<cmSourceFile const*>& order);
bool VisitCustomCommand(std::set<cmSourceFile const*>& temp,
std::set<cmSourceFile const*>& perm,
std::vector<cmSourceFile const*>& order,
cmSourceFile const* sf);
void WriteSources(std::ostream& fout_proj);
void WriteSourceProperty(std::ostream& fout, const cmSourceFile* sf,
std::string const& propName,
std::string const& propFlag);
static void WriteObjectLangOverride(std::ostream& fout,
const cmSourceFile* sourceFile);
bool DetermineIfIntegrityApp();
cmGeneratorTarget* GeneratorTarget;
cmLocalGhsMultiGenerator* LocalGenerator;
cmMakefile* Makefile;
std::map<std::string, std::string> FlagsByLanguage;
std::map<std::string, std::string> DefinesByLanguage;
std::string TargetNameReal;
GhsMultiGpj::Types TagType;
std::string const Name;
std::string ConfigName; /* CMAKE_BUILD_TYPE */
bool const CmdWindowsShell; /* custom commands run in cmd.exe or /bin/sh */
};
#endif // ! cmGhsMultiTargetGenerator_h