Bläddra i källkod

Merge topic 'cxxmodules-dyndep-error-on-private-usage' into release-3.29

3f8a59a05c cxxmodules: return failure from the collator when private usage is found

Acked-by: Kitware Robot <[email protected]>
Tested-by: buildbot <[email protected]>
Merge-request: !9257
Brad King 1 år sedan
förälder
incheckning
0e60e84d35
3 ändrade filer med 10 tillägg och 3 borttagningar
  1. 2 1
      Source/cmCxxModuleMapper.cxx
  2. 1 1
      Source/cmCxxModuleMapper.h
  3. 7 1
      Source/cmGlobalNinjaGenerator.cxx

+ 2 - 1
Source/cmCxxModuleMapper.cxx

@@ -305,7 +305,7 @@ cm::static_string_view CxxModuleMapExtension(
 
 std::set<std::string> CxxModuleUsageSeed(
   CxxModuleLocations const& loc, std::vector<cmScanDepInfo> const& objects,
-  CxxModuleUsage& usages)
+  CxxModuleUsage& usages, bool& private_usage_found)
 {
   // Track inner usages to populate usages from internal bits.
   //
@@ -334,6 +334,7 @@ std::set<std::string> CxxModuleUsageSeed(
           cmStrCat("Unable to use module '", r.LogicalName,
                    "' as it is 'PRIVATE' and therefore not accessible outside "
                    "of its owning target."));
+        private_usage_found = true;
         continue;
       }
 

+ 1 - 1
Source/cmCxxModuleMapper.h

@@ -93,7 +93,7 @@ cm::static_string_view CxxModuleMapExtension(
 // import cycle).
 std::set<std::string> CxxModuleUsageSeed(
   CxxModuleLocations const& loc, std::vector<cmScanDepInfo> const& objects,
-  CxxModuleUsage& usages);
+  CxxModuleUsage& usages, bool& private_usage_found);
 
 // Return the contents of the module map in the given format for the
 // object file.

+ 7 - 1
Source/cmGlobalNinjaGenerator.cxx

@@ -2742,7 +2742,9 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
 
     // Insert information about the current target's modules.
     if (modmap_fmt) {
-      auto cycle_modules = CxxModuleUsageSeed(locs, objects, usages);
+      bool private_usage_found = false;
+      auto cycle_modules =
+        CxxModuleUsageSeed(locs, objects, usages, private_usage_found);
       if (!cycle_modules.empty()) {
         cmSystemTools::Error(
           cmStrCat("Circular dependency detected in the C++ module import "
@@ -2750,6 +2752,10 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
                    cmJoin(cycle_modules, R"(", ")"_s), '"'));
         return false;
       }
+      if (private_usage_found) {
+        // Already errored in the function.
+        return false;
+      }
     }
 
     cmNinjaBuild build("dyndep");