@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,692 +0,0 @@
1
- #!/usr/bin/env python3
2
-
3
- # Copyright (c) 2012 Google Inc. All rights reserved.
4
- # Use of this source code is governed by a BSD-style license that can be
5
- # found in the LICENSE file.
6
-
7
-
8
- import copy
9
- import gyp.input
10
- import argparse
11
- import os.path
12
- import re
13
- import shlex
14
- import sys
15
- import traceback
16
- from gyp.common import GypError
17
-
18
-
19
- # Default debug modes for GYP
20
- debug = {}
21
-
22
- # List of "official" debug modes, but you can use anything you like.
23
- DEBUG_GENERAL = "general"
24
- DEBUG_VARIABLES = "variables"
25
- DEBUG_INCLUDES = "includes"
26
-
27
-
28
- def DebugOutput(mode, message, *args):
29
- if "all" in gyp.debug or mode in gyp.debug:
30
- ctx = ("unknown", 0, "unknown")
31
- try:
32
- f = traceback.extract_stack(limit=2)
33
- if f:
34
- ctx = f[0][:3]
35
- except Exception:
36
- pass
37
- if args:
38
- message %= args
39
- print(
40
- "%s:%s:%d:%s %s"
41
- % (mode.upper(), os.path.basename(ctx[0]), ctx[1], ctx[2], message)
42
- )
43
-
44
-
45
- def FindBuildFiles():
46
- extension = ".gyp"
47
- files = os.listdir(os.getcwd())
48
- build_files = []
49
- for file in files:
50
- if file.endswith(extension):
51
- build_files.append(file)
52
- return build_files
53
-
54
-
55
- def Load(
56
- build_files,
57
- format,
58
- default_variables={},
59
- includes=[],
60
- depth=".",
61
- params=None,
62
- check=False,
63
- circular_check=True,
64
- ):
65
- """
66
- Loads one or more specified build files.
67
- default_variables and includes will be copied before use.
68
- Returns the generator for the specified format and the
69
- data returned by loading the specified build files.
70
- """
71
- if params is None:
72
- params = {}
73
-
74
- if "-" in format:
75
- format, params["flavor"] = format.split("-", 1)
76
-
77
- default_variables = copy.copy(default_variables)
78
-
79
- # Default variables provided by this program and its modules should be
80
- # named WITH_CAPITAL_LETTERS to provide a distinct "best practice" namespace,
81
- # avoiding collisions with user and automatic variables.
82
- default_variables["GENERATOR"] = format
83
- default_variables["GENERATOR_FLAVOR"] = params.get("flavor", "")
84
-
85
- # Format can be a custom python file, or by default the name of a module
86
- # within gyp.generator.
87
- if format.endswith(".py"):
88
- generator_name = os.path.splitext(format)[0]
89
- path, generator_name = os.path.split(generator_name)
90
-
91
- # Make sure the path to the custom generator is in sys.path
92
- # Don't worry about removing it once we are done. Keeping the path
93
- # to each generator that is used in sys.path is likely harmless and
94
- # arguably a good idea.
95
- path = os.path.abspath(path)
96
- if path not in sys.path:
97
- sys.path.insert(0, path)
98
- else:
99
- generator_name = "gyp.generator." + format
100
-
101
- # These parameters are passed in order (as opposed to by key)
102
- # because ActivePython cannot handle key parameters to __import__.
103
- generator = __import__(generator_name, globals(), locals(), generator_name)
104
- for (key, val) in generator.generator_default_variables.items():
105
- default_variables.setdefault(key, val)
106
-
107
- output_dir = params["options"].generator_output or params["options"].toplevel_dir
108
- if default_variables["GENERATOR"] == "ninja":
109
- default_variables.setdefault(
110
- "PRODUCT_DIR_ABS",
111
- os.path.join(
112
- output_dir, "out", default_variables.get("build_type", "default")
113
- ),
114
- )
115
- else:
116
- default_variables.setdefault(
117
- "PRODUCT_DIR_ABS",
118
- os.path.join(output_dir, default_variables["CONFIGURATION_NAME"]),
119
- )
120
-
121
- # Give the generator the opportunity to set additional variables based on
122
- # the params it will receive in the output phase.
123
- if getattr(generator, "CalculateVariables", None):
124
- generator.CalculateVariables(default_variables, params)
125
-
126
- # Give the generator the opportunity to set generator_input_info based on
127
- # the params it will receive in the output phase.
128
- if getattr(generator, "CalculateGeneratorInputInfo", None):
129
- generator.CalculateGeneratorInputInfo(params)
130
-
131
- # Fetch the generator specific info that gets fed to input, we use getattr
132
- # so we can default things and the generators only have to provide what
133
- # they need.
134
- generator_input_info = {
135
- "non_configuration_keys": getattr(
136
- generator, "generator_additional_non_configuration_keys", []
137
- ),
138
- "path_sections": getattr(generator, "generator_additional_path_sections", []),
139
- "extra_sources_for_rules": getattr(
140
- generator, "generator_extra_sources_for_rules", []
141
- ),
142
- "generator_supports_multiple_toolsets": getattr(
143
- generator, "generator_supports_multiple_toolsets", False
144
- ),
145
- "generator_wants_static_library_dependencies_adjusted": getattr(
146
- generator, "generator_wants_static_library_dependencies_adjusted", True
147
- ),
148
- "generator_wants_sorted_dependencies": getattr(
149
- generator, "generator_wants_sorted_dependencies", False
150
- ),
151
- "generator_filelist_paths": getattr(
152
- generator, "generator_filelist_paths", None
153
- ),
154
- }
155
-
156
- # Process the input specific to this generator.
157
- result = gyp.input.Load(
158
- build_files,
159
- default_variables,
160
- includes[:],
161
- depth,
162
- generator_input_info,
163
- check,
164
- circular_check,
165
- params["parallel"],
166
- params["root_targets"],
167
- )
168
- return [generator] + result
169
-
170
-
171
- def NameValueListToDict(name_value_list):
172
- """
173
- Takes an array of strings of the form 'NAME=VALUE' and creates a dictionary
174
- of the pairs. If a string is simply NAME, then the value in the dictionary
175
- is set to True. If VALUE can be converted to an integer, it is.
176
- """
177
- result = {}
178
- for item in name_value_list:
179
- tokens = item.split("=", 1)
180
- if len(tokens) == 2:
181
- # If we can make it an int, use that, otherwise, use the string.
182
- try:
183
- token_value = int(tokens[1])
184
- except ValueError:
185
- token_value = tokens[1]
186
- # Set the variable to the supplied value.
187
- result[tokens[0]] = token_value
188
- else:
189
- # No value supplied, treat it as a boolean and set it.
190
- result[tokens[0]] = True
191
- return result
192
-
193
-
194
- def ShlexEnv(env_name):
195
- flags = os.environ.get(env_name, [])
196
- if flags:
197
- flags = shlex.split(flags)
198
- return flags
199
-
200
-
201
- def FormatOpt(opt, value):
202
- if opt.startswith("--"):
203
- return f"{opt}={value}"
204
- return opt + value
205
-
206
-
207
- def RegenerateAppendFlag(flag, values, predicate, env_name, options):
208
- """Regenerate a list of command line flags, for an option of action='append'.
209
-
210
- The |env_name|, if given, is checked in the environment and used to generate
211
- an initial list of options, then the options that were specified on the
212
- command line (given in |values|) are appended. This matches the handling of
213
- environment variables and command line flags where command line flags override
214
- the environment, while not requiring the environment to be set when the flags
215
- are used again.
216
- """
217
- flags = []
218
- if options.use_environment and env_name:
219
- for flag_value in ShlexEnv(env_name):
220
- value = FormatOpt(flag, predicate(flag_value))
221
- if value in flags:
222
- flags.remove(value)
223
- flags.append(value)
224
- if values:
225
- for flag_value in values:
226
- flags.append(FormatOpt(flag, predicate(flag_value)))
227
- return flags
228
-
229
-
230
- def RegenerateFlags(options):
231
- """Given a parsed options object, and taking the environment variables into
232
- account, returns a list of flags that should regenerate an equivalent options
233
- object (even in the absence of the environment variables.)
234
-
235
- Any path options will be normalized relative to depth.
236
-
237
- The format flag is not included, as it is assumed the calling generator will
238
- set that as appropriate.
239
- """
240
-
241
- def FixPath(path):
242
- path = gyp.common.FixIfRelativePath(path, options.depth)
243
- if not path:
244
- return os.path.curdir
245
- return path
246
-
247
- def Noop(value):
248
- return value
249
-
250
- # We always want to ignore the environment when regenerating, to avoid
251
- # duplicate or changed flags in the environment at the time of regeneration.
252
- flags = ["--ignore-environment"]
253
- for name, metadata in options._regeneration_metadata.items():
254
- opt = metadata["opt"]
255
- value = getattr(options, name)
256
- value_predicate = metadata["type"] == "path" and FixPath or Noop
257
- action = metadata["action"]
258
- env_name = metadata["env_name"]
259
- if action == "append":
260
- flags.extend(
261
- RegenerateAppendFlag(opt, value, value_predicate, env_name, options)
262
- )
263
- elif action in ("store", None): # None is a synonym for 'store'.
264
- if value:
265
- flags.append(FormatOpt(opt, value_predicate(value)))
266
- elif options.use_environment and env_name and os.environ.get(env_name):
267
- flags.append(FormatOpt(opt, value_predicate(os.environ.get(env_name))))
268
- elif action in ("store_true", "store_false"):
269
- if (action == "store_true" and value) or (
270
- action == "store_false" and not value
271
- ):
272
- flags.append(opt)
273
- elif options.use_environment and env_name:
274
- print(
275
- "Warning: environment regeneration unimplemented "
276
- "for %s flag %r env_name %r" % (action, opt, env_name),
277
- file=sys.stderr,
278
- )
279
- else:
280
- print(
281
- "Warning: regeneration unimplemented for action %r "
282
- "flag %r" % (action, opt),
283
- file=sys.stderr,
284
- )
285
-
286
- return flags
287
-
288
-
289
- class RegeneratableOptionParser(argparse.ArgumentParser):
290
- def __init__(self, usage):
291
- self.__regeneratable_options = {}
292
- argparse.ArgumentParser.__init__(self, usage=usage)
293
-
294
- def add_argument(self, *args, **kw):
295
- """Add an option to the parser.
296
-
297
- This accepts the same arguments as ArgumentParser.add_argument, plus the
298
- following:
299
- regenerate: can be set to False to prevent this option from being included
300
- in regeneration.
301
- env_name: name of environment variable that additional values for this
302
- option come from.
303
- type: adds type='path', to tell the regenerator that the values of
304
- this option need to be made relative to options.depth
305
- """
306
- env_name = kw.pop("env_name", None)
307
- if "dest" in kw and kw.pop("regenerate", True):
308
- dest = kw["dest"]
309
-
310
- # The path type is needed for regenerating, for optparse we can just treat
311
- # it as a string.
312
- type = kw.get("type")
313
- if type == "path":
314
- kw["type"] = str
315
-
316
- self.__regeneratable_options[dest] = {
317
- "action": kw.get("action"),
318
- "type": type,
319
- "env_name": env_name,
320
- "opt": args[0],
321
- }
322
-
323
- argparse.ArgumentParser.add_argument(self, *args, **kw)
324
-
325
- def parse_args(self, *args):
326
- values, args = argparse.ArgumentParser.parse_known_args(self, *args)
327
- values._regeneration_metadata = self.__regeneratable_options
328
- return values, args
329
-
330
-
331
- def gyp_main(args):
332
- my_name = os.path.basename(sys.argv[0])
333
- usage = "usage: %(prog)s [options ...] [build_file ...]"
334
-
335
- parser = RegeneratableOptionParser(usage=usage.replace("%s", "%(prog)s"))
336
- parser.add_argument(
337
- "--build",
338
- dest="configs",
339
- action="append",
340
- help="configuration for build after project generation",
341
- )
342
- parser.add_argument(
343
- "--check", dest="check", action="store_true", help="check format of gyp files"
344
- )
345
- parser.add_argument(
346
- "--config-dir",
347
- dest="config_dir",
348
- action="store",
349
- env_name="GYP_CONFIG_DIR",
350
- default=None,
351
- help="The location for configuration files like " "include.gypi.",
352
- )
353
- parser.add_argument(
354
- "-d",
355
- "--debug",
356
- dest="debug",
357
- metavar="DEBUGMODE",
358
- action="append",
359
- default=[],
360
- help="turn on a debugging "
361
- 'mode for debugging GYP. Supported modes are "variables", '
362
- '"includes" and "general" or "all" for all of them.',
363
- )
364
- parser.add_argument(
365
- "-D",
366
- dest="defines",
367
- action="append",
368
- metavar="VAR=VAL",
369
- env_name="GYP_DEFINES",
370
- help="sets variable VAR to value VAL",
371
- )
372
- parser.add_argument(
373
- "--depth",
374
- dest="depth",
375
- metavar="PATH",
376
- type="path",
377
- help="set DEPTH gyp variable to a relative path to PATH",
378
- )
379
- parser.add_argument(
380
- "-f",
381
- "--format",
382
- dest="formats",
383
- action="append",
384
- env_name="GYP_GENERATORS",
385
- regenerate=False,
386
- help="output formats to generate",
387
- )
388
- parser.add_argument(
389
- "-G",
390
- dest="generator_flags",
391
- action="append",
392
- default=[],
393
- metavar="FLAG=VAL",
394
- env_name="GYP_GENERATOR_FLAGS",
395
- help="sets generator flag FLAG to VAL",
396
- )
397
- parser.add_argument(
398
- "--generator-output",
399
- dest="generator_output",
400
- action="store",
401
- default=None,
402
- metavar="DIR",
403
- type="path",
404
- env_name="GYP_GENERATOR_OUTPUT",
405
- help="puts generated build files under DIR",
406
- )
407
- parser.add_argument(
408
- "--ignore-environment",
409
- dest="use_environment",
410
- action="store_false",
411
- default=True,
412
- regenerate=False,
413
- help="do not read options from environment variables",
414
- )
415
- parser.add_argument(
416
- "-I",
417
- "--include",
418
- dest="includes",
419
- action="append",
420
- metavar="INCLUDE",
421
- type="path",
422
- help="files to include in all loaded .gyp files",
423
- )
424
- # --no-circular-check disables the check for circular relationships between
425
- # .gyp files. These relationships should not exist, but they've only been
426
- # observed to be harmful with the Xcode generator. Chromium's .gyp files
427
- # currently have some circular relationships on non-Mac platforms, so this
428
- # option allows the strict behavior to be used on Macs and the lenient
429
- # behavior to be used elsewhere.
430
- # TODO(mark): Remove this option when http://crbug.com/35878 is fixed.
431
- parser.add_argument(
432
- "--no-circular-check",
433
- dest="circular_check",
434
- action="store_false",
435
- default=True,
436
- regenerate=False,
437
- help="don't check for circular relationships between files",
438
- )
439
- parser.add_argument(
440
- "--no-parallel",
441
- action="store_true",
442
- default=False,
443
- help="Disable multiprocessing",
444
- )
445
- parser.add_argument(
446
- "-S",
447
- "--suffix",
448
- dest="suffix",
449
- default="",
450
- help="suffix to add to generated files",
451
- )
452
- parser.add_argument(
453
- "--toplevel-dir",
454
- dest="toplevel_dir",
455
- action="store",
456
- default=None,
457
- metavar="DIR",
458
- type="path",
459
- help="directory to use as the root of the source tree",
460
- )
461
- parser.add_argument(
462
- "-R",
463
- "--root-target",
464
- dest="root_targets",
465
- action="append",
466
- metavar="TARGET",
467
- help="include only TARGET and its deep dependencies",
468
- )
469
- parser.add_argument(
470
- "-V",
471
- "--version",
472
- dest="version",
473
- action="store_true",
474
- help="Show the version and exit.",
475
- )
476
-
477
- options, build_files_arg = parser.parse_args(args)
478
- if options.version:
479
- import pkg_resources
480
- print(f"v{pkg_resources.get_distribution('gyp-next').version}")
481
- return 0
482
- build_files = build_files_arg
483
-
484
- # Set up the configuration directory (defaults to ~/.gyp)
485
- if not options.config_dir:
486
- home = None
487
- home_dot_gyp = None
488
- if options.use_environment:
489
- home_dot_gyp = os.environ.get("GYP_CONFIG_DIR", None)
490
- if home_dot_gyp:
491
- home_dot_gyp = os.path.expanduser(home_dot_gyp)
492
-
493
- if not home_dot_gyp:
494
- home_vars = ["HOME"]
495
- if sys.platform in ("cygwin", "win32"):
496
- home_vars.append("USERPROFILE")
497
- for home_var in home_vars:
498
- home = os.getenv(home_var)
499
- if home:
500
- home_dot_gyp = os.path.join(home, ".gyp")
501
- if not os.path.exists(home_dot_gyp):
502
- home_dot_gyp = None
503
- else:
504
- break
505
- else:
506
- home_dot_gyp = os.path.expanduser(options.config_dir)
507
-
508
- if home_dot_gyp and not os.path.exists(home_dot_gyp):
509
- home_dot_gyp = None
510
-
511
- if not options.formats:
512
- # If no format was given on the command line, then check the env variable.
513
- generate_formats = []
514
- if options.use_environment:
515
- generate_formats = os.environ.get("GYP_GENERATORS", [])
516
- if generate_formats:
517
- generate_formats = re.split(r"[\s,]", generate_formats)
518
- if generate_formats:
519
- options.formats = generate_formats
520
- else:
521
- # Nothing in the variable, default based on platform.
522
- if sys.platform == "darwin":
523
- options.formats = ["xcode"]
524
- elif sys.platform in ("win32", "cygwin"):
525
- options.formats = ["msvs"]
526
- else:
527
- options.formats = ["make"]
528
-
529
- if not options.generator_output and options.use_environment:
530
- g_o = os.environ.get("GYP_GENERATOR_OUTPUT")
531
- if g_o:
532
- options.generator_output = g_o
533
-
534
- options.parallel = not options.no_parallel
535
-
536
- for mode in options.debug:
537
- gyp.debug[mode] = 1
538
-
539
- # Do an extra check to avoid work when we're not debugging.
540
- if DEBUG_GENERAL in gyp.debug:
541
- DebugOutput(DEBUG_GENERAL, "running with these options:")
542
- for option, value in sorted(options.__dict__.items()):
543
- if option[0] == "_":
544
- continue
545
- if isinstance(value, str):
546
- DebugOutput(DEBUG_GENERAL, " %s: '%s'", option, value)
547
- else:
548
- DebugOutput(DEBUG_GENERAL, " %s: %s", option, value)
549
-
550
- if not build_files:
551
- build_files = FindBuildFiles()
552
- if not build_files:
553
- raise GypError((usage + "\n\n%s: error: no build_file") % (my_name, my_name))
554
-
555
- # TODO(mark): Chromium-specific hack!
556
- # For Chromium, the gyp "depth" variable should always be a relative path
557
- # to Chromium's top-level "src" directory. If no depth variable was set
558
- # on the command line, try to find a "src" directory by looking at the
559
- # absolute path to each build file's directory. The first "src" component
560
- # found will be treated as though it were the path used for --depth.
561
- if not options.depth:
562
- for build_file in build_files:
563
- build_file_dir = os.path.abspath(os.path.dirname(build_file))
564
- build_file_dir_components = build_file_dir.split(os.path.sep)
565
- components_len = len(build_file_dir_components)
566
- for index in range(components_len - 1, -1, -1):
567
- if build_file_dir_components[index] == "src":
568
- options.depth = os.path.sep.join(build_file_dir_components)
569
- break
570
- del build_file_dir_components[index]
571
-
572
- # If the inner loop found something, break without advancing to another
573
- # build file.
574
- if options.depth:
575
- break
576
-
577
- if not options.depth:
578
- raise GypError(
579
- "Could not automatically locate src directory. This is"
580
- "a temporary Chromium feature that will be removed. Use"
581
- "--depth as a workaround."
582
- )
583
-
584
- # If toplevel-dir is not set, we assume that depth is the root of our source
585
- # tree.
586
- if not options.toplevel_dir:
587
- options.toplevel_dir = options.depth
588
-
589
- # -D on the command line sets variable defaults - D isn't just for define,
590
- # it's for default. Perhaps there should be a way to force (-F?) a
591
- # variable's value so that it can't be overridden by anything else.
592
- cmdline_default_variables = {}
593
- defines = []
594
- if options.use_environment:
595
- defines += ShlexEnv("GYP_DEFINES")
596
- if options.defines:
597
- defines += options.defines
598
- cmdline_default_variables = NameValueListToDict(defines)
599
- if DEBUG_GENERAL in gyp.debug:
600
- DebugOutput(
601
- DEBUG_GENERAL, "cmdline_default_variables: %s", cmdline_default_variables
602
- )
603
-
604
- # Set up includes.
605
- includes = []
606
-
607
- # If ~/.gyp/include.gypi exists, it'll be forcibly included into every
608
- # .gyp file that's loaded, before anything else is included.
609
- if home_dot_gyp:
610
- default_include = os.path.join(home_dot_gyp, "include.gypi")
611
- if os.path.exists(default_include):
612
- print("Using overrides found in " + default_include)
613
- includes.append(default_include)
614
-
615
- # Command-line --include files come after the default include.
616
- if options.includes:
617
- includes.extend(options.includes)
618
-
619
- # Generator flags should be prefixed with the target generator since they
620
- # are global across all generator runs.
621
- gen_flags = []
622
- if options.use_environment:
623
- gen_flags += ShlexEnv("GYP_GENERATOR_FLAGS")
624
- if options.generator_flags:
625
- gen_flags += options.generator_flags
626
- generator_flags = NameValueListToDict(gen_flags)
627
- if DEBUG_GENERAL in gyp.debug:
628
- DebugOutput(DEBUG_GENERAL, "generator_flags: %s", generator_flags)
629
-
630
- # Generate all requested formats (use a set in case we got one format request
631
- # twice)
632
- for format in set(options.formats):
633
- params = {
634
- "options": options,
635
- "build_files": build_files,
636
- "generator_flags": generator_flags,
637
- "cwd": os.getcwd(),
638
- "build_files_arg": build_files_arg,
639
- "gyp_binary": sys.argv[0],
640
- "home_dot_gyp": home_dot_gyp,
641
- "parallel": options.parallel,
642
- "root_targets": options.root_targets,
643
- "target_arch": cmdline_default_variables.get("target_arch", ""),
644
- }
645
-
646
- # Start with the default variables from the command line.
647
- [generator, flat_list, targets, data] = Load(
648
- build_files,
649
- format,
650
- cmdline_default_variables,
651
- includes,
652
- options.depth,
653
- params,
654
- options.check,
655
- options.circular_check,
656
- )
657
-
658
- # TODO(mark): Pass |data| for now because the generator needs a list of
659
- # build files that came in. In the future, maybe it should just accept
660
- # a list, and not the whole data dict.
661
- # NOTE: flat_list is the flattened dependency graph specifying the order
662
- # that targets may be built. Build systems that operate serially or that
663
- # need to have dependencies defined before dependents reference them should
664
- # generate targets in the order specified in flat_list.
665
- generator.GenerateOutput(flat_list, targets, data, params)
666
-
667
- if options.configs:
668
- valid_configs = targets[flat_list[0]]["configurations"]
669
- for conf in options.configs:
670
- if conf not in valid_configs:
671
- raise GypError("Invalid config specified via --build: %s" % conf)
672
- generator.PerformBuild(data, options.configs, params)
673
-
674
- # Done
675
- return 0
676
-
677
-
678
- def main(args):
679
- try:
680
- return gyp_main(args)
681
- except GypError as e:
682
- sys.stderr.write("gyp: %s\n" % e)
683
- return 1
684
-
685
-
686
- # NOTE: setuptools generated console_scripts calls function with no arguments
687
- def script_main():
688
- return main(sys.argv[1:])
689
-
690
-
691
- if __name__ == "__main__":
692
- sys.exit(script_main())