|
| 1 | +# Copyright (c) Meta Platforms, Inc. and affiliates. |
| 2 | +# |
| 3 | +# This source code is dual-licensed under either the MIT license found in the |
| 4 | +# LICENSE-MIT file in the root directory of this source tree or the Apache |
| 5 | +# License, Version 2.0 found in the LICENSE-APACHE file in the root directory |
| 6 | +# of this source tree. You may select, at your option, one of the |
| 7 | +# above-listed licenses. |
| 8 | + |
| 9 | +# TODO(cjhopman): This was generated by scripts/hacks/rules_shim_with_docs.py, |
| 10 | +# but should be manually edited going forward. There may be some errors in |
| 11 | +# the generated docs, and so those should be verified to be accurate and |
| 12 | +# well-formatted (and then delete this TODO) |
| 13 | + |
| 14 | +FrameworkVersion = ["net35", "net40", "net45", "net46"] |
| 15 | + |
| 16 | +def _srcs_arg(): |
| 17 | + return { |
| 18 | + "srcs": attrs.list(attrs.one_of(attrs.source(), attrs.tuple(attrs.source(), attrs.list(attrs.arg()))), default = [], doc = """ |
| 19 | + The set of C, C++, Objective-C, Objective-C++, or assembly source files |
| 20 | + to be preprocessed, compiled, and assembled by this |
| 21 | + rule. We determine which stages to run on each input source based on its file extension. See the |
| 22 | + [GCC documentation](https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html) for more detail on how file extensions are interpreted. Each element can be either a string |
| 23 | + specifying a source file (e.g. `''`) or a tuple of |
| 24 | + a string specifying a source file and a list of compilation flags |
| 25 | + (e.g. `('', ['-Wall', '-Werror'])` ). In the latter case the specified flags will be used in addition to the rule's other |
| 26 | + flags when preprocessing and compiling that file (if applicable). |
| 27 | +"""), |
| 28 | + } |
| 29 | + |
| 30 | +def _resources_arg(): |
| 31 | + return { |
| 32 | + "resources": attrs.dict(key = attrs.string(), value = attrs.source(), sorted = False, default = {}, doc = """ |
| 33 | + Resources that should be embedded within the built DLL. The format |
| 34 | + is the name of the resource once mapped into the DLL as the key, and |
| 35 | + the value being the resource that should be merged. This allows |
| 36 | + non-unique keys to be identified quickly. |
| 37 | +"""), |
| 38 | + } |
| 39 | + |
| 40 | +def _framework_ver_arg(): |
| 41 | + return { |
| 42 | + "framework_ver": attrs.enum(FrameworkVersion, doc = """ |
| 43 | + The version of the .Net framework that this library targets. This is |
| 44 | + one of 'net35', 'net40', 'net45' and 'net46'. |
| 45 | +"""), |
| 46 | + } |
| 47 | + |
| 48 | +def _deps_arg(): |
| 49 | + return { |
| 50 | + "deps": attrs.list(attrs.one_of(attrs.dep(), attrs.string()), default = [], doc = """ |
| 51 | + The set of targets or system-provided assemblies to rely on. Any |
| 52 | + values that are targets must be either csharp\\_library or `prebuilt_dotnet_library` |
| 53 | + instances. |
| 54 | +"""), |
| 55 | + } |
| 56 | + |
| 57 | +def _compiler_flags_arg(): |
| 58 | + return { |
| 59 | + "compiler_flags": attrs.list(attrs.string(), default = [], doc = """ |
| 60 | + The set of additional compiler flags to pass to the compiler. |
| 61 | +"""), |
| 62 | + } |
| 63 | + |
| 64 | +def _add_hermetic_arguments_arg(): |
| 65 | + return {"add_hermetic_arguments": attrs.bool(default = True)} |
| 66 | + |
| 67 | +dotnet_common = struct( |
| 68 | + srcs_arg = _srcs_arg, |
| 69 | + resources_arg = _resources_arg, |
| 70 | + framework_ver_arg = _framework_ver_arg, |
| 71 | + deps_arg = _deps_arg, |
| 72 | + compiler_flags_arg = _compiler_flags_arg, |
| 73 | + add_hermetic_arguments_arg = _add_hermetic_arguments_arg, |
| 74 | +) |
0 commit comments