Sfoglia il codice sorgente

fileapi: Add test launcher to codemodel-v2

We do not need to bump the minor version because it was recently bumped
by addition of the cross-compiling emulator as another kind of launcher.
Ralf Habacker 1 anno fa
parent
commit
88863d83d6

+ 4 - 0
Help/manual/cmake-file-api.7.rst

@@ -1022,6 +1022,10 @@ with members:
         An emulator for the target platform when cross-compiling.
         See the :prop_tgt:`CROSSCOMPILING_EMULATOR` target property.
 
+      ``test``
+        A start program for the execution of tests.
+        See the :prop_tgt:`TEST_LAUNCHER` target property.
+
     This field was added in codemodel version 2.7.
 
 ``link``

+ 8 - 5
Source/cmFileAPICodemodel.cxx

@@ -2112,15 +2112,18 @@ Json::Value Target::DumpLauncher(const char* name, const char* type)
 Json::Value Target::DumpLaunchers()
 {
   Json::Value launchers;
-  bool allow =
-    this->GT->Makefile->GetDefinition("CMAKE_CROSSCOMPILING").IsOn();
-  Json::Value launcher;
-  if (allow) {
-    launcher = DumpLauncher("CROSSCOMPILING_EMULATOR", "emulator");
+  {
+    Json::Value launcher = DumpLauncher("TEST_LAUNCHER", "test");
     if (!launcher.empty()) {
       launchers.append(std::move(launcher));
     }
   }
+  if (this->GT->Makefile->IsOn("CMAKE_CROSSCOMPILING")) {
+    Json::Value emulator = DumpLauncher("CROSSCOMPILING_EMULATOR", "emulator");
+    if (!emulator.empty()) {
+      launchers.append(std::move(emulator));
+    }
+  }
   return launchers;
 }
 }

+ 2 - 0
Tests/RunCMake/FileAPI/codemodel-v2-check.py

@@ -809,6 +809,8 @@ def gen_check_targets(c, g, inSource):
         read_codemodel_json_data("targets/cxx_exe.json"),
         read_codemodel_json_data("targets/cxx_exe_cross_emulator.json"),
         read_codemodel_json_data("targets/cxx_exe_cross_emulator_args.json"),
+        read_codemodel_json_data("targets/cxx_exe_test_launcher_and_cross_emulator.json"),
+        read_codemodel_json_data("targets/cxx_exe_test_launcher.json"),
         read_codemodel_json_data("targets/cxx_standard_compile_feature_exe.json"),
         read_codemodel_json_data("targets/cxx_standard_exe.json"),
         read_codemodel_json_data("targets/cxx_shared_lib.json"),

+ 2 - 1
Tests/RunCMake/FileAPI/codemodel-v2-data/directories/cxx.cross.json

@@ -6,7 +6,8 @@
     "childSources": null,
     "targetIds": [
         "^cxx_exe_cross_emulator::@ee4a268216d1f53c4e2e$",
-        "^cxx_exe_cross_emulator_args::@ee4a268216d1f53c4e2e$"
+        "^cxx_exe_cross_emulator_args::@ee4a268216d1f53c4e2e$",
+        "^cxx_exe_test_launcher_and_cross_emulator::@ee4a268216d1f53c4e2e$"
     ],
     "projectName": "Cxx",
     "minimumCMakeVersion": "3.13",

+ 1 - 0
Tests/RunCMake/FileAPI/codemodel-v2-data/directories/cxx.json

@@ -9,6 +9,7 @@
         "^ALL_BUILD::@a56b12a3f5c0529fb296$",
         "^ZERO_CHECK::@a56b12a3f5c0529fb296$",
         "^cxx_exe::@a56b12a3f5c0529fb296$",
+        "^cxx_exe_test_launcher::@a56b12a3f5c0529fb296$",
         "^cxx_standard_compile_feature_exe::@a56b12a3f5c0529fb296$",
         "^cxx_standard_exe::@a56b12a3f5c0529fb296$",
         "^cxx_lib::@a56b12a3f5c0529fb296$",

+ 2 - 0
Tests/RunCMake/FileAPI/codemodel-v2-data/projects/cxx.json

@@ -13,6 +13,8 @@
         "^cxx_exe::@a56b12a3f5c0529fb296$",
         "^cxx_exe_cross_emulator::@ee4a268216d1f53c4e2e$",
         "^cxx_exe_cross_emulator_args::@ee4a268216d1f53c4e2e$",
+        "^cxx_exe_test_launcher_and_cross_emulator::@ee4a268216d1f53c4e2e$",
+        "^cxx_exe_test_launcher::@a56b12a3f5c0529fb296$",
         "^cxx_standard_compile_feature_exe::@a56b12a3f5c0529fb296$",
         "^cxx_standard_exe::@a56b12a3f5c0529fb296$",
         "^cxx_shared_lib::@a56b12a3f5c0529fb296$",

