Procházet zdrojové kódy

Command that generates a VSCode task for Windows

default_compile_flags
vector-of-bool před 4 roky
rodič
revize
b807d1249c
2 změnil soubory, kde provedl 62 přidání a 0 odebrání
  1. +1
    -0
      pyproject.toml
  2. +61
    -0
      tools/dds_ci/msvs.py

+ 1
- 0
pyproject.toml Zobrazit soubor

@@ -29,6 +29,7 @@ yapf = "^0.30.0"
[tool.poetry.scripts]
dds-ci = "dds_ci.main:start"
dds-format = "dds_ci.format:start"
gen-msvs-vsc-task = "dds_ci.msvs:generate_vsc_task"

[build-system]
requires = ["poetry>=0.12"]

+ 61
- 0
tools/dds_ci/msvs.py Zobrazit soubor

@@ -0,0 +1,61 @@
import argparse
import json
import os
from pathlib import Path
from typing import Optional, Dict
from typing_extensions import Protocol

from . import paths


class Arguments(Protocol):
out: Optional[Path]


def gen_task_json_data() -> Dict:
dds_ci_exe = paths.find_exe('dds-ci')
assert dds_ci_exe, 'Unable to find the dds-ci executable. This command should be run in a Poetry'
envs = {key: os.environ[key]
for key in (
'CL',
'_CL_',
'PATH',
'INCLUDE',
'LIBPATH',
'LIB',
) if key in os.environ}
task = {
'label': 'MSVC Build',
'type': 'process',
'command': str(dds_ci_exe.resolve()),
'args': ['--rapid'],
'group': {
'kind': 'build',
},
'options': {
'env': envs,
},
'problemMatcher': '$msCompile',
}
return task


def generate_vsc_task():
parser = argparse.ArgumentParser()
parser.add_argument('--out', '-o', help='File to write into', type=Path)
args: Arguments = parser.parse_args()

cl = paths.find_exe('cl')
if cl is None:
raise RuntimeError('There is not cl.exe on your PATH. You need to run '
'this command from within a Visual Studio environment.')

data = gen_task_json_data()
task_str = json.dumps(data, indent=4)
if args.out:
args.out.write_text(task_str)
print(f'The task JSON has been written to {args.out}.')
else:
print(task_str)
print('^^^ The task JSON has been written above ^^^')
print('Add the JSON object to "tasks.json" to use it in VS Code')

Načítá se…
Zrušit
Uložit