1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
// Copyright (C) 2025 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
using System.Collections.Generic;
using System.Linq;
namespace QtVsTools.Core.MsBuild
{
using CommandLine;
using Common;
public sealed class QtRepc : QtTool
{
public const string ItemTypeName = "QtRepc";
public const string ToolExecName = "repc.exe";
public enum Property
{
ExecutionDescription,
QTDIR,
InputFileType,
InputFile,
OutputFileType,
OutputFile,
IncludePath,
AlwaysClass,
PrintDebug
}
private readonly Dictionary<Property, Option> options = new();
public QtRepc()
: base(defaultInputOutput: false)
{
Parser.AddOption(options[Property.InputFileType] =
new Option("i", "<rep|src>", Option.Flag.ShortOptionStyle));
Parser.AddOption(options[Property.OutputFileType] =
new Option("o", "<source|replica|merged|rep>", Option.Flag.ShortOptionStyle));
Parser.AddOption(options[Property.IncludePath] =
new Option("I", "dir", Option.Flag.ShortOptionStyle));
Parser.AddOption(options[Property.AlwaysClass] =
new Option("c"));
Parser.AddOption(options[Property.PrintDebug] =
new Option("d"));
}
protected override void ExtractInputOutput(string toolExecName, out string inputPath,
out string outputPath)
{
inputPath = outputPath = "";
var args = new Queue<string>(Parser.PositionalArguments
.Where(arg => !arg.EndsWith(toolExecName, Utils.IgnoreCase)));
if (args.Any())
inputPath = args.Dequeue();
if (args.Any())
outputPath = args.Dequeue();
}
public bool ParseCommandLine(string commandLine, IVsMacroExpander macros,
out Dictionary<Property, string> properties)
{
properties = new Dictionary<Property, string>();
if (!ParseCommandLine(commandLine, macros, ToolExecName, out var qtDir,
out var inputPath, out var outputPath)) {
return false;
}
if (!string.IsNullOrEmpty(qtDir))
properties[Property.QTDIR] = qtDir;
if (Parser.IsSet(options[Property.InputFileType])) {
properties[Property.InputFileType] =
Parser.Value(options[Property.InputFileType]);
}
if (!string.IsNullOrEmpty(inputPath))
properties[Property.InputFile] = inputPath;
if (Parser.IsSet(options[Property.OutputFileType])) {
properties[Property.OutputFileType] =
Parser.Value(options[Property.OutputFileType]);
}
if (!string.IsNullOrEmpty(outputPath))
properties[Property.OutputFile] = outputPath;
if (Parser.IsSet(options[Property.IncludePath])) {
properties[Property.IncludePath] =
string.Join(";", Parser.Values(options[Property.IncludePath]));
}
if (Parser.IsSet(options[Property.AlwaysClass]))
properties[Property.AlwaysClass] = "true";
if (Parser.IsSet(options[Property.PrintDebug]))
properties[Property.PrintDebug] = "true";
return true;
}
}
}
|