Kaynağa Gözat

Merge branch 'backport-4.0-fileapi-instrumentation-initial-cache'

Brad King 6 gün önce
ebeveyn
işleme
1bd6e70430

+ 2 - 1
Source/cmFileAPI.cxx

@@ -72,7 +72,8 @@ void cmFileAPI::ReadQueries()
 {
   std::string const query_dir = cmStrCat(this->APIv1, "/query");
   std::string const user_query_dir = cmStrCat(this->UserAPIv1, "/query");
-  this->QueryExists = cmSystemTools::FileIsDirectory(query_dir);
+  this->QueryExists =
+    this->QueryExists || cmSystemTools::FileIsDirectory(query_dir);
   if (!this->UserAPIv1.empty()) {
     this->QueryExists =
       this->QueryExists || cmSystemTools::FileIsDirectory(user_query_dir);

+ 11 - 1
Source/cmake.cxx

@@ -718,6 +718,7 @@ bool cmake::SetCacheArgs(std::vector<std::string> const& args)
         // Resolve script path specified on command line
         // relative to $PWD.
         auto path = cmSystemTools::ToNormalizedPathOnDisk(value);
+        state->InitializeFileAPI();
         state->ReadListFile(args, path);
         return true;
       } },
@@ -2665,7 +2666,7 @@ int cmake::ActualConfigure()
   }
 
 #if !defined(CMAKE_BOOTSTRAP)
-  this->FileAPI = cm::make_unique<cmFileAPI>(this);
+  this->InitializeFileAPI();
   this->FileAPI->ReadQueries();
 
   this->Instrumentation = cm::make_unique<cmInstrumentation>(
@@ -2929,6 +2930,15 @@ void cmake::StopDebuggerIfNeeded(int exitCode)
 
 #endif
 
+void cmake::InitializeFileAPI()
+{
+#ifndef CMAKE_BOOTSTRAP
+  if (!this->FileAPI) {
+    this->FileAPI = cm::make_unique<cmFileAPI>(this);
+  }
+#endif
+}
+
 // handle a command line invocation
 int cmake::Run(std::vector<std::string> const& args, bool noconfigure)
 {

+ 1 - 0
Source/cmake.h

@@ -708,6 +708,7 @@ public:
     return this->Instrumentation.get();
   }
 #endif
+  void InitializeFileAPI();
 
   cmState* GetState() const { return this->State.get(); }
   void SetCurrentSnapshot(cmStateSnapshot const& snapshot)

+ 8 - 0
Tests/RunCMake/FileAPI/InitialCache-check.cmake

@@ -0,0 +1,8 @@
+set(expect
+  reply
+  reply/codemodel-v2-[0-9a-f]+.json
+  .*reply/index-[0-9.T-]+.json.*
+)
+
+# Only need to check for existence. Other tests check the reply contents.
+check_api("^${expect}$")

+ 5 - 0
Tests/RunCMake/FileAPI/InitialCache-script.cmake

@@ -0,0 +1,5 @@
+cmake_file_api(
+  QUERY
+  API_VERSION 1
+  CODEMODEL 2
+)

+ 0 - 0
Tests/RunCMake/FileAPI/InitialCache.cmake


+ 1 - 0
Tests/RunCMake/FileAPI/RunCMakeTest.cmake

@@ -140,6 +140,7 @@ run_cmake(ClientStateless)
 run_cmake(MixedStateless)
 run_cmake(DuplicateStateless)
 run_cmake(ClientStateful)
+run_cmake_with_options(InitialCache -C ${RunCMake_SOURCE_DIR}/InitialCache-script.cmake)
 run_cmake(ProjectQueryGood)
 run_cmake(ProjectQueryBad)
 run_cmake(FailConfigure)