diff --git a/source/Nuke.Common/Tools/ClangSharpPInvokeGenerator/ClangSharpPInvokeGenerator.json b/source/Nuke.Common/Tools/ClangSharpPInvokeGenerator/ClangSharpPInvokeGenerator.json new file mode 100644 index 000000000..8fc40723f --- /dev/null +++ b/source/Nuke.Common/Tools/ClangSharpPInvokeGenerator/ClangSharpPInvokeGenerator.json @@ -0,0 +1,281 @@ +{ + "$schema": "https://raw.githubusercontent.com/nuke-build/nuke/master/source/Nuke.Tooling.Generator/schema.json", + "name": "ClangSharpPInvokeGenerator", + "officialUrl": "https://github.com/dotnet/clangsharp/", + "help": "ClangSharp P/Invoke Binding Generator is a tool for generating strongly-typed safe bindings written in C# for .NET and Mono.", + "nugetPackageId": "ClangSharpPInvokeGenerator", + "packageExecutable": "ClangSharpPInvokeGenerator.dll", + "customExitHandler": true, + "tasks": [ + { + "settingsClass": { + "properties": [ + { + "name": "Additional", + "type": "List", + "format": "--additional {value}", + "help": "An argument to pass to Clang when parsing the input files." + }, + { + "name": "Config", + "type": "List", + "format": "--config {value}", + "help": "A configuration option that controls how the bindings are generated." + }, + { + "name": "DefineMacro", + "type": "List", + "format": "--define-macro {value}", + "help": "Define to (or 1 if omitted)." + }, + { + "name": "Exclude", + "type": "List", + "format": "--exclude {value}", + "help": "A declaration name to exclude from binding generation." + }, + { + "name": "File", + "type": "List", + "format": "--file {value}", + "help": "A file to parse and generate bindings for." + }, + { + "name": "FileDirectories", + "type": "List", + "format": "--file-directory {value}", + "help": "The base path for files to parse." + }, + { + "name": "HeaderFiles", + "type": "List", + "format": "--headerFile {value}", + "help": "A file which contains the header to prefix every generated file with." + }, + { + "name": "Include", + "type": "List", + "format": "--include {value}", + "help": "A declaration name to include in binding generation." + }, + { + "name": "IncludeDirectory", + "type": "List", + "format": "--include-directory {value}", + "help": "Add directory to include search path." + }, + { + "name": "Language", + "type": "string", + "format": "--language {value}", + "help": "Treat subsequent input files as having type ." + }, + { + "name": "LibraryPath", + "type": "string", + "format": "--libraryPath {value}", + "help": "The string to use in the DllImport attribute used when generating bindings." + }, + { + "name": "MethodClassName", + "type": "string", + "format": "--methodClassName {value}", + "help": "The name of the static class that will contain the generated method bindings." + }, + { + "name": "Namespace", + "type": "string", + "format": "--namespace {value}", + "help": "The namespace in which to place the generated bindings." + }, + { + "name": "NativeTypeNamesToStrip", + "type": "string", + "format": "--nativeTypeNamesToStrip {value}", + "help": "The contents to strip from the generated NativeTypeName attributes." + }, + { + "name": "OutputMode", + "type": "ClangSharpPInvokeGeneratorOutputMode", + "format": "--output-mode {value}", + "help": "The mode describing how the information collected from the headers are presented in the resultant bindings." + }, + { + "name": "Output", + "type": "string", + "format": "--output {value}", + "help": "The output location to write the generated bindings to." + }, + { + "name": "PrefixStrip", + "type": "List", + "format": "--prefixStrip {value}", + "help": "The prefix to strip from the generated method bindings." + }, + { + "name": "Remap", + "type": "List", + "format": "--remap {value}", + "help": "A declaration name to be remapped to another name during binding generation." + }, + { + "name": "Std", + "type": "string", + "format": "--std {value}", + "help": "Language standard to compile for." + }, + { + "name": "TestOutput", + "type": "string", + "format": "--test-output {value}", + "help": "The output location to write the generated tests to." + }, + { + "name": "Traverse", + "type": "List", + "format": "--traverse {value}", + "help": "A file name included either directly or indirectly by -f that should be traversed during binding generation." + }, + { + "name": "WithAccessSpecifier", + "type": "List", + "format": "--with-access-specifier {value}", + "help": "An access specifier to be used with the given qualified or remapped declaration name during binding generation. Supports wildcards." + }, + { + "name": "WithAttribute", + "type": "List", + "format": "--with-attribute {value}", + "help": "An attribute to be added to the given remapped declaration name during binding generation. Supports wildcards." + }, + { + "name": "WithCallConv", + "type": "List", + "format": "--with-callconv {value}", + "help": "A calling convention to be used for the given declaration during binding generation. Supports wildcards." + }, + { + "name": "WithClass", + "type": "List", + "format": "--with-class {value}", + "help": "A class to be used for the given remapped constant or function declaration name during binding generation. Supports wildcards." + }, + { + "name": "WithGuid", + "type": "List", + "format": "--with-guid {value}", + "help": "A GUID to be used for the given declaration during binding generation. Supports wildcards." + }, + { + "name": "WithLibraryPath", + "type": "List", + "format": "--with-librarypath {value}", + "help": "A library path to be used for the given declaration during binding generation. Supports wildcards." + }, + { + "name": "WithManualImport", + "type": "List", + "format": "--with-manual-import {value}", + "help": "A remapped function name to be treated as a manual import during binding generation. Supports wildcards." + }, + { + "name": "WithNamespace", + "type": "List", + "format": "--with-namespace {value}", + "help": "A namespace to be used for the given remapped declaration name during binding generation. Supports wildcards." + }, + { + "name": "WithPacking", + "type": "List", + "format": "--with-packing {value}", + "help": "Overrides the StructLayoutAttribute.Pack property for the given type. Supports wildcards." + }, + { + "name": "WithSetLastError", + "type": "List", + "format": "--with-setlasterror {value}", + "help": "Add the SetLastError=true modifier to a given DllImport or UnmanagedFunctionPointer. Supports wildcards." + }, + { + "name": "WithSuppressGCTransition", + "type": "List", + "format": "--with-suppressgctransition {value}", + "help": "Add the SuppressGCTransition calling convention to a given DllImport or UnmanagedFunctionPointer. Supports wildcards." + }, + { + "name": "WithTransparentStruct", + "type": "List", + "format": "--with-transparent-struct {value}", + "help": "A remapped type name to be treated as a transparent wrapper during binding generation. Supports wildcards." + }, + { + "name": "WithType", + "type": "List", + "format": "--with-type {value}", + "help": "A type to be used for the given enum declaration during binding generation. Supports wildcards." + }, + { + "name": "WithUsing", + "type": "List", + "format": "--with-using {value}", + "help": "A using directive to be included for the given remapped declaration name during binding generation. Supports wildcards." + } + ] + } + } + ], + "enumerations": [ + { + "name": "ClangSharpPInvokeGeneratorConfigOption", + "values": [ + "compatible-codegen", + "default-codegen", + "latest-codegen", + "preview-codegen", + "single-file", + "multi-file", + "unix-types", + "windows-types", + "exclude-anonymous-field-helpers", + "exclude-com-proxies", + "exclude-default-remappings", + "exclude-empty-records", + "exclude-enum-operators", + "exclude-fnptr-codegen", + "exclude-funcs-with-body", + "exclude-using-statics-for-enums", + "explicit-vtbls", + "implicit-vtbls", + "trimmable-vtbls", + "generate-tests-nunit", + "generate-tests-xunit", + "generate-aggressive-inlining", + "generate-callconv-member-function", + "generate-cpp-attributes", + "generate-disable-runtime-marshalling", + "generate-doc-includes", + "generate-file-scoped-namespaces", + "generate-guid-member", + "generate-helper-types", + "generate-macro-bindings", + "generate-marker-interfaces", + "generate-native-bitfield-attribute", + "generate-native-inheritance-attribute", + "generate-setslastsystemerror-attribute", + "generate-template-bindings", + "generate-unmanaged-constants", + "generate-vtbl-index-attribute", + "log-exclusions", + "log-potential-typedef-remappings", + "log-visited-files" + ] + }, + { + "name": "ClangSharpPInvokeGeneratorOutputMode", + "values": [ + "CSharp", + "Xml" + ] + } + ] +} diff --git a/source/Nuke.Common/Tools/ClangSharpPInvokeGenerator/ClangSharpPInvokeGeneratorTasks.cs b/source/Nuke.Common/Tools/ClangSharpPInvokeGenerator/ClangSharpPInvokeGeneratorTasks.cs new file mode 100644 index 000000000..facce97cd --- /dev/null +++ b/source/Nuke.Common/Tools/ClangSharpPInvokeGenerator/ClangSharpPInvokeGeneratorTasks.cs @@ -0,0 +1,16 @@ +// Copyright 2023 Maintainers of NUKE. +// Distributed under the MIT License. +// https://github.com/nuke-build/nuke/blob/master/LICENSE + +using Nuke.Common.Tooling; + +namespace Nuke.Common.Tools.ClangSharpPInvokeGenerator +{ + public partial class ClangSharpPInvokeGeneratorTasks + { + public static void CustomExitHandler(ToolSettings toolSettings, IProcess process) + { + process.AssertNonNegativeExitCode(); + } + } +} diff --git a/source/Nuke.Tooling/ProcessExtensions.cs b/source/Nuke.Tooling/ProcessExtensions.cs index 826dda204..a51da0b77 100644 --- a/source/Nuke.Tooling/ProcessExtensions.cs +++ b/source/Nuke.Tooling/ProcessExtensions.cs @@ -2,7 +2,6 @@ // Distributed under the MIT License. // https://github.com/nuke-build/nuke/blob/master/LICENSE -using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; @@ -41,6 +40,19 @@ public static IProcess AssertZeroExitCode( return process; } + [AssertionMethod] + public static IProcess AssertNonNegativeExitCode( + [AssertionCondition(AssertionConditionType.IS_NOT_NULL)] [NotNull] + this IProcess process) + { + process.AssertWaitForExit(); + + if (process.ExitCode < 0) + throw new ProcessException(process); + + return process; + } + public static IReadOnlyCollection EnsureOnlyStd(this IReadOnlyCollection output) { foreach (var o in output) @@ -65,4 +77,4 @@ public static JObject StdToJson(this IEnumerable output) { return output.StdToJson(); } -} \ No newline at end of file +}