+ 8 - 0
Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_cxx.json

@@ -90,6 +90,14 @@
             "id": "^cxx_exe_cross_emulator_args::@ee4a268216d1f53c4e2e$",
             "backtrace": null
         },
+        {
+            "id": "^cxx_exe_test_launcher_and_cross_emulator::@ee4a268216d1f53c4e2e$",
+            "backtrace": null
+        },
+        {
+            "id": "^cxx_exe_test_launcher::@a56b12a3f5c0529fb296$",
+            "backtrace": null
+        },
         {
             "id": "^cxx_standard_compile_feature_exe::@a56b12a3f5c0529fb296$",
             "backtrace": null

+ 8 - 0
Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_top.json

@@ -130,6 +130,14 @@
             "id": "^cxx_exe_cross_emulator_args::@ee4a268216d1f53c4e2e$",
             "backtrace": null
         },
+        {
+            "id": "^cxx_exe_test_launcher_and_cross_emulator::@ee4a268216d1f53c4e2e$",
+            "backtrace": null
+        },
+        {
+            "id": "^cxx_exe_test_launcher::@a56b12a3f5c0529fb296$",
+            "backtrace": null
+        },
         {
             "id": "^cxx_standard_compile_feature_exe::@a56b12a3f5c0529fb296$",
             "backtrace": null

+ 105 - 0
Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_exe_test_launcher.json

@@ -0,0 +1,105 @@
+{
+    "name": "cxx_exe_test_launcher",
+    "id": "^cxx_exe_test_launcher::@a56b12a3f5c0529fb296$",
+    "directorySource": "^cxx$",
+    "projectName": "Cxx",
+    "type": "EXECUTABLE",
+    "isGeneratorProvided": null,
+    "fileSets": null,
+    "sources": [
+        {
+            "path": "^empty\\.cxx$",
+            "isGenerated": null,
+            "fileSetName": null,
+            "sourceGroupName": "Source Files",
+            "compileGroupLanguage": "CXX",
+            "backtrace": [
+                {
+                    "file": "^cxx/CMakeLists\\.txt$",
+                    "line": 49,
+                    "command": "add_executable",
+                    "hasParent": true
+                },
+                {
+                    "file": "^cxx/CMakeLists\\.txt$",
+                    "line": null,
+                    "command": null,
+                    "hasParent": false
+                }
+            ]
+        }
+    ],
+    "sourceGroups": [
+        {
+            "name": "Source Files",
+            "sourcePaths": [
+                "^empty\\.cxx$"
+            ]
+        }
+    ],
+    "compileGroups": [
+        {
+            "language": "CXX",
+            "sourcePaths": [
+                "^empty\\.cxx$"
+            ],
+            "includes": null,
+            "frameworks": null,
+            "defines": null,
+            "compileCommandFragments": null
+        }
+    ],
+    "backtrace": [
+        {
+            "file": "^cxx/CMakeLists\\.txt$",
+            "line": 49,
+            "command": "add_executable",
+            "hasParent": true
+        },
+        {
+            "file": "^cxx/CMakeLists\\.txt$",
+            "line": null,
+            "command": null,
+            "hasParent": false
+        }
+    ],
+    "folder": null,
+    "nameOnDisk": "^cxx_exe_test_launcher(\\.exe)?$",
+    "artifacts": [
+        {
+            "path": "^cxx/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?cxx_exe_test_launcher(\\.exe)?$",
+            "_dllExtra": false
+        },
+        {
+            "path": "^cxx/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?cxx_exe_test_launcher\\.pdb$",
+            "_dllExtra": true
+        }
+    ],
+    "build": "^cxx$",
+    "source": "^cxx$",
+    "install": null,
+    "launchers" : [
+        {
+            "command": "^no-such-launcher(\\.exe)?$",
+            "type" : "test"
+        }
+    ],
+    "link": {
+        "language": "CXX",
+        "lto": null,
+        "commandFragments": [
+            {
+                "fragment" : ".*",
+                "role" : "flags",
+                "backtrace": null
+            }
+        ]
+    },
+    "archive": null,
+    "dependencies": [
+        {
+            "id": "^ZERO_CHECK::@a56b12a3f5c0529fb296$",
+            "backtrace": null
+        }
+    ]
+}

+ 109 - 0
Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_exe_test_launcher_and_cross_emulator.json

@@ -0,0 +1,109 @@
+{
+    "name": "cxx_exe_test_launcher_and_cross_emulator",
+    "id": "^cxx_exe_test_launcher_and_cross_emulator::@ee4a268216d1f53c4e2e$",
+    "directorySource": "^cxx/cross$",
+    "projectName": "Cxx",
+    "type": "EXECUTABLE",
+    "isGeneratorProvided": null,
+    "fileSets": null,
+    "sources": [
+        {
+            "path": "^empty\\.cxx$",
+            "isGenerated": null,
+            "fileSetName": null,
+            "sourceGroupName": "Source Files",
+            "compileGroupLanguage": "CXX",
+            "backtrace": [
+                {
+                    "file": "^cxx/cross/CMakeLists\\.txt$",
+                    "line": 9,
+                    "command": "add_executable",
+                    "hasParent": true
+                },
+                {
+                    "file": "^cxx/cross/CMakeLists\\.txt$",
+                    "line": null,
+                    "command": null,
+                    "hasParent": false
+                }
+            ]
+        }
+    ],
+    "sourceGroups": [
+        {
+            "name": "Source Files",
+            "sourcePaths": [
+                "^empty\\.cxx$"
+            ]
+        }
+    ],
+    "compileGroups": [
+        {
+            "language": "CXX",
+            "sourcePaths": [
+                "^empty\\.cxx$"
+            ],
+            "includes": null,
+            "frameworks": null,
+            "defines": null,
+            "compileCommandFragments": null
+        }
+    ],
+    "backtrace": [
+        {
+            "file": "^cxx/cross/CMakeLists\\.txt$",
+            "line": 9,
+            "command": "add_executable",
+            "hasParent": true
+        },
+        {
+            "file": "^cxx/cross/CMakeLists\\.txt$",
+            "line": null,
+            "command": null,
+            "hasParent": false
+        }
+    ],
+    "folder": null,
+    "nameOnDisk": "^cxx_exe_test_launcher_and_cross_emulator(\\.exe)?$",
+    "artifacts": [
+        {
+            "path": "^cxx/cross/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?cxx_exe_test_launcher_and_cross_emulator(\\.exe)?$",
+            "_dllExtra": false
+        },
+        {
+            "path": "^cxx/cross/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?cxx_exe_test_launcher_and_cross_emulator\\.pdb$",
+            "_dllExtra": true
+        }
+    ],
+    "build": "^cxx/cross$",
+    "source": "^cxx/cross$",
+    "install": null,
+    "launchers" : [
+        {
+            "command": "^no-such-launcher(\\.exe)?$",
+            "type" : "test"
+        },
+        {
+            "command": "^no-such-emulator(\\.exe)?$",
+            "type" : "emulator"
+        }
+    ],
+    "link": {
+        "language": "CXX",
+        "lto": null,
+        "commandFragments": [
+            {
+                "fragment" : ".*",
+                "role" : "flags",
+                "backtrace": null
+            }
+        ]
+    },
+    "archive": null,
+    "dependencies": [
+        {
+            "id": "^ZERO_CHECK::@6890427a1f51a3e7e1df$",
+            "backtrace": null
+        }
+    ]
+}

+ 3 - 0
Tests/RunCMake/FileAPI/cxx/CMakeLists.txt

@@ -46,4 +46,7 @@ if(_rdeps)
     )
 endif()
 
