Sfoglia il codice sorgente

GHS: Integrity Application updates

-- Check the property "ghs_integrity_app" on executables to set [INTEGRITY Application]
   If the property is not set then check if an integrate file is one of the source files (.int file).
   Dynamic Downloads that do not have an integrate file can use this property along with setting
   the compiler flag "-dynamic".

-- Remove parsing for -dynamic flag; it is only used to print a comment
   The MULTI GUI will show if it is a Monolith or Dynamic Download application

-- Use project references to specify which executables are part of the Integrity Application
   Usually Implicit Dependency Analysis will ensure that executable targets
   become part of the application.  This does not work for Dynamic Download without integrate files.
   Use `add_dependencies(dd vas)` to mark that the vas target is part of dd target.

-- Update file locations in the Integrate files.
Fred Baksik 6 anni fa
parent
commit
0c9e47d7cd

+ 19 - 10
Help/generator/Green Hills MULTI.rst

@@ -18,37 +18,46 @@ If the toolset is not specified then the latest toolset will be used.
 
 
 * ``GHS_TARGET_PLATFORM``
 * ``GHS_TARGET_PLATFORM``
 
 
-Default to ``integrity``.
-Usual values are ``integrity``, ``threadx``, ``uvelosity``,
-``velosity``, ``vxworks``, ``standalone``.
+  | Defaults to ``integrity``.
+  | Usual values are ``integrity``, ``threadx``, ``uvelosity``, ``velosity``,
+    ``vxworks``, ``standalone``.
+
 
 
 * ``GHS_PRIMARY_TARGET``
 * ``GHS_PRIMARY_TARGET``
 
 
-Sets ``primaryTarget`` field in project file.
-Defaults to ``<arch>_<GHS_TARGET_PLATFORM>.tgt``.
+  | Sets ``primaryTarget`` entry in project file.
+  | Defaults to ``<arch>_<GHS_TARGET_PLATFORM>.tgt``.
 
 
 * ``GHS_TOOLSET_ROOT``
 * ``GHS_TOOLSET_ROOT``
 
 
-Default to ``C:/ghs``.  Root path for ``toolset``.
+  | Root path for ``toolset``.
+  | Defaults to ``C:/ghs``.
 
 
 * ``GHS_OS_ROOT``
 * ``GHS_OS_ROOT``
 
 
-Default to ``C:/ghs``.  Root path for RTOS searches.
+  | Root path for RTOS searches.
+  | Defaults to ``C:/ghs``.
 
 
 * ``GHS_OS_DIR``
 * ``GHS_OS_DIR``
 
 
-Default to latest platform OS installation at ``GHS_OS_ROOT``.  Set this value if
-a specific RTOS is to be used.
+  | Sets ``-os_dir`` entry in project file.
+  | Defaults to latest platform OS installation at ``GHS_OS_ROOT``.  Set this value if
+    a specific RTOS is to be used.
 
 
 * ``GHS_BSP_NAME``
 * ``GHS_BSP_NAME``
 
 
-Defaults to ``sim<arch>`` if not set by user.
+  | Sets ``-bsp`` entry in project file.
+  | Defaults to ``sim<arch>`` for ``integrity`` platforms.
 
 
 Customizations are available through the following cache variables:
 Customizations are available through the following cache variables:
 
 
 * ``GHS_CUSTOMIZATION``
 * ``GHS_CUSTOMIZATION``
 * ``GHS_GPJ_MACROS``
 * ``GHS_GPJ_MACROS``
 
 
+The following properties are available:
+
+* :prop_tgt:`GHS_INTEGRITY_APP`
+
 .. note::
 .. note::
   This generator is deemed experimental as of CMake |release|
   This generator is deemed experimental as of CMake |release|
   and is still a work in progress.  Future versions of CMake
   and is still a work in progress.  Future versions of CMake

+ 1 - 0
Help/manual/cmake-properties.7.rst

