@btc-vision/bitcoin 6.4.9 → 6.4.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. package/.babelrc +4 -4
  2. package/.mocharc.json +13 -13
  3. package/.prettierrc.json +12 -12
  4. package/CHANGELOG.md +403 -403
  5. package/CONTRIBUTING.md +83 -83
  6. package/LICENSE +21 -21
  7. package/README.md +201 -201
  8. package/browser/index.d.ts +1 -1
  9. package/browser/index.js +1 -1
  10. package/browser/{ops.d.ts → opcodes.d.ts} +2 -3
  11. package/browser/script.d.ts +2 -2
  12. package/build/address.js +2 -1
  13. package/build/index.d.ts +1 -1
  14. package/build/index.js +1 -1
  15. package/build/{ops.d.ts → opcodes.d.ts} +2 -3
  16. package/build/{ops.js → opcodes.js} +4 -5
  17. package/build/payments/embed.js +1 -1
  18. package/build/payments/p2ms.js +1 -1
  19. package/build/payments/p2op.js +1 -1
  20. package/build/payments/p2pk.js +1 -1
  21. package/build/payments/p2pkh.js +1 -1
  22. package/build/payments/p2sh.js +3 -3
  23. package/build/payments/p2tr.js +1 -1
  24. package/build/payments/p2wpkh.js +2 -2
  25. package/build/payments/p2wsh.js +2 -2
  26. package/build/push_data.js +9 -9
  27. package/build/script.d.ts +2 -2
  28. package/build/script.js +12 -12
  29. package/build/transaction.js +1 -1
  30. package/cjs/package.json +3 -3
  31. package/gulpfile.js +42 -42
  32. package/package.json +150 -150
  33. package/src/address.ts +304 -303
  34. package/src/bip66.ts +107 -107
  35. package/src/block.ts +233 -233
  36. package/src/bufferutils.ts +188 -188
  37. package/src/crypto.ts +108 -108
  38. package/src/ecc_lib.ts +94 -94
  39. package/src/hooks/AdvancedSignatureManager.ts +104 -104
  40. package/src/hooks/SignatureManager.ts +84 -84
  41. package/src/index.ts +105 -105
  42. package/src/merkle.ts +31 -31
  43. package/src/{ops.ts → opcodes.ts} +280 -282
  44. package/src/payments/bip341.ts +140 -140
  45. package/src/payments/embed.ts +61 -61
  46. package/src/payments/index.ts +172 -172
  47. package/src/payments/lazy.ts +28 -28
  48. package/src/payments/p2ms.ts +156 -156
  49. package/src/payments/p2op.ts +195 -195
  50. package/src/payments/p2pk.ts +93 -93
  51. package/src/payments/p2pkh.ts +214 -214
  52. package/src/payments/p2sh.ts +210 -210
  53. package/src/payments/p2tr.ts +309 -309
  54. package/src/payments/p2wpkh.ts +144 -144
  55. package/src/payments/p2wsh.ts +217 -217
  56. package/src/psbt/bip371.ts +441 -441
  57. package/src/push_data.ts +97 -97
  58. package/src/script.ts +247 -247
  59. package/src/script_number.ts +72 -72
  60. package/src/script_signature.ts +91 -91
  61. package/src/transaction.ts +656 -656
  62. package/test/address.spec.ts +155 -155
  63. package/test/bitcoin.core.spec.ts +212 -212
  64. package/test/block.spec.ts +171 -171
  65. package/test/bufferutils.spec.ts +450 -450
  66. package/test/crypto.spec.ts +49 -49
  67. package/test/fixtures/address.json +329 -329
  68. package/test/fixtures/block.json +148 -148
  69. package/test/fixtures/bufferutils.json +102 -102
  70. package/test/fixtures/core/README.md +26 -26
  71. package/test/fixtures/core/base58_encode_decode.json +50 -50
  72. package/test/fixtures/core/base58_keys_invalid.json +152 -152
  73. package/test/fixtures/core/base58_keys_valid.json +452 -452
  74. package/test/fixtures/core/blocks.json +27 -27
  75. package/test/fixtures/core/sig_canonical.json +7 -7
  76. package/test/fixtures/core/sig_noncanonical.json +33 -33
  77. package/test/fixtures/core/sighash.json +3505 -3505
  78. package/test/fixtures/core/tx_valid.json +2023 -2023
  79. package/test/fixtures/crypto.json +43 -43
  80. package/test/fixtures/ecdsa.json +217 -217
  81. package/test/fixtures/ecpair.json +141 -141
  82. package/test/fixtures/embed.json +108 -108
  83. package/test/fixtures/p2ms.json +434 -434
  84. package/test/fixtures/p2pk.json +179 -179
  85. package/test/fixtures/p2pkh.json +276 -276
  86. package/test/fixtures/p2sh.json +508 -508
  87. package/test/fixtures/p2tr.json +1198 -1198
  88. package/test/fixtures/p2wpkh.json +290 -290
  89. package/test/fixtures/p2wsh.json +489 -489
  90. package/test/fixtures/psbt.json +924 -924
  91. package/test/fixtures/script.json +465 -465
  92. package/test/fixtures/script_number.json +225 -225
  93. package/test/fixtures/signature.json +140 -140
  94. package/test/fixtures/transaction.json +916 -916
  95. package/test/integration/_regtest.ts +6 -6
  96. package/test/integration/addresses.spec.ts +142 -142
  97. package/test/integration/bip32.spec.ts +130 -130
  98. package/test/integration/blocks.spec.ts +28 -28
  99. package/test/integration/cltv.spec.ts +241 -241
  100. package/test/integration/csv.spec.ts +452 -452
  101. package/test/integration/payments.spec.ts +110 -110
  102. package/test/integration/taproot.spec.ts +663 -663
  103. package/test/integration/transactions.spec.ts +668 -668
  104. package/test/payments.spec.ts +114 -114
  105. package/test/payments.utils.ts +165 -165
  106. package/test/psbt.spec.ts +1285 -1285
  107. package/test/script.spec.ts +186 -186
  108. package/test/script_number.spec.ts +26 -26
  109. package/test/script_signature.spec.ts +66 -66
  110. package/test/transaction.spec.ts +337 -337
  111. package/test/ts-node-register.js +7 -7
  112. package/test/tsconfig.json +48 -48
  113. package/test/types.spec.ts +53 -53
  114. package/tsconfig.base.json +27 -27
  115. package/tsconfig.json +19 -19
  116. package/tsconfig.webpack.json +18 -18
  117. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/.ready +0 -0
  118. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/.release-please-manifest.json +0 -3
  119. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/CHANGELOG.md +0 -962
  120. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/CONTRIBUTING.md +0 -34
  121. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/LICENSE +0 -24
  122. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/README.md +0 -273
  123. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/SECURITY.md +0 -2
  124. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/addon.gypi +0 -204
  125. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/bin/node-gyp.js +0 -138
  126. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/.release-please-manifest.json +0 -3
  127. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/LICENSE +0 -28
  128. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/data/ninja/build.ninja +0 -4
  129. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/data/win/large-pdb-shim.cc +0 -12
  130. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/GypVsCMake.md +0 -116
  131. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/Hacking.md +0 -46
  132. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/InputFormatReference.md +0 -1080
  133. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/LanguageSpecification.md +0 -430
  134. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/README.md +0 -27
  135. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/Testing.md +0 -450
  136. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/UserDocumentation.md +0 -965
  137. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/gyp +0 -8
  138. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/gyp.bat +0 -5
  139. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/gyp_main.py +0 -45
  140. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +0 -365
  141. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSProject.py +0 -206
  142. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py +0 -1272
  143. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py +0 -1547
  144. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSToolFile.py +0 -59
  145. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSUserFile.py +0 -153
  146. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSUtil.py +0 -271
  147. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +0 -574
  148. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/__init__.py +0 -692
  149. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/common.py +0 -711
  150. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/common_test.py +0 -171
  151. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py +0 -169
  152. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py +0 -113
  153. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/flock_tool.py +0 -55
  154. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/__init__.py +0 -0
  155. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py +0 -804
  156. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py +0 -1173
  157. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py +0 -1318
  158. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/compile_commands_json.py +0 -127
  159. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/dump_dependency_json.py +0 -103
  160. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py +0 -461
  161. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/gypd.py +0 -89
  162. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/gypsh.py +0 -57
  163. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +0 -2745
  164. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +0 -3976
  165. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py +0 -44
  166. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +0 -2964
  167. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py +0 -67
  168. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py +0 -1391
  169. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode_test.py +0 -25
  170. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/input.py +0 -3115
  171. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/input_test.py +0 -98
  172. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/mac_tool.py +0 -771
  173. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +0 -1260
  174. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/ninja_syntax.py +0 -174
  175. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py +0 -61
  176. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/win_tool.py +0 -373
  177. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py +0 -1938
  178. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation_test.py +0 -53
  179. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py +0 -302
  180. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +0 -3198
  181. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xml_fix.py +0 -65
  182. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/LICENSE +0 -3
  183. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/LICENSE.APACHE +0 -177
  184. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/LICENSE.BSD +0 -23
  185. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/__init__.py +0 -15
  186. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_elffile.py +0 -108
  187. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_manylinux.py +0 -252
  188. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_musllinux.py +0 -83
  189. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_parser.py +0 -359
  190. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_structures.py +0 -61
  191. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_tokenizer.py +0 -192
  192. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/markers.py +0 -252
  193. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/metadata.py +0 -825
  194. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/py.typed +0 -0
  195. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/requirements.py +0 -90
  196. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/specifiers.py +0 -1030
  197. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/tags.py +0 -553
  198. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/utils.py +0 -172
  199. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/version.py +0 -563
  200. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pyproject.toml +0 -120
  201. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/release-please-config.json +0 -11
  202. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/test_gyp.py +0 -261
  203. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/Find-VisualStudio.cs +0 -250
  204. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/build.js +0 -227
  205. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/clean.js +0 -15
  206. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/configure.js +0 -328
  207. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/create-config-gypi.js +0 -150
  208. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/download.js +0 -39
  209. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/find-node-directory.js +0 -63
  210. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/find-python.js +0 -310
  211. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/find-visualstudio.js +0 -590
  212. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/install.js +0 -415
  213. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/list.js +0 -26
  214. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/log.js +0 -168
  215. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/node-gyp.js +0 -188
  216. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/process-release.js +0 -146
  217. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/rebuild.js +0 -12
  218. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/remove.js +0 -43
  219. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/util.js +0 -81
  220. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/macOS_Catalina_acid_test.sh +0 -21
  221. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/package.json +0 -51
  222. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/release-please-config.json +0 -40
  223. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/src/win_delay_load_hook.cc +0 -39
  224. package/coverage/tmp/coverage-31752-1735543485354-0.json +0 -1
  225. package/coverage/tmp/coverage-59920-1735543484555-0.json +0 -1
  226. package/coverage/tmp/coverage-66252-1735543483919-0.json +0 -1
  227. package/coverage/tmp/coverage-68440-1735543485236-0.json +0 -1
  228. package/coverage/tmp/coverage-70588-1735543484426-0.json +0 -1
  229. package/coverage/tmp/coverage-79292-1735543485296-0.json +0 -1
  230. package/coverage/tmp/coverage-80212-1735543483980-0.json +0 -1
@@ -1,574 +0,0 @@
1
- # Copyright (c) 2013 Google Inc. All rights reserved.
2
- # Use of this source code is governed by a BSD-style license that can be
3
- # found in the LICENSE file.
4
-
5
- """Handle version information related to Visual Stuio."""
6
-
7
- import errno
8
- import os
9
- import re
10
- import subprocess
11
- import sys
12
- import glob
13
-
14
-
15
- def JoinPath(*args):
16
- return os.path.normpath(os.path.join(*args))
17
-
18
-
19
- class VisualStudioVersion:
20
- """Information regarding a version of Visual Studio."""
21
-
22
- def __init__(
23
- self,
24
- short_name,
25
- description,
26
- solution_version,
27
- project_version,
28
- flat_sln,
29
- uses_vcxproj,
30
- path,
31
- sdk_based,
32
- default_toolset=None,
33
- compatible_sdks=None,
34
- ):
35
- self.short_name = short_name
36
- self.description = description
37
- self.solution_version = solution_version
38
- self.project_version = project_version
39
- self.flat_sln = flat_sln
40
- self.uses_vcxproj = uses_vcxproj
41
- self.path = path
42
- self.sdk_based = sdk_based
43
- self.default_toolset = default_toolset
44
- compatible_sdks = compatible_sdks or []
45
- compatible_sdks.sort(key=lambda v: float(v.replace("v", "")), reverse=True)
46
- self.compatible_sdks = compatible_sdks
47
-
48
- def ShortName(self):
49
- return self.short_name
50
-
51
- def Description(self):
52
- """Get the full description of the version."""
53
- return self.description
54
-
55
- def SolutionVersion(self):
56
- """Get the version number of the sln files."""
57
- return self.solution_version
58
-
59
- def ProjectVersion(self):
60
- """Get the version number of the vcproj or vcxproj files."""
61
- return self.project_version
62
-
63
- def FlatSolution(self):
64
- return self.flat_sln
65
-
66
- def UsesVcxproj(self):
67
- """Returns true if this version uses a vcxproj file."""
68
- return self.uses_vcxproj
69
-
70
- def ProjectExtension(self):
71
- """Returns the file extension for the project."""
72
- return self.uses_vcxproj and ".vcxproj" or ".vcproj"
73
-
74
- def Path(self):
75
- """Returns the path to Visual Studio installation."""
76
- return self.path
77
-
78
- def ToolPath(self, tool):
79
- """Returns the path to a given compiler tool. """
80
- return os.path.normpath(os.path.join(self.path, "VC/bin", tool))
81
-
82
- def DefaultToolset(self):
83
- """Returns the msbuild toolset version that will be used in the absence
84
- of a user override."""
85
- return self.default_toolset
86
-
87
- def _SetupScriptInternal(self, target_arch):
88
- """Returns a command (with arguments) to be used to set up the
89
- environment."""
90
- assert target_arch in ("x86", "x64"), "target_arch not supported"
91
- # If WindowsSDKDir is set and SetEnv.Cmd exists then we are using the
92
- # depot_tools build tools and should run SetEnv.Cmd to set up the
93
- # environment. The check for WindowsSDKDir alone is not sufficient because
94
- # this is set by running vcvarsall.bat.
95
- sdk_dir = os.environ.get("WindowsSDKDir", "")
96
- setup_path = JoinPath(sdk_dir, "Bin", "SetEnv.Cmd")
97
- if self.sdk_based and sdk_dir and os.path.exists(setup_path):
98
- return [setup_path, "/" + target_arch]
99
-
100
- is_host_arch_x64 = (
101
- os.environ.get("PROCESSOR_ARCHITECTURE") == "AMD64"
102
- or os.environ.get("PROCESSOR_ARCHITEW6432") == "AMD64"
103
- )
104
-
105
- # For VS2017 (and newer) it's fairly easy
106
- if self.short_name >= "2017":
107
- script_path = JoinPath(
108
- self.path, "VC", "Auxiliary", "Build", "vcvarsall.bat"
109
- )
110
-
111
- # Always use a native executable, cross-compiling if necessary.
112
- host_arch = "amd64" if is_host_arch_x64 else "x86"
113
- msvc_target_arch = "amd64" if target_arch == "x64" else "x86"
114
- arg = host_arch
115
- if host_arch != msvc_target_arch:
116
- arg += "_" + msvc_target_arch
117
-
118
- return [script_path, arg]
119
-
120
- # We try to find the best version of the env setup batch.
121
- vcvarsall = JoinPath(self.path, "VC", "vcvarsall.bat")
122
- if target_arch == "x86":
123
- if (
124
- self.short_name >= "2013"
125
- and self.short_name[-1] != "e"
126
- and is_host_arch_x64
127
- ):
128
- # VS2013 and later, non-Express have a x64-x86 cross that we want
129
- # to prefer.
130
- return [vcvarsall, "amd64_x86"]
131
- else:
132
- # Otherwise, the standard x86 compiler. We don't use VC/vcvarsall.bat
133
- # for x86 because vcvarsall calls vcvars32, which it can only find if
134
- # VS??COMNTOOLS is set, which isn't guaranteed.
135
- return [JoinPath(self.path, "Common7", "Tools", "vsvars32.bat")]
136
- elif target_arch == "x64":
137
- arg = "x86_amd64"
138
- # Use the 64-on-64 compiler if we're not using an express edition and
139
- # we're running on a 64bit OS.
140
- if self.short_name[-1] != "e" and is_host_arch_x64:
141
- arg = "amd64"
142
- return [vcvarsall, arg]
143
-
144
- def SetupScript(self, target_arch):
145
- script_data = self._SetupScriptInternal(target_arch)
146
- script_path = script_data[0]
147
- if not os.path.exists(script_path):
148
- raise Exception(
149
- "%s is missing - make sure VC++ tools are installed." % script_path
150
- )
151
- return script_data
152
-
153
-
154
- def _RegistryQueryBase(sysdir, key, value):
155
- """Use reg.exe to read a particular key.
156
-
157
- While ideally we might use the win32 module, we would like gyp to be
158
- python neutral, so for instance cygwin python lacks this module.
159
-
160
- Arguments:
161
- sysdir: The system subdirectory to attempt to launch reg.exe from.
162
- key: The registry key to read from.
163
- value: The particular value to read.
164
- Return:
165
- stdout from reg.exe, or None for failure.
166
- """
167
- # Skip if not on Windows or Python Win32 setup issue
168
- if sys.platform not in ("win32", "cygwin"):
169
- return None
170
- # Setup params to pass to and attempt to launch reg.exe
171
- cmd = [os.path.join(os.environ.get("WINDIR", ""), sysdir, "reg.exe"), "query", key]
172
- if value:
173
- cmd.extend(["/v", value])
174
- p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
175
- # Obtain the stdout from reg.exe, reading to the end so p.returncode is valid
176
- # Note that the error text may be in [1] in some cases
177
- text = p.communicate()[0].decode("utf-8")
178
- # Check return code from reg.exe; officially 0==success and 1==error
179
- if p.returncode:
180
- return None
181
- return text
182
-
183
-
184
- def _RegistryQuery(key, value=None):
185
- r"""Use reg.exe to read a particular key through _RegistryQueryBase.
186
-
187
- First tries to launch from %WinDir%\Sysnative to avoid WoW64 redirection. If
188
- that fails, it falls back to System32. Sysnative is available on Vista and
189
- up and available on Windows Server 2003 and XP through KB patch 942589. Note
190
- that Sysnative will always fail if using 64-bit python due to it being a
191
- virtual directory and System32 will work correctly in the first place.
192
-
193
- KB 942589 - http://support.microsoft.com/kb/942589/en-us.
194
-
195
- Arguments:
196
- key: The registry key.
197
- value: The particular registry value to read (optional).
198
- Return:
199
- stdout from reg.exe, or None for failure.
200
- """
201
- text = None
202
- try:
203
- text = _RegistryQueryBase("Sysnative", key, value)
204
- except OSError as e:
205
- if e.errno == errno.ENOENT:
206
- text = _RegistryQueryBase("System32", key, value)
207
- else:
208
- raise
209
- return text
210
-
211
-
212
- def _RegistryGetValueUsingWinReg(key, value):
213
- """Use the _winreg module to obtain the value of a registry key.
214
-
215
- Args:
216
- key: The registry key.
217
- value: The particular registry value to read.
218
- Return:
219
- contents of the registry key's value, or None on failure. Throws
220
- ImportError if winreg is unavailable.
221
- """
222
- from winreg import HKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
223
- try:
224
- root, subkey = key.split("\\", 1)
225
- assert root == "HKLM" # Only need HKLM for now.
226
- with OpenKey(HKEY_LOCAL_MACHINE, subkey) as hkey:
227
- return QueryValueEx(hkey, value)[0]
228
- except OSError:
229
- return None
230
-
231
-
232
- def _RegistryGetValue(key, value):
233
- """Use _winreg or reg.exe to obtain the value of a registry key.
234
-
235
- Using _winreg is preferable because it solves an issue on some corporate
236
- environments where access to reg.exe is locked down. However, we still need
237
- to fallback to reg.exe for the case where the _winreg module is not available
238
- (for example in cygwin python).
239
-
240
- Args:
241
- key: The registry key.
242
- value: The particular registry value to read.
243
- Return:
244
- contents of the registry key's value, or None on failure.
245
- """
246
- try:
247
- return _RegistryGetValueUsingWinReg(key, value)
248
- except ImportError:
249
- pass
250
-
251
- # Fallback to reg.exe if we fail to import _winreg.
252
- text = _RegistryQuery(key, value)
253
- if not text:
254
- return None
255
- # Extract value.
256
- match = re.search(r"REG_\w+\s+([^\r]+)\r\n", text)
257
- if not match:
258
- return None
259
- return match.group(1)
260
-
261
-
262
- def _CreateVersion(name, path, sdk_based=False):
263
- """Sets up MSVS project generation.
264
-
265
- Setup is based off the GYP_MSVS_VERSION environment variable or whatever is
266
- autodetected if GYP_MSVS_VERSION is not explicitly specified. If a version is
267
- passed in that doesn't match a value in versions python will throw a error.
268
- """
269
- if path:
270
- path = os.path.normpath(path)
271
- versions = {
272
- "2022": VisualStudioVersion(
273
- "2022",
274
- "Visual Studio 2022",
275
- solution_version="12.00",
276
- project_version="17.0",
277
- flat_sln=False,
278
- uses_vcxproj=True,
279
- path=path,
280
- sdk_based=sdk_based,
281
- default_toolset="v143",
282
- compatible_sdks=["v8.1", "v10.0"],
283
- ),
284
- "2019": VisualStudioVersion(
285
- "2019",
286
- "Visual Studio 2019",
287
- solution_version="12.00",
288
- project_version="16.0",
289
- flat_sln=False,
290
- uses_vcxproj=True,
291
- path=path,
292
- sdk_based=sdk_based,
293
- default_toolset="v142",
294
- compatible_sdks=["v8.1", "v10.0"],
295
- ),
296
- "2017": VisualStudioVersion(
297
- "2017",
298
- "Visual Studio 2017",
299
- solution_version="12.00",
300
- project_version="15.0",
301
- flat_sln=False,
302
- uses_vcxproj=True,
303
- path=path,
304
- sdk_based=sdk_based,
305
- default_toolset="v141",
306
- compatible_sdks=["v8.1", "v10.0"],
307
- ),
308
- "2015": VisualStudioVersion(
309
- "2015",
310
- "Visual Studio 2015",
311
- solution_version="12.00",
312
- project_version="14.0",
313
- flat_sln=False,
314
- uses_vcxproj=True,
315
- path=path,
316
- sdk_based=sdk_based,
317
- default_toolset="v140",
318
- ),
319
- "2013": VisualStudioVersion(
320
- "2013",
321
- "Visual Studio 2013",
322
- solution_version="13.00",
323
- project_version="12.0",
324
- flat_sln=False,
325
- uses_vcxproj=True,
326
- path=path,
327
- sdk_based=sdk_based,
328
- default_toolset="v120",
329
- ),
330
- "2013e": VisualStudioVersion(
331
- "2013e",
332
- "Visual Studio 2013",
333
- solution_version="13.00",
334
- project_version="12.0",
335
- flat_sln=True,
336
- uses_vcxproj=True,
337
- path=path,
338
- sdk_based=sdk_based,
339
- default_toolset="v120",
340
- ),
341
- "2012": VisualStudioVersion(
342
- "2012",
343
- "Visual Studio 2012",
344
- solution_version="12.00",
345
- project_version="4.0",
346
- flat_sln=False,
347
- uses_vcxproj=True,
348
- path=path,
349
- sdk_based=sdk_based,
350
- default_toolset="v110",
351
- ),
352
- "2012e": VisualStudioVersion(
353
- "2012e",
354
- "Visual Studio 2012",
355
- solution_version="12.00",
356
- project_version="4.0",
357
- flat_sln=True,
358
- uses_vcxproj=True,
359
- path=path,
360
- sdk_based=sdk_based,
361
- default_toolset="v110",
362
- ),
363
- "2010": VisualStudioVersion(
364
- "2010",
365
- "Visual Studio 2010",
366
- solution_version="11.00",
367
- project_version="4.0",
368
- flat_sln=False,
369
- uses_vcxproj=True,
370
- path=path,
371
- sdk_based=sdk_based,
372
- ),
373
- "2010e": VisualStudioVersion(
374
- "2010e",
375
- "Visual C++ Express 2010",
376
- solution_version="11.00",
377
- project_version="4.0",
378
- flat_sln=True,
379
- uses_vcxproj=True,
380
- path=path,
381
- sdk_based=sdk_based,
382
- ),
383
- "2008": VisualStudioVersion(
384
- "2008",
385
- "Visual Studio 2008",
386
- solution_version="10.00",
387
- project_version="9.00",
388
- flat_sln=False,
389
- uses_vcxproj=False,
390
- path=path,
391
- sdk_based=sdk_based,
392
- ),
393
- "2008e": VisualStudioVersion(
394
- "2008e",
395
- "Visual Studio 2008",
396
- solution_version="10.00",
397
- project_version="9.00",
398
- flat_sln=True,
399
- uses_vcxproj=False,
400
- path=path,
401
- sdk_based=sdk_based,
402
- ),
403
- "2005": VisualStudioVersion(
404
- "2005",
405
- "Visual Studio 2005",
406
- solution_version="9.00",
407
- project_version="8.00",
408
- flat_sln=False,
409
- uses_vcxproj=False,
410
- path=path,
411
- sdk_based=sdk_based,
412
- ),
413
- "2005e": VisualStudioVersion(
414
- "2005e",
415
- "Visual Studio 2005",
416
- solution_version="9.00",
417
- project_version="8.00",
418
- flat_sln=True,
419
- uses_vcxproj=False,
420
- path=path,
421
- sdk_based=sdk_based,
422
- ),
423
- }
424
- return versions[str(name)]
425
-
426
-
427
- def _ConvertToCygpath(path):
428
- """Convert to cygwin path if we are using cygwin."""
429
- if sys.platform == "cygwin":
430
- p = subprocess.Popen(["cygpath", path], stdout=subprocess.PIPE)
431
- path = p.communicate()[0].decode("utf-8").strip()
432
- return path
433
-
434
-
435
- def _DetectVisualStudioVersions(versions_to_check, force_express):
436
- """Collect the list of installed visual studio versions.
437
-
438
- Returns:
439
- A list of visual studio versions installed in descending order of
440
- usage preference.
441
- Base this on the registry and a quick check if devenv.exe exists.
442
- Possibilities are:
443
- 2005(e) - Visual Studio 2005 (8)
444
- 2008(e) - Visual Studio 2008 (9)
445
- 2010(e) - Visual Studio 2010 (10)
446
- 2012(e) - Visual Studio 2012 (11)
447
- 2013(e) - Visual Studio 2013 (12)
448
- 2015 - Visual Studio 2015 (14)
449
- 2017 - Visual Studio 2017 (15)
450
- 2019 - Visual Studio 2019 (16)
451
- 2022 - Visual Studio 2022 (17)
452
- Where (e) is e for express editions of MSVS and blank otherwise.
453
- """
454
- version_to_year = {
455
- "8.0": "2005",
456
- "9.0": "2008",
457
- "10.0": "2010",
458
- "11.0": "2012",
459
- "12.0": "2013",
460
- "14.0": "2015",
461
- "15.0": "2017",
462
- "16.0": "2019",
463
- "17.0": "2022",
464
- }
465
- versions = []
466
- for version in versions_to_check:
467
- # Old method of searching for which VS version is installed
468
- # We don't use the 2010-encouraged-way because we also want to get the
469
- # path to the binaries, which it doesn't offer.
470
- keys = [
471
- r"HKLM\Software\Microsoft\VisualStudio\%s" % version,
472
- r"HKLM\Software\Wow6432Node\Microsoft\VisualStudio\%s" % version,
473
- r"HKLM\Software\Microsoft\VCExpress\%s" % version,
474
- r"HKLM\Software\Wow6432Node\Microsoft\VCExpress\%s" % version,
475
- ]
476
- for index in range(len(keys)):
477
- path = _RegistryGetValue(keys[index], "InstallDir")
478
- if not path:
479
- continue
480
- path = _ConvertToCygpath(path)
481
- # Check for full.
482
- full_path = os.path.join(path, "devenv.exe")
483
- express_path = os.path.join(path, "*express.exe")
484
- if not force_express and os.path.exists(full_path):
485
- # Add this one.
486
- versions.append(
487
- _CreateVersion(
488
- version_to_year[version], os.path.join(path, "..", "..")
489
- )
490
- )
491
- # Check for express.
492
- elif glob.glob(express_path):
493
- # Add this one.
494
- versions.append(
495
- _CreateVersion(
496
- version_to_year[version] + "e", os.path.join(path, "..", "..")
497
- )
498
- )
499
-
500
- # The old method above does not work when only SDK is installed.
501
- keys = [
502
- r"HKLM\Software\Microsoft\VisualStudio\SxS\VC7",
503
- r"HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7",
504
- r"HKLM\Software\Microsoft\VisualStudio\SxS\VS7",
505
- r"HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VS7",
506
- ]
507
- for index in range(len(keys)):
508
- path = _RegistryGetValue(keys[index], version)
509
- if not path:
510
- continue
511
- path = _ConvertToCygpath(path)
512
- if version == "15.0":
513
- if os.path.exists(path):
514
- versions.append(_CreateVersion("2017", path))
515
- elif version != "14.0": # There is no Express edition for 2015.
516
- versions.append(
517
- _CreateVersion(
518
- version_to_year[version] + "e",
519
- os.path.join(path, ".."),
520
- sdk_based=True,
521
- )
522
- )
523
-
524
- return versions
525
-
526
-
527
- def SelectVisualStudioVersion(version="auto", allow_fallback=True):
528
- """Select which version of Visual Studio projects to generate.
529
-
530
- Arguments:
531
- version: Hook to allow caller to force a particular version (vs auto).
532
- Returns:
533
- An object representing a visual studio project format version.
534
- """
535
- # In auto mode, check environment variable for override.
536
- if version == "auto":
537
- version = os.environ.get("GYP_MSVS_VERSION", "auto")
538
- version_map = {
539
- "auto": ("17.0", "16.0", "15.0", "14.0", "12.0", "10.0", "9.0", "8.0", "11.0"),
540
- "2005": ("8.0",),
541
- "2005e": ("8.0",),
542
- "2008": ("9.0",),
543
- "2008e": ("9.0",),
544
- "2010": ("10.0",),
545
- "2010e": ("10.0",),
546
- "2012": ("11.0",),
547
- "2012e": ("11.0",),
548
- "2013": ("12.0",),
549
- "2013e": ("12.0",),
550
- "2015": ("14.0",),
551
- "2017": ("15.0",),
552
- "2019": ("16.0",),
553
- "2022": ("17.0",),
554
- }
555
- override_path = os.environ.get("GYP_MSVS_OVERRIDE_PATH")
556
- if override_path:
557
- msvs_version = os.environ.get("GYP_MSVS_VERSION")
558
- if not msvs_version:
559
- raise ValueError(
560
- "GYP_MSVS_OVERRIDE_PATH requires GYP_MSVS_VERSION to be "
561
- "set to a particular version (e.g. 2010e)."
562
- )
563
- return _CreateVersion(msvs_version, override_path, sdk_based=True)
564
- version = str(version)
565
- versions = _DetectVisualStudioVersions(version_map[version], "e" in version)
566
- if not versions:
567
- if not allow_fallback:
568
- raise ValueError("Could not locate Visual Studio installation.")
569
- if version == "auto":
570
- # Default to 2005 if we couldn't find anything
571
- return _CreateVersion("2005", None)
572
- else:
573
- return _CreateVersion(version, None)
574
- return versions[0]