@btc-vision/bitcoin 6.4.10 → 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 (207) 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/cjs/package.json +3 -3
  9. package/gulpfile.js +42 -42
  10. package/package.json +150 -150
  11. package/src/bip66.ts +107 -107
  12. package/src/block.ts +233 -233
  13. package/src/bufferutils.ts +188 -188
  14. package/src/crypto.ts +108 -108
  15. package/src/ecc_lib.ts +94 -94
  16. package/src/hooks/AdvancedSignatureManager.ts +104 -104
  17. package/src/hooks/SignatureManager.ts +84 -84
  18. package/src/index.ts +105 -105
  19. package/src/merkle.ts +31 -31
  20. package/src/opcodes.ts +280 -280
  21. package/src/payments/bip341.ts +140 -140
  22. package/src/payments/embed.ts +61 -61
  23. package/src/payments/index.ts +172 -172
  24. package/src/payments/lazy.ts +28 -28
  25. package/src/payments/p2ms.ts +156 -156
  26. package/src/payments/p2op.ts +195 -195
  27. package/src/payments/p2pk.ts +93 -93
  28. package/src/payments/p2pkh.ts +214 -214
  29. package/src/payments/p2tr.ts +309 -309
  30. package/src/psbt/bip371.ts +441 -441
  31. package/src/push_data.ts +97 -97
  32. package/src/script.ts +247 -247
  33. package/src/script_number.ts +72 -72
  34. package/src/script_signature.ts +91 -91
  35. package/src/transaction.ts +656 -656
  36. package/test/address.spec.ts +155 -155
  37. package/test/bitcoin.core.spec.ts +212 -212
  38. package/test/block.spec.ts +171 -171
  39. package/test/bufferutils.spec.ts +450 -450
  40. package/test/crypto.spec.ts +49 -49
  41. package/test/fixtures/address.json +329 -329
  42. package/test/fixtures/block.json +148 -148
  43. package/test/fixtures/bufferutils.json +102 -102
  44. package/test/fixtures/core/README.md +26 -26
  45. package/test/fixtures/core/base58_encode_decode.json +50 -50
  46. package/test/fixtures/core/base58_keys_invalid.json +152 -152
  47. package/test/fixtures/core/base58_keys_valid.json +452 -452
  48. package/test/fixtures/core/blocks.json +27 -27
  49. package/test/fixtures/core/sig_canonical.json +7 -7
  50. package/test/fixtures/core/sig_noncanonical.json +33 -33
  51. package/test/fixtures/core/sighash.json +3505 -3505
  52. package/test/fixtures/core/tx_valid.json +2023 -2023
  53. package/test/fixtures/crypto.json +43 -43
  54. package/test/fixtures/ecdsa.json +217 -217
  55. package/test/fixtures/ecpair.json +141 -141
  56. package/test/fixtures/embed.json +108 -108
  57. package/test/fixtures/p2ms.json +434 -434
  58. package/test/fixtures/p2pk.json +179 -179
  59. package/test/fixtures/p2pkh.json +276 -276
  60. package/test/fixtures/p2sh.json +508 -508
  61. package/test/fixtures/p2tr.json +1198 -1198
  62. package/test/fixtures/p2wpkh.json +290 -290
  63. package/test/fixtures/p2wsh.json +489 -489
  64. package/test/fixtures/psbt.json +924 -924
  65. package/test/fixtures/script.json +465 -465
  66. package/test/fixtures/script_number.json +225 -225
  67. package/test/fixtures/signature.json +140 -140
  68. package/test/fixtures/transaction.json +916 -916
  69. package/test/integration/_regtest.ts +6 -6
  70. package/test/integration/addresses.spec.ts +142 -142
  71. package/test/integration/bip32.spec.ts +130 -130
  72. package/test/integration/blocks.spec.ts +28 -28
  73. package/test/integration/cltv.spec.ts +241 -241
  74. package/test/integration/csv.spec.ts +452 -452
  75. package/test/integration/payments.spec.ts +110 -110
  76. package/test/integration/taproot.spec.ts +663 -663
  77. package/test/integration/transactions.spec.ts +668 -668
  78. package/test/payments.spec.ts +114 -114
  79. package/test/payments.utils.ts +165 -165
  80. package/test/psbt.spec.ts +1285 -1285
  81. package/test/script.spec.ts +186 -186
  82. package/test/script_number.spec.ts +26 -26
  83. package/test/script_signature.spec.ts +66 -66
  84. package/test/transaction.spec.ts +337 -337
  85. package/test/ts-node-register.js +7 -7
  86. package/test/tsconfig.json +48 -48
  87. package/test/types.spec.ts +53 -53
  88. package/tsconfig.base.json +27 -27
  89. package/tsconfig.json +19 -19
  90. package/tsconfig.webpack.json +18 -18
  91. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/.ready +0 -0
  92. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/.release-please-manifest.json +0 -3
  93. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/CHANGELOG.md +0 -962
  94. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/CONTRIBUTING.md +0 -34
  95. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/LICENSE +0 -24
  96. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/README.md +0 -273
  97. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/SECURITY.md +0 -2
  98. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/addon.gypi +0 -204
  99. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/bin/node-gyp.js +0 -138
  100. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/.release-please-manifest.json +0 -3
  101. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/LICENSE +0 -28
  102. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/data/ninja/build.ninja +0 -4
  103. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/data/win/large-pdb-shim.cc +0 -12
  104. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/GypVsCMake.md +0 -116
  105. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/Hacking.md +0 -46
  106. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/InputFormatReference.md +0 -1080
  107. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/LanguageSpecification.md +0 -430
  108. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/README.md +0 -27
  109. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/Testing.md +0 -450
  110. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/UserDocumentation.md +0 -965
  111. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/gyp +0 -8
  112. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/gyp.bat +0 -5
  113. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/gyp_main.py +0 -45
  114. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +0 -365
  115. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSProject.py +0 -206
  116. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py +0 -1272
  117. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py +0 -1547
  118. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSToolFile.py +0 -59
  119. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSUserFile.py +0 -153
  120. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSUtil.py +0 -271
  121. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +0 -574
  122. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/__init__.py +0 -692
  123. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/common.py +0 -711
  124. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/common_test.py +0 -171
  125. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py +0 -169
  126. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py +0 -113
  127. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/flock_tool.py +0 -55
  128. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/__init__.py +0 -0
  129. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py +0 -804
  130. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py +0 -1173
  131. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py +0 -1318
  132. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/compile_commands_json.py +0 -127
  133. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/dump_dependency_json.py +0 -103
  134. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py +0 -461
  135. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/gypd.py +0 -89
  136. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/gypsh.py +0 -57
  137. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +0 -2745
  138. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +0 -3976
  139. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py +0 -44
  140. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +0 -2964
  141. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py +0 -67
  142. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py +0 -1391
  143. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode_test.py +0 -25
  144. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/input.py +0 -3115
  145. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/input_test.py +0 -98
  146. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/mac_tool.py +0 -771
  147. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +0 -1260
  148. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/ninja_syntax.py +0 -174
  149. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py +0 -61
  150. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/win_tool.py +0 -373
  151. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py +0 -1938
  152. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation_test.py +0 -53
  153. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py +0 -302
  154. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +0 -3198
  155. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xml_fix.py +0 -65
  156. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/LICENSE +0 -3
  157. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/LICENSE.APACHE +0 -177
  158. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/LICENSE.BSD +0 -23
  159. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/__init__.py +0 -15
  160. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_elffile.py +0 -108
  161. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_manylinux.py +0 -252
  162. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_musllinux.py +0 -83
  163. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_parser.py +0 -359
  164. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_structures.py +0 -61
  165. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_tokenizer.py +0 -192
  166. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/markers.py +0 -252
  167. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/metadata.py +0 -825
  168. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/py.typed +0 -0
  169. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/requirements.py +0 -90
  170. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/specifiers.py +0 -1030
  171. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/tags.py +0 -553
  172. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/utils.py +0 -172
  173. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/version.py +0 -563
  174. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pyproject.toml +0 -120
  175. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/release-please-config.json +0 -11
  176. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/test_gyp.py +0 -261
  177. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/Find-VisualStudio.cs +0 -250
  178. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/build.js +0 -227
  179. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/clean.js +0 -15
  180. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/configure.js +0 -328
  181. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/create-config-gypi.js +0 -150
  182. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/download.js +0 -39
  183. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/find-node-directory.js +0 -63
  184. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/find-python.js +0 -310
  185. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/find-visualstudio.js +0 -590
  186. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/install.js +0 -415
  187. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/list.js +0 -26
  188. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/log.js +0 -168
  189. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/node-gyp.js +0 -188
  190. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/process-release.js +0 -146
  191. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/rebuild.js +0 -12
  192. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/remove.js +0 -43
  193. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/util.js +0 -81
  194. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/macOS_Catalina_acid_test.sh +0 -21
  195. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/package.json +0 -51
  196. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/release-please-config.json +0 -40
  197. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/src/win_delay_load_hook.cc +0 -39
  198. package/browser/ops.d.ts +0 -126
  199. package/build/ops.d.ts +0 -126
  200. package/build/ops.js +0 -127
  201. package/coverage/tmp/coverage-31752-1735543485354-0.json +0 -1
  202. package/coverage/tmp/coverage-59920-1735543484555-0.json +0 -1
  203. package/coverage/tmp/coverage-66252-1735543483919-0.json +0 -1
  204. package/coverage/tmp/coverage-68440-1735543485236-0.json +0 -1
  205. package/coverage/tmp/coverage-70588-1735543484426-0.json +0 -1
  206. package/coverage/tmp/coverage-79292-1735543485296-0.json +0 -1
  207. package/coverage/tmp/coverage-80212-1735543483980-0.json +0 -1