@@ -193,6 +193,7 @@ Properties on Targets
    /prop_tgt/FRAMEWORK
    /prop_tgt/FRAMEWORK
    /prop_tgt/FRAMEWORK_VERSION
    /prop_tgt/FRAMEWORK_VERSION
    /prop_tgt/GENERATOR_FILE_NAME
    /prop_tgt/GENERATOR_FILE_NAME
+   /prop_tgt/GHS_INTEGRITY_APP
    /prop_tgt/GNUtoMS
    /prop_tgt/GNUtoMS
    /prop_tgt/HAS_CXX
    /prop_tgt/HAS_CXX
    /prop_tgt/IMPLICIT_DEPENDS_INCLUDE_TRANSFORM
    /prop_tgt/IMPLICIT_DEPENDS_INCLUDE_TRANSFORM

+ 10 - 0
Help/prop_tgt/GHS_INTEGRITY_APP.rst

@@ -0,0 +1,10 @@
+GHS_INTEGRITY_APP
+-----------------
+
+``ON`` / ``OFF`` boolean to determine if an executable target should
+be treated as an `Integrity Application`.
+
+If no value is set and if a `.int` file is added as a source file to the
+executable target it will be treated as an `Integrity Application`.
+
+Supported on :generator:`Green Hills MULTI`.

+ 1 - 1
Help/variable/GHS-MULTI.rst

@@ -1,4 +1,4 @@
 GHS-MULTI
 GHS-MULTI
 ---------
 ---------
 
 
-True when using Green Hills MULTI
+``True`` when using :generator:`Green Hills MULTI` generator.

+ 41 - 37
Source/cmGhsMultiTargetGenerator.cxx

@@ -13,15 +13,11 @@
 #include "cmSourceGroup.h"
 #include "cmSourceGroup.h"
 #include "cmTarget.h"
 #include "cmTarget.h"
 
 
-std::string const cmGhsMultiTargetGenerator::DDOption("-dynamic");
-
 cmGhsMultiTargetGenerator::cmGhsMultiTargetGenerator(cmGeneratorTarget* target)
 cmGhsMultiTargetGenerator::cmGhsMultiTargetGenerator(cmGeneratorTarget* target)
   : GeneratorTarget(target)
   : GeneratorTarget(target)
   , LocalGenerator(
   , LocalGenerator(
       static_cast<cmLocalGhsMultiGenerator*>(target->GetLocalGenerator()))
       static_cast<cmLocalGhsMultiGenerator*>(target->GetLocalGenerator()))
   , Makefile(target->Target->GetMakefile())
   , Makefile(target->Target->GetMakefile())
-  , TargetGroup(DetermineIfTargetGroup(target))
-  , DynamicDownload(false)
   , Name(target->GetName())
   , Name(target->GetName())
 {
 {
   // Store the configuration name that is being used
   // Store the configuration name that is being used
@@ -50,8 +46,7 @@ void cmGhsMultiTargetGenerator::Generate()
       this->GeneratorTarget->GetExecutableNames(
       this->GeneratorTarget->GetExecutableNames(
         targetName, this->TargetNameReal, targetNameImport, targetNamePDB,
         targetName, this->TargetNameReal, targetNameImport, targetNamePDB,
         this->ConfigName);
         this->ConfigName);
-      if (cmGhsMultiTargetGenerator::DetermineIfTargetGroup(
-            this->GeneratorTarget)) {
+      if (cmGhsMultiTargetGenerator::DetermineIfIntegrityApp()) {
         this->TagType = GhsMultiGpj::INTERGRITY_APPLICATION;
         this->TagType = GhsMultiGpj::INTERGRITY_APPLICATION;
       } else {
       } else {
         this->TagType = GhsMultiGpj::PROGRAM;
         this->TagType = GhsMultiGpj::PROGRAM;
@@ -126,11 +121,7 @@ void cmGhsMultiTargetGenerator::GenerateTarget()
 
 
   const std::string language(
   const std::string language(
     this->GeneratorTarget->GetLinkerLanguage(this->ConfigName));
     this->GeneratorTarget->GetLinkerLanguage(this->ConfigName));
-  this->DynamicDownload =
-    this->DetermineIfDynamicDownload(this->ConfigName, language);
-  if (this->DynamicDownload) {
-    fout << "#component integrity_dynamic_download" << std::endl;
-  }
+
   this->WriteTargetSpecifics(fout, this->ConfigName);
   this->WriteTargetSpecifics(fout, this->ConfigName);
   this->SetCompilerFlags(this->ConfigName, language);
   this->SetCompilerFlags(this->ConfigName, language);
   this->WriteCompilerFlags(fout, this->ConfigName, language);
   this->WriteCompilerFlags(fout, this->ConfigName, language);
@@ -139,7 +130,7 @@ void cmGhsMultiTargetGenerator::GenerateTarget()
   this->WriteTargetLinkLine(fout, this->ConfigName);
   this->WriteTargetLinkLine(fout, this->ConfigName);
   this->WriteCustomCommands(fout);
   this->WriteCustomCommands(fout);
   this->WriteSources(fout);
   this->WriteSources(fout);
-
+  this->WriteReferences(fout);
   fout.Close();
   fout.Close();
 }
 }
 
 
@@ -541,36 +532,49 @@ void cmGhsMultiTargetGenerator::WriteObjectLangOverride(
     }
     }
   }
   }
 }
 }
-
-bool cmGhsMultiTargetGenerator::DetermineIfTargetGroup(
-  const cmGeneratorTarget* target)
+void cmGhsMultiTargetGenerator::WriteReferences(std::ostream& fout)
 {
 {
-  bool output = false;
-  std::vector<cmSourceFile*> sources;
-  std::string config =
-    target->Target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE");
-  target->GetSourceFiles(sources, config);
-  for (std::vector<cmSourceFile*>::const_iterator sources_i = sources.begin();
-       sources.end() != sources_i; ++sources_i) {
-    if ("int" == (*sources_i)->GetExtension()) {
-      output = true;
-    }
+  // This only applies to INTEGRITY Applications
+  if (this->TagType != GhsMultiGpj::INTERGRITY_APPLICATION) {
+    return;
+  }
+
+  // Get the targets that this one depends upon
+  cmTargetDependSet unordered =
+    this->GetGlobalGenerator()->GetTargetDirectDepends(this->GeneratorTarget);
+  cmGlobalGhsMultiGenerator::OrderedTargetDependSet ordered(unordered,
+                                                            this->Name);
+  for (auto& t : ordered) {
+    std::string tname = t->GetName();
+    std::string tpath = t->LocalGenerator->GetCurrentBinaryDirectory();
+    std::string rootpath = this->LocalGenerator->GetCurrentBinaryDirectory();
+    std::string outpath =
+      this->LocalGenerator->ConvertToRelativePath(rootpath, tpath) + "/" +
+      tname + "REF" + cmGlobalGhsMultiGenerator::FILE_EXTENSION;
+
+    fout << outpath;
+    fout << "    ";
+    GhsMultiGpj::WriteGpjTag(GhsMultiGpj::REFERENCE, fout);
+
+    // Tell the global generator that a refernce project needs to be created
+    t->Target->SetProperty("GHS_REFERENCE_PROJECT", "ON");
   }
   }
-  return output;
 }
 }
 
 
-bool cmGhsMultiTargetGenerator::DetermineIfDynamicDownload(
-  std::string const& config, const std::string& language)
+bool cmGhsMultiTargetGenerator::DetermineIfIntegrityApp(void)
 {
 {
-  std::vector<std::string> options;
-  bool output = false;
-  this->GeneratorTarget->GetCompileOptions(options, config, language);
-  for (std::vector<std::string>::const_iterator options_i = options.begin();
-       options_i != options.end(); ++options_i) {
-    std::string option = *options_i;
-    if (this->DDOption == option) {
-      output = true;
+  const char* p = this->GeneratorTarget->GetProperty("ghs_integrity_app");
+  if (p) {
+    return cmSystemTools::IsOn(
+      this->GeneratorTarget->GetProperty("ghs_integrity_app"));
+  } else {
+    std::vector<cmSourceFile*> sources;
+    this->GeneratorTarget->GetSourceFiles(sources, this->ConfigName);
+    for (auto& sf : sources) {
+      if ("int" == sf->GetExtension()) {
+        return true;
+      }
     }
     }
+    return false;
   }
   }
-  return output;
 }
 }

+ 2 - 9
Source/cmGhsMultiTargetGenerator.h

@@ -29,8 +29,6 @@ private:
 
 
   void GenerateTarget();
   void GenerateTarget();
 
 
-  bool IsTargetGroup() const { return this->TargetGroup; }
-
   void WriteTargetSpecifics(std::ostream& fout, const std::string& config);
   void WriteTargetSpecifics(std::ostream& fout, const std::string& config);
 
 
   void WriteCompilerFlags(std::ostream& fout, const std::string& config,
   void WriteCompilerFlags(std::ostream& fout, const std::string& config,
@@ -54,19 +52,14 @@ private:
   void WriteSources(std::ostream& fout_proj);
   void WriteSources(std::ostream& fout_proj);
   void WriteSourceProperty(std::ostream& fout, const cmSourceFile* sf,
   void WriteSourceProperty(std::ostream& fout, const cmSourceFile* sf,
                            std::string propName, std::string propFlag);
                            std::string propName, std::string propFlag);
+  void WriteReferences(std::ostream& fout);
   static void WriteObjectLangOverride(std::ostream& fout,
   static void WriteObjectLangOverride(std::ostream& fout,
                                       const cmSourceFile* sourceFile);
                                       const cmSourceFile* sourceFile);
 
 
-  static bool DetermineIfTargetGroup(const cmGeneratorTarget* target);
-  bool DetermineIfDynamicDownload(std::string const& config,
-                                  const std::string& language);
-
+  bool DetermineIfIntegrityApp(void);
   cmGeneratorTarget* GeneratorTarget;
   cmGeneratorTarget* GeneratorTarget;
   cmLocalGhsMultiGenerator* LocalGenerator;
   cmLocalGhsMultiGenerator* LocalGenerator;
   cmMakefile* Makefile;
   cmMakefile* Makefile;
-  bool TargetGroup;
-  bool DynamicDownload;
-  static std::string const DDOption;
   std::map<std::string, std::string> FlagsByLanguage;
   std::map<std::string, std::string> FlagsByLanguage;
   std::map<std::string, std::string> DefinesByLanguage;
   std::map<std::string, std::string> DefinesByLanguage;
 
 

+ 2 - 1
Source/cmGlobalGenerator.cxx

@@ -302,7 +302,8 @@ bool cmGlobalGenerator::CheckTargetsForMissingSources() const
     for (cmGeneratorTarget* target : targets) {
     for (cmGeneratorTarget* target : targets) {
       if (target->GetType() == cmStateEnums::TargetType::GLOBAL_TARGET ||
       if (target->GetType() == cmStateEnums::TargetType::GLOBAL_TARGET ||
           target->GetType() == cmStateEnums::TargetType::INTERFACE_LIBRARY ||
           target->GetType() == cmStateEnums::TargetType::INTERFACE_LIBRARY ||
-          target->GetType() == cmStateEnums::TargetType::UTILITY) {
+          target->GetType() == cmStateEnums::TargetType::UTILITY ||
+          cmSystemTools::IsOn(target->GetProperty("ghs_integrity_app"))) {
         continue;
         continue;
       }
       }
 
 

+ 19 - 1
Source/cmGlobalGhsMultiGenerator.cxx

@@ -315,8 +315,26 @@ void cmGlobalGhsMultiGenerator::WriteSubProjects(
       if (cmSystemTools::IsOn(target->GetProperty("EXCLUDE_FROM_ALL"))) {
       if (cmSystemTools::IsOn(target->GetProperty("EXCLUDE_FROM_ALL"))) {
         fout << "{comment} ";
         fout << "{comment} ";
       }
       }
-      fout << dir << projName << FILE_EXTENSION;
+      std::string projFile = dir + projName + FILE_EXTENSION;
+      fout << projFile;
       fout << " " << projType << std::endl;
       fout << " " << projType << std::endl;
+
+      if (cmSystemTools::IsOn(target->GetProperty("GHS_REFERENCE_PROJECT"))) {
+        // create reference project
+        std::string fname = dir;
+        fname += target->GetName();
+        fname += "REF";
+        fname += FILE_EXTENSION;
+
+        cmGeneratedFileStream fref(fname.c_str());
+        fref.SetCopyIfDifferent(true);
+
+        this->WriteFileHeader(fref);
+        GhsMultiGpj::WriteGpjTag(GhsMultiGpj::REFERENCE, fref);
+        fref << "    :reference=" << projFile << std::endl;
+
+        fref.Close();
+      }
     }
     }
   }
   }
 }
 }

+ 1 - 0
Tests/CMakeLists.txt

@@ -2292,6 +2292,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
       if (NOT ghs_skip_integrity AND (NOT ghs_target_platform OR ghs_target_platform MATCHES "integrity"))
       if (NOT ghs_skip_integrity AND (NOT ghs_target_platform OR ghs_target_platform MATCHES "integrity"))
         add_test_GhsMulti(integrityDDInt GhsMultiIntegrity/GhsMultiIntegrityDDInt "" "" "")
         add_test_GhsMulti(integrityDDInt GhsMultiIntegrity/GhsMultiIntegrityDDInt "" "" "")
         add_test_GhsMulti(integrityMonolith GhsMultiIntegrity/GhsMultiIntegrityMonolith "" "" "")
         add_test_GhsMulti(integrityMonolith GhsMultiIntegrity/GhsMultiIntegrityMonolith "" "" "")
+        add_test_GhsMulti(integrityDD GhsMultiIntegrity/GhsMultiIntegrityDD "" "" "")
       endif ()
       endif ()
       add_test_GhsMulti(duplicate_source_filenames GhsMultiDuplicateSourceFilenames "" "" "")
       add_test_GhsMulti(duplicate_source_filenames GhsMultiDuplicateSourceFilenames "" "" "")
       add_test_GhsMulti_rename_install(SINGLE_EXEC)
       add_test_GhsMulti_rename_install(SINGLE_EXEC)

+ 17 - 0
Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/CMakeLists.txt

@@ -0,0 +1,17 @@
+# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
+
+project(test C)
+
+# create virtual AS
+add_executable(vas exe.c)
+target_link_libraries(vas lib)
+add_library(lib func.c)
+
+# create dynamic download INTEGRITY application
+add_executable(dynamic)
+set_target_properties(dynamic PROPERTIES ghs_integrity_app ON)
+target_compile_options(dynamic PRIVATE -dynamic)
+add_dependencies(dynamic vas)

+ 5 - 0
Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/exe.c

@@ -0,0 +1,5 @@
+extern int func(void);
+int main(void)
+{
+  return func();
+}

+ 4 - 0
Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/func.c

@@ -0,0 +1,4 @@
+int func(void)
+{
+  return 2;
+}

+ 1 - 1
Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Int/AppDD.int

@@ -7,6 +7,6 @@ Kernel
 EndKernel
 EndKernel
 
 
 AddressSpace        App
 AddressSpace        App
-  Filename      "App/App.as"
+  Filename          "App/App"
   Language C
   Language C
 EndAddressSpace
 EndAddressSpace

+ 2 - 2
Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/test.int

@@ -1,8 +1,8 @@
 Kernel
 Kernel
-  Filename        kernel/kernel.as
+  Filename        kernel
 EndKernel
 EndKernel
 
 
 AddressSpace      App
 AddressSpace      App
-  Filename        "vas/vas.as"
+  Filename        vas
   Language C
   Language C
 EndAddressSpace
 EndAddressSpace