10

我有一个构建任务至少需要 2 秒才能在 tasks.json 中完成。
我也有不同的非常快速的任务来清理tasks.json中的一些文件。

我在 launch.json 中有 3 个配置:服务器、server_running_on_top_of_server 和客户端。
它们都可以单独运行,因此它们都应该将构建作为 preLaunchTask。

因此,如果我将这 3 个配置分别运行为 preLaunchTask 并在构建的依赖项中指定清理,那就很好了。

但是当我想将这 3 种配置作为一个组合一起运行时,它不是很直观。
我想先运行构建任务,然后是服务器,在服务器启动后,然后是 server_running_on_top_of_server 和客户端。
清理配置应该只为客户端运行,但可以在每次运行构建任务时运行。

"compounds": [
    {
        "name": "server, server_running_on_top_of_server and client",
        "configurations": ["server", "server_running_on_top_of_server", "client"]
    }

"tasks": [
    {
        "label": "build",
        "type": "shell",
        "command": "make",
        "args": [
            "-j4",
            "debug"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        },
        "dependsOn": "delete something",
        "presentation": {
            "panel": "shared"
        }
    },
    {
        "label": "delete something",
        "type": "shell",
        "command": "rm",
        "args": [
            "-f", "something"
        ],
        "presentation": {
            "panel": "shared"
        }
    },
    {
        "label": "wait 5 seconds",
        "type": "shell",
        "command": "sleep",
        "args": [
            "5"
        ]
    }
]

但是构建任务以这种方式运行 3 次,并且即使使用presentation.panel:“shared”也分别在 3 个终端中运行,因此它使用 12 个内核而不是 4 个,因此它完全落后于我的 PC。
如何解决?

以及如何在服务器启动后运行剩余的 2 个配置?有没有比创建另一个等待一段时间的任务更好的方法?

是否有可能在 preLaunchTask 中指定多个任务?所以我只能为客户分配构建和清理任务。

4

0 回答 0