Skip to content

Commit 2f55e8b

Browse files
Add wrapper for ClangSharpPInvokeGenerator.
1 parent 6eb7796 commit 2f55e8b

File tree

3 files changed

+313
-2
lines changed

3 files changed

+313
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,281 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/nuke-build/nuke/master/source/Nuke.Tooling.Generator/schema.json",
3+
"name": "ClangSharpPInvokeGenerator",
4+
"officialUrl": "https://github.com/dotnet/clangsharp/",
5+
"help": "ClangSharp P/Invoke Binding Generator is a tool for generating strongly-typed safe bindings written in C# for .NET and Mono.",
6+
"nugetPackageId": "ClangSharpPInvokeGenerator",
7+
"packageExecutable": "ClangSharpPInvokeGenerator.dll",
8+
"customExitHandler": true,
9+
"tasks": [
10+
{
11+
"settingsClass": {
12+
"properties": [
13+
{
14+
"name": "Additional",
15+
"type": "List<string>",
16+
"format": "--additional {value}",
17+
"help": "An argument to pass to Clang when parsing the input files."
18+
},
19+
{
20+
"name": "Config",
21+
"type": "List<ClangSharpPInvokeGeneratorConfigOption>",
22+
"format": "--config {value}",
23+
"help": "A configuration option that controls how the bindings are generated."
24+
},
25+
{
26+
"name": "DefineMacro",
27+
"type": "List<string>",
28+
"format": "--define-macro {value}",
29+
"help": "Define <macro> to <value> (or 1 if <value> omitted)."
30+
},
31+
{
32+
"name": "Exclude",
33+
"type": "List<string>",
34+
"format": "--exclude {value}",
35+
"help": "A declaration name to exclude from binding generation."
36+
},
37+
{
38+
"name": "File",
39+
"type": "List<string>",
40+
"format": "--file {value}",
41+
"help": "A file to parse and generate bindings for."
42+
},
43+
{
44+
"name": "FileDirectory",
45+
"type": "List<string>",
46+
"format": "--file-directory {value}",
47+
"help": "The base path for files to parse."
48+
},
49+
{
50+
"name": "HeaderFile",
51+
"type": "List<string>",
52+
"format": "--headerFile {value}",
53+
"help": "A file which contains the header to prefix every generated file with."
54+
},
55+
{
56+
"name": "Include",
57+
"type": "List<string>",
58+
"format": "--include {value}",
59+
"help": "A declaration name to include in binding generation."
60+
},
61+
{
62+
"name": "IncludeDirectory",
63+
"type": "List<string>",
64+
"format": "--include-directory {value}",
65+
"help": "Add directory to include search path."
66+
},
67+
{
68+
"name": "Language",
69+
"type": "string",
70+
"format": "--language {value}",
71+
"help": "Treat subsequent input files as having type <language>."
72+
},
73+
{
74+
"name": "LibraryPath",
75+
"type": "string",
76+
"format": "--libraryPath {value}",
77+
"help": "The string to use in the <c>DllImport</c> attribute used when generating bindings."
78+
},
79+
{
80+
"name": "MethodClassName",
81+
"type": "string",
82+
"format": "--methodClassName {value}",
83+
"help": "The name of the static class that will contain the generated method bindings."
84+
},
85+
{
86+
"name": "Namespace",
87+
"type": "string",
88+
"format": "--namespace {value}",
89+
"help": "The namespace in which to place the generated bindings."
90+
},
91+
{
92+
"name": "NativeTypeNamesToStrip",
93+
"type": "string",
94+
"format": "--nativeTypeNamesToStrip {value}",
95+
"help": "The contents to strip from the generated NativeTypeName attributes."
96+
},
97+
{
98+
"name": "OutputMode",
99+
"type": "ClangSharpPInvokeGeneratorOutputMode",
100+
"format": "--output-mode {value}",
101+
"help": "The mode describing how the information collected from the headers are presented in the resultant bindings."
102+
},
103+
{
104+
"name": "Output",
105+
"type": "string",
106+
"format": "--output {value}",
107+
"help": "The output location to write the generated bindings to."
108+
},
109+
{
110+
"name": "PrefixStrip",
111+
"type": "List<string>",
112+
"format": "--prefixStrip {value}",
113+
"help": "The prefix to strip from the generated method bindings."
114+
},
115+
{
116+
"name": "Remap",
117+
"type": "List<string>",
118+
"format": "--remap {value}",
119+
"help": "A declaration name to be remapped to another name during binding generation."
120+
},
121+
{
122+
"name": "Std",
123+
"type": "string",
124+
"format": "--std {value}",
125+
"help": "Language standard to compile for."
126+
},
127+
{
128+
"name": "TestOutput",
129+
"type": "string",
130+
"format": "--test-output {value}",
131+
"help": "The output location to write the generated tests to."
132+
},
133+
{
134+
"name": "Traverse",
135+
"type": "List<string>",
136+
"format": "--traverse {value}",
137+
"help": "A file name included either directly or indirectly by -f that should be traversed during binding generation."
138+
},
139+
{
140+
"name": "WithAccessSpecifier",
141+
"type": "List<string>",
142+
"format": "--with-access-specifier {value}",
143+
"help": "An access specifier to be used with the given qualified or remapped declaration name during binding generation. Supports wildcards."
144+
},
145+
{
146+
"name": "WithAttribute",
147+
"type": "List<string>",
148+
"format": "--with-attribute {value}",
149+
"help": "An attribute to be added to the given remapped declaration name during binding generation. Supports wildcards."
150+
},
151+
{
152+
"name": "WithCallConv",
153+
"type": "List<string>",
154+
"format": "--with-callconv {value}",
155+
"help": "A calling convention to be used for the given declaration during binding generation. Supports wildcards."
156+
},
157+
{
158+
"name": "WithClass",
159+
"type": "List<string>",
160+
"format": "--with-class {value}",
161+
"help": "A class to be used for the given remapped constant or function declaration name during binding generation. Supports wildcards."
162+
},
163+
{
164+
"name": "WithGuid",
165+
"type": "List<string>",
166+
"format": "--with-guid {value}",
167+
"help": "A GUID to be used for the given declaration during binding generation. Supports wildcards."
168+
},
169+
{
170+
"name": "WithLibraryPath",
171+
"type": "List<string>",
172+
"format": "--with-librarypath {value}",
173+
"help": "A library path to be used for the given declaration during binding generation. Supports wildcards."
174+
},
175+
{
176+
"name": "WithManualImport",
177+
"type": "List<string>",
178+
"format": "--with-manual-import {value}",
179+
"help": "A remapped function name to be treated as a manual import during binding generation. Supports wildcards."
180+
},
181+
{
182+
"name": "WithNamespace",
183+
"type": "List<string>",
184+
"format": "--with-namespace {value}",
185+
"help": "A namespace to be used for the given remapped declaration name during binding generation. Supports wildcards."
186+
},
187+
{
188+
"name": "WithPacking",
189+
"type": "List<string>",
190+
"format": "--with-packing {value}",
191+
"help": "Overrides the <c>StructLayoutAttribute.Pack</c> property for the given type. Supports wildcards."
192+
},
193+
{
194+
"name": "WithSetLastError",
195+
"type": "List<string>",
196+
"format": "--with-setlasterror {value}",
197+
"help": "Add the <c>SetLastError=true</c> modifier to a given <c>DllImport</c> or <c>UnmanagedFunctionPointer</c>. Supports wildcards."
198+
},
199+
{
200+
"name": "WithSuppressGCTransition",
201+
"type": "List<string>",
202+
"format": "--with-suppressgctransition {value}",
203+
"help": "Add the <c>SuppressGCTransition</c> calling convention to a given <c>DllImport</c> or <c>UnmanagedFunctionPointer</c>. Supports wildcards."
204+
},
205+
{
206+
"name": "WithTransparentStruct",
207+
"type": "List<string>",
208+
"format": "--with-transparent-struct {value}",
209+
"help": "A remapped type name to be treated as a transparent wrapper during binding generation. Supports wildcards."
210+
},
211+
{
212+
"name": "WithType",
213+
"type": "List<string>",
214+
"format": "--with-type {value}",
215+
"help": "A type to be used for the given enum declaration during binding generation. Supports wildcards."
216+
},
217+
{
218+
"name": "WithUsing",
219+
"type": "List<string>",
220+
"format": "--with-using {value}",
221+
"help": "A using directive to be included for the given remapped declaration name during binding generation. Supports wildcards."
222+
}
223+
]
224+
}
225+
}
226+
],
227+
"enumerations": [
228+
{
229+
"name": "ClangSharpPInvokeGeneratorConfigOption",
230+
"values": [
231+
"compatible-codegen",
232+
"default-codegen",
233+
"latest-codegen",
234+
"preview-codegen",
235+
"single-file",
236+
"multi-file",
237+
"unix-types",
238+
"windows-types",
239+
"exclude-anonymous-field-helpers",
240+
"exclude-com-proxies",
241+
"exclude-default-remappings",
242+
"exclude-empty-records",
243+
"exclude-enum-operators",
244+
"exclude-fnptr-codegen",
245+
"exclude-funcs-with-body",
246+
"exclude-using-statics-for-enums",
247+
"explicit-vtbls",
248+
"implicit-vtbls",
249+
"trimmable-vtbls",
250+
"generate-tests-nunit",
251+
"generate-tests-xunit",
252+
"generate-aggressive-inlining",
253+
"generate-callconv-member-function",
254+
"generate-cpp-attributes",
255+
"generate-disable-runtime-marshalling",
256+
"generate-doc-includes",
257+
"generate-file-scoped-namespaces",
258+
"generate-guid-member",
259+
"generate-helper-types",
260+
"generate-macro-bindings",
261+
"generate-marker-interfaces",
262+
"generate-native-bitfield-attribute",
263+
"generate-native-inheritance-attribute",
264+
"generate-setslastsystemerror-attribute",
265+
"generate-template-bindings",
266+
"generate-unmanaged-constants",
267+
"generate-vtbl-index-attribute",
268+
"log-exclusions",
269+
"log-potential-typedef-remappings",
270+
"log-visited-files"
271+
]
272+
},
273+
{
274+
"name": "ClangSharpPInvokeGeneratorOutputMode",
275+
"values": [
276+
"CSharp",
277+
"Xml"
278+
]
279+
}
280+
]
281+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2023 Maintainers of NUKE.
2+
// Distributed under the MIT License.
3+
// https://github.com/nuke-build/nuke/blob/master/LICENSE
4+
5+
using Nuke.Common.Tooling;
6+
7+
namespace Nuke.Common.Tools.ClangSharpPInvokeGenerator
8+
{
9+
public partial class ClangSharpPInvokeGeneratorTasks
10+
{
11+
public static void CustomExitHandler(ToolSettings toolSettings, IProcess process)
12+
{
13+
process.AssertNonNegativeExitCode();
14+
}
15+
}
16+
}

source/Nuke.Tooling/ProcessExtensions.cs

+16-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Distributed under the MIT License.
33
// https://github.com/nuke-build/nuke/blob/master/LICENSE
44

5-
using System;
65
using System.Collections.Generic;
76
using System.Diagnostics;
87
using System.Linq;
@@ -41,6 +40,21 @@ public static IProcess AssertZeroExitCode(
4140
return process;
4241
}
4342

43+
[AssertionMethod]
44+
public static IProcess AssertNonNegativeExitCode(
45+
[AssertionCondition(AssertionConditionType.IS_NOT_NULL)] [NotNull]
46+
this IProcess process)
47+
{
48+
process.AssertWaitForExit();
49+
50+
if (process.ExitCode < 0)
51+
{
52+
throw new ProcessException(process);
53+
}
54+
55+
return process;
56+
}
57+
4458
public static IReadOnlyCollection<Output> EnsureOnlyStd(this IReadOnlyCollection<Output> output)
4559
{
4660
foreach (var o in output)
@@ -65,4 +79,4 @@ public static JObject StdToJson(this IEnumerable<Output> output)
6579
{
6680
return output.StdToJson<JObject>();
6781
}
68-
}
82+
}

0 commit comments

Comments
 (0)