@@ -1,1080 +0,0 @@
1
- # Input Format Reference
2
-
3
- ## Primitive Types
4
-
5
- The following primitive types are found within input files:
6
-
7
- * String values, which may be represented by enclosing them in
8
- `'single quotes'` or `"double quotes"`. By convention, single
9
- quotes are used.
10
- * Integer values, which are represented in decimal without any special
11
- decoration. Integers are fairly rare in input files, but have a few
12
- applications in boolean contexts, where the convention is to
13
- represent true values with `1` and false with `0`.
14
- * Lists, which are represented as a sequence of items separated by
15
- commas (`,`) within square brackets (`[` and `]`). A list may
16
- contain any other primitive types, including other lists.
17
- Generally, each item of a list must be of the same type as all other
18
- items in the list, but in some cases (such as within `conditions`
19
- sections), the list structure is more tightly specified. A trailing
20
- comma is permitted.
21
-
22
- This example list contains three string values.
23
-
24
- ```
25
- [ 'Generate', 'Your', 'Projects', ]
26
- ```
27
-
28
- * Dictionaries, which map keys to values. All keys are strings.
29
- Values may be of any other primitive type, including other
30
- dictionaries. A dictionary is enclosed within curly braces (`{` and
31
- `}`). Keys precede values, separated by a colon (`:`). Successive
32
- dictionary entries are separated by commas (`,`). A trailing comma
33
- is permitted. It is an error for keys to be duplicated within a
34
- single dictionary as written in an input file, although keys may
35
- replace other keys during [merging](#Merging).
36
-
37
- This example dictionary maps each of three keys to different values.
38
-
39
- ```
40
- {
41
- 'inputs': ['version.c.in'],
42
- 'outputs': ['version.c'],
43
- 'process_outputs_as_sources': 1,
44
- }
45
- ```
46
-
47
- ## Overall Structure
48
-
49
- A GYP input file is organized as structured data. At the root scope of
50
- each `.gyp` or `.gypi` (include) file is a dictionary. The keys and
51
- values of this dictionary, along with any descendants contained within
52
- the values, provide the data contained within the file. This data is
53
- given meaning by interpreting specific key names and their associated
54
- values in specific ways (see [Settings Keys](#Settings_Keys)).
55
-
56
- ### Comments (#)
57
-
58
- Within an input file, a comment is introduced by a pound sign (`#`) not
59
- within a string. Any text following the pound sign, up until the end of
60
- the line, is treated as a comment.
61
-
62
- #### Example
63
-
64
- ```
65
- {
66
- 'school_supplies': [
67
- 'Marble composition book',
68
- 'Sharp #2 pencil',
69
- 'Safety scissors', # You still shouldn't run with these
70
- ],
71
- }
72
- ```
73
-
74
- In this example, the # in `'Sharp #2 pencil'` is not taken as
75
- introducing a comment because it occurs within a string, but the text
76
- after `'Safety scissors'` is treated as a comment having no impact on
77
- the data within the file.
78
-
79
- ## Merging
80
-
81
- ### Merge Basics (=, ?, +)
82
-
83
- Many operations on GYP input files occurs by merging dictionary and list
84
- items together. During merge operations, it is important to recognize
85
- the distinction between source and destination values. Items from the
86
- source value are merged into the destination, which leaves the source
87
- unchanged and the destination modified by the source. A dictionary may
88
- only be merged into another dictionary, and a list may only be merged
89
- into another list.
90
-
91
- * When merging a dictionary, for each key in the source:
92
- * If the key does not exist in the destination dictionary, insert it
93
- and copy the associated value directly.
94
- * If the key does exist:
95
- * If the associated value is a dictionary, perform the dictionary
96
- merging procedure using the source's and destination's value
97
- dictionaries.
98
- * If the associated value is a list, perform the list merging
99
- procedure using the source's and destination's value lists.
100
- * If the associated value is a string or integer, the destination
101
- value is replaced by the source value.
102
- * When merging a list, merge according to the suffix appended to the
103
- key name, if the list is a value within a dictionary.
104
- * If the key ends with an equals sign (`=`), the policy is for the
105
- source list to completely replace the destination list if it
106
- exists. _Mnemonic: `=` for assignment._
107
- * If the key ends with a question mark (`?`), the policy is for the
108
- source list to be set as the destination list only if the key is
109
- not already present in the destination. _Mnemonic: `?` for
110
- conditional assignment_.
111
- * If the key ends with a plus sign (`+`), the policy is for the
112
- source list contents to be prepended to the destination list.
113
- _Mnemonic: `+` for addition or concatenation._
114
- * If the list key is undecorated, the policy is for the source list
115
- contents to be appended to the destination list. This is the
116
- default list merge policy.
117
-
118
- #### Example
119
-
120
- Source dictionary:
121
-
122
- ```
123
- {
124
- 'include_dirs+': [
125
- 'shared_stuff/public',
126
- ],
127
- 'link_settings': {
128
- 'libraries': [
129
- '-lshared_stuff',
130
- ],
131
- },
132
- 'test': 1,
133
- }
134
- ```
135
-
136
- Destination dictionary:
137
-
138
- ```
139
- {
140
- 'target_name': 'hello',
141
- 'sources': [
142
- 'kitty.cc',
143
- ],
144
- 'include_dirs': [
145
- 'headers',
146
- ],
147
- 'link_settings': {
148
- 'libraries': [
149
- '-lm',
150
- ],
151
- 'library_dirs': [
152
- '/usr/lib',
153
- ],
154
- },
155
- 'test': 0,
156
- }
157
- ```
158
-
159
- Merged dictionary:
160
-
161
- ```
162
- {
163
- 'target_name': 'hello',
164
- 'sources': [
165
- 'kitty.cc',
166
- ],
167
- 'include_dirs': [
168
- 'shared_stuff/public', # Merged, list item prepended due to include_dirs+
169
- 'headers',
170
- ],
171
- 'link_settings': {
172
- 'libraries': [
173
- '-lm',
174
- '-lshared_stuff', # Merged, list item appended
175
- ],
176
- 'library_dirs': [
177
- '/usr/lib',
178
- ],
179
- },
180
- 'test': 1, # Merged, int value replaced
181
- }
182
- ```
183
-
184
- ## Pathname Relativization
185
-
186
- In a `.gyp` or `.gypi` file, many string values are treated as pathnames
187
- relative to the file in which they are defined.
188
-
189
- String values associated with the following keys, or contained within
190
- lists associated with the following keys, are treated as pathnames:
191
-
192
- * destination
193
- * files
194
- * include\_dirs
195
- * inputs
196
- * libraries
197
- * outputs
198
- * sources
199
- * mac\_bundle\_resources
200
- * mac\_framework\_dirs
201
- * msvs\_cygwin\_dirs
202
- * msvs\_props
203
-
204
- Additionally, string values associated with keys ending in the following
205
- suffixes, or contained within lists associated with keys ending in the
206
- following suffixes, are treated as pathnames:
207
-
208
- * `_dir`
209
- * `_dirs`
210
- * `_file`
211
- * `_files`
212
- * `_path`
213
- * `_paths`
214
-
215
- However, any string value beginning with any of these characters is
216
- excluded from pathname relativization:
217
-
218
- * `/` for identifying absolute paths.
219
- * `$` for introducing build system variable expansions.
220
- * `-` to support specifying such items as `-llib`, meaning “library
221
- `lib` in the library search path.”
222
- * `<`, `>`, and `!` for GYP expansions.
223
-
224
- When merging such relative pathnames, they are adjusted so that they can
225
- remain valid relative pathnames, despite being relative to a new home.
226
-
227
- #### Example
228
-
229
- Source dictionary from `../build/common.gypi`:
230
-
231
- ```
232
- {
233
- 'include_dirs': ['include'], # Treated as relative to ../build
234
- 'libraries': ['-lz'], # Not treated as a pathname, begins with a dash
235
- 'defines': ['NDEBUG'], # defines does not contain pathnames
236
- }
237
- ```
238
-
239
- Target dictionary, from `base.gyp`:
240
-
241
- ```
242
- {
243
- 'sources': ['string_util.cc'],
244
- }
245
- ```
246
-
247
- Merged dictionary:
248
-
249
- ```
250
- {
251
- 'sources': ['string_util.cc'],
252
- 'include_dirs': ['../build/include'],
253
- 'libraries': ['-lz'],
254
- 'defines': ['NDEBUG'],
255
- }
256
- ```
257
-
258
- Because of pathname relativization, after the merge is complete, all of
259
- the pathnames in the merged dictionary are valid relative to the
260
- directory containing `base.gyp`.
261
-
262
- ## List Singletons
263
-
264
- Some list items are treated as singletons, and the list merge process
265
- will enforce special rules when merging them. At present, any string
266
- item in a list that does not begin with a dash (`-`) is treated as a
267
- singleton, although **this is subject to change.** When appending or
268
- prepending a singleton to a list, if the item is already in the list,
269
- only the earlier instance is retained in the merged list.
270
-
271
- #### Example
272
-
273
- Source dictionary:
274
-
275
- ```
276
- {
277
- 'defines': [
278
- 'EXPERIMENT=1',
279
- 'NDEBUG',
280
- ],
281
- }
282
- ```
283
-
284
- Destination dictionary:
285
-
286
- ```
287
- {
288
- 'defines': [
289
- 'NDEBUG',
290
- 'USE_THREADS',
291
- ],
292
- }
293
- ```
294
-
295
- Merged dictionary:
296
-
297
- ```
298
- {
299
- 'defines': [
300
- 'NDEBUG',
301
- 'USE_THREADS',
302
- 'EXPERIMENT=1', # Note that NDEBUG is not appended after this.
303
- ],
304
- }
305
- ```
306
-
307
- ## Including Other Files
308
-
309
- If the `-I` (`--include`) argument was used to invoke GYP, any files
310
- specified will be implicitly merged into the root dictionary of all
311
- `.gyp` files.
312
-
313
- An [includes](#includes) section may be placed anywhere within a
314
- `.gyp` or `.gypi` (include) file. `includes` sections contain lists of
315
- other files to include. They are processed sequentially and merged into
316
- the enclosing dictionary at the point that the `includes` section was
317
- found. `includes` sections at the root of a `.gyp` file dictionary are
318
- merged after any `-I` includes from the command line.
319
-
320
- [includes](#includes) sections are processed immediately after a file is
321
- loaded, even before [variable and conditional
322
- processing](#Variables_and_Conditionals), so it is not possible to
323
- include a file based on a [variable reference](#Variable_Expansions).
324
- While it would be useful to be able to include files based on variable
325
- expansions, it is most likely more useful to allow included files access
326
- to variables set by the files that included them.
327
-
328
- An [includes](#includes) section may, however, be placed within a
329
- [conditional](#Conditionals) section. The included file itself will
330
- be loaded unconditionally, but its dictionary will be discarded if the
331
- associated condition is not true.
332
-
333
- ## Variables and Conditionals
334
-
335
- ### Variables
336
-
337
- There are three main types of variables within GYP.
338
-
339
- * Predefined variables. By convention, these are named with
340
- `CAPITAL_LETTERS`. Predefined variables are set automatically by
341
- GYP. They may be overridden, but it is not advisable to do so. See
342
- [Predefined Variables](#Predefined_Variables) for a list of
343
- variables that GYP provides.
344
- * User-defined variables. Within any dictionary, a key named
345
- `variables` can be provided, containing a mapping between variable
346
- names (keys) and their contents (values), which may be strings,
347
- integers, or lists of strings. By convention, user-defined
348
- variables are named with `lowercase_letters`.
349
- * Automatic variables. Within any dictionary, any key with a string
350
- value has a corresponding automatic variable whose name is the same
351
- as the key name with an underscore (`_`) prefixed. For example, if
352
- your dictionary contains `type: 'static_library'`, an automatic
353
- variable named `_type` will be provided, and its value will be a
354
- string, `'static_library'`.
355
-
356
- Variables are inherited from enclosing scopes.
357
-
358
- ### Providing Default Values for Variables (%)
359
-
360
- Within a `variables` section, keys named with percent sign (`%`)
361
- suffixes mean that the variable should be set only if it is undefined at
362
- the time it is processed. This can be used to provide defaults for
363
- variables that would otherwise be undefined, so that they may reliably
364
- be used in [variable expansion or conditional
365
- processing](#Variables_and_Conditionals).
366
-
367
- ### Predefined Variables
368
-
369
- Each GYP generator module provides defaults for the following variables:
370
-
371
- * `OS`: The name of the operating system that the generator produces
372
- output for. Common values for values for `OS` are:
373
-
374
- * `'linux'`
375
- * `'mac'`
376
- * `'win'`
377
-
378
- But other values may be encountered and this list should not be
379
- considered exhaustive. The `gypd` (debug) generator module does not
380
- provide a predefined value for `OS`. When invoking GYP with the
381
- `gypd` module, if a value for `OS` is needed, it must be provided on
382
- the command line, such as `gyp -f gypd -DOS=mac`.
383
-
384
- GYP generators also provide defaults for these variables. They may
385
- be expressed in terms of variables used by the build system that
386
- they generate for, often in `$(VARIABLE)` format. For example, the
387
- GYP `PRODUCT_DIR` variable maps to the Xcode `BUILT_PRODUCTS_DIR`
388
- variable, so `PRODUCT_DIR` is defined by the Xcode generator as
389
- `$(BUILT_PRODUCTS_DIR)`.
390
- * `EXECUTABLE_PREFIX`: A prefix, if any, applied to executable names.
391
- Usually this will be an empty string.
392
- * `EXECUTABLE_SUFFIX`: A suffix, if any, applied to executable names.
393
- On Windows, this will be `.exe`, elsewhere, it will usually be an
394
- empty string.
395
- * `INTERMEDIATE_DIR`: A directory that can be used to place
396
- intermediate build results in. `INTERMEDIATE_DIR` is only
397
- guaranteed to be accessible within a single target (See targets).
398
- This variable is most useful within the context of rules and actions
399
- (See rules, See actions). Compare with `SHARED_INTERMEDIATE_DIR`.
400
- * `PRODUCT_DIR`: The directory in which the primary output of each
401
- target, such as executables and libraries, is placed.
402
- * `RULE_INPUT_ROOT`: The base name for the input file (e.g. "`foo`").
403
- See Rules.
404
- * `RULE_INPUT_EXT`: The file extension for the input file (e.g.
405
- "`.cc`"). See Rules.
406
- * `RULE_INPUT_NAME`: Full name of the input file (e.g. "`foo.cc`").
407
- See Rules.
408
- * `RULE_INPUT_PATH`: Full path to the input file (e.g.
409
- "`/bar/foo.cc`"). See Rules.
410
- * `SHARED_INTERMEDIATE_DIR`: A directory that can be used to place
411
- intermediate build results in, and have them be accessible to other
412
- targets. Unlike `INTERMEDIATE_DIR`, each target in a project,
413
- possibly spanning multiple `.gyp` files, shares the same
414
- `SHARED_INTERMEDIATE_DIR`.
415
-
416
- The following additional predefined variables may be available under
417
- certain circumstances:
418
-
419
- * `DEPTH`. When GYP is invoked with a `--depth` argument, when
420
- processing any `.gyp` file, `DEPTH` will be a relative path from the
421
- `.gyp` file to the directory specified by the `--depth` argument.
422
-
423
- ### User-Defined Variables
424
-
425
- A user-defined variable may be defined in terms of other variables, but
426
- not other variables that have definitions provided in the same scope.
427
-
428
- ### Variable Expansions (<, >, <@, >@)
429
-
430
- GYP provides two forms of variable expansions, “early” or “pre”
431
- expansions, and “late,” “post,” or “target” expansions. They have
432
- similar syntax, differing only in the character used to introduce them.
433
-
434
- * Early expansions are introduced by a less-than (`<`) character.
435
- _Mnemonic: the arrow points to the left, earlier on a timeline._
436
- * Late expansions are introduced by a less-than (`>`) character.
437
- _Mnemonic: the arrow points to the right, later on a timeline._
438
-
439
- The difference the two phases of expansion is described in [Early and
440
- Late Phases](#Early_and_Late_Phases).
441
-
442
- These characters were chosen based upon the requirement that they not
443
- conflict with the variable format used natively by build systems. While
444
- the dollar sign (`$`) is the most natural fit for variable expansions,
445
- its use was ruled out because most build systems already use that
446
- character for their own variable expansions. Using different characters
447
- means that no escaping mechanism was needed to differentiate between GYP
448
- variables and build system variables, and writing build system variables
449
- into GYP files is not cumbersome.
450
-
451
- Variables may contain lists or strings, and variable expansions may
452
- occur in list or string context. There are variant forms of variable
453
- expansions that may be used to determine how each type of variable is to
454
- be expanded in each context.
455
-
456
- * When a variable is referenced by `<(VAR)` or `>(VAR)`:
457
- * If `VAR` is a string, the variable reference within the string is
458
- replaced by variable's string value.
459
- * If `VAR` is a list, the variable reference within the string is
460
- replaced by a string containing the concatenation of all of the
461
- variable’s list items. Generally, the items are joined with
462
- spaces between each, but the specific behavior is
463
- generator-specific. The precise encoding used by any generator
464
- should be one that would allow each list item to be treated as a
465
- separate argument when used as program arguments on the system
466
- that the generator produces output for.
467
- * When a variable is referenced by `<@(VAR)` or `>@(VAR)`:
468
- * The expansion must occur in list context.
469
- * The list item must be `'<@(VAR)'` or `'>@(VAR)'` exactly.
470
- * If `VAR` is a list, each of its elements are inserted into the
471
- list in which expansion is taking place, replacing the list item
472
- containing the variable reference.
473
- * If `VAR` is a string, the string is converted to a list which is
474
- inserted into the list in which expansion is taking place as
475
- above. The conversion into a list is generator-specific, but
476
- generally, spaces in the string are taken as separators between
477
- list items. The specific method of converting the string to a
478
- list should be the inverse of the encoding method used to expand
479
- list variables in string context, above.
480
-
481
- GYP treats references to undefined variables as errors.
482
-
483
- ### Command Expansions (<!, <!@)
484
-
485
- Command expansions function similarly to variable expansions, but
486
- instead of resolving variable references, they cause GYP to execute a
487
- command at generation time and use the command’s output as the
488
- replacement. Command expansions are introduced by a less than and
489
- exclamation mark (`<!`).
490
-
491
- In a command expansion, the entire string contained within the
492
- parentheses is passed to the system’s shell. The command’s output is
493
- assigned to a string value that may subsequently be expanded in list
494
- context in the same way as variable expansions if an `@` character is
495
- used.
496
-
497
- In addition, command expansions (unlike other variable expansions) may
498
- include nested variable expansions. So something like this is allowed:
499
-
500
- ```
501
- 'variables' : [
502
- 'foo': '<!(echo Build Date <!(date))',
503
- ],
504
- ```
505
-
506
- expands to:
507
-
508
- ```
509
- 'variables' : [
510
- 'foo': 'Build Date 02:10:38 PM Fri Jul 24, 2009 -0700 PDT',
511
- ],
512
- ```
513
-
514
- You may also put commands into arrays in order to quote arguments (but
515
- note that you need to use a different string quoting character):
516
-
517
- ```
518
- 'variables' : [
519
- 'files': '<!(["ls", "-1", "Filename With Spaces"])',
520
- ],
521
- ```
522
-
523
- GYP treats command failures (as indicated by a nonzero exit status)
524
- during command expansion as errors.
525
-
526
- #### Example
527
-
528
- ```
529
- {
530
- 'sources': [
531
- '!(echo filename with space.cc)',
532
- ],
533
- 'libraries': [
534
- '!@(pkg-config --libs-only-l apr-1)',
535
- ],
536
- }
537
- ```
538
-
539
- might expand to:
540
-
541
- ```
542
- {
543
- 'sources': [
544
- 'filename with space.cc', # no @, expands into a single string
545
- ],
546
- 'libraries': [ # @ was used, so there's a separate list item for each lib
547
- '-lapr-1',
548
- '-lpthread',
549
- ],
550
- }
551
- ```
552
-
553
- ## Conditionals
554
-
555
- Conditionals use the same set of variables used for variable expansion.
556
- As with variable expansion, there are two phases of conditional
557
- evaluation:
558
-
559
- * “Early” or “pre” conditional evaluation, introduced in
560
- [conditions](#conditions) sections.
561
- * “Late,” “post,” or “target” conditional evaluation, introduced in
562
- [target\_conditions](#target_conditions) sections.
563
-
564
- The syntax for each type is identical, they differ only in the key name
565
- used to identify them and the timing of their evaluation. A more
566
- complete description of syntax and use is provided in
567
- [conditions](#conditions).
568
-
569
- The difference the two phases of evaluation is described in [Early and
570
- Late Phases](#Early_and_Late_Phases).
571
-
572
- ## Timing of Variable Expansion and Conditional Evaluation
573
-
574
- ### Early and Late Phases
575
-
576
- GYP performs two phases of variable expansion and conditional evaluation:
577
-
578
- * The “early” or “pre” phase operates on [conditions](#conditions)
579
- sections and the `<` form of [variable
580
- expansions](#Variable_Expansions).
581
- * The “late,” “post,” or “target” phase operates on
582
- [target\_conditions](#target_conditions) sections, the `>` form
583
- of [variable expansions](#Variable_Expansions),
584
- and on the `!` form of [command
585
- expansions](#Command_Expansions_(!,_!@)).
586
-
587
- These two phases are provided because there are some circumstances in
588
- which each is desirable.
589
-
590
- The “early” phase is appropriate for most expansions and evaluations.
591
- “Early” expansions and evaluations may be performed anywhere within any
592
- `.gyp` or `.gypi` file.
593
-
594
- The “late” phase is appropriate when expansion or evaluation must be
595
- deferred until a specific section has been merged into target context.
596
- “Late” expansions and evaluations only occur within `targets` sections
597
- and their descendants. The typical use case for a late-phase expansion
598
- is to provide, in some globally-included `.gypi` file, distinct
599
- behaviors depending on the specifics of a target.
600
-
601
- #### Example
602
-
603
- Given this input:
604
-
605
- ```
606
- {
607
- 'target_defaults': {
608
- 'target_conditions': [
609
- ['_type=="shared_library"', {'cflags': ['-fPIC']}],
610
- ],
611
- },
612
- 'targets': [
613
- {
614
- 'target_name': 'sharing_is_caring',
615
- 'type': 'shared_library',
616
- },
617
- {
618
- 'target_name': 'static_in_the_attic',
619
- 'type': 'static_library',
620
- },
621
- ]
622
- }
623
- ```
624
-
625
- The conditional needs to be evaluated only in target context; it is
626
- nonsense outside of target context because no `_type` variable is
627
- defined. [target\_conditions](#target_conditions) allows evaluation
628
- to be deferred until after the [targets](#targets) sections are
629
- merged into their copies of [target\_defaults](#target_defaults).
630
- The resulting targets, after “late” phase processing:
631
-
632
- ```
633
- {
634
- 'targets': [
635
- {
636
- 'target_name': 'sharing_is_caring',
637
- 'type': 'shared_library',
638
- 'cflags': ['-fPIC'],
639
- },
640
- {
641
- 'target_name': 'static_in_the_attic',
642
- 'type': 'static_library',
643
- },
644
- ]
645
- }
646
- ```
647
-
648
- ### Expansion and Evaluation Performed Simultaneously
649
-
650
- During any expansion and evaluation phase, both expansion and evaluation
651
- are performed simultaneously. The process for handling variable
652
- expansions and conditional evaluation within a dictionary is:
653
-
654
- * Load [automatic variables](#Variables) (those with leading
655
- underscores).
656
- * If a [variables](#variables) section is present, recurse into its
657
- dictionary. This allows [conditionals](#Conditionals) to be
658
- present within the `variables` dictionary.
659
- * Load [Variables user-defined variables](#User-Defined) from the
660
- [variables](#variables) section.
661
- * For each string value in the dictionary, perform [variable
662
- expansion](#Variable_Expansions) and, if operating
663
- during the “late” phase, [command
664
- expansions](#Command_Expansions).
665
- * Reload [automatic variables](#Variables) and [Variables
666
- user-defined variables](#User-Defined) because the variable
667
- expansion step may have resulted in changes to the automatic
668
- variables.
669
- * If a [conditions](#conditions) or
670
- [target\_conditions](#target_conditions) section (depending on
671
- phase) is present, recurse into its dictionary. This is done after
672
- variable expansion so that conditionals may take advantage of
673
- expanded automatic variables.
674
- * Evaluate [conditionals](#Conditionals).
675
- * Reload [automatic variables](#Variables) and [Variables
676
- user-defined variables](#User-Defined) because the conditional
677
- evaluation step may have resulted in changes to the automatic
678
- variables.
679
- * Recurse into child dictionaries or lists that have not yet been
680
- processed.
681
-
682
- One quirk of this ordering is that you cannot expect a
683
- [variables](#variables) section within a dictionary’s
684
- [conditional](#Conditionals) to be effective in the dictionary
685
- itself, but the added variables will be effective in any child
686
- dictionaries or lists. It is thought to be far more worthwhile to
687
- provide resolved [automatic variables](#Variables) to
688
- [conditional](#Conditionals) sections, though. As a workaround, to
689
- conditionalize variable values, place a [conditions](#conditions) or
690
- [target\_conditions](#target_conditions) section within the
691
- [variables](#variables) section.
692
-
693
- ## Dependencies and Dependents
694
-
695
- In GYP, “dependents” are targets that rely on other targets, called
696
- “dependencies.” Dependents declare their reliance with a special
697
- section within their target dictionary,
698
- [dependencies](#dependencies).
699
-
700
- ### Dependent Settings
701
-
702
- It is useful for targets to “advertise” settings to their dependents.
703
- For example, a target might require that all of its dependents add
704
- certain directories to their include paths, link against special
705
- libraries, or define certain preprocessor macros. GYP allows these
706
- cases to be handled gracefully with “dependent settings” sections.
707
- There are three types of such sections:
708
-
709
- * [direct\_dependent\_settings](#direct_dependent_settings), which
710
- advertises settings to a target's direct dependents only.
711
- * [all\_dependent\_settings](#all_dependnet_settings), which
712
- advertises settings to all of a target's dependents, both direct and
713
- indirect.
714
- * [link\_settings](#link_settings), which contains settings that
715
- should be applied when a target’s object files are used as linker
716
- input.
717
-
718
- Furthermore, in some cases, a target needs to pass its dependencies’
719
- settings on to its own dependents. This might happen when a target’s
720
- own public header files include header files provided by its dependency.
721
- [export\_dependent\_settings](#export_dependent_settings) allows a
722
- target to declare dependencies for which
723
- [direct\_dependent\_settings](#direct_dependent_settings) should be
724
- passed through to its own dependents.
725
-
726
- Dependent settings processing merges a copy of the relevant dependent
727
- settings dictionary from a dependency into its relevant dependent
728
- targets.
729
-
730
- In most instances,
731
- [direct\_dependent\_settings](#direct_dependent_settings) will be
732
- used. There are very few cases where
733
- [all\_dependent\_settings](#all_dependent_settings) is actually
734
- correct; in most of the cases where it is tempting to use, it would be
735
- preferable to declare
736
- [export\_dependent\_settings](#export_dependent_settings). Most
737
- [libraries](#libraries) and [library\_dirs](#library_dirs)
738
- sections should be placed within [link\_settings](#link_settings)
739
- sections.
740
-
741
- #### Example
742
-
743
- Given:
744
-
745
- ```
746
- {
747
- 'targets': [
748
- {
749
- 'target_name': 'cruncher',
750
- 'type': 'static_library',
751
- 'sources': ['cruncher.cc'],
752
- 'direct_dependent_settings': {
753
- 'include_dirs': ['.'], # dependents need to find cruncher.h.
754
- },
755
- 'link_settings': {
756
- 'libraries': ['-lm'], # cruncher.cc does math.
757
- },
758
- },
759
- {
760
- 'target_name': 'cruncher_test',
761
- 'type': 'executable',
762
- 'dependencies': ['cruncher'],
763
- 'sources': ['cruncher_test.cc'],
764
- },
765
- ],
766
- }
767
- ```
768
-
769
- After dependent settings processing, the dictionary for `cruncher_test`
770
- will be:
771
-
772
- ```
773
- {
774
- 'target_name': 'cruncher_test',
775
- 'type': 'executable',
776
- 'dependencies': ['cruncher'], # implies linking against cruncher
777
- 'sources': ['cruncher_test.cc'],
778
- 'include_dirs': ['.']
779
- 'libraries': ['-lm'],
780
- },
781
- ```
782
-
783
- If `cruncher` was declared as a `shared_library` instead of a
784
- `static_library`, the `cruncher_test` target would not contain `-lm`,
785
- but instead, `cruncher` itself would link against `-lm`.
786
-
787
- ## Linking Dependencies
788
-
789
- The precise meaning of a dependency relationship varies with the
790
- [types](#type) of the [targets](#targets) at either end of the
791
- relationship. In GYP, a dependency relationship can indicate two things
792
- about how targets relate to each other:
793
-
794
- * Whether the dependent target needs to link against the dependency.
795
- * Whether the dependency target needs to be built prior to the
796
- dependent. If the former case is true, this case must be true as
797
- well.
798
-
799
- The analysis of the first item is complicated by the differences between
800
- static and shared libraries.
801
-
802
- * Static libraries are simply collections of object files (`.o` or
803
- `.obj`) that are used as inputs to a linker (`ld` or `link.exe`).
804
- Static libraries don't link against other libraries, they’re
805
- collected together and used when eventually linking a shared library
806
- or executable.
807
- * Shared libraries are linker output and must undergo symbol
808
- resolution. They must link against other libraries (static or
809
- shared) in order to facilitate symbol resolution. They may be used
810
- as libraries in subsequent link steps.
811
- * Executables are also linker output, and also undergo symbol
812
- resolution. Like shared libraries, they must link against static
813
- and shared libraries to facilitate symbol resolution. They may not
814
- be reused as linker inputs in subsequent link steps.
815
-
816
- Accordingly, GYP performs an operation referred to as “static library
817
- dependency adjustment,” in which it makes each linker output target
818
- (shared libraries and executables) link against the static libraries it
819
- depends on, either directly or indirectly. Because the linkable targets
820
- link against these static libraries, they are also made direct
821
- dependents of the static libraries.
822
-
823
- As part of this process, GYP is also able to remove the direct
824
- dependency relationships between two static library targets, as a
825
- dependent static library does not actually need to link against a
826
- dependency static library. This removal facilitates speedier builds
827
- under some build systems, as they are now free to build the two targets
828
- in parallel. The removal of this dependency is incorrect in some cases,
829
- such as when the dependency target contains [rules](#rules) or
830
- [actions](#actions) that generate header files required by the
831
- dependent target. In such cases, the dependency target, the one
832
- providing the side-effect files, must declare itself as a
833
- [hard\_dependency](#hard_dependency). This setting instructs GYP to
834
- not remove the dependency link between two static library targets in its
835
- generated output.
836
-
837
- ## Loading Files to Resolve Dependencies
838
-
839
- When GYP runs, it loads all `.gyp` files needed to resolve dependencies
840
- found in [dependencies](#dependencies) sections. These files are not
841
- merged into the files that reference them, but they may contain special
842
- sections that are merged into dependent target dictionaries.
843
-
844
- ## Build Configurations
845
-
846
- Explain this.
847
-
848
- ## List Filters
849
-
850
- GYP allows list items to be filtered by “exclusions” and “patterns.”
851
- Any list containing string values in a dictionary may have this
852
- filtering applied. For the purposes of this section, a list modified by
853
- exclusions or patterns is referred to as a “base list”, in contrast to
854
- the “exclusion list” and “pattern list” that operates on it.
855
-
856
- * For a base list identified by key name `key`, the `key!` list
857
- provides exclusions.
858
- * For a base list identified by key name `key`, the `key/` list
859
- provides regular expression pattern-based filtering.
860
-
861
- Both `key!` and `key/` may be present. The `key!` exclusion list will
862
- be processed first, followed by the `key/` pattern list.
863
-
864
- Exclusion lists are most powerful when used in conjunction with
865
- [conditionals](#Conditionals).
866
-
867
- ## Exclusion Lists (!)
868
-
869
- An exclusion list provides a way to remove items from the related list
870
- based on exact matching. Any item found in an exclusion list will be
871
- removed from the corresponding base list.
872
-
873
- #### Example
874
-
875
- This example excludes files from the `sources` based on the setting of
876
- the `OS` variable.
877
-
878
- ```
879
- {
880
- 'sources:' [
881
- 'mac_util.mm',
882
- 'win_util.cc',
883
- ],
884
- 'conditions': [
885
- ['OS=="mac"', {'sources!': ['win_util.cc']}],
886
- ['OS=="win"', {'sources!': ['mac_util.cc']}],
887
- ],
888
- }
889
- ```
890
-
891
- ## Pattern Lists (/)
892
-
893
- Pattern lists are similar to, but more powerful than, [exclusion
894
- lists](#Exclusion_Lists_(!)). Each item in a pattern list is itself
895
- a two-element list. The first item is a string, either `'include'` or
896
- `'exclude'`, specifying the action to take. The second item is a string
897
- specifying a regular expression. Any item in the base list matching the
898
- regular expression pattern will either be included or excluded, based on
899
- the action specified.
900
-
901
- Items in a pattern list are processed in sequence, and an excluded item
902
- that is later included will not be removed from the list (unless it is
903
- subsequently excluded again.)
904
-
905
- Pattern lists are processed after [exclusion
906
- lists](#Exclusion_Lists_(!)), so it is possible for a pattern list to
907
- re-include items previously excluded by an exclusion list.
908
-
909
- Nothing is actually removed from a base list until all items in an
910
- [exclusion list](#Exclusion_Lists_(!)) and pattern list have been
911
- evaluated. This allows items to retain their correct position relative
912
- to one another even after being excluded and subsequently included.
913
-
914
- #### Example
915
-
916
- In this example, a uniform naming scheme is adopted for
917
- platform-specific files.
918
-
919
- ```
920
- {
921
- 'sources': [
922
- 'io_posix.cc',
923
- 'io_win.cc',
924
- 'launcher_mac.cc',
925
- 'main.cc',
926
- 'platform_util_linux.cc',
927
- 'platform_util_mac.mm',
928
- ],
929
- 'sources/': [
930
- ['exclude', '_win\\.cc$'],
931
- ],
932
- 'conditions': [
933
- ['OS!="linux"', {'sources/': [['exclude', '_linux\\.cc$']]}],
934
- ['OS!="mac"', {'sources/': [['exclude', '_mac\\.cc|mm?$']]}],
935
- ['OS=="win"', {'sources/': [
936
- ['include', '_win\\.cc$'],
937
- ['exclude', '_posix\\.cc$'],
938
- ]}],
939
- ],
940
- }
941
- ```
942
-
943
- After the pattern list is applied, `sources` will have the following
944
- values, depending on the setting of `OS`:
945
-
946
- * When `OS` is `linux`: `['io_posix.cc', 'main.cc',
947
- 'platform_util_linux.cc']`
948
- * When `OS` is `mac`: `['io_posix.cc', 'launcher_mac.cc', 'main.cc',
949
- 'platform_util_mac.mm']`
950
- * When `OS` is `win`: `['io_win.cc', 'main.cc',
951
- 'platform_util_win.cc']`
952
-
953
- Note that when `OS` is `win`, the `include` for `_win.cc` files is
954
- processed after the `exclude` matching the same pattern, because the
955
- `sources/` list participates in [merging](#Merging) during
956
- [conditional evaluation](#Conditonals) just like any other list
957
- would. This guarantees that the `_win.cc` files, previously
958
- unconditionally excluded, will be re-included when `OS` is `win`.
959
-
960
- ## Locating Excluded Items
961
-
962
- In some cases, a GYP generator needs to access to items that were
963
- excluded by an [exclusion list](#Exclusion_Lists_(!)) or [pattern
964
- list](#Pattern_Lists_(/)). When GYP excludes items during processing
965
- of either of these list types, it places the results in an `_excluded`
966
- list. In the example above, when `OS` is `mac`, `sources_excluded`
967
- would be set to `['io_win.cc', 'platform_util_linux.cc']`. Some GYP
968
- generators use this feature to display excluded files in the project
969
- files they generate for the convenience of users, who may wish to refer
970
- to other implementations.
971
-
972
- ## Processing Order
973
-
974
- GYP uses a defined and predictable order to execute the various steps
975
- performed between loading files and generating output.
976
-
977
- * Load files.
978
- * Load `.gyp` files. Merge any [command-line
979
- includes](#Including_Other_Files) into each `.gyp` file’s root
980
- dictionary. As [includes](#Including_Other_Files) are found,
981
- load them as well and [merge](#Merging) them into the scope in
982
- which the [includes](#includes) section was found.
983
- * Perform [“early” or “pre”](#Early_and_Late_Phases) [variable
984
- expansion and conditional
985
- evaluation](#Variables_and_Conditionals).
986
- * [Merge](#Merging) each [target’s](#targets) dictionary into
987
- the `.gyp` file’s root [target\_defaults](#target_defaults)
988
- dictionary.
989
- * Scan each [target](#targets) for
990
- [dependencies](#dependencies), and repeat the above steps for
991
- any newly-referenced `.gyp` files not yet loaded.
992
- * Scan each [target](#targets) for wildcard
993
- [dependencies](#dependencies), expanding the wildcards.
994
- * Process [dependent settings](#Dependent_Settings). These
995
- sections are processed, in order:
996
- * [all\_dependent\_settings](#all_dependent_settings)
997
- * [direct\_dependent\_settings](#direct_dependent_settings)
998
- * [link\_dependent\_settings](#link_dependent_settings)
999
- * Perform [static library dependency
1000
- adjustment](#Linking_Dependencies).
1001
- * Perform [“late,” “post,” or “target”](#Early_and_Late_Phases)
1002
- [variable expansion and conditional
1003
- evaluation](#Variables_and_Conditionals) on [target](#targets)
1004
- dictionaries.
1005
- * Merge [target](#targets) settings into
1006
- [configurations](#configurations) as appropriate.
1007
- * Process [exclusion and pattern
1008
- lists](#List_Exclusions_and_Patterns).
1009
-
1010
- ## Settings Keys
1011
-
1012
- ### Settings that may appear anywhere
1013
-
1014
- #### conditions
1015
-
1016
- _List of `condition` items_
1017
-
1018
- A `conditions` section introduces a subdictionary that is only merged
1019
- into the enclosing scope based on the evaluation of a conditional
1020
- expression. Each `condition` within a `conditions` list is itself a
1021
- list of at least two items:
1022
-
1023
- 1. A string containing the conditional expression itself. Conditional
1024
- expressions may take the following forms:
1025
- * For string values, `var=="value"` and `var!="value"` to test
1026
- equality and inequality. For example, `'OS=="linux"'` is true
1027
- when the `OS` variable is set to `"linux"`.
1028
- * For integer values, `var==value`, `var!=value`, `var<value`,
1029
- `var<=value`, `var>=value`, and `var>value`, to test equality and
1030
- several common forms of inequality. For example,
1031
- `'chromium_code==0'` is true when the `chromium_code` variable is
1032
- set to `0`.
1033
- * It is an error for a conditional expression to reference any
1034
- undefined variable.
1035
- 1. A dictionary containing the subdictionary to be merged into the
1036
- enclosing scope if the conditional expression evaluates to true.
1037
-
1038
- These two items can be followed by any number of similar two items that
1039
- will be evaluated if the previous conditional expression does not
1040
- evaluate to true.
1041
-
1042
- An additional optional dictionary can be appended to this sequence of
1043
- two items. This optional dictionary will be merged into the enclosing
1044
- scope if none of the conditional expressions evaluate to true.
1045
-
1046
- Within a `conditions` section, each item is processed sequentially, so
1047
- it is possible to predict the order in which operations will occur.
1048
-
1049
- There is no restriction on nesting `conditions` sections.
1050
-
1051
- `conditions` sections are very similar to `target_conditions` sections.
1052
- See target\_conditions.
1053
-
1054
- #### Example
1055
-
1056
- ```
1057
- {
1058
- 'sources': [
1059
- 'common.cc',
1060
- ],
1061
- 'conditions': [
1062
- ['OS=="mac"', {'sources': ['mac_util.mm']}],
1063
- ['OS=="win"', {'sources': ['win_main.cc']}, {'sources': ['posix_main.cc']}],
1064
- ['OS=="mac"', {'sources': ['mac_impl.mm']},
1065
- 'OS=="win"', {'sources': ['win_impl.cc']},
1066
- {'sources': ['default_impl.cc']}
1067
- ],
1068
- ],
1069
- }
1070
- ```
1071
-
1072
- Given this input, the `sources` list will take on different values based
1073
- on the `OS` variable.
1074
-
1075
- * If `OS` is `"mac"`, `sources` will contain `['common.cc',
1076
- 'mac_util.mm', 'posix_main.cc', 'mac_impl.mm']`.
1077
- * If `OS` is `"win"`, `sources` will contain `['common.cc',
1078
- 'win_main.cc', 'win_impl.cc']`.
1079
- * If `OS` is any other value such as `"linux"`, `sources` will contain
1080
- `['common.cc', 'posix_main.cc', 'default_impl.cc']`.