+add_executable(cxx_exe_test_launcher ../empty.cxx)
+set_property(TARGET cxx_exe_test_launcher PROPERTY TEST_LAUNCHER no-such-launcher)
+
 add_subdirectory(cross)

+ 4 - 0
Tests/RunCMake/FileAPI/cxx/cross/CMakeLists.txt

@@ -5,3 +5,7 @@ set_property(TARGET cxx_exe_cross_emulator PROPERTY CROSSCOMPILING_EMULATOR no-s
 
 add_executable(cxx_exe_cross_emulator_args ../../empty.cxx)
 set_property(TARGET cxx_exe_cross_emulator_args PROPERTY CROSSCOMPILING_EMULATOR "no-such-emulator;arg1;arg2 with space")
+
+add_executable(cxx_exe_test_launcher_and_cross_emulator ../../empty.cxx)
+set_property(TARGET cxx_exe_test_launcher_and_cross_emulator PROPERTY TEST_LAUNCHER "no-such-launcher")
+set_property(TARGET cxx_exe_test_launcher_and_cross_emulator PROPERTY CROSSCOMPILING_EMULATOR "no-such-emulator")

+ 1 - 0
Tests/RunCMake/property_init/Executable.cmake

@@ -17,6 +17,7 @@ set(properties
 
   # Metadata
   "CROSSCOMPILING_EMULATOR"       "emu"     "<SAME>"
+  "TEST_LAUNCHER"                 "test"    "<SAME>"
   )
 
 prepare_target_types(executable