├── .github └── workflows │ └── main.yml ├── .gitignore ├── LICENSE ├── README.md └── wit-abi ├── Cargo.lock ├── Cargo.toml └── src └── main.rs /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | push: 4 | branches: [main] 5 | pull_request: 6 | branches: [main] 7 | defaults: 8 | run: 9 | shell: bash 10 | 11 | # Cancel any in-flight jobs for the same PR/branch so there's only one active 12 | # at a time 13 | concurrency: 14 | group: ${{ github.workflow }}-${{ github.ref }} 15 | cancel-in-progress: true 16 | 17 | jobs: 18 | # Check Code style quickly by running `rustfmt` over all code 19 | rustfmt: 20 | name: Rustfmt 21 | runs-on: ubuntu-latest 22 | steps: 23 | - uses: actions/checkout@v2 24 | - run: rustup update stable && rustup default stable 25 | - run: rustup component add rustfmt 26 | - run: cargo fmt --all -- --check 27 | working-directory: wit-abi 28 | 29 | checks: 30 | name: Check 31 | runs-on: ubuntu-latest 32 | steps: 33 | - uses: actions/checkout@v2 34 | - run: rustup update stable && rustup default stable 35 | - run: cargo test 36 | working-directory: wit-abi 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | 204 | 205 | --- LLVM Exceptions to the Apache 2.0 License ---- 206 | 207 | As an exception, if, as a result of your compiling your source code, portions 208 | of this Software are embedded into an Object form of such source code, you 209 | may redistribute such embedded portions in such Object form without complying 210 | with the conditions of Sections 4(a), 4(b) and 4(d) of the License. 211 | 212 | In addition, if you combine or link compiled forms of this Software with 213 | software that is licensed under the GPLv2 ("Combined Software") and if a 214 | court of competent jurisdiction determines that the patent provision (Section 215 | 3), the indemnity provision (Section 9) or other Section of the License 216 | conflicts with the conditions of the GPLv2, you may retroactively and 217 | prospectively choose to deem waived or otherwise exclude such Section(s) of 218 | the License, but only in their entirety and only with respect to the Combined 219 | Software. 220 | 221 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Wasi Tools 2 | 3 | This repository previously contained a tool named wit-abi, which among other things generated markdown descriptions of Wit APIs. 4 | 5 | This functionality is now part of [wit-bindgen], and wit-abi is no longer used. 6 | 7 | [wit-bindgen]: https://github.com/bytecodealliance/wit-bindgen 8 | -------------------------------------------------------------------------------- /wit-abi/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "anstream" 7 | version = "0.5.0" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" 10 | dependencies = [ 11 | "anstyle", 12 | "anstyle-parse", 13 | "anstyle-query", 14 | "anstyle-wincon", 15 | "colorchoice", 16 | "utf8parse", 17 | ] 18 | 19 | [[package]] 20 | name = "anstyle" 21 | version = "1.0.0" 22 | source = "registry+https://github.com/rust-lang/crates.io-index" 23 | checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" 24 | 25 | [[package]] 26 | name = "anstyle-parse" 27 | version = "0.2.0" 28 | source = "registry+https://github.com/rust-lang/crates.io-index" 29 | checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" 30 | dependencies = [ 31 | "utf8parse", 32 | ] 33 | 34 | [[package]] 35 | name = "anstyle-query" 36 | version = "1.0.0" 37 | source = "registry+https://github.com/rust-lang/crates.io-index" 38 | checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" 39 | dependencies = [ 40 | "windows-sys", 41 | ] 42 | 43 | [[package]] 44 | name = "anstyle-wincon" 45 | version = "2.1.0" 46 | source = "registry+https://github.com/rust-lang/crates.io-index" 47 | checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" 48 | dependencies = [ 49 | "anstyle", 50 | "windows-sys", 51 | ] 52 | 53 | [[package]] 54 | name = "anyhow" 55 | version = "1.0.75" 56 | source = "registry+https://github.com/rust-lang/crates.io-index" 57 | checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" 58 | 59 | [[package]] 60 | name = "bitflags" 61 | version = "1.3.2" 62 | source = "registry+https://github.com/rust-lang/crates.io-index" 63 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 64 | 65 | [[package]] 66 | name = "bitflags" 67 | version = "2.4.0" 68 | source = "registry+https://github.com/rust-lang/crates.io-index" 69 | checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" 70 | 71 | [[package]] 72 | name = "clap" 73 | version = "4.4.1" 74 | source = "registry+https://github.com/rust-lang/crates.io-index" 75 | checksum = "7c8d502cbaec4595d2e7d5f61e318f05417bd2b66fdc3809498f0d3fdf0bea27" 76 | dependencies = [ 77 | "clap_builder", 78 | "clap_derive", 79 | "once_cell", 80 | ] 81 | 82 | [[package]] 83 | name = "clap_builder" 84 | version = "4.4.1" 85 | source = "registry+https://github.com/rust-lang/crates.io-index" 86 | checksum = "5891c7bc0edb3e1c2204fc5e94009affabeb1821c9e5fdc3959536c5c0bb984d" 87 | dependencies = [ 88 | "anstream", 89 | "anstyle", 90 | "clap_lex", 91 | "strsim", 92 | ] 93 | 94 | [[package]] 95 | name = "clap_derive" 96 | version = "4.4.0" 97 | source = "registry+https://github.com/rust-lang/crates.io-index" 98 | checksum = "c9fd1a5729c4548118d7d70ff234a44868d00489a4b6597b0b020918a0e91a1a" 99 | dependencies = [ 100 | "heck", 101 | "proc-macro2", 102 | "quote", 103 | "syn", 104 | ] 105 | 106 | [[package]] 107 | name = "clap_lex" 108 | version = "0.5.0" 109 | source = "registry+https://github.com/rust-lang/crates.io-index" 110 | checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" 111 | 112 | [[package]] 113 | name = "colorchoice" 114 | version = "1.0.0" 115 | source = "registry+https://github.com/rust-lang/crates.io-index" 116 | checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" 117 | 118 | [[package]] 119 | name = "equivalent" 120 | version = "1.0.1" 121 | source = "registry+https://github.com/rust-lang/crates.io-index" 122 | checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" 123 | 124 | [[package]] 125 | name = "form_urlencoded" 126 | version = "1.1.0" 127 | source = "registry+https://github.com/rust-lang/crates.io-index" 128 | checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" 129 | dependencies = [ 130 | "percent-encoding", 131 | ] 132 | 133 | [[package]] 134 | name = "hashbrown" 135 | version = "0.14.0" 136 | source = "registry+https://github.com/rust-lang/crates.io-index" 137 | checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" 138 | 139 | [[package]] 140 | name = "heck" 141 | version = "0.4.1" 142 | source = "registry+https://github.com/rust-lang/crates.io-index" 143 | checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" 144 | dependencies = [ 145 | "unicode-segmentation", 146 | ] 147 | 148 | [[package]] 149 | name = "id-arena" 150 | version = "2.2.1" 151 | source = "registry+https://github.com/rust-lang/crates.io-index" 152 | checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" 153 | 154 | [[package]] 155 | name = "idna" 156 | version = "0.3.0" 157 | source = "registry+https://github.com/rust-lang/crates.io-index" 158 | checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" 159 | dependencies = [ 160 | "unicode-bidi", 161 | "unicode-normalization", 162 | ] 163 | 164 | [[package]] 165 | name = "indexmap" 166 | version = "2.0.0" 167 | source = "registry+https://github.com/rust-lang/crates.io-index" 168 | checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" 169 | dependencies = [ 170 | "equivalent", 171 | "hashbrown", 172 | "serde", 173 | ] 174 | 175 | [[package]] 176 | name = "itoa" 177 | version = "1.0.9" 178 | source = "registry+https://github.com/rust-lang/crates.io-index" 179 | checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" 180 | 181 | [[package]] 182 | name = "leb128" 183 | version = "0.2.5" 184 | source = "registry+https://github.com/rust-lang/crates.io-index" 185 | checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" 186 | 187 | [[package]] 188 | name = "log" 189 | version = "0.4.18" 190 | source = "registry+https://github.com/rust-lang/crates.io-index" 191 | checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" 192 | 193 | [[package]] 194 | name = "memchr" 195 | version = "2.5.0" 196 | source = "registry+https://github.com/rust-lang/crates.io-index" 197 | checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" 198 | 199 | [[package]] 200 | name = "once_cell" 201 | version = "1.17.2" 202 | source = "registry+https://github.com/rust-lang/crates.io-index" 203 | checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b" 204 | 205 | [[package]] 206 | name = "percent-encoding" 207 | version = "2.2.0" 208 | source = "registry+https://github.com/rust-lang/crates.io-index" 209 | checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" 210 | 211 | [[package]] 212 | name = "proc-macro2" 213 | version = "1.0.66" 214 | source = "registry+https://github.com/rust-lang/crates.io-index" 215 | checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" 216 | dependencies = [ 217 | "unicode-ident", 218 | ] 219 | 220 | [[package]] 221 | name = "pulldown-cmark" 222 | version = "0.9.3" 223 | source = "registry+https://github.com/rust-lang/crates.io-index" 224 | checksum = "77a1a2f1f0a7ecff9c31abbe177637be0e97a0aef46cf8738ece09327985d998" 225 | dependencies = [ 226 | "bitflags 1.3.2", 227 | "memchr", 228 | "unicase", 229 | ] 230 | 231 | [[package]] 232 | name = "quote" 233 | version = "1.0.28" 234 | source = "registry+https://github.com/rust-lang/crates.io-index" 235 | checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" 236 | dependencies = [ 237 | "proc-macro2", 238 | ] 239 | 240 | [[package]] 241 | name = "ryu" 242 | version = "1.0.15" 243 | source = "registry+https://github.com/rust-lang/crates.io-index" 244 | checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" 245 | 246 | [[package]] 247 | name = "semver" 248 | version = "1.0.17" 249 | source = "registry+https://github.com/rust-lang/crates.io-index" 250 | checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" 251 | 252 | [[package]] 253 | name = "serde" 254 | version = "1.0.188" 255 | source = "registry+https://github.com/rust-lang/crates.io-index" 256 | checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" 257 | dependencies = [ 258 | "serde_derive", 259 | ] 260 | 261 | [[package]] 262 | name = "serde_derive" 263 | version = "1.0.188" 264 | source = "registry+https://github.com/rust-lang/crates.io-index" 265 | checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" 266 | dependencies = [ 267 | "proc-macro2", 268 | "quote", 269 | "syn", 270 | ] 271 | 272 | [[package]] 273 | name = "serde_json" 274 | version = "1.0.105" 275 | source = "registry+https://github.com/rust-lang/crates.io-index" 276 | checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" 277 | dependencies = [ 278 | "itoa", 279 | "ryu", 280 | "serde", 281 | ] 282 | 283 | [[package]] 284 | name = "smallvec" 285 | version = "1.11.0" 286 | source = "registry+https://github.com/rust-lang/crates.io-index" 287 | checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" 288 | 289 | [[package]] 290 | name = "spdx" 291 | version = "0.10.2" 292 | source = "registry+https://github.com/rust-lang/crates.io-index" 293 | checksum = "b19b32ed6d899ab23174302ff105c1577e45a06b08d4fe0a9dd13ce804bbbf71" 294 | dependencies = [ 295 | "smallvec", 296 | ] 297 | 298 | [[package]] 299 | name = "strsim" 300 | version = "0.10.0" 301 | source = "registry+https://github.com/rust-lang/crates.io-index" 302 | checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" 303 | 304 | [[package]] 305 | name = "syn" 306 | version = "2.0.29" 307 | source = "registry+https://github.com/rust-lang/crates.io-index" 308 | checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" 309 | dependencies = [ 310 | "proc-macro2", 311 | "quote", 312 | "unicode-ident", 313 | ] 314 | 315 | [[package]] 316 | name = "tinyvec" 317 | version = "1.6.0" 318 | source = "registry+https://github.com/rust-lang/crates.io-index" 319 | checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" 320 | dependencies = [ 321 | "tinyvec_macros", 322 | ] 323 | 324 | [[package]] 325 | name = "tinyvec_macros" 326 | version = "0.1.1" 327 | source = "registry+https://github.com/rust-lang/crates.io-index" 328 | checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" 329 | 330 | [[package]] 331 | name = "unicase" 332 | version = "2.6.0" 333 | source = "registry+https://github.com/rust-lang/crates.io-index" 334 | checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" 335 | dependencies = [ 336 | "version_check", 337 | ] 338 | 339 | [[package]] 340 | name = "unicode-bidi" 341 | version = "0.3.13" 342 | source = "registry+https://github.com/rust-lang/crates.io-index" 343 | checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" 344 | 345 | [[package]] 346 | name = "unicode-ident" 347 | version = "1.0.9" 348 | source = "registry+https://github.com/rust-lang/crates.io-index" 349 | checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" 350 | 351 | [[package]] 352 | name = "unicode-normalization" 353 | version = "0.1.22" 354 | source = "registry+https://github.com/rust-lang/crates.io-index" 355 | checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" 356 | dependencies = [ 357 | "tinyvec", 358 | ] 359 | 360 | [[package]] 361 | name = "unicode-segmentation" 362 | version = "1.10.1" 363 | source = "registry+https://github.com/rust-lang/crates.io-index" 364 | checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" 365 | 366 | [[package]] 367 | name = "unicode-xid" 368 | version = "0.2.4" 369 | source = "registry+https://github.com/rust-lang/crates.io-index" 370 | checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" 371 | 372 | [[package]] 373 | name = "url" 374 | version = "2.3.1" 375 | source = "registry+https://github.com/rust-lang/crates.io-index" 376 | checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" 377 | dependencies = [ 378 | "form_urlencoded", 379 | "idna", 380 | "percent-encoding", 381 | ] 382 | 383 | [[package]] 384 | name = "utf8parse" 385 | version = "0.2.1" 386 | source = "registry+https://github.com/rust-lang/crates.io-index" 387 | checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" 388 | 389 | [[package]] 390 | name = "version_check" 391 | version = "0.9.4" 392 | source = "registry+https://github.com/rust-lang/crates.io-index" 393 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 394 | 395 | [[package]] 396 | name = "wasm-encoder" 397 | version = "0.32.0" 398 | source = "registry+https://github.com/rust-lang/crates.io-index" 399 | checksum = "1ba64e81215916eaeb48fee292f29401d69235d62d8b8fd92a7b2844ec5ae5f7" 400 | dependencies = [ 401 | "leb128", 402 | ] 403 | 404 | [[package]] 405 | name = "wasm-metadata" 406 | version = "0.10.3" 407 | source = "registry+https://github.com/rust-lang/crates.io-index" 408 | checksum = "08dc59d1fa569150851542143ca79438ca56845ccb31696c70225c638e063471" 409 | dependencies = [ 410 | "anyhow", 411 | "indexmap", 412 | "serde", 413 | "serde_json", 414 | "spdx", 415 | "wasm-encoder", 416 | "wasmparser", 417 | ] 418 | 419 | [[package]] 420 | name = "wasmparser" 421 | version = "0.112.0" 422 | source = "registry+https://github.com/rust-lang/crates.io-index" 423 | checksum = "e986b010f47fcce49cf8ea5d5f9e5d2737832f12b53ae8ae785bbe895d0877bf" 424 | dependencies = [ 425 | "indexmap", 426 | "semver", 427 | ] 428 | 429 | [[package]] 430 | name = "windows-sys" 431 | version = "0.48.0" 432 | source = "registry+https://github.com/rust-lang/crates.io-index" 433 | checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" 434 | dependencies = [ 435 | "windows-targets", 436 | ] 437 | 438 | [[package]] 439 | name = "windows-targets" 440 | version = "0.48.0" 441 | source = "registry+https://github.com/rust-lang/crates.io-index" 442 | checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" 443 | dependencies = [ 444 | "windows_aarch64_gnullvm", 445 | "windows_aarch64_msvc", 446 | "windows_i686_gnu", 447 | "windows_i686_msvc", 448 | "windows_x86_64_gnu", 449 | "windows_x86_64_gnullvm", 450 | "windows_x86_64_msvc", 451 | ] 452 | 453 | [[package]] 454 | name = "windows_aarch64_gnullvm" 455 | version = "0.48.0" 456 | source = "registry+https://github.com/rust-lang/crates.io-index" 457 | checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" 458 | 459 | [[package]] 460 | name = "windows_aarch64_msvc" 461 | version = "0.48.0" 462 | source = "registry+https://github.com/rust-lang/crates.io-index" 463 | checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" 464 | 465 | [[package]] 466 | name = "windows_i686_gnu" 467 | version = "0.48.0" 468 | source = "registry+https://github.com/rust-lang/crates.io-index" 469 | checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" 470 | 471 | [[package]] 472 | name = "windows_i686_msvc" 473 | version = "0.48.0" 474 | source = "registry+https://github.com/rust-lang/crates.io-index" 475 | checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" 476 | 477 | [[package]] 478 | name = "windows_x86_64_gnu" 479 | version = "0.48.0" 480 | source = "registry+https://github.com/rust-lang/crates.io-index" 481 | checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" 482 | 483 | [[package]] 484 | name = "windows_x86_64_gnullvm" 485 | version = "0.48.0" 486 | source = "registry+https://github.com/rust-lang/crates.io-index" 487 | checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" 488 | 489 | [[package]] 490 | name = "windows_x86_64_msvc" 491 | version = "0.48.0" 492 | source = "registry+https://github.com/rust-lang/crates.io-index" 493 | checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" 494 | 495 | [[package]] 496 | name = "wit-abi" 497 | version = "0.1.0" 498 | dependencies = [ 499 | "anyhow", 500 | "clap", 501 | "wit-bindgen-c", 502 | "wit-bindgen-core", 503 | "wit-bindgen-go", 504 | "wit-bindgen-markdown", 505 | "wit-bindgen-rust", 506 | "wit-bindgen-teavm-java", 507 | ] 508 | 509 | [[package]] 510 | name = "wit-bindgen-c" 511 | version = "0.11.0" 512 | source = "registry+https://github.com/rust-lang/crates.io-index" 513 | checksum = "9cefd9398cf155e095f6b38deb15cfbb1c0c041f453900fe200542680a835753" 514 | dependencies = [ 515 | "anyhow", 516 | "clap", 517 | "heck", 518 | "wasm-encoder", 519 | "wasm-metadata", 520 | "wit-bindgen-core", 521 | "wit-component", 522 | ] 523 | 524 | [[package]] 525 | name = "wit-bindgen-core" 526 | version = "0.11.0" 527 | source = "registry+https://github.com/rust-lang/crates.io-index" 528 | checksum = "77255512565dfbd0b61de466e854918041d1da53c7bc049d6188c6e02643dc1e" 529 | dependencies = [ 530 | "anyhow", 531 | "wit-component", 532 | "wit-parser", 533 | ] 534 | 535 | [[package]] 536 | name = "wit-bindgen-go" 537 | version = "0.11.0" 538 | source = "registry+https://github.com/rust-lang/crates.io-index" 539 | checksum = "77ebd992853b6e1ec879171e66cc442e09679967f246c50867b0c254a2bfa2ad" 540 | dependencies = [ 541 | "anyhow", 542 | "clap", 543 | "heck", 544 | "wit-bindgen-c", 545 | "wit-bindgen-core", 546 | "wit-component", 547 | ] 548 | 549 | [[package]] 550 | name = "wit-bindgen-markdown" 551 | version = "0.11.0" 552 | source = "registry+https://github.com/rust-lang/crates.io-index" 553 | checksum = "0219754f17e86610fb557d16b908c1d6aeadadb3ffe72bb1745668731187707c" 554 | dependencies = [ 555 | "anyhow", 556 | "clap", 557 | "heck", 558 | "pulldown-cmark", 559 | "wit-bindgen-core", 560 | "wit-component", 561 | ] 562 | 563 | [[package]] 564 | name = "wit-bindgen-rust" 565 | version = "0.11.0" 566 | source = "registry+https://github.com/rust-lang/crates.io-index" 567 | checksum = "399c60e6ea8598d1380e792f13d557007834f0fb799fea6503408cbc5debb4ae" 568 | dependencies = [ 569 | "anyhow", 570 | "clap", 571 | "heck", 572 | "wasm-metadata", 573 | "wit-bindgen-core", 574 | "wit-bindgen-rust-lib", 575 | "wit-component", 576 | ] 577 | 578 | [[package]] 579 | name = "wit-bindgen-rust-lib" 580 | version = "0.11.0" 581 | source = "registry+https://github.com/rust-lang/crates.io-index" 582 | checksum = "cd9fb7a43c7dc28b0b727d6ae01bf369981229b7539e768fba2b7a4df13feeeb" 583 | dependencies = [ 584 | "heck", 585 | "wit-bindgen-core", 586 | ] 587 | 588 | [[package]] 589 | name = "wit-bindgen-teavm-java" 590 | version = "0.11.0" 591 | source = "registry+https://github.com/rust-lang/crates.io-index" 592 | checksum = "e7bab06fde7dc3f6bf916e3d6e47a044fab2ba69f53be7335188608a0768dedf" 593 | dependencies = [ 594 | "anyhow", 595 | "clap", 596 | "heck", 597 | "wasm-metadata", 598 | "wit-bindgen-core", 599 | "wit-component", 600 | ] 601 | 602 | [[package]] 603 | name = "wit-component" 604 | version = "0.14.0" 605 | source = "registry+https://github.com/rust-lang/crates.io-index" 606 | checksum = "66d9f2d16dd55d1a372dcfd4b7a466ea876682a5a3cb97e71ec9eef04affa876" 607 | dependencies = [ 608 | "anyhow", 609 | "bitflags 2.4.0", 610 | "indexmap", 611 | "log", 612 | "serde", 613 | "serde_json", 614 | "wasm-encoder", 615 | "wasm-metadata", 616 | "wasmparser", 617 | "wit-parser", 618 | ] 619 | 620 | [[package]] 621 | name = "wit-parser" 622 | version = "0.11.0" 623 | source = "registry+https://github.com/rust-lang/crates.io-index" 624 | checksum = "61e8b849bea13cc2315426b16efe6eb6813466d78f5fde69b0bb150c9c40e0dc" 625 | dependencies = [ 626 | "anyhow", 627 | "id-arena", 628 | "indexmap", 629 | "log", 630 | "pulldown-cmark", 631 | "semver", 632 | "unicode-xid", 633 | "url", 634 | ] 635 | -------------------------------------------------------------------------------- /wit-abi/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "wit-abi" 3 | version = "0.1.0" 4 | edition = "2021" 5 | publish = false 6 | 7 | [dependencies] 8 | anyhow = "1.0" 9 | clap = { version = "4.1.4", features = ["derive"] } 10 | wit-bindgen-core = "0.11.0" 11 | wit-bindgen-markdown = { version = "0.11.0", optional = true, features = ["clap"] } 12 | wit-bindgen-rust = { version = "0.11.0", optional = true, features = ["clap"] } 13 | wit-bindgen-c = { version = "0.11.0", optional = true, features = ["clap"] } 14 | wit-bindgen-teavm-java = { version = "0.11.0", optional = true, features = ["clap"] } 15 | wit-bindgen-go = { version = "0.11.0", optional = true, features = ["clap"] } 16 | 17 | [features] 18 | default = ['c', 'rust', 'markdown', 'teavm-java', 'go'] 19 | c = ['dep:wit-bindgen-c'] 20 | rust = ['dep:wit-bindgen-rust'] 21 | markdown = ['dep:wit-bindgen-markdown'] 22 | teavm-java = ['dep:wit-bindgen-teavm-java'] 23 | go = ['dep:wit-bindgen-go'] 24 | -------------------------------------------------------------------------------- /wit-abi/src/main.rs: -------------------------------------------------------------------------------- 1 | use anyhow::{bail, Context, Result}; 2 | use clap::Parser; 3 | use std::path::PathBuf; 4 | use std::str; 5 | use wit_bindgen_core::{wit_parser, Files, WorldGenerator}; 6 | use wit_parser::{Resolve, UnresolvedPackage}; 7 | 8 | /// Helper for passing VERSION to opt. 9 | /// If CARGO_VERSION_INFO is set, use it, otherwise use CARGO_PKG_VERSION. 10 | fn version() -> &'static str { 11 | option_env!("CARGO_VERSION_INFO").unwrap_or(env!("CARGO_PKG_VERSION")) 12 | } 13 | 14 | #[derive(Debug, Parser)] 15 | #[command(version = version())] 16 | enum Opt { 17 | /// This generator outputs a Markdown file describing an interface. 18 | #[cfg(feature = "markdown")] 19 | Markdown { 20 | #[clap(flatten)] 21 | opts: wit_bindgen_markdown::Opts, 22 | #[clap(flatten)] 23 | args: Common, 24 | }, 25 | /// Generates bindings for Rust guest modules. 26 | #[cfg(feature = "rust")] 27 | Rust { 28 | #[clap(flatten)] 29 | opts: wit_bindgen_rust::Opts, 30 | #[clap(flatten)] 31 | args: Common, 32 | }, 33 | /// Generates bindings for C/CPP guest modules. 34 | #[cfg(feature = "c")] 35 | C { 36 | #[clap(flatten)] 37 | opts: wit_bindgen_c::Opts, 38 | #[clap(flatten)] 39 | args: Common, 40 | }, 41 | 42 | /// Generates bindings for TeaVM-based Java guest modules. 43 | #[cfg(feature = "teavm-java")] 44 | TeavmJava { 45 | #[clap(flatten)] 46 | opts: wit_bindgen_teavm_java::Opts, 47 | #[clap(flatten)] 48 | args: Common, 49 | }, 50 | /// Generates bindings for TinyGo-based Go guest modules. 51 | #[cfg(feature = "go")] 52 | TinyGo { 53 | #[clap(flatten)] 54 | opts: wit_bindgen_go::Opts, 55 | #[clap(flatten)] 56 | args: Common, 57 | }, 58 | } 59 | 60 | #[derive(Debug, Parser)] 61 | struct Common { 62 | /// Where to place output files 63 | #[clap(long = "out-dir")] 64 | out_dir: Option, 65 | 66 | /// WIT document to generate bindings for. 67 | #[clap(value_name = "DOCUMENT", index = 1)] 68 | wit: PathBuf, 69 | 70 | /// World within the WIT document specified to generate bindings for. 71 | /// 72 | /// This can either be `foo` which is the default world in document `foo` or 73 | /// it's `foo.bar` which is the world named `bar` within document `foo`. 74 | #[clap(short, long)] 75 | world: Option, 76 | 77 | /// Indicates that no files are written and instead files are checked if 78 | /// they're up-to-date with the source files. 79 | #[clap(long)] 80 | check: bool, 81 | } 82 | 83 | fn main() -> Result<()> { 84 | let mut files = Files::default(); 85 | let (generator, opt) = match Opt::parse() { 86 | #[cfg(feature = "markdown")] 87 | Opt::Markdown { opts, args } => (opts.build(), args), 88 | #[cfg(feature = "c")] 89 | Opt::C { opts, args } => (opts.build(), args), 90 | #[cfg(feature = "rust")] 91 | Opt::Rust { opts, args } => (opts.build(), args), 92 | #[cfg(feature = "teavm-java")] 93 | Opt::TeavmJava { opts, args } => (opts.build(), args), 94 | #[cfg(feature = "go")] 95 | Opt::TinyGo { opts, args } => (opts.build(), args), 96 | }; 97 | 98 | gen_world(generator, &opt, &mut files)?; 99 | 100 | for (name, contents) in files.iter() { 101 | let dst = match &opt.out_dir { 102 | Some(path) => path.join(name), 103 | None => name.into(), 104 | }; 105 | println!("Generating {:?}", dst); 106 | 107 | if opt.check { 108 | let prev = std::fs::read(&dst).with_context(|| format!("failed to read {:?}", dst))?; 109 | if prev != contents { 110 | // The contents differ. If it looks like textual contents, do a 111 | // line-by-line comparison so that we can tell users what the 112 | // problem is directly. 113 | if let (Ok(utf8_prev), Ok(utf8_contents)) = 114 | (str::from_utf8(&prev), str::from_utf8(contents)) 115 | { 116 | if !utf8_prev 117 | .chars() 118 | .any(|c| c.is_control() && !matches!(c, '\n' | '\r' | '\t')) 119 | && utf8_prev.lines().eq(utf8_contents.lines()) 120 | { 121 | bail!("{} differs only in line endings (CRLF vs. LF). If this is a text file, configure git to mark the file as `text eol=lf`.", dst.display()); 122 | } 123 | } 124 | // The contents are binary or there are other differences; just 125 | // issue a generic error. 126 | bail!("not up to date: {}", dst.display()); 127 | } 128 | continue; 129 | } 130 | 131 | if let Some(parent) = dst.parent() { 132 | std::fs::create_dir_all(parent) 133 | .with_context(|| format!("failed to create {:?}", parent))?; 134 | } 135 | std::fs::write(&dst, contents).with_context(|| format!("failed to write {:?}", dst))?; 136 | } 137 | 138 | Ok(()) 139 | } 140 | 141 | fn gen_world( 142 | mut generator: Box, 143 | opts: &Common, 144 | files: &mut Files, 145 | ) -> Result<()> { 146 | let mut resolve = Resolve::default(); 147 | let pkg = if opts.wit.is_dir() { 148 | resolve.push_dir(&opts.wit)?.0 149 | } else { 150 | resolve.push(UnresolvedPackage::parse_file(&opts.wit)?)? 151 | }; 152 | let world = resolve.select_world(pkg, opts.world.as_deref())?; 153 | let _ = generator.generate(&resolve, world, files); 154 | Ok(()) 155 | } 156 | 157 | #[test] 158 | fn verify_cli() { 159 | use clap::CommandFactory; 160 | Opt::command().debug_assert() 161 | } 162 | --------------------------------------------------------------------------------