Răsfoiți Sursa

cmScanDepFormat: support P1689R5

This adds the `is-interface` key on provides fields.
Ben Boeckel 3 ani în urmă
părinte
comite
d7f5064ff7

+ 2 - 2
Help/dev/experimental.rst

@@ -58,7 +58,7 @@ dependencies to the file specified by the ``<DYNDEP_FILE>`` placeholder. The
 for scandep rules which use ``msvc``-style dependency reporting.
 
 The module dependencies should be written in the format described
-by the `P1689r4`_ paper.
+by the `P1689r5`_ paper.
 
 Compiler writers may try out their scanning functionality using
 the `cxx-modules-sandbox`_ test project, modified to set variables
@@ -85,5 +85,5 @@ the GCC documentation, but the relevant section for the purposes of CMake is:
     -- GCC module mapper documentation
 
 .. _`D1483r1`: https://mathstuf.fedorapeople.org/fortran-modules/fortran-modules.html
-.. _`P1689r4`: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p1689r4.html
+.. _`P1689r5`: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1689r5.html
 .. _`cxx-modules-sandbox`: https://github.com/mathstuf/cxx-modules-sandbox

+ 6 - 0
Help/release/dev/p1689r5.rst

@@ -0,0 +1,6 @@
+p1689r5
+-------
+
+* C++ module scanning now supports the latest revision, `P1689R5`_.
+
+.. _`P1689r5`: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1689r5.html

+ 15 - 0
Source/cmScanDepFormat.cxx

@@ -188,6 +188,19 @@ bool cmScanDepFormat_P1689_Parse(std::string const& arg_pp,
             return false;
           }
 
+          if (provide.isMember("is-interface")) {
+            Json::Value const& is_interface = provide["is-interface"];
+            if (!is_interface.isBool()) {
+              cmSystemTools::Error(
+                cmStrCat("-E cmake_ninja_dyndep failed to parse ", arg_pp,
+                         ": is-interface is not a boolean"));
+              return false;
+            }
+            provide_info.IsInterface = is_interface.asBool();
+          } else {
+            provide_info.IsInterface = true;
+          }
+
           info->Provides.push_back(provide_info);
         }
       }
@@ -308,6 +321,8 @@ bool cmScanDepFormat_P1689_Write(std::string const& path,
       provide_obj["source-path"] = EncodeFilename(provide.SourcePath);
     }
 
+    provide_obj["is-interface"] = provide.IsInterface;
+
     provides.append(provide_obj);
   }
 

+ 5 - 0
Source/cmScanDepFormat.h

@@ -18,6 +18,11 @@ struct cmSourceReqInfo
   std::string SourcePath;
   std::string CompiledModulePath;
   bool UseSourcePath = false;
+
+  // Provides-only fields.
+  bool IsInterface = true;
+
+  // Requires-only fields.
   LookupMethod Method = LookupMethod::ByName;
 };