libv8 3.16.14.1 → 3.16.14.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (1025) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +3 -0
  3. data/.travis.yml +2 -1
  4. data/README.md +13 -0
  5. data/Rakefile +6 -11
  6. data/ext/libv8/arch.rb +1 -1
  7. data/ext/libv8/builder.rb +31 -3
  8. data/ext/libv8/checkout.rb +48 -0
  9. data/ext/libv8/compiler.rb +6 -1
  10. data/lib/libv8/version.rb +1 -1
  11. data/libv8.gemspec +3 -0
  12. data/patches/disable-building-tests.patch +25 -0
  13. data/patches/do-not-imply-vfp3-and-armv7.patch +28 -0
  14. data/patches/fPIC-for-static.patch +13 -0
  15. data/patches/gcc48-wno-unused-local-typedefs.patch +28 -0
  16. data/spec/location_spec.rb +3 -3
  17. data/vendor/gyp/.gitignore +1 -0
  18. data/vendor/gyp/AUTHORS +6 -0
  19. data/vendor/gyp/DEPS +26 -0
  20. data/vendor/gyp/LICENSE +27 -0
  21. data/vendor/gyp/MANIFEST +21 -0
  22. data/vendor/gyp/OWNERS +1 -0
  23. data/vendor/gyp/PRESUBMIT.py +109 -0
  24. data/vendor/gyp/buildbot/buildbot_run.py +98 -0
  25. data/vendor/gyp/codereview.settings +10 -0
  26. data/vendor/gyp/gyp +18 -0
  27. data/vendor/gyp/gyp.bat +5 -0
  28. data/vendor/gyp/gyp_dummy.c +7 -0
  29. data/vendor/gyp/gyptest.py +266 -0
  30. data/vendor/gyp/pylib/gyp/MSVSNew.py +341 -0
  31. data/vendor/gyp/pylib/gyp/MSVSProject.py +208 -0
  32. data/vendor/gyp/pylib/gyp/MSVSSettings.py +1046 -0
  33. data/vendor/gyp/pylib/gyp/MSVSSettings_test.py +1482 -0
  34. data/vendor/gyp/pylib/gyp/MSVSToolFile.py +58 -0
  35. data/vendor/gyp/pylib/gyp/MSVSUserFile.py +147 -0
  36. data/vendor/gyp/pylib/gyp/MSVSVersion.py +366 -0
  37. data/vendor/gyp/pylib/gyp/SCons.py +199 -0
  38. data/vendor/gyp/pylib/gyp/__init__.py +520 -0
  39. data/vendor/gyp/pylib/gyp/common.py +473 -0
  40. data/vendor/gyp/pylib/gyp/common_test.py +71 -0
  41. data/vendor/gyp/pylib/gyp/easy_xml.py +157 -0
  42. data/vendor/gyp/pylib/gyp/easy_xml_test.py +103 -0
  43. data/vendor/gyp/pylib/gyp/generator/__init__.py +0 -0
  44. data/vendor/gyp/pylib/gyp/generator/android.py +1077 -0
  45. data/vendor/gyp/pylib/gyp/generator/dump_dependency_json.py +66 -0
  46. data/vendor/gyp/pylib/gyp/generator/eclipse.py +273 -0
  47. data/vendor/gyp/pylib/gyp/generator/gypd.py +87 -0
  48. data/vendor/gyp/pylib/gyp/generator/gypsh.py +56 -0
  49. data/vendor/gyp/pylib/gyp/generator/make.py +2177 -0
  50. data/vendor/gyp/pylib/gyp/generator/msvs.py +3165 -0
  51. data/vendor/gyp/pylib/gyp/generator/msvs_test.py +35 -0
  52. data/vendor/gyp/pylib/gyp/generator/ninja.py +1744 -0
  53. data/vendor/gyp/pylib/gyp/generator/ninja_test.py +44 -0
  54. data/vendor/gyp/pylib/gyp/generator/scons.py +1072 -0
  55. data/vendor/gyp/pylib/gyp/generator/xcode.py +1230 -0
  56. data/vendor/gyp/pylib/gyp/input.py +2487 -0
  57. data/vendor/gyp/pylib/gyp/mac_tool.py +210 -0
  58. data/vendor/gyp/pylib/gyp/msvs_emulation.py +691 -0
  59. data/vendor/gyp/pylib/gyp/ninja_syntax.py +152 -0
  60. data/vendor/gyp/pylib/gyp/sun_tool.py +51 -0
  61. data/vendor/gyp/pylib/gyp/system_test.py +68 -0
  62. data/vendor/gyp/pylib/gyp/win_tool.py +193 -0
  63. data/vendor/gyp/pylib/gyp/xcode_emulation.py +1065 -0
  64. data/vendor/gyp/pylib/gyp/xcodeproj_file.py +2868 -0
  65. data/vendor/gyp/pylib/gyp/xml_fix.py +69 -0
  66. data/vendor/gyp/pylintrc +307 -0
  67. data/vendor/gyp/samples/samples +81 -0
  68. data/vendor/gyp/samples/samples.bat +5 -0
  69. data/vendor/gyp/setup.py +26 -0
  70. data/vendor/gyp/test/actions-bare/gyptest-bare.py +23 -0
  71. data/vendor/gyp/test/actions-bare/src/bare.gyp +25 -0
  72. data/vendor/gyp/test/actions-bare/src/bare.py +11 -0
  73. data/vendor/gyp/test/actions-multiple/gyptest-all.py +72 -0
  74. data/vendor/gyp/test/actions-multiple/src/actions.gyp +226 -0
  75. data/vendor/gyp/test/actions-multiple/src/copy.py +9 -0
  76. data/vendor/gyp/test/actions-multiple/src/filter.py +12 -0
  77. data/vendor/gyp/test/actions-multiple/src/foo.c +11 -0
  78. data/vendor/gyp/test/actions-multiple/src/input.txt +1 -0
  79. data/vendor/gyp/test/actions-multiple/src/main.c +22 -0
  80. data/vendor/gyp/test/actions-none/gyptest-none.py +26 -0
  81. data/vendor/gyp/test/actions-none/src/fake_cross.py +12 -0
  82. data/vendor/gyp/test/actions-none/src/foo.cc +1 -0
  83. data/vendor/gyp/test/actions-none/src/none_with_source_files.gyp +35 -0
  84. data/vendor/gyp/test/actions-subdir/gyptest-action.py +26 -0
  85. data/vendor/gyp/test/actions-subdir/src/make-file.py +11 -0
  86. data/vendor/gyp/test/actions-subdir/src/none.gyp +31 -0
  87. data/vendor/gyp/test/actions-subdir/src/subdir/make-subdir-file.py +11 -0
  88. data/vendor/gyp/test/actions-subdir/src/subdir/subdir.gyp +28 -0
  89. data/vendor/gyp/test/actions/gyptest-all.py +102 -0
  90. data/vendor/gyp/test/actions/gyptest-default.py +69 -0
  91. data/vendor/gyp/test/actions/gyptest-errors.py +24 -0
  92. data/vendor/gyp/test/actions/src/action_missing_name.gyp +24 -0
  93. data/vendor/gyp/test/actions/src/actions.gyp +114 -0
  94. data/vendor/gyp/test/actions/src/confirm-dep-files.py +21 -0
  95. data/vendor/gyp/test/actions/src/subdir1/counter.py +46 -0
  96. data/vendor/gyp/test/actions/src/subdir1/executable.gyp +74 -0
  97. data/vendor/gyp/test/actions/src/subdir1/make-prog1.py +20 -0
  98. data/vendor/gyp/test/actions/src/subdir1/make-prog2.py +20 -0
  99. data/vendor/gyp/test/actions/src/subdir1/program.c +12 -0
  100. data/vendor/gyp/test/actions/src/subdir2/make-file.py +11 -0
  101. data/vendor/gyp/test/actions/src/subdir2/none.gyp +33 -0
  102. data/vendor/gyp/test/actions/src/subdir3/generate_main.py +21 -0
  103. data/vendor/gyp/test/actions/src/subdir3/null_input.gyp +29 -0
  104. data/vendor/gyp/test/additional-targets/gyptest-additional.py +56 -0
  105. data/vendor/gyp/test/additional-targets/src/all.gyp +13 -0
  106. data/vendor/gyp/test/additional-targets/src/dir1/actions.gyp +56 -0
  107. data/vendor/gyp/test/additional-targets/src/dir1/emit.py +11 -0
  108. data/vendor/gyp/test/additional-targets/src/dir1/lib1.c +6 -0
  109. data/vendor/gyp/test/assembly/gyptest-assembly.py +31 -0
  110. data/vendor/gyp/test/assembly/src/as.bat +4 -0
  111. data/vendor/gyp/test/assembly/src/assembly.gyp +62 -0
  112. data/vendor/gyp/test/assembly/src/lib1.S +15 -0
  113. data/vendor/gyp/test/assembly/src/lib1.c +3 -0
  114. data/vendor/gyp/test/assembly/src/program.c +12 -0
  115. data/vendor/gyp/test/build-option/gyptest-build.py +22 -0
  116. data/vendor/gyp/test/build-option/hello.c +13 -0
  117. data/vendor/gyp/test/build-option/hello.gyp +15 -0
  118. data/vendor/gyp/test/builddir/gyptest-all.py +85 -0
  119. data/vendor/gyp/test/builddir/gyptest-default.py +85 -0
  120. data/vendor/gyp/test/builddir/src/builddir.gypi +21 -0
  121. data/vendor/gyp/test/builddir/src/func1.c +6 -0
  122. data/vendor/gyp/test/builddir/src/func2.c +6 -0
  123. data/vendor/gyp/test/builddir/src/func3.c +6 -0
  124. data/vendor/gyp/test/builddir/src/func4.c +6 -0
  125. data/vendor/gyp/test/builddir/src/func5.c +6 -0
  126. data/vendor/gyp/test/builddir/src/prog1.c +10 -0
  127. data/vendor/gyp/test/builddir/src/prog1.gyp +30 -0
  128. data/vendor/gyp/test/builddir/src/subdir2/prog2.c +10 -0
  129. data/vendor/gyp/test/builddir/src/subdir2/prog2.gyp +19 -0
  130. data/vendor/gyp/test/builddir/src/subdir2/subdir3/prog3.c +10 -0
  131. data/vendor/gyp/test/builddir/src/subdir2/subdir3/prog3.gyp +19 -0
  132. data/vendor/gyp/test/builddir/src/subdir2/subdir3/subdir4/prog4.c +10 -0
  133. data/vendor/gyp/test/builddir/src/subdir2/subdir3/subdir4/prog4.gyp +19 -0
  134. data/vendor/gyp/test/builddir/src/subdir2/subdir3/subdir4/subdir5/prog5.c +10 -0
  135. data/vendor/gyp/test/builddir/src/subdir2/subdir3/subdir4/subdir5/prog5.gyp +19 -0
  136. data/vendor/gyp/test/cflags/cflags.c +15 -0
  137. data/vendor/gyp/test/cflags/cflags.gyp +16 -0
  138. data/vendor/gyp/test/cflags/gyptest-cflags.py +65 -0
  139. data/vendor/gyp/test/compilable/gyptest-headers.py +29 -0
  140. data/vendor/gyp/test/compilable/src/headers.gyp +26 -0
  141. data/vendor/gyp/test/compilable/src/lib1.cpp +7 -0
  142. data/vendor/gyp/test/compilable/src/lib1.hpp +6 -0
  143. data/vendor/gyp/test/compilable/src/program.cpp +9 -0
  144. data/vendor/gyp/test/compiler-override/compiler-global-settings.gyp.in +34 -0
  145. data/vendor/gyp/test/compiler-override/compiler-host.gyp +17 -0
  146. data/vendor/gyp/test/compiler-override/compiler.gyp +16 -0
  147. data/vendor/gyp/test/compiler-override/cxxtest.cc +7 -0
  148. data/vendor/gyp/test/compiler-override/gyptest-compiler-env.py +55 -0
  149. data/vendor/gyp/test/compiler-override/gyptest-compiler-global-settings.py +52 -0
  150. data/vendor/gyp/test/compiler-override/my_cc.py +6 -0
  151. data/vendor/gyp/test/compiler-override/my_cxx.py +6 -0
  152. data/vendor/gyp/test/compiler-override/my_ld.py +6 -0
  153. data/vendor/gyp/test/compiler-override/test.c +7 -0
  154. data/vendor/gyp/test/configurations/basics/configurations.c +15 -0
  155. data/vendor/gyp/test/configurations/basics/configurations.gyp +32 -0
  156. data/vendor/gyp/test/configurations/basics/gyptest-configurations.py +29 -0
  157. data/vendor/gyp/test/configurations/inheritance/configurations.c +21 -0
  158. data/vendor/gyp/test/configurations/inheritance/configurations.gyp +40 -0
  159. data/vendor/gyp/test/configurations/inheritance/gyptest-inheritance.py +33 -0
  160. data/vendor/gyp/test/configurations/invalid/actions.gyp +18 -0
  161. data/vendor/gyp/test/configurations/invalid/all_dependent_settings.gyp +18 -0
  162. data/vendor/gyp/test/configurations/invalid/configurations.gyp +18 -0
  163. data/vendor/gyp/test/configurations/invalid/dependencies.gyp +18 -0
  164. data/vendor/gyp/test/configurations/invalid/direct_dependent_settings.gyp +18 -0
  165. data/vendor/gyp/test/configurations/invalid/gyptest-configurations.py +38 -0
  166. data/vendor/gyp/test/configurations/invalid/libraries.gyp +18 -0
  167. data/vendor/gyp/test/configurations/invalid/link_settings.gyp +18 -0
  168. data/vendor/gyp/test/configurations/invalid/sources.gyp +18 -0
  169. data/vendor/gyp/test/configurations/invalid/target_name.gyp +18 -0
  170. data/vendor/gyp/test/configurations/invalid/type.gyp +18 -0
  171. data/vendor/gyp/test/configurations/target_platform/configurations.gyp +58 -0
  172. data/vendor/gyp/test/configurations/target_platform/front.c +8 -0
  173. data/vendor/gyp/test/configurations/target_platform/gyptest-target_platform.py +40 -0
  174. data/vendor/gyp/test/configurations/target_platform/left.c +3 -0
  175. data/vendor/gyp/test/configurations/target_platform/right.c +3 -0
  176. data/vendor/gyp/test/configurations/x64/configurations.c +12 -0
  177. data/vendor/gyp/test/configurations/x64/configurations.gyp +38 -0
  178. data/vendor/gyp/test/configurations/x64/gyptest-x86.py +31 -0
  179. data/vendor/gyp/test/copies/gyptest-all.py +40 -0
  180. data/vendor/gyp/test/copies/gyptest-default.py +40 -0
  181. data/vendor/gyp/test/copies/gyptest-slash.py +38 -0
  182. data/vendor/gyp/test/copies/gyptest-updir.py +23 -0
  183. data/vendor/gyp/test/copies/src/copies-slash.gyp +36 -0
  184. data/vendor/gyp/test/copies/src/copies-updir.gyp +21 -0
  185. data/vendor/gyp/test/copies/src/copies.gyp +70 -0
  186. data/vendor/gyp/test/copies/src/directory/file3 +1 -0
  187. data/vendor/gyp/test/copies/src/directory/file4 +1 -0
  188. data/vendor/gyp/test/copies/src/directory/subdir/file5 +1 -0
  189. data/vendor/gyp/test/copies/src/file1 +1 -0
  190. data/vendor/gyp/test/copies/src/file2 +1 -0
  191. data/vendor/gyp/test/copies/src/parentdir/subdir/file6 +1 -0
  192. data/vendor/gyp/test/custom-generator/gyptest-custom-generator.py +18 -0
  193. data/vendor/gyp/test/custom-generator/mygenerator.py +14 -0
  194. data/vendor/gyp/test/custom-generator/test.gyp +15 -0
  195. data/vendor/gyp/test/cxxflags/cxxflags.cc +15 -0
  196. data/vendor/gyp/test/cxxflags/cxxflags.gyp +16 -0
  197. data/vendor/gyp/test/cxxflags/gyptest-cxxflags.py +65 -0
  198. data/vendor/gyp/test/defines-escaping/defines-escaping.c +11 -0
  199. data/vendor/gyp/test/defines-escaping/defines-escaping.gyp +19 -0
  200. data/vendor/gyp/test/defines-escaping/gyptest-defines-escaping.py +184 -0
  201. data/vendor/gyp/test/defines/defines-env.gyp +22 -0
  202. data/vendor/gyp/test/defines/defines.c +23 -0
  203. data/vendor/gyp/test/defines/defines.gyp +38 -0
  204. data/vendor/gyp/test/defines/gyptest-define-override.py +34 -0
  205. data/vendor/gyp/test/defines/gyptest-defines-env-regyp.py +51 -0
  206. data/vendor/gyp/test/defines/gyptest-defines-env.py +85 -0
  207. data/vendor/gyp/test/defines/gyptest-defines.py +27 -0
  208. data/vendor/gyp/test/dependencies/a.c +9 -0
  209. data/vendor/gyp/test/dependencies/b/b.c +3 -0
  210. data/vendor/gyp/test/dependencies/b/b.gyp +22 -0
  211. data/vendor/gyp/test/dependencies/b/b3.c +9 -0
  212. data/vendor/gyp/test/dependencies/c/c.c +4 -0
  213. data/vendor/gyp/test/dependencies/c/c.gyp +22 -0
  214. data/vendor/gyp/test/dependencies/c/d.c +3 -0
  215. data/vendor/gyp/test/dependencies/double_dependency.gyp +23 -0
  216. data/vendor/gyp/test/dependencies/double_dependent.gyp +12 -0
  217. data/vendor/gyp/test/dependencies/extra_targets.gyp +18 -0
  218. data/vendor/gyp/test/dependencies/gyptest-double-dependency.py +19 -0
  219. data/vendor/gyp/test/dependencies/gyptest-extra-targets.py +21 -0
  220. data/vendor/gyp/test/dependencies/gyptest-lib-only.py +39 -0
  221. data/vendor/gyp/test/dependencies/gyptest-none-traversal.py +25 -0
  222. data/vendor/gyp/test/dependencies/lib_only.gyp +16 -0
  223. data/vendor/gyp/test/dependencies/main.c +14 -0
  224. data/vendor/gyp/test/dependencies/none_traversal.gyp +46 -0
  225. data/vendor/gyp/test/dependency-copy/gyptest-copy.py +26 -0
  226. data/vendor/gyp/test/dependency-copy/src/copies.gyp +25 -0
  227. data/vendor/gyp/test/dependency-copy/src/file1.c +7 -0
  228. data/vendor/gyp/test/dependency-copy/src/file2.c +7 -0
  229. data/vendor/gyp/test/errors/duplicate_basenames.gyp +13 -0
  230. data/vendor/gyp/test/errors/duplicate_node.gyp +12 -0
  231. data/vendor/gyp/test/errors/duplicate_rule.gyp +22 -0
  232. data/vendor/gyp/test/errors/duplicate_targets.gyp +14 -0
  233. data/vendor/gyp/test/errors/gyptest-errors.py +49 -0
  234. data/vendor/gyp/test/errors/missing_dep.gyp +15 -0
  235. data/vendor/gyp/test/errors/missing_targets.gyp +8 -0
  236. data/vendor/gyp/test/escaping/colon/test.gyp +21 -0
  237. data/vendor/gyp/test/escaping/gyptest-colon.py +43 -0
  238. data/vendor/gyp/test/exclusion/exclusion.gyp +23 -0
  239. data/vendor/gyp/test/exclusion/gyptest-exclusion.py +22 -0
  240. data/vendor/gyp/test/exclusion/hello.c +15 -0
  241. data/vendor/gyp/test/external-cross-compile/gyptest-cross.py +35 -0
  242. data/vendor/gyp/test/external-cross-compile/src/bogus1.cc +1 -0
  243. data/vendor/gyp/test/external-cross-compile/src/bogus2.c +1 -0
  244. data/vendor/gyp/test/external-cross-compile/src/cross.gyp +83 -0
  245. data/vendor/gyp/test/external-cross-compile/src/cross_compile.gypi +23 -0
  246. data/vendor/gyp/test/external-cross-compile/src/fake_cross.py +18 -0
  247. data/vendor/gyp/test/external-cross-compile/src/program.cc +16 -0
  248. data/vendor/gyp/test/external-cross-compile/src/test1.cc +1 -0
  249. data/vendor/gyp/test/external-cross-compile/src/test2.c +1 -0
  250. data/vendor/gyp/test/external-cross-compile/src/test3.cc +1 -0
  251. data/vendor/gyp/test/external-cross-compile/src/test4.c +1 -0
  252. data/vendor/gyp/test/external-cross-compile/src/tochar.py +13 -0
  253. data/vendor/gyp/test/generator-output/actions/actions.gyp +16 -0
  254. data/vendor/gyp/test/generator-output/actions/build/README.txt +4 -0
  255. data/vendor/gyp/test/generator-output/actions/subdir1/actions-out/README.txt +4 -0
  256. data/vendor/gyp/test/generator-output/actions/subdir1/build/README.txt +4 -0
  257. data/vendor/gyp/test/generator-output/actions/subdir1/executable.gyp +44 -0
  258. data/vendor/gyp/test/generator-output/actions/subdir1/make-prog1.py +20 -0
  259. data/vendor/gyp/test/generator-output/actions/subdir1/make-prog2.py +20 -0
  260. data/vendor/gyp/test/generator-output/actions/subdir1/program.c +12 -0
  261. data/vendor/gyp/test/generator-output/actions/subdir2/actions-out/README.txt +4 -0
  262. data/vendor/gyp/test/generator-output/actions/subdir2/build/README.txt +4 -0
  263. data/vendor/gyp/test/generator-output/actions/subdir2/make-file.py +11 -0
  264. data/vendor/gyp/test/generator-output/actions/subdir2/none.gyp +31 -0
  265. data/vendor/gyp/test/generator-output/copies/build/README.txt +4 -0
  266. data/vendor/gyp/test/generator-output/copies/copies-out/README.txt +4 -0
  267. data/vendor/gyp/test/generator-output/copies/copies.gyp +50 -0
  268. data/vendor/gyp/test/generator-output/copies/file1 +1 -0
  269. data/vendor/gyp/test/generator-output/copies/file2 +1 -0
  270. data/vendor/gyp/test/generator-output/copies/subdir/build/README.txt +4 -0
  271. data/vendor/gyp/test/generator-output/copies/subdir/copies-out/README.txt +4 -0
  272. data/vendor/gyp/test/generator-output/copies/subdir/file3 +1 -0
  273. data/vendor/gyp/test/generator-output/copies/subdir/file4 +1 -0
  274. data/vendor/gyp/test/generator-output/copies/subdir/subdir.gyp +32 -0
  275. data/vendor/gyp/test/generator-output/gyptest-actions.py +58 -0
  276. data/vendor/gyp/test/generator-output/gyptest-copies.py +59 -0
  277. data/vendor/gyp/test/generator-output/gyptest-mac-bundle.py +29 -0
  278. data/vendor/gyp/test/generator-output/gyptest-relocate.py +60 -0
  279. data/vendor/gyp/test/generator-output/gyptest-rules.py +59 -0
  280. data/vendor/gyp/test/generator-output/gyptest-subdir2-deep.py +37 -0
  281. data/vendor/gyp/test/generator-output/gyptest-top-all.py +54 -0
  282. data/vendor/gyp/test/generator-output/mac-bundle/Info.plist +32 -0
  283. data/vendor/gyp/test/generator-output/mac-bundle/app.order +1 -0
  284. data/vendor/gyp/test/generator-output/mac-bundle/header.h +1 -0
  285. data/vendor/gyp/test/generator-output/mac-bundle/main.c +1 -0
  286. data/vendor/gyp/test/generator-output/mac-bundle/resource.sb +1 -0
  287. data/vendor/gyp/test/generator-output/mac-bundle/test.gyp +25 -0
  288. data/vendor/gyp/test/generator-output/rules/build/README.txt +4 -0
  289. data/vendor/gyp/test/generator-output/rules/copy-file.py +12 -0
  290. data/vendor/gyp/test/generator-output/rules/rules.gyp +16 -0
  291. data/vendor/gyp/test/generator-output/rules/subdir1/build/README.txt +4 -0
  292. data/vendor/gyp/test/generator-output/rules/subdir1/define3.in0 +1 -0
  293. data/vendor/gyp/test/generator-output/rules/subdir1/define4.in0 +1 -0
  294. data/vendor/gyp/test/generator-output/rules/subdir1/executable.gyp +59 -0
  295. data/vendor/gyp/test/generator-output/rules/subdir1/function1.in1 +6 -0
  296. data/vendor/gyp/test/generator-output/rules/subdir1/function2.in1 +6 -0
  297. data/vendor/gyp/test/generator-output/rules/subdir1/program.c +18 -0
  298. data/vendor/gyp/test/generator-output/rules/subdir2/build/README.txt +4 -0
  299. data/vendor/gyp/test/generator-output/rules/subdir2/file1.in0 +1 -0
  300. data/vendor/gyp/test/generator-output/rules/subdir2/file2.in0 +1 -0
  301. data/vendor/gyp/test/generator-output/rules/subdir2/file3.in1 +1 -0
  302. data/vendor/gyp/test/generator-output/rules/subdir2/file4.in1 +1 -0
  303. data/vendor/gyp/test/generator-output/rules/subdir2/none.gyp +49 -0
  304. data/vendor/gyp/test/generator-output/rules/subdir2/rules-out/README.txt +4 -0
  305. data/vendor/gyp/test/generator-output/src/build/README.txt +4 -0
  306. data/vendor/gyp/test/generator-output/src/inc.h +1 -0
  307. data/vendor/gyp/test/generator-output/src/inc1/include1.h +1 -0
  308. data/vendor/gyp/test/generator-output/src/prog1.c +18 -0
  309. data/vendor/gyp/test/generator-output/src/prog1.gyp +28 -0
  310. data/vendor/gyp/test/generator-output/src/subdir2/build/README.txt +4 -0
  311. data/vendor/gyp/test/generator-output/src/subdir2/deeper/build/README.txt +4 -0
  312. data/vendor/gyp/test/generator-output/src/subdir2/deeper/deeper.c +7 -0
  313. data/vendor/gyp/test/generator-output/src/subdir2/deeper/deeper.gyp +18 -0
  314. data/vendor/gyp/test/generator-output/src/subdir2/deeper/deeper.h +1 -0
  315. data/vendor/gyp/test/generator-output/src/subdir2/inc2/include2.h +1 -0
  316. data/vendor/gyp/test/generator-output/src/subdir2/prog2.c +18 -0
  317. data/vendor/gyp/test/generator-output/src/subdir2/prog2.gyp +28 -0
  318. data/vendor/gyp/test/generator-output/src/subdir3/build/README.txt +4 -0
  319. data/vendor/gyp/test/generator-output/src/subdir3/inc3/include3.h +1 -0
  320. data/vendor/gyp/test/generator-output/src/subdir3/prog3.c +18 -0
  321. data/vendor/gyp/test/generator-output/src/subdir3/prog3.gyp +25 -0
  322. data/vendor/gyp/test/generator-output/src/symroot.gypi +16 -0
  323. data/vendor/gyp/test/gyp-defines/defines.gyp +26 -0
  324. data/vendor/gyp/test/gyp-defines/echo.py +11 -0
  325. data/vendor/gyp/test/gyp-defines/gyptest-multiple-values.py +34 -0
  326. data/vendor/gyp/test/gyp-defines/gyptest-regyp.py +40 -0
  327. data/vendor/gyp/test/hard_dependency/gyptest-exported-hard-dependency.py +37 -0
  328. data/vendor/gyp/test/hard_dependency/gyptest-no-exported-hard-dependency.py +36 -0
  329. data/vendor/gyp/test/hard_dependency/src/a.c +9 -0
  330. data/vendor/gyp/test/hard_dependency/src/a.h +12 -0
  331. data/vendor/gyp/test/hard_dependency/src/b.c +9 -0
  332. data/vendor/gyp/test/hard_dependency/src/b.h +12 -0
  333. data/vendor/gyp/test/hard_dependency/src/c.c +10 -0
  334. data/vendor/gyp/test/hard_dependency/src/c.h +10 -0
  335. data/vendor/gyp/test/hard_dependency/src/d.c +9 -0
  336. data/vendor/gyp/test/hard_dependency/src/emit.py +11 -0
  337. data/vendor/gyp/test/hard_dependency/src/hard_dependency.gyp +78 -0
  338. data/vendor/gyp/test/hello/gyptest-all.py +24 -0
  339. data/vendor/gyp/test/hello/gyptest-default.py +24 -0
  340. data/vendor/gyp/test/hello/gyptest-disable-regyp.py +32 -0
  341. data/vendor/gyp/test/hello/gyptest-regyp.py +32 -0
  342. data/vendor/gyp/test/hello/gyptest-target.py +24 -0
  343. data/vendor/gyp/test/hello/hello.c +11 -0
  344. data/vendor/gyp/test/hello/hello.gyp +15 -0
  345. data/vendor/gyp/test/hello/hello2.c +11 -0
  346. data/vendor/gyp/test/hello/hello2.gyp +15 -0
  347. data/vendor/gyp/test/home_dot_gyp/gyptest-home-includes-regyp.py +44 -0
  348. data/vendor/gyp/test/home_dot_gyp/gyptest-home-includes.py +30 -0
  349. data/vendor/gyp/test/home_dot_gyp/home/.gyp/include.gypi +5 -0
  350. data/vendor/gyp/test/home_dot_gyp/home2/.gyp/include.gypi +5 -0
  351. data/vendor/gyp/test/home_dot_gyp/src/all.gyp +22 -0
  352. data/vendor/gyp/test/home_dot_gyp/src/printfoo.c +7 -0
  353. data/vendor/gyp/test/include_dirs/gyptest-all.py +46 -0
  354. data/vendor/gyp/test/include_dirs/gyptest-default.py +46 -0
  355. data/vendor/gyp/test/include_dirs/src/inc.h +1 -0
  356. data/vendor/gyp/test/include_dirs/src/inc1/include1.h +1 -0
  357. data/vendor/gyp/test/include_dirs/src/includes.c +19 -0
  358. data/vendor/gyp/test/include_dirs/src/includes.gyp +27 -0
  359. data/vendor/gyp/test/include_dirs/src/shadow1/shadow.h +1 -0
  360. data/vendor/gyp/test/include_dirs/src/shadow2/shadow.h +1 -0
  361. data/vendor/gyp/test/include_dirs/src/subdir/inc.h +1 -0
  362. data/vendor/gyp/test/include_dirs/src/subdir/inc2/include2.h +1 -0
  363. data/vendor/gyp/test/include_dirs/src/subdir/subdir_includes.c +14 -0
  364. data/vendor/gyp/test/include_dirs/src/subdir/subdir_includes.gyp +20 -0
  365. data/vendor/gyp/test/intermediate_dir/gyptest-intermediate-dir.py +42 -0
  366. data/vendor/gyp/test/intermediate_dir/src/script.py +24 -0
  367. data/vendor/gyp/test/intermediate_dir/src/shared_infile.txt +1 -0
  368. data/vendor/gyp/test/intermediate_dir/src/test.gyp +42 -0
  369. data/vendor/gyp/test/intermediate_dir/src/test2.gyp +42 -0
  370. data/vendor/gyp/test/lib/README.txt +17 -0
  371. data/vendor/gyp/test/lib/TestCmd.py +1597 -0
  372. data/vendor/gyp/test/lib/TestCommon.py +570 -0
  373. data/vendor/gyp/test/lib/TestGyp.py +1049 -0
  374. data/vendor/gyp/test/library/gyptest-shared-obj-install-path.py +42 -0
  375. data/vendor/gyp/test/library/gyptest-shared.py +84 -0
  376. data/vendor/gyp/test/library/gyptest-static.py +84 -0
  377. data/vendor/gyp/test/library/src/lib1.c +10 -0
  378. data/vendor/gyp/test/library/src/lib1_moveable.c +10 -0
  379. data/vendor/gyp/test/library/src/lib2.c +10 -0
  380. data/vendor/gyp/test/library/src/lib2_moveable.c +10 -0
  381. data/vendor/gyp/test/library/src/library.gyp +58 -0
  382. data/vendor/gyp/test/library/src/program.c +15 -0
  383. data/vendor/gyp/test/library/src/shared_dependency.gyp +33 -0
  384. data/vendor/gyp/test/link-objects/base.c +6 -0
  385. data/vendor/gyp/test/link-objects/extra.c +5 -0
  386. data/vendor/gyp/test/link-objects/gyptest-all.py +28 -0
  387. data/vendor/gyp/test/link-objects/link-objects.gyp +24 -0
  388. data/vendor/gyp/test/mac/action-envvars/action/action.gyp +34 -0
  389. data/vendor/gyp/test/mac/action-envvars/action/action.sh +8 -0
  390. data/vendor/gyp/test/mac/app-bundle/TestApp/English.lproj/InfoPlist.strings +3 -0
  391. data/vendor/gyp/test/mac/app-bundle/TestApp/English.lproj/MainMenu.xib +4119 -0
  392. data/vendor/gyp/test/mac/app-bundle/TestApp/TestApp-Info.plist +32 -0
  393. data/vendor/gyp/test/mac/app-bundle/TestApp/TestAppAppDelegate.h +13 -0
  394. data/vendor/gyp/test/mac/app-bundle/TestApp/TestAppAppDelegate.m +15 -0
  395. data/vendor/gyp/test/mac/app-bundle/TestApp/main.m +10 -0
  396. data/vendor/gyp/test/mac/app-bundle/empty.c +0 -0
  397. data/vendor/gyp/test/mac/app-bundle/test.gyp +39 -0
  398. data/vendor/gyp/test/mac/archs/my_file.cc +4 -0
  399. data/vendor/gyp/test/mac/archs/my_main_file.cc +9 -0
  400. data/vendor/gyp/test/mac/archs/test-archs-x86_64.gyp +27 -0
  401. data/vendor/gyp/test/mac/archs/test-no-archs.gyp +21 -0
  402. data/vendor/gyp/test/mac/cflags/ccfile.cc +7 -0
  403. data/vendor/gyp/test/mac/cflags/ccfile_withcflags.cc +7 -0
  404. data/vendor/gyp/test/mac/cflags/cfile.c +7 -0
  405. data/vendor/gyp/test/mac/cflags/cppfile.cpp +7 -0
  406. data/vendor/gyp/test/mac/cflags/cppfile_withcflags.cpp +7 -0
  407. data/vendor/gyp/test/mac/cflags/cxxfile.cxx +7 -0
  408. data/vendor/gyp/test/mac/cflags/cxxfile_withcflags.cxx +7 -0
  409. data/vendor/gyp/test/mac/cflags/mfile.m +7 -0
  410. data/vendor/gyp/test/mac/cflags/mmfile.mm +7 -0
  411. data/vendor/gyp/test/mac/cflags/mmfile_withcflags.mm +7 -0
  412. data/vendor/gyp/test/mac/cflags/test.gyp +119 -0
  413. data/vendor/gyp/test/mac/copy-dylib/empty.c +1 -0
  414. data/vendor/gyp/test/mac/copy-dylib/test.gyp +31 -0
  415. data/vendor/gyp/test/mac/debuginfo/file.c +6 -0
  416. data/vendor/gyp/test/mac/debuginfo/test.gyp +82 -0
  417. data/vendor/gyp/test/mac/depend-on-bundle/English.lproj/InfoPlist.strings +1 -0
  418. data/vendor/gyp/test/mac/depend-on-bundle/Info.plist +28 -0
  419. data/vendor/gyp/test/mac/depend-on-bundle/bundle.c +1 -0
  420. data/vendor/gyp/test/mac/depend-on-bundle/executable.c +4 -0
  421. data/vendor/gyp/test/mac/depend-on-bundle/test.gyp +28 -0
  422. data/vendor/gyp/test/mac/framework-dirs/calculate.c +15 -0
  423. data/vendor/gyp/test/mac/framework-dirs/framework-dirs.gyp +21 -0
  424. data/vendor/gyp/test/mac/framework-headers/myframework.h +8 -0
  425. data/vendor/gyp/test/mac/framework-headers/myframework.m +8 -0
  426. data/vendor/gyp/test/mac/framework-headers/test.gyp +44 -0
  427. data/vendor/gyp/test/mac/framework/TestFramework/English.lproj/InfoPlist.strings +2 -0
  428. data/vendor/gyp/test/mac/framework/TestFramework/Info.plist +28 -0
  429. data/vendor/gyp/test/mac/framework/TestFramework/ObjCVector.h +28 -0
  430. data/vendor/gyp/test/mac/framework/TestFramework/ObjCVector.mm +63 -0
  431. data/vendor/gyp/test/mac/framework/TestFramework/ObjCVectorInternal.h +9 -0
  432. data/vendor/gyp/test/mac/framework/TestFramework/TestFramework_Prefix.pch +7 -0
  433. data/vendor/gyp/test/mac/framework/empty.c +0 -0
  434. data/vendor/gyp/test/mac/framework/framework.gyp +74 -0
  435. data/vendor/gyp/test/mac/global-settings/src/dir1/dir1.gyp +11 -0
  436. data/vendor/gyp/test/mac/global-settings/src/dir2/dir2.gyp +22 -0
  437. data/vendor/gyp/test/mac/global-settings/src/dir2/file.txt +1 -0
  438. data/vendor/gyp/test/mac/gyptest-action-envvars.py +30 -0
  439. data/vendor/gyp/test/mac/gyptest-app.py +47 -0
  440. data/vendor/gyp/test/mac/gyptest-archs.py +37 -0
  441. data/vendor/gyp/test/mac/gyptest-cflags.py +21 -0
  442. data/vendor/gyp/test/mac/gyptest-copies.py +49 -0
  443. data/vendor/gyp/test/mac/gyptest-copy-dylib.py +25 -0
  444. data/vendor/gyp/test/mac/gyptest-debuginfo.py +36 -0
  445. data/vendor/gyp/test/mac/gyptest-depend-on-bundle.py +40 -0
  446. data/vendor/gyp/test/mac/gyptest-framework-dirs.py +23 -0
  447. data/vendor/gyp/test/mac/gyptest-framework-headers.py +38 -0
  448. data/vendor/gyp/test/mac/gyptest-framework.py +50 -0
  449. data/vendor/gyp/test/mac/gyptest-global-settings.py +26 -0
  450. data/vendor/gyp/test/mac/gyptest-infoplist-process.py +51 -0
  451. data/vendor/gyp/test/mac/gyptest-installname.py +79 -0
  452. data/vendor/gyp/test/mac/gyptest-ldflags-passed-to-libtool.py +31 -0
  453. data/vendor/gyp/test/mac/gyptest-ldflags.py +68 -0
  454. data/vendor/gyp/test/mac/gyptest-libraries.py +22 -0
  455. data/vendor/gyp/test/mac/gyptest-loadable-module.py +45 -0
  456. data/vendor/gyp/test/mac/gyptest-missing-cfbundlesignature.py +29 -0
  457. data/vendor/gyp/test/mac/gyptest-non-strs-flattened-to-env.py +33 -0
  458. data/vendor/gyp/test/mac/gyptest-objc-gc.py +45 -0
  459. data/vendor/gyp/test/mac/gyptest-postbuild-copy-bundle.py +62 -0
  460. data/vendor/gyp/test/mac/gyptest-postbuild-defaults.py +29 -0
  461. data/vendor/gyp/test/mac/gyptest-postbuild-fail.py +55 -0
  462. data/vendor/gyp/test/mac/gyptest-postbuild-multiple-configurations.py +26 -0
  463. data/vendor/gyp/test/mac/gyptest-postbuild-static-library.gyp +28 -0
  464. data/vendor/gyp/test/mac/gyptest-postbuild.py +53 -0
  465. data/vendor/gyp/test/mac/gyptest-prefixheader.py +19 -0
  466. data/vendor/gyp/test/mac/gyptest-rebuild.py +41 -0
  467. data/vendor/gyp/test/mac/gyptest-rpath.py +49 -0
  468. data/vendor/gyp/test/mac/gyptest-sdkroot.py +20 -0
  469. data/vendor/gyp/test/mac/gyptest-sourceless-module.gyp +46 -0
  470. data/vendor/gyp/test/mac/gyptest-strip.py +53 -0
  471. data/vendor/gyp/test/mac/gyptest-type-envvars.py +24 -0
  472. data/vendor/gyp/test/mac/gyptest-xcode-env-order.py +83 -0
  473. data/vendor/gyp/test/mac/gyptest-xcode-gcc.py +39 -0
  474. data/vendor/gyp/test/mac/infoplist-process/Info.plist +36 -0
  475. data/vendor/gyp/test/mac/infoplist-process/main.c +7 -0
  476. data/vendor/gyp/test/mac/infoplist-process/test1.gyp +25 -0
  477. data/vendor/gyp/test/mac/infoplist-process/test2.gyp +25 -0
  478. data/vendor/gyp/test/mac/infoplist-process/test3.gyp +25 -0
  479. data/vendor/gyp/test/mac/installname/Info.plist +28 -0
  480. data/vendor/gyp/test/mac/installname/file.c +1 -0
  481. data/vendor/gyp/test/mac/installname/main.c +1 -0
  482. data/vendor/gyp/test/mac/installname/test.gyp +93 -0
  483. data/vendor/gyp/test/mac/ldflags-libtool/file.c +1 -0
  484. data/vendor/gyp/test/mac/ldflags-libtool/test.gyp +17 -0
  485. data/vendor/gyp/test/mac/ldflags/subdirectory/Info.plist +8 -0
  486. data/vendor/gyp/test/mac/ldflags/subdirectory/file.c +2 -0
  487. data/vendor/gyp/test/mac/ldflags/subdirectory/symbol_list.def +1 -0
  488. data/vendor/gyp/test/mac/ldflags/subdirectory/test.gyp +66 -0
  489. data/vendor/gyp/test/mac/libraries/subdir/README.txt +1 -0
  490. data/vendor/gyp/test/mac/libraries/subdir/hello.cc +10 -0
  491. data/vendor/gyp/test/mac/libraries/subdir/mylib.c +7 -0
  492. data/vendor/gyp/test/mac/libraries/subdir/test.gyp +66 -0
  493. data/vendor/gyp/test/mac/loadable-module/Info.plist +26 -0
  494. data/vendor/gyp/test/mac/loadable-module/module.c +11 -0
  495. data/vendor/gyp/test/mac/loadable-module/test.gyp +18 -0
  496. data/vendor/gyp/test/mac/missing-cfbundlesignature/Info.plist +10 -0
  497. data/vendor/gyp/test/mac/missing-cfbundlesignature/Other-Info.plist +12 -0
  498. data/vendor/gyp/test/mac/missing-cfbundlesignature/Third-Info.plist +12 -0
  499. data/vendor/gyp/test/mac/missing-cfbundlesignature/file.c +1 -0
  500. data/vendor/gyp/test/mac/missing-cfbundlesignature/test.gyp +34 -0
  501. data/vendor/gyp/test/mac/non-strs-flattened-to-env/Info.plist +15 -0
  502. data/vendor/gyp/test/mac/non-strs-flattened-to-env/main.c +7 -0
  503. data/vendor/gyp/test/mac/non-strs-flattened-to-env/test.gyp +24 -0
  504. data/vendor/gyp/test/mac/objc-gc/c-file.c +1 -0
  505. data/vendor/gyp/test/mac/objc-gc/cc-file.cc +1 -0
  506. data/vendor/gyp/test/mac/objc-gc/main.m +6 -0
  507. data/vendor/gyp/test/mac/objc-gc/needs-gc-mm.mm +1 -0
  508. data/vendor/gyp/test/mac/objc-gc/needs-gc.m +1 -0
  509. data/vendor/gyp/test/mac/objc-gc/test.gyp +102 -0
  510. data/vendor/gyp/test/mac/postbuild-copy-bundle/Framework-Info.plist +30 -0
  511. data/vendor/gyp/test/mac/postbuild-copy-bundle/TestApp-Info.plist +32 -0
  512. data/vendor/gyp/test/mac/postbuild-copy-bundle/empty.c +0 -0
  513. data/vendor/gyp/test/mac/postbuild-copy-bundle/main.c +4 -0
  514. data/vendor/gyp/test/mac/postbuild-copy-bundle/postbuild-copy-framework.sh +9 -0
  515. data/vendor/gyp/test/mac/postbuild-copy-bundle/resource_file.sb +1 -0
  516. data/vendor/gyp/test/mac/postbuild-copy-bundle/test.gyp +43 -0
  517. data/vendor/gyp/test/mac/postbuild-defaults/Info.plist +13 -0
  518. data/vendor/gyp/test/mac/postbuild-defaults/main.c +7 -0
  519. data/vendor/gyp/test/mac/postbuild-defaults/postbuild-defaults.sh +15 -0
  520. data/vendor/gyp/test/mac/postbuild-defaults/test.gyp +26 -0
  521. data/vendor/gyp/test/mac/postbuild-fail/file.c +6 -0
  522. data/vendor/gyp/test/mac/postbuild-fail/postbuild-fail.sh +6 -0
  523. data/vendor/gyp/test/mac/postbuild-fail/test.gyp +38 -0
  524. data/vendor/gyp/test/mac/postbuild-fail/touch-dynamic.sh +7 -0
  525. data/vendor/gyp/test/mac/postbuild-fail/touch-static.sh +7 -0
  526. data/vendor/gyp/test/mac/postbuild-multiple-configurations/main.c +4 -0
  527. data/vendor/gyp/test/mac/postbuild-multiple-configurations/postbuild-touch-file.sh +7 -0
  528. data/vendor/gyp/test/mac/postbuild-multiple-configurations/test.gyp +26 -0
  529. data/vendor/gyp/test/mac/postbuild-static-library/empty.c +4 -0
  530. data/vendor/gyp/test/mac/postbuild-static-library/postbuild-touch-file.sh +7 -0
  531. data/vendor/gyp/test/mac/postbuild-static-library/test.gyp +34 -0
  532. data/vendor/gyp/test/mac/postbuilds/copy.sh +3 -0
  533. data/vendor/gyp/test/mac/postbuilds/file.c +4 -0
  534. data/vendor/gyp/test/mac/postbuilds/file_g.c +4 -0
  535. data/vendor/gyp/test/mac/postbuilds/file_h.c +4 -0
  536. data/vendor/gyp/test/mac/postbuilds/script/shared_library_postbuild.sh +23 -0
  537. data/vendor/gyp/test/mac/postbuilds/script/static_library_postbuild.sh +23 -0
  538. data/vendor/gyp/test/mac/postbuilds/subdirectory/copied_file.txt +1 -0
  539. data/vendor/gyp/test/mac/postbuilds/subdirectory/nested_target.gyp +53 -0
  540. data/vendor/gyp/test/mac/postbuilds/test.gyp +87 -0
  541. data/vendor/gyp/test/mac/prefixheader/file.c +1 -0
  542. data/vendor/gyp/test/mac/prefixheader/file.cc +1 -0
  543. data/vendor/gyp/test/mac/prefixheader/file.m +1 -0
  544. data/vendor/gyp/test/mac/prefixheader/file.mm +1 -0
  545. data/vendor/gyp/test/mac/prefixheader/header.h +1 -0
  546. data/vendor/gyp/test/mac/prefixheader/test.gyp +82 -0
  547. data/vendor/gyp/test/mac/rebuild/TestApp-Info.plist +32 -0
  548. data/vendor/gyp/test/mac/rebuild/delay-touch.sh +6 -0
  549. data/vendor/gyp/test/mac/rebuild/empty.c +0 -0
  550. data/vendor/gyp/test/mac/rebuild/main.c +1 -0
  551. data/vendor/gyp/test/mac/rebuild/test.gyp +56 -0
  552. data/vendor/gyp/test/mac/rpath/file.c +1 -0
  553. data/vendor/gyp/test/mac/rpath/main.c +1 -0
  554. data/vendor/gyp/test/mac/rpath/test.gyp +48 -0
  555. data/vendor/gyp/test/mac/sdkroot/file.cc +5 -0
  556. data/vendor/gyp/test/mac/sdkroot/test.gyp +21 -0
  557. data/vendor/gyp/test/mac/sdkroot/test_shorthand.sh +8 -0
  558. data/vendor/gyp/test/mac/sourceless-module/empty.c +1 -0
  559. data/vendor/gyp/test/mac/sourceless-module/test.gyp +39 -0
  560. data/vendor/gyp/test/mac/strip/file.c +9 -0
  561. data/vendor/gyp/test/mac/strip/strip.saves +5 -0
  562. data/vendor/gyp/test/mac/strip/subdirectory/nested_file.c +1 -0
  563. data/vendor/gyp/test/mac/strip/subdirectory/nested_strip.saves +5 -0
  564. data/vendor/gyp/test/mac/strip/subdirectory/subdirectory.gyp +38 -0
  565. data/vendor/gyp/test/mac/strip/subdirectory/test_reading_save_file_from_postbuild.sh +5 -0
  566. data/vendor/gyp/test/mac/strip/test.gyp +119 -0
  567. data/vendor/gyp/test/mac/type_envvars/file.c +6 -0
  568. data/vendor/gyp/test/mac/type_envvars/test.gyp +100 -0
  569. data/vendor/gyp/test/mac/type_envvars/test_bundle_executable.sh +21 -0
  570. data/vendor/gyp/test/mac/type_envvars/test_bundle_loadable_module.sh +22 -0
  571. data/vendor/gyp/test/mac/type_envvars/test_bundle_shared_library.sh +23 -0
  572. data/vendor/gyp/test/mac/type_envvars/test_nonbundle_executable.sh +22 -0
  573. data/vendor/gyp/test/mac/type_envvars/test_nonbundle_loadable_module.sh +21 -0
  574. data/vendor/gyp/test/mac/type_envvars/test_nonbundle_none.sh +22 -0
  575. data/vendor/gyp/test/mac/type_envvars/test_nonbundle_shared_library.sh +21 -0
  576. data/vendor/gyp/test/mac/type_envvars/test_nonbundle_static_library.sh +21 -0
  577. data/vendor/gyp/test/mac/xcode-env-order/Info.plist +56 -0
  578. data/vendor/gyp/test/mac/xcode-env-order/file.ext1 +0 -0
  579. data/vendor/gyp/test/mac/xcode-env-order/file.ext2 +0 -0
  580. data/vendor/gyp/test/mac/xcode-env-order/file.ext3 +0 -0
  581. data/vendor/gyp/test/mac/xcode-env-order/main.c +7 -0
  582. data/vendor/gyp/test/mac/xcode-env-order/test.gyp +121 -0
  583. data/vendor/gyp/test/mac/xcode-gcc/test.gyp +60 -0
  584. data/vendor/gyp/test/mac/xcode-gcc/valid_c.c +8 -0
  585. data/vendor/gyp/test/mac/xcode-gcc/valid_cc.cc +8 -0
  586. data/vendor/gyp/test/mac/xcode-gcc/valid_m.m +8 -0
  587. data/vendor/gyp/test/mac/xcode-gcc/valid_mm.mm +8 -0
  588. data/vendor/gyp/test/mac/xcode-gcc/warn_about_invalid_offsetof_macro.cc +15 -0
  589. data/vendor/gyp/test/mac/xcode-gcc/warn_about_missing_newline.c +8 -0
  590. data/vendor/gyp/test/make/dependencies.gyp +15 -0
  591. data/vendor/gyp/test/make/gyptest-dependencies.py +26 -0
  592. data/vendor/gyp/test/make/gyptest-noload.py +57 -0
  593. data/vendor/gyp/test/make/main.cc +12 -0
  594. data/vendor/gyp/test/make/main.h +0 -0
  595. data/vendor/gyp/test/make/noload/all.gyp +18 -0
  596. data/vendor/gyp/test/make/noload/lib/shared.c +3 -0
  597. data/vendor/gyp/test/make/noload/lib/shared.gyp +16 -0
  598. data/vendor/gyp/test/make/noload/lib/shared.h +1 -0
  599. data/vendor/gyp/test/make/noload/main.c +9 -0
  600. data/vendor/gyp/test/many-actions/file0 +0 -0
  601. data/vendor/gyp/test/many-actions/file1 +0 -0
  602. data/vendor/gyp/test/many-actions/file2 +0 -0
  603. data/vendor/gyp/test/many-actions/file3 +0 -0
  604. data/vendor/gyp/test/many-actions/file4 +0 -0
  605. data/vendor/gyp/test/many-actions/gyptest-many-actions-unsorted.py +34 -0
  606. data/vendor/gyp/test/many-actions/gyptest-many-actions.py +20 -0
  607. data/vendor/gyp/test/many-actions/many-actions-unsorted.gyp +154 -0
  608. data/vendor/gyp/test/many-actions/many-actions.gyp +1817 -0
  609. data/vendor/gyp/test/module/gyptest-default.py +29 -0
  610. data/vendor/gyp/test/module/src/lib1.c +10 -0
  611. data/vendor/gyp/test/module/src/lib2.c +10 -0
  612. data/vendor/gyp/test/module/src/module.gyp +55 -0
  613. data/vendor/gyp/test/module/src/program.c +111 -0
  614. data/vendor/gyp/test/msvs/config_attrs/gyptest-config_attrs.py +31 -0
  615. data/vendor/gyp/test/msvs/config_attrs/hello.c +11 -0
  616. data/vendor/gyp/test/msvs/config_attrs/hello.gyp +21 -0
  617. data/vendor/gyp/test/msvs/express/base/base.gyp +22 -0
  618. data/vendor/gyp/test/msvs/express/express.gyp +19 -0
  619. data/vendor/gyp/test/msvs/express/gyptest-express.py +29 -0
  620. data/vendor/gyp/test/msvs/list_excluded/gyptest-all.py +51 -0
  621. data/vendor/gyp/test/msvs/list_excluded/hello.cpp +10 -0
  622. data/vendor/gyp/test/msvs/list_excluded/hello_exclude.gyp +19 -0
  623. data/vendor/gyp/test/msvs/list_excluded/hello_mac.cpp +10 -0
  624. data/vendor/gyp/test/msvs/missing_sources/gyptest-missing.py +41 -0
  625. data/vendor/gyp/test/msvs/missing_sources/hello_missing.gyp +15 -0
  626. data/vendor/gyp/test/msvs/props/AppName.props +14 -0
  627. data/vendor/gyp/test/msvs/props/AppName.vsprops +11 -0
  628. data/vendor/gyp/test/msvs/props/gyptest-props.py +22 -0
  629. data/vendor/gyp/test/msvs/props/hello.c +11 -0
  630. data/vendor/gyp/test/msvs/props/hello.gyp +22 -0
  631. data/vendor/gyp/test/msvs/shared_output/common.gypi +17 -0
  632. data/vendor/gyp/test/msvs/shared_output/gyptest-shared_output.py +41 -0
  633. data/vendor/gyp/test/msvs/shared_output/hello.c +12 -0
  634. data/vendor/gyp/test/msvs/shared_output/hello.gyp +21 -0
  635. data/vendor/gyp/test/msvs/shared_output/there/there.c +12 -0
  636. data/vendor/gyp/test/msvs/shared_output/there/there.gyp +16 -0
  637. data/vendor/gyp/test/msvs/uldi2010/gyptest-all.py +20 -0
  638. data/vendor/gyp/test/msvs/uldi2010/hello.c +13 -0
  639. data/vendor/gyp/test/msvs/uldi2010/hello.gyp +26 -0
  640. data/vendor/gyp/test/msvs/uldi2010/hello2.c +10 -0
  641. data/vendor/gyp/test/multiple-targets/gyptest-all.py +35 -0
  642. data/vendor/gyp/test/multiple-targets/gyptest-default.py +35 -0
  643. data/vendor/gyp/test/multiple-targets/src/common.c +7 -0
  644. data/vendor/gyp/test/multiple-targets/src/multiple.gyp +24 -0
  645. data/vendor/gyp/test/multiple-targets/src/prog1.c +10 -0
  646. data/vendor/gyp/test/multiple-targets/src/prog2.c +10 -0
  647. data/vendor/gyp/test/ninja/action_dependencies/gyptest-action-dependencies.py +53 -0
  648. data/vendor/gyp/test/ninja/action_dependencies/src/a.c +10 -0
  649. data/vendor/gyp/test/ninja/action_dependencies/src/a.h +13 -0
  650. data/vendor/gyp/test/ninja/action_dependencies/src/action_dependencies.gyp +88 -0
  651. data/vendor/gyp/test/ninja/action_dependencies/src/b.c +18 -0
  652. data/vendor/gyp/test/ninja/action_dependencies/src/b.h +13 -0
  653. data/vendor/gyp/test/ninja/action_dependencies/src/c.c +10 -0
  654. data/vendor/gyp/test/ninja/action_dependencies/src/c.h +13 -0
  655. data/vendor/gyp/test/ninja/action_dependencies/src/emit.py +11 -0
  656. data/vendor/gyp/test/ninja/chained-dependency/chained-dependency.gyp +53 -0
  657. data/vendor/gyp/test/ninja/chained-dependency/chained.c +5 -0
  658. data/vendor/gyp/test/ninja/chained-dependency/gyptest-chained-dependency.py +26 -0
  659. data/vendor/gyp/test/ninja/normalize-paths-win/gyptest-normalize-paths.py +42 -0
  660. data/vendor/gyp/test/ninja/normalize-paths-win/hello.cc +7 -0
  661. data/vendor/gyp/test/ninja/normalize-paths-win/normalize-paths.gyp +56 -0
  662. data/vendor/gyp/test/ninja/solibs_avoid_relinking/gyptest-solibs-avoid-relinking.py +41 -0
  663. data/vendor/gyp/test/ninja/solibs_avoid_relinking/main.cc +5 -0
  664. data/vendor/gyp/test/ninja/solibs_avoid_relinking/solib.cc +8 -0
  665. data/vendor/gyp/test/ninja/solibs_avoid_relinking/solibs_avoid_relinking.gyp +38 -0
  666. data/vendor/gyp/test/no-output/gyptest-no-output.py +21 -0
  667. data/vendor/gyp/test/no-output/src/nooutput.gyp +17 -0
  668. data/vendor/gyp/test/product/gyptest-product.py +44 -0
  669. data/vendor/gyp/test/product/hello.c +15 -0
  670. data/vendor/gyp/test/product/product.gyp +128 -0
  671. data/vendor/gyp/test/relative/foo/a/a.cc +9 -0
  672. data/vendor/gyp/test/relative/foo/a/a.gyp +13 -0
  673. data/vendor/gyp/test/relative/foo/a/c/c.cc +9 -0
  674. data/vendor/gyp/test/relative/foo/a/c/c.gyp +12 -0
  675. data/vendor/gyp/test/relative/foo/b/b.cc +9 -0
  676. data/vendor/gyp/test/relative/foo/b/b.gyp +9 -0
  677. data/vendor/gyp/test/relative/gyptest-default.py +25 -0
  678. data/vendor/gyp/test/rename/filecase/file.c +1 -0
  679. data/vendor/gyp/test/rename/filecase/test-casesensitive.gyp +15 -0
  680. data/vendor/gyp/test/rename/filecase/test.gyp +14 -0
  681. data/vendor/gyp/test/rename/gyptest-filecase.py +35 -0
  682. data/vendor/gyp/test/restat/gyptest-restat.py +31 -0
  683. data/vendor/gyp/test/restat/src/create_intermediate.py +17 -0
  684. data/vendor/gyp/test/restat/src/restat.gyp +50 -0
  685. data/vendor/gyp/test/restat/src/touch.py +16 -0
  686. data/vendor/gyp/test/rules-dirname/gyptest-dirname.py +38 -0
  687. data/vendor/gyp/test/rules-dirname/src/actions.gyp +15 -0
  688. data/vendor/gyp/test/rules-dirname/src/copy-file.py +11 -0
  689. data/vendor/gyp/test/rules-dirname/src/subdir/a/b/c.gencc +11 -0
  690. data/vendor/gyp/test/rules-dirname/src/subdir/a/b/c.printvars +1 -0
  691. data/vendor/gyp/test/rules-dirname/src/subdir/foo/bar/baz.gencc +11 -0
  692. data/vendor/gyp/test/rules-dirname/src/subdir/foo/bar/baz.printvars +1 -0
  693. data/vendor/gyp/test/rules-dirname/src/subdir/input-rule-dirname.gyp +92 -0
  694. data/vendor/gyp/test/rules-dirname/src/subdir/main.cc +12 -0
  695. data/vendor/gyp/test/rules-dirname/src/subdir/printvars.py +14 -0
  696. data/vendor/gyp/test/rules-rebuild/gyptest-all.py +70 -0
  697. data/vendor/gyp/test/rules-rebuild/gyptest-default.py +91 -0
  698. data/vendor/gyp/test/rules-rebuild/src/main.c +12 -0
  699. data/vendor/gyp/test/rules-rebuild/src/make-sources.py +19 -0
  700. data/vendor/gyp/test/rules-rebuild/src/prog1.in +7 -0
  701. data/vendor/gyp/test/rules-rebuild/src/prog2.in +7 -0
  702. data/vendor/gyp/test/rules-rebuild/src/same_target.gyp +31 -0
  703. data/vendor/gyp/test/rules-variables/gyptest-rules-variables.py +26 -0
  704. data/vendor/gyp/test/rules-variables/src/input_ext.c +9 -0
  705. data/vendor/gyp/test/rules-variables/src/input_name/test.c +9 -0
  706. data/vendor/gyp/test/rules-variables/src/input_path/subdir/test.c +9 -0
  707. data/vendor/gyp/test/rules-variables/src/subdir/input_dirname.c +9 -0
  708. data/vendor/gyp/test/rules-variables/src/subdir/test.c +18 -0
  709. data/vendor/gyp/test/rules-variables/src/test.input_root.c +9 -0
  710. data/vendor/gyp/test/rules-variables/src/variables.gyp +40 -0
  711. data/vendor/gyp/test/rules/gyptest-all.py +69 -0
  712. data/vendor/gyp/test/rules/gyptest-default.py +55 -0
  713. data/vendor/gyp/test/rules/gyptest-input-root.py +26 -0
  714. data/vendor/gyp/test/rules/gyptest-special-variables.py +18 -0
  715. data/vendor/gyp/test/rules/src/actions.gyp +22 -0
  716. data/vendor/gyp/test/rules/src/an_asm.S +6 -0
  717. data/vendor/gyp/test/rules/src/as.bat +7 -0
  718. data/vendor/gyp/test/rules/src/copy-file.py +11 -0
  719. data/vendor/gyp/test/rules/src/external/external.gyp +66 -0
  720. data/vendor/gyp/test/rules/src/external/file1.in +1 -0
  721. data/vendor/gyp/test/rules/src/external/file2.in +1 -0
  722. data/vendor/gyp/test/rules/src/input-root.gyp +24 -0
  723. data/vendor/gyp/test/rules/src/noaction/file1.in +1 -0
  724. data/vendor/gyp/test/rules/src/noaction/no_action_with_rules_fails.gyp +37 -0
  725. data/vendor/gyp/test/rules/src/rule.py +17 -0
  726. data/vendor/gyp/test/rules/src/somefile.ext +0 -0
  727. data/vendor/gyp/test/rules/src/special-variables.gyp +35 -0
  728. data/vendor/gyp/test/rules/src/subdir1/executable.gyp +37 -0
  729. data/vendor/gyp/test/rules/src/subdir1/function1.in +6 -0
  730. data/vendor/gyp/test/rules/src/subdir1/function2.in +6 -0
  731. data/vendor/gyp/test/rules/src/subdir1/program.c +12 -0
  732. data/vendor/gyp/test/rules/src/subdir2/file1.in +1 -0
  733. data/vendor/gyp/test/rules/src/subdir2/file2.in +1 -0
  734. data/vendor/gyp/test/rules/src/subdir2/never_used.gyp +31 -0
  735. data/vendor/gyp/test/rules/src/subdir2/no_action.gyp +38 -0
  736. data/vendor/gyp/test/rules/src/subdir2/no_inputs.gyp +32 -0
  737. data/vendor/gyp/test/rules/src/subdir2/none.gyp +33 -0
  738. data/vendor/gyp/test/rules/src/subdir3/executable2.gyp +37 -0
  739. data/vendor/gyp/test/rules/src/subdir3/function3.in +6 -0
  740. data/vendor/gyp/test/rules/src/subdir3/program.c +10 -0
  741. data/vendor/gyp/test/rules/src/subdir4/asm-function.asm +10 -0
  742. data/vendor/gyp/test/rules/src/subdir4/build-asm.gyp +49 -0
  743. data/vendor/gyp/test/rules/src/subdir4/program.c +19 -0
  744. data/vendor/gyp/test/same-gyp-name/gyptest-all.py +34 -0
  745. data/vendor/gyp/test/same-gyp-name/gyptest-default.py +34 -0
  746. data/vendor/gyp/test/same-gyp-name/src/all.gyp +16 -0
  747. data/vendor/gyp/test/same-gyp-name/src/subdir1/executable.gyp +15 -0
  748. data/vendor/gyp/test/same-gyp-name/src/subdir1/main1.cc +6 -0
  749. data/vendor/gyp/test/same-gyp-name/src/subdir2/executable.gyp +15 -0
  750. data/vendor/gyp/test/same-gyp-name/src/subdir2/main2.cc +6 -0
  751. data/vendor/gyp/test/same-rule-output-file-name/gyptest-all.py +23 -0
  752. data/vendor/gyp/test/same-rule-output-file-name/src/subdir1/subdir1.gyp +30 -0
  753. data/vendor/gyp/test/same-rule-output-file-name/src/subdir2/subdir2.gyp +30 -0
  754. data/vendor/gyp/test/same-rule-output-file-name/src/subdirs.gyp +16 -0
  755. data/vendor/gyp/test/same-rule-output-file-name/src/touch.py +11 -0
  756. data/vendor/gyp/test/same-source-file-name/gyptest-all.py +34 -0
  757. data/vendor/gyp/test/same-source-file-name/gyptest-default.py +34 -0
  758. data/vendor/gyp/test/same-source-file-name/gyptest-fail.py +0 -0
  759. data/vendor/gyp/test/same-source-file-name/src/all.gyp +30 -0
  760. data/vendor/gyp/test/same-source-file-name/src/double.gyp +0 -0
  761. data/vendor/gyp/test/same-source-file-name/src/func.c +6 -0
  762. data/vendor/gyp/test/same-source-file-name/src/prog1.c +16 -0
  763. data/vendor/gyp/test/same-source-file-name/src/prog2.c +16 -0
  764. data/vendor/gyp/test/same-source-file-name/src/subdir1/func.c +6 -0
  765. data/vendor/gyp/test/same-source-file-name/src/subdir2/func.c +6 -0
  766. data/vendor/gyp/test/same-target-name-different-directory/gyptest-all.py +36 -0
  767. data/vendor/gyp/test/same-target-name-different-directory/src/subdir1/subdir1.gyp +66 -0
  768. data/vendor/gyp/test/same-target-name-different-directory/src/subdir2/subdir2.gyp +66 -0
  769. data/vendor/gyp/test/same-target-name-different-directory/src/subdirs.gyp +16 -0
  770. data/vendor/gyp/test/same-target-name-different-directory/src/touch.py +11 -0
  771. data/vendor/gyp/test/same-target-name/gyptest-same-target-name.py +18 -0
  772. data/vendor/gyp/test/same-target-name/src/all.gyp +16 -0
  773. data/vendor/gyp/test/same-target-name/src/executable1.gyp +15 -0
  774. data/vendor/gyp/test/same-target-name/src/executable2.gyp +15 -0
  775. data/vendor/gyp/test/sanitize-rule-names/blah.S +0 -0
  776. data/vendor/gyp/test/sanitize-rule-names/gyptest-sanitize-rule-names.py +17 -0
  777. data/vendor/gyp/test/sanitize-rule-names/hello.cc +7 -0
  778. data/vendor/gyp/test/sanitize-rule-names/sanitize-rule-names.gyp +27 -0
  779. data/vendor/gyp/test/sanitize-rule-names/script.py +10 -0
  780. data/vendor/gyp/test/scons_tools/gyptest-tools.py +26 -0
  781. data/vendor/gyp/test/scons_tools/site_scons/site_tools/this_tool.py +10 -0
  782. data/vendor/gyp/test/scons_tools/tools.c +13 -0
  783. data/vendor/gyp/test/scons_tools/tools.gyp +18 -0
  784. data/vendor/gyp/test/sibling/gyptest-all.py +39 -0
  785. data/vendor/gyp/test/sibling/gyptest-relocate.py +41 -0
  786. data/vendor/gyp/test/sibling/src/build/all.gyp +17 -0
  787. data/vendor/gyp/test/sibling/src/prog1/prog1.c +7 -0
  788. data/vendor/gyp/test/sibling/src/prog1/prog1.gyp +15 -0
  789. data/vendor/gyp/test/sibling/src/prog2/prog2.c +7 -0
  790. data/vendor/gyp/test/sibling/src/prog2/prog2.gyp +15 -0
  791. data/vendor/gyp/test/small/gyptest-small.py +53 -0
  792. data/vendor/gyp/test/standalone/gyptest-standalone.py +33 -0
  793. data/vendor/gyp/test/standalone/standalone.gyp +12 -0
  794. data/vendor/gyp/test/subdirectory/gyptest-SYMROOT-all.py +36 -0
  795. data/vendor/gyp/test/subdirectory/gyptest-SYMROOT-default.py +37 -0
  796. data/vendor/gyp/test/subdirectory/gyptest-subdir-all.py +33 -0
  797. data/vendor/gyp/test/subdirectory/gyptest-subdir-default.py +33 -0
  798. data/vendor/gyp/test/subdirectory/gyptest-subdir2-deep.py +25 -0
  799. data/vendor/gyp/test/subdirectory/gyptest-top-all.py +43 -0
  800. data/vendor/gyp/test/subdirectory/gyptest-top-default.py +43 -0
  801. data/vendor/gyp/test/subdirectory/src/prog1.c +7 -0
  802. data/vendor/gyp/test/subdirectory/src/prog1.gyp +21 -0
  803. data/vendor/gyp/test/subdirectory/src/subdir/prog2.c +7 -0
  804. data/vendor/gyp/test/subdirectory/src/subdir/prog2.gyp +18 -0
  805. data/vendor/gyp/test/subdirectory/src/subdir/subdir2/prog3.c +7 -0
  806. data/vendor/gyp/test/subdirectory/src/subdir/subdir2/prog3.gyp +18 -0
  807. data/vendor/gyp/test/subdirectory/src/symroot.gypi +16 -0
  808. data/vendor/gyp/test/toolsets/gyptest-toolsets.py +23 -0
  809. data/vendor/gyp/test/toolsets/main.cc +11 -0
  810. data/vendor/gyp/test/toolsets/toolsets.cc +11 -0
  811. data/vendor/gyp/test/toolsets/toolsets.gyp +49 -0
  812. data/vendor/gyp/test/toplevel-dir/gyptest-toplevel-dir.py +31 -0
  813. data/vendor/gyp/test/toplevel-dir/src/sub1/main.gyp +18 -0
  814. data/vendor/gyp/test/toplevel-dir/src/sub1/prog1.c +7 -0
  815. data/vendor/gyp/test/toplevel-dir/src/sub2/prog2.c +7 -0
  816. data/vendor/gyp/test/toplevel-dir/src/sub2/prog2.gyp +15 -0
  817. data/vendor/gyp/test/variables/commands/commands-repeated.gyp +128 -0
  818. data/vendor/gyp/test/variables/commands/commands-repeated.gyp.stdout +136 -0
  819. data/vendor/gyp/test/variables/commands/commands-repeated.gypd.golden +72 -0
  820. data/vendor/gyp/test/variables/commands/commands.gyp +86 -0
  821. data/vendor/gyp/test/variables/commands/commands.gyp.ignore-env.stdout +86 -0
  822. data/vendor/gyp/test/variables/commands/commands.gyp.stdout +86 -0
  823. data/vendor/gyp/test/variables/commands/commands.gypd.golden +56 -0
  824. data/vendor/gyp/test/variables/commands/commands.gypi +16 -0
  825. data/vendor/gyp/test/variables/commands/gyptest-commands-ignore-env.py +46 -0
  826. data/vendor/gyp/test/variables/commands/gyptest-commands-repeated.py +38 -0
  827. data/vendor/gyp/test/variables/commands/gyptest-commands.py +39 -0
  828. data/vendor/gyp/test/variables/commands/test.py +1 -0
  829. data/vendor/gyp/test/variables/commands/update_golden +11 -0
  830. data/vendor/gyp/test/variables/filelist/filelist.gyp.stdout +26 -0
  831. data/vendor/gyp/test/variables/filelist/filelist.gypd.golden +43 -0
  832. data/vendor/gyp/test/variables/filelist/gyptest-filelist.py +50 -0
  833. data/vendor/gyp/test/variables/filelist/src/filelist.gyp +93 -0
  834. data/vendor/gyp/test/variables/filelist/update_golden +8 -0
  835. data/vendor/gyp/test/variables/latelate/gyptest-latelate.py +25 -0
  836. data/vendor/gyp/test/variables/latelate/src/latelate.gyp +34 -0
  837. data/vendor/gyp/test/variables/latelate/src/program.cc +13 -0
  838. data/vendor/gyp/test/variables/variable-in-path/C1/hello.cc +7 -0
  839. data/vendor/gyp/test/variables/variable-in-path/gyptest-variable-in-path.py +23 -0
  840. data/vendor/gyp/test/variables/variable-in-path/variable-in-path.gyp +31 -0
  841. data/vendor/gyp/test/variants/gyptest-variants.py +45 -0
  842. data/vendor/gyp/test/variants/src/variants.c +13 -0
  843. data/vendor/gyp/test/variants/src/variants.gyp +27 -0
  844. data/vendor/gyp/test/win/asm-files/asm-files.gyp +17 -0
  845. data/vendor/gyp/test/win/asm-files/b.s +0 -0
  846. data/vendor/gyp/test/win/asm-files/c.S +0 -0
  847. data/vendor/gyp/test/win/asm-files/hello.cc +7 -0
  848. data/vendor/gyp/test/win/batch-file-action/batch-file-action.gyp +21 -0
  849. data/vendor/gyp/test/win/batch-file-action/infile +1 -0
  850. data/vendor/gyp/test/win/batch-file-action/somecmd.bat +5 -0
  851. data/vendor/gyp/test/win/command-quote/a.S +0 -0
  852. data/vendor/gyp/test/win/command-quote/bat with spaces.bat +7 -0
  853. data/vendor/gyp/test/win/command-quote/command-quote.gyp +84 -0
  854. data/vendor/gyp/test/win/command-quote/go.bat +7 -0
  855. data/vendor/gyp/test/win/command-quote/subdir/and/another/in-subdir.gyp +28 -0
  856. data/vendor/gyp/test/win/compiler-flags/additional-include-dirs.cc +10 -0
  857. data/vendor/gyp/test/win/compiler-flags/additional-include-dirs.gyp +20 -0
  858. data/vendor/gyp/test/win/compiler-flags/additional-options.cc +10 -0
  859. data/vendor/gyp/test/win/compiler-flags/additional-options.gyp +31 -0
  860. data/vendor/gyp/test/win/compiler-flags/buffer-security-check.gyp +51 -0
  861. data/vendor/gyp/test/win/compiler-flags/buffer-security.cc +12 -0
  862. data/vendor/gyp/test/win/compiler-flags/character-set-mbcs.cc +11 -0
  863. data/vendor/gyp/test/win/compiler-flags/character-set-unicode.cc +15 -0
  864. data/vendor/gyp/test/win/compiler-flags/character-set.gyp +35 -0
  865. data/vendor/gyp/test/win/compiler-flags/debug-format.gyp +48 -0
  866. data/vendor/gyp/test/win/compiler-flags/exception-handling-on.cc +24 -0
  867. data/vendor/gyp/test/win/compiler-flags/exception-handling.gyp +46 -0
  868. data/vendor/gyp/test/win/compiler-flags/function-level-linking.cc +11 -0
  869. data/vendor/gyp/test/win/compiler-flags/function-level-linking.gyp +28 -0
  870. data/vendor/gyp/test/win/compiler-flags/hello.cc +7 -0
  871. data/vendor/gyp/test/win/compiler-flags/optimizations.gyp +147 -0
  872. data/vendor/gyp/test/win/compiler-flags/pdbname.cc +7 -0
  873. data/vendor/gyp/test/win/compiler-flags/pdbname.gyp +24 -0
  874. data/vendor/gyp/test/win/compiler-flags/rtti-on.cc +11 -0
  875. data/vendor/gyp/test/win/compiler-flags/rtti.gyp +37 -0
  876. data/vendor/gyp/test/win/compiler-flags/runtime-checks.cc +11 -0
  877. data/vendor/gyp/test/win/compiler-flags/runtime-checks.gyp +29 -0
  878. data/vendor/gyp/test/win/compiler-flags/runtime-library-md.cc +19 -0
  879. data/vendor/gyp/test/win/compiler-flags/runtime-library-mdd.cc +19 -0
  880. data/vendor/gyp/test/win/compiler-flags/runtime-library-mt.cc +19 -0
  881. data/vendor/gyp/test/win/compiler-flags/runtime-library-mtd.cc +19 -0
  882. data/vendor/gyp/test/win/compiler-flags/runtime-library.gyp +48 -0
  883. data/vendor/gyp/test/win/compiler-flags/subdir/header.h +0 -0
  884. data/vendor/gyp/test/win/compiler-flags/warning-as-error.cc +9 -0
  885. data/vendor/gyp/test/win/compiler-flags/warning-as-error.gyp +37 -0
  886. data/vendor/gyp/test/win/compiler-flags/warning-level.gyp +115 -0
  887. data/vendor/gyp/test/win/compiler-flags/warning-level1.cc +8 -0
  888. data/vendor/gyp/test/win/compiler-flags/warning-level2.cc +14 -0
  889. data/vendor/gyp/test/win/compiler-flags/warning-level3.cc +11 -0
  890. data/vendor/gyp/test/win/compiler-flags/warning-level4.cc +10 -0
  891. data/vendor/gyp/test/win/gyptest-asm-files.py +26 -0
  892. data/vendor/gyp/test/win/gyptest-cl-additional-include-dirs.py +22 -0
  893. data/vendor/gyp/test/win/gyptest-cl-additional-options.py +28 -0
  894. data/vendor/gyp/test/win/gyptest-cl-buffer-security-check.py +53 -0
  895. data/vendor/gyp/test/win/gyptest-cl-character-set.py +22 -0
  896. data/vendor/gyp/test/win/gyptest-cl-debug-format.py +43 -0
  897. data/vendor/gyp/test/win/gyptest-cl-exception-handling.py +33 -0
  898. data/vendor/gyp/test/win/gyptest-cl-function-level-linking.py +52 -0
  899. data/vendor/gyp/test/win/gyptest-cl-optimizations.py +79 -0
  900. data/vendor/gyp/test/win/gyptest-cl-pdbname.py +26 -0
  901. data/vendor/gyp/test/win/gyptest-cl-rtti.py +30 -0
  902. data/vendor/gyp/test/win/gyptest-cl-runtime-checks.py +30 -0
  903. data/vendor/gyp/test/win/gyptest-cl-runtime-library.py +22 -0
  904. data/vendor/gyp/test/win/gyptest-cl-warning-as-error.py +30 -0
  905. data/vendor/gyp/test/win/gyptest-cl-warning-level.py +41 -0
  906. data/vendor/gyp/test/win/gyptest-command-quote.py +37 -0
  907. data/vendor/gyp/test/win/gyptest-link-additional-deps.py +22 -0
  908. data/vendor/gyp/test/win/gyptest-link-additional-options.py +22 -0
  909. data/vendor/gyp/test/win/gyptest-link-aslr.py +35 -0
  910. data/vendor/gyp/test/win/gyptest-link-debug-info.py +26 -0
  911. data/vendor/gyp/test/win/gyptest-link-default-libs.py +22 -0
  912. data/vendor/gyp/test/win/gyptest-link-deffile.py +43 -0
  913. data/vendor/gyp/test/win/gyptest-link-delay-load-dlls.py +35 -0
  914. data/vendor/gyp/test/win/gyptest-link-entrypointsymbol.py +24 -0
  915. data/vendor/gyp/test/win/gyptest-link-fixed-base.py +40 -0
  916. data/vendor/gyp/test/win/gyptest-link-generate-manifest.py +44 -0
  917. data/vendor/gyp/test/win/gyptest-link-incremental.py +37 -0
  918. data/vendor/gyp/test/win/gyptest-link-library-adjust.py +21 -0
  919. data/vendor/gyp/test/win/gyptest-link-library-directories.py +35 -0
  920. data/vendor/gyp/test/win/gyptest-link-nodefaultlib.py +24 -0
  921. data/vendor/gyp/test/win/gyptest-link-nxcompat.py +37 -0
  922. data/vendor/gyp/test/win/gyptest-link-opt-icf.py +41 -0
  923. data/vendor/gyp/test/win/gyptest-link-opt-ref.py +40 -0
  924. data/vendor/gyp/test/win/gyptest-link-outputfile.py +28 -0
  925. data/vendor/gyp/test/win/gyptest-link-restat-importlib.py +39 -0
  926. data/vendor/gyp/test/win/gyptest-link-subsystem.py +28 -0
  927. data/vendor/gyp/test/win/gyptest-link-uldi.py +28 -0
  928. data/vendor/gyp/test/win/gyptest-long-command-line.py +23 -0
  929. data/vendor/gyp/test/win/gyptest-macro-projectname.py +24 -0
  930. data/vendor/gyp/test/win/gyptest-macro-vcinstalldir.py +24 -0
  931. data/vendor/gyp/test/win/gyptest-macros-containing-gyp.py +21 -0
  932. data/vendor/gyp/test/win/gyptest-macros-in-inputs-and-outputs.py +27 -0
  933. data/vendor/gyp/test/win/gyptest-midl-rules.py +22 -0
  934. data/vendor/gyp/test/win/gyptest-quoting-commands.py +25 -0
  935. data/vendor/gyp/test/win/gyptest-rc-build.py +24 -0
  936. data/vendor/gyp/test/win/idl-rules/basic-idl.gyp +30 -0
  937. data/vendor/gyp/test/win/idl-rules/history_indexer.idl +17 -0
  938. data/vendor/gyp/test/win/idl-rules/history_indexer_user.cc +15 -0
  939. data/vendor/gyp/test/win/importlib/has-exports.cc +10 -0
  940. data/vendor/gyp/test/win/importlib/hello.cc +9 -0
  941. data/vendor/gyp/test/win/importlib/importlib.gyp +30 -0
  942. data/vendor/gyp/test/win/linker-flags/additional-deps.cc +10 -0
  943. data/vendor/gyp/test/win/linker-flags/additional-deps.gyp +30 -0
  944. data/vendor/gyp/test/win/linker-flags/additional-options.gyp +29 -0
  945. data/vendor/gyp/test/win/linker-flags/aslr.gyp +35 -0
  946. data/vendor/gyp/test/win/linker-flags/debug-info.gyp +28 -0
  947. data/vendor/gyp/test/win/linker-flags/default-libs.cc +30 -0
  948. data/vendor/gyp/test/win/linker-flags/default-libs.gyp +13 -0
  949. data/vendor/gyp/test/win/linker-flags/deffile-multiple.gyp +17 -0
  950. data/vendor/gyp/test/win/linker-flags/deffile.cc +10 -0
  951. data/vendor/gyp/test/win/linker-flags/deffile.def +8 -0
  952. data/vendor/gyp/test/win/linker-flags/deffile.gyp +38 -0
  953. data/vendor/gyp/test/win/linker-flags/delay-load-dlls.gyp +27 -0
  954. data/vendor/gyp/test/win/linker-flags/delay-load.cc +10 -0
  955. data/vendor/gyp/test/win/linker-flags/entrypointsymbol.cc +13 -0
  956. data/vendor/gyp/test/win/linker-flags/entrypointsymbol.gyp +28 -0
  957. data/vendor/gyp/test/win/linker-flags/extra.manifest +11 -0
  958. data/vendor/gyp/test/win/linker-flags/extra2.manifest +11 -0
  959. data/vendor/gyp/test/win/linker-flags/fixed-base.gyp +52 -0
  960. data/vendor/gyp/test/win/linker-flags/generate-manifest.gyp +64 -0
  961. data/vendor/gyp/test/win/linker-flags/hello.cc +7 -0
  962. data/vendor/gyp/test/win/linker-flags/incremental.gyp +65 -0
  963. data/vendor/gyp/test/win/linker-flags/library-adjust.cc +10 -0
  964. data/vendor/gyp/test/win/linker-flags/library-adjust.gyp +16 -0
  965. data/vendor/gyp/test/win/linker-flags/library-directories-define.cc +7 -0
  966. data/vendor/gyp/test/win/linker-flags/library-directories-reference.cc +10 -0
  967. data/vendor/gyp/test/win/linker-flags/library-directories.gyp +42 -0
  968. data/vendor/gyp/test/win/linker-flags/nodefaultlib.cc +13 -0
  969. data/vendor/gyp/test/win/linker-flags/nodefaultlib.gyp +30 -0
  970. data/vendor/gyp/test/win/linker-flags/nxcompat.gyp +35 -0
  971. data/vendor/gyp/test/win/linker-flags/opt-icf.cc +29 -0
  972. data/vendor/gyp/test/win/linker-flags/opt-icf.gyp +63 -0
  973. data/vendor/gyp/test/win/linker-flags/opt-ref.cc +11 -0
  974. data/vendor/gyp/test/win/linker-flags/opt-ref.gyp +56 -0
  975. data/vendor/gyp/test/win/linker-flags/outputfile.gyp +58 -0
  976. data/vendor/gyp/test/win/linker-flags/subdir/library.gyp +13 -0
  977. data/vendor/gyp/test/win/linker-flags/subsystem-windows.cc +9 -0
  978. data/vendor/gyp/test/win/linker-flags/subsystem.gyp +48 -0
  979. data/vendor/gyp/test/win/long-command-line/function.cc +7 -0
  980. data/vendor/gyp/test/win/long-command-line/hello.cc +7 -0
  981. data/vendor/gyp/test/win/long-command-line/long-command-line.gyp +54 -0
  982. data/vendor/gyp/test/win/precompiled/gyptest-all.py +21 -0
  983. data/vendor/gyp/test/win/precompiled/hello.c +14 -0
  984. data/vendor/gyp/test/win/precompiled/hello.gyp +28 -0
  985. data/vendor/gyp/test/win/precompiled/hello2.c +13 -0
  986. data/vendor/gyp/test/win/precompiled/precomp.c +8 -0
  987. data/vendor/gyp/test/win/rc-build/Resource.h +26 -0
  988. data/vendor/gyp/test/win/rc-build/hello.cpp +30 -0
  989. data/vendor/gyp/test/win/rc-build/hello.gyp +58 -0
  990. data/vendor/gyp/test/win/rc-build/hello.h +3 -0
  991. data/vendor/gyp/test/win/rc-build/hello.ico +0 -0
  992. data/vendor/gyp/test/win/rc-build/hello.rc +86 -0
  993. data/vendor/gyp/test/win/rc-build/small.ico +0 -0
  994. data/vendor/gyp/test/win/rc-build/subdir/hello2.rc +87 -0
  995. data/vendor/gyp/test/win/rc-build/subdir/include.h +1 -0
  996. data/vendor/gyp/test/win/rc-build/targetver.h +24 -0
  997. data/vendor/gyp/test/win/uldi/a.cc +7 -0
  998. data/vendor/gyp/test/win/uldi/b.cc +7 -0
  999. data/vendor/gyp/test/win/uldi/main.cc +10 -0
  1000. data/vendor/gyp/test/win/uldi/uldi.gyp +45 -0
  1001. data/vendor/gyp/test/win/vs-macros/as.py +18 -0
  1002. data/vendor/gyp/test/win/vs-macros/containing-gyp.gyp +40 -0
  1003. data/vendor/gyp/test/win/vs-macros/do_stuff.py +8 -0
  1004. data/vendor/gyp/test/win/vs-macros/hello.cc +7 -0
  1005. data/vendor/gyp/test/win/vs-macros/input-output-macros.gyp +33 -0
  1006. data/vendor/gyp/test/win/vs-macros/input.S +0 -0
  1007. data/vendor/gyp/test/win/vs-macros/projectname.gyp +29 -0
  1008. data/vendor/gyp/test/win/vs-macros/stuff.blah +1 -0
  1009. data/vendor/gyp/test/win/vs-macros/test_exists.py +10 -0
  1010. data/vendor/gyp/test/win/vs-macros/vcinstalldir.gyp +41 -0
  1011. data/vendor/gyp/tools/README +15 -0
  1012. data/vendor/gyp/tools/Xcode/README +5 -0
  1013. data/vendor/gyp/tools/Xcode/Specifications/gyp.pbfilespec +27 -0
  1014. data/vendor/gyp/tools/Xcode/Specifications/gyp.xclangspec +226 -0
  1015. data/vendor/gyp/tools/emacs/README +12 -0
  1016. data/vendor/gyp/tools/emacs/gyp-tests.el +54 -0
  1017. data/vendor/gyp/tools/emacs/gyp.el +251 -0
  1018. data/vendor/gyp/tools/emacs/run-unit-tests.sh +7 -0
  1019. data/vendor/gyp/tools/emacs/testdata/media.gyp +1105 -0
  1020. data/vendor/gyp/tools/emacs/testdata/media.gyp.fontified +1107 -0
  1021. data/vendor/gyp/tools/graphviz.py +100 -0
  1022. data/vendor/gyp/tools/pretty_gyp.py +155 -0
  1023. data/vendor/gyp/tools/pretty_sln.py +168 -0
  1024. data/vendor/gyp/tools/pretty_vcproj.py +329 -0
  1025. metadata +1015 -1007
@@ -0,0 +1,3165 @@
1
+ # Copyright (c) 2012 Google Inc. All rights reserved.
2
+ # Use of this source code is governed by a BSD-style license that can be
3
+ # found in the LICENSE file.
4
+
5
+ import copy
6
+ import ntpath
7
+ import os
8
+ import posixpath
9
+ import re
10
+ import subprocess
11
+ import sys
12
+
13
+ import gyp.common
14
+ import gyp.easy_xml as easy_xml
15
+ import gyp.MSVSNew as MSVSNew
16
+ import gyp.MSVSProject as MSVSProject
17
+ import gyp.MSVSSettings as MSVSSettings
18
+ import gyp.MSVSToolFile as MSVSToolFile
19
+ import gyp.MSVSUserFile as MSVSUserFile
20
+ import gyp.MSVSVersion as MSVSVersion
21
+ from gyp.common import GypError
22
+
23
+
24
+ # Regular expression for validating Visual Studio GUIDs. If the GUID
25
+ # contains lowercase hex letters, MSVS will be fine. However,
26
+ # IncrediBuild BuildConsole will parse the solution file, but then
27
+ # silently skip building the target causing hard to track down errors.
28
+ # Note that this only happens with the BuildConsole, and does not occur
29
+ # if IncrediBuild is executed from inside Visual Studio. This regex
30
+ # validates that the string looks like a GUID with all uppercase hex
31
+ # letters.
32
+ VALID_MSVS_GUID_CHARS = re.compile('^[A-F0-9\-]+$')
33
+
34
+
35
+ generator_default_variables = {
36
+ 'EXECUTABLE_PREFIX': '',
37
+ 'EXECUTABLE_SUFFIX': '.exe',
38
+ 'STATIC_LIB_PREFIX': '',
39
+ 'SHARED_LIB_PREFIX': '',
40
+ 'STATIC_LIB_SUFFIX': '.lib',
41
+ 'SHARED_LIB_SUFFIX': '.dll',
42
+ 'INTERMEDIATE_DIR': '$(IntDir)',
43
+ 'SHARED_INTERMEDIATE_DIR': '$(OutDir)obj/global_intermediate',
44
+ 'OS': 'win',
45
+ 'PRODUCT_DIR': '$(OutDir)',
46
+ 'LIB_DIR': '$(OutDir)lib',
47
+ 'RULE_INPUT_ROOT': '$(InputName)',
48
+ 'RULE_INPUT_DIRNAME': '$(InputDir)',
49
+ 'RULE_INPUT_EXT': '$(InputExt)',
50
+ 'RULE_INPUT_NAME': '$(InputFileName)',
51
+ 'RULE_INPUT_PATH': '$(InputPath)',
52
+ 'CONFIGURATION_NAME': '$(ConfigurationName)',
53
+ }
54
+
55
+
56
+ # The msvs specific sections that hold paths
57
+ generator_additional_path_sections = [
58
+ 'msvs_cygwin_dirs',
59
+ 'msvs_props',
60
+ ]
61
+
62
+
63
+ generator_additional_non_configuration_keys = [
64
+ 'msvs_cygwin_dirs',
65
+ 'msvs_cygwin_shell',
66
+ 'msvs_shard',
67
+ ]
68
+
69
+
70
+ # List of precompiled header related keys.
71
+ precomp_keys = [
72
+ 'msvs_precompiled_header',
73
+ 'msvs_precompiled_source',
74
+ ]
75
+
76
+
77
+ cached_username = None
78
+
79
+
80
+ cached_domain = None
81
+
82
+
83
+ # TODO(gspencer): Switch the os.environ calls to be
84
+ # win32api.GetDomainName() and win32api.GetUserName() once the
85
+ # python version in depot_tools has been updated to work on Vista
86
+ # 64-bit.
87
+ def _GetDomainAndUserName():
88
+ if sys.platform not in ('win32', 'cygwin'):
89
+ return ('DOMAIN', 'USERNAME')
90
+ global cached_username
91
+ global cached_domain
92
+ if not cached_domain or not cached_username:
93
+ domain = os.environ.get('USERDOMAIN')
94
+ username = os.environ.get('USERNAME')
95
+ if not domain or not username:
96
+ call = subprocess.Popen(['net', 'config', 'Workstation'],
97
+ stdout=subprocess.PIPE)
98
+ config = call.communicate()[0]
99
+ username_re = re.compile('^User name\s+(\S+)', re.MULTILINE)
100
+ username_match = username_re.search(config)
101
+ if username_match:
102
+ username = username_match.group(1)
103
+ domain_re = re.compile('^Logon domain\s+(\S+)', re.MULTILINE)
104
+ domain_match = domain_re.search(config)
105
+ if domain_match:
106
+ domain = domain_match.group(1)
107
+ cached_domain = domain
108
+ cached_username = username
109
+ return (cached_domain, cached_username)
110
+
111
+ fixpath_prefix = None
112
+
113
+
114
+ def _NormalizedSource(source):
115
+ """Normalize the path.
116
+
117
+ But not if that gets rid of a variable, as this may expand to something
118
+ larger than one directory.
119
+
120
+ Arguments:
121
+ source: The path to be normalize.d
122
+
123
+ Returns:
124
+ The normalized path.
125
+ """
126
+ normalized = os.path.normpath(source)
127
+ if source.count('$') == normalized.count('$'):
128
+ source = normalized
129
+ return source
130
+
131
+
132
+ def _FixPath(path):
133
+ """Convert paths to a form that will make sense in a vcproj file.
134
+
135
+ Arguments:
136
+ path: The path to convert, may contain / etc.
137
+ Returns:
138
+ The path with all slashes made into backslashes.
139
+ """
140
+ if fixpath_prefix and path and not os.path.isabs(path) and not path[0] == '$':
141
+ path = os.path.join(fixpath_prefix, path)
142
+ path = path.replace('/', '\\')
143
+ path = _NormalizedSource(path)
144
+ if path and path[-1] == '\\':
145
+ path = path[:-1]
146
+ return path
147
+
148
+
149
+ def _FixPaths(paths):
150
+ """Fix each of the paths of the list."""
151
+ return [_FixPath(i) for i in paths]
152
+
153
+
154
+ def _ConvertSourcesToFilterHierarchy(sources, prefix=None, excluded=None,
155
+ list_excluded=True):
156
+ """Converts a list split source file paths into a vcproj folder hierarchy.
157
+
158
+ Arguments:
159
+ sources: A list of source file paths split.
160
+ prefix: A list of source file path layers meant to apply to each of sources.
161
+ excluded: A set of excluded files.
162
+
163
+ Returns:
164
+ A hierarchy of filenames and MSVSProject.Filter objects that matches the
165
+ layout of the source tree.
166
+ For example:
167
+ _ConvertSourcesToFilterHierarchy([['a', 'bob1.c'], ['b', 'bob2.c']],
168
+ prefix=['joe'])
169
+ -->
170
+ [MSVSProject.Filter('a', contents=['joe\\a\\bob1.c']),
171
+ MSVSProject.Filter('b', contents=['joe\\b\\bob2.c'])]
172
+ """
173
+ if not prefix: prefix = []
174
+ result = []
175
+ excluded_result = []
176
+ folders = dict()
177
+ # Gather files into the final result, excluded, or folders.
178
+ for s in sources:
179
+ if len(s) == 1:
180
+ filename = _NormalizedSource('\\'.join(prefix + s))
181
+ if filename in excluded:
182
+ excluded_result.append(filename)
183
+ else:
184
+ result.append(filename)
185
+ else:
186
+ if not folders.get(s[0]):
187
+ folders[s[0]] = []
188
+ folders[s[0]].append(s[1:])
189
+ # Add a folder for excluded files.
190
+ if excluded_result and list_excluded:
191
+ excluded_folder = MSVSProject.Filter('_excluded_files',
192
+ contents=excluded_result)
193
+ result.append(excluded_folder)
194
+ # Populate all the folders.
195
+ for f in folders:
196
+ contents = _ConvertSourcesToFilterHierarchy(folders[f], prefix=prefix + [f],
197
+ excluded=excluded,
198
+ list_excluded=list_excluded)
199
+ contents = MSVSProject.Filter(f, contents=contents)
200
+ result.append(contents)
201
+
202
+ return result
203
+
204
+
205
+ def _ToolAppend(tools, tool_name, setting, value, only_if_unset=False):
206
+ if not value: return
207
+ # TODO(bradnelson): ugly hack, fix this more generally!!!
208
+ if 'Directories' in setting or 'Dependencies' in setting:
209
+ if type(value) == str:
210
+ value = value.replace('/', '\\')
211
+ else:
212
+ value = [i.replace('/', '\\') for i in value]
213
+ if not tools.get(tool_name):
214
+ tools[tool_name] = dict()
215
+ tool = tools[tool_name]
216
+ if tool.get(setting):
217
+ if only_if_unset: return
218
+ if type(tool[setting]) == list:
219
+ tool[setting] += value
220
+ else:
221
+ raise TypeError(
222
+ 'Appending "%s" to a non-list setting "%s" for tool "%s" is '
223
+ 'not allowed, previous value: %s' % (
224
+ value, setting, tool_name, str(tool[setting])))
225
+ else:
226
+ tool[setting] = value
227
+
228
+
229
+ def _ConfigPlatform(config_data):
230
+ return config_data.get('msvs_configuration_platform', 'Win32')
231
+
232
+
233
+ def _ConfigBaseName(config_name, platform_name):
234
+ if config_name.endswith('_' + platform_name):
235
+ return config_name[0:-len(platform_name)-1]
236
+ else:
237
+ return config_name
238
+
239
+
240
+ def _ConfigFullName(config_name, config_data):
241
+ platform_name = _ConfigPlatform(config_data)
242
+ return '%s|%s' % (_ConfigBaseName(config_name, platform_name), platform_name)
243
+
244
+
245
+ def _BuildCommandLineForRuleRaw(spec, cmd, cygwin_shell, has_input_path,
246
+ quote_cmd, do_setup_env):
247
+
248
+ if [x for x in cmd if '$(InputDir)' in x]:
249
+ input_dir_preamble = (
250
+ 'set INPUTDIR=$(InputDir)\n'
251
+ 'set INPUTDIR=%INPUTDIR:$(ProjectDir)=%\n'
252
+ 'set INPUTDIR=%INPUTDIR:~0,-1%\n'
253
+ )
254
+ else:
255
+ input_dir_preamble = ''
256
+
257
+ if cygwin_shell:
258
+ # Find path to cygwin.
259
+ cygwin_dir = _FixPath(spec.get('msvs_cygwin_dirs', ['.'])[0])
260
+ # Prepare command.
261
+ direct_cmd = cmd
262
+ direct_cmd = [i.replace('$(IntDir)',
263
+ '`cygpath -m "${INTDIR}"`') for i in direct_cmd]
264
+ direct_cmd = [i.replace('$(OutDir)',
265
+ '`cygpath -m "${OUTDIR}"`') for i in direct_cmd]
266
+ direct_cmd = [i.replace('$(InputDir)',
267
+ '`cygpath -m "${INPUTDIR}"`') for i in direct_cmd]
268
+ if has_input_path:
269
+ direct_cmd = [i.replace('$(InputPath)',
270
+ '`cygpath -m "${INPUTPATH}"`')
271
+ for i in direct_cmd]
272
+ direct_cmd = ['\\"%s\\"' % i.replace('"', '\\\\\\"') for i in direct_cmd]
273
+ #direct_cmd = gyp.common.EncodePOSIXShellList(direct_cmd)
274
+ direct_cmd = ' '.join(direct_cmd)
275
+ # TODO(quote): regularize quoting path names throughout the module
276
+ cmd = ''
277
+ if do_setup_env:
278
+ cmd += 'call "$(ProjectDir)%(cygwin_dir)s\\setup_env.bat" && '
279
+ cmd += 'set CYGWIN=nontsec&& '
280
+ if direct_cmd.find('NUMBER_OF_PROCESSORS') >= 0:
281
+ cmd += 'set /a NUMBER_OF_PROCESSORS_PLUS_1=%%NUMBER_OF_PROCESSORS%%+1&& '
282
+ if direct_cmd.find('INTDIR') >= 0:
283
+ cmd += 'set INTDIR=$(IntDir)&& '
284
+ if direct_cmd.find('OUTDIR') >= 0:
285
+ cmd += 'set OUTDIR=$(OutDir)&& '
286
+ if has_input_path and direct_cmd.find('INPUTPATH') >= 0:
287
+ cmd += 'set INPUTPATH=$(InputPath) && '
288
+ cmd += 'bash -c "%(cmd)s"'
289
+ cmd = cmd % {'cygwin_dir': cygwin_dir,
290
+ 'cmd': direct_cmd}
291
+ return input_dir_preamble + cmd
292
+ else:
293
+ # Convert cat --> type to mimic unix.
294
+ if cmd[0] == 'cat':
295
+ command = ['type']
296
+ else:
297
+ command = [cmd[0].replace('/', '\\')]
298
+ # Add call before command to ensure that commands can be tied together one
299
+ # after the other without aborting in Incredibuild, since IB makes a bat
300
+ # file out of the raw command string, and some commands (like python) are
301
+ # actually batch files themselves.
302
+ command.insert(0, 'call')
303
+ # Fix the paths
304
+ # TODO(quote): This is a really ugly heuristic, and will miss path fixing
305
+ # for arguments like "--arg=path" or "/opt:path".
306
+ # If the argument starts with a slash or dash, it's probably a command line
307
+ # switch
308
+ arguments = [i if (i[:1] in "/-") else _FixPath(i) for i in cmd[1:]]
309
+ arguments = [i.replace('$(InputDir)','%INPUTDIR%') for i in arguments]
310
+ arguments = [MSVSSettings.FixVCMacroSlashes(i) for i in arguments]
311
+ if quote_cmd:
312
+ # Support a mode for using cmd directly.
313
+ # Convert any paths to native form (first element is used directly).
314
+ # TODO(quote): regularize quoting path names throughout the module
315
+ arguments = ['"%s"' % i for i in arguments]
316
+ # Collapse into a single command.
317
+ return input_dir_preamble + ' '.join(command + arguments)
318
+
319
+
320
+ def _BuildCommandLineForRule(spec, rule, has_input_path, do_setup_env):
321
+ # Currently this weird argument munging is used to duplicate the way a
322
+ # python script would need to be run as part of the chrome tree.
323
+ # Eventually we should add some sort of rule_default option to set this
324
+ # per project. For now the behavior chrome needs is the default.
325
+ mcs = rule.get('msvs_cygwin_shell')
326
+ if mcs is None:
327
+ mcs = int(spec.get('msvs_cygwin_shell', 1))
328
+ elif isinstance(mcs, str):
329
+ mcs = int(mcs)
330
+ quote_cmd = int(rule.get('msvs_quote_cmd', 1))
331
+ return _BuildCommandLineForRuleRaw(spec, rule['action'], mcs, has_input_path,
332
+ quote_cmd, do_setup_env=do_setup_env)
333
+
334
+
335
+ def _AddActionStep(actions_dict, inputs, outputs, description, command):
336
+ """Merge action into an existing list of actions.
337
+
338
+ Care must be taken so that actions which have overlapping inputs either don't
339
+ get assigned to the same input, or get collapsed into one.
340
+
341
+ Arguments:
342
+ actions_dict: dictionary keyed on input name, which maps to a list of
343
+ dicts describing the actions attached to that input file.
344
+ inputs: list of inputs
345
+ outputs: list of outputs
346
+ description: description of the action
347
+ command: command line to execute
348
+ """
349
+ # Require there to be at least one input (call sites will ensure this).
350
+ assert inputs
351
+
352
+ action = {
353
+ 'inputs': inputs,
354
+ 'outputs': outputs,
355
+ 'description': description,
356
+ 'command': command,
357
+ }
358
+
359
+ # Pick where to stick this action.
360
+ # While less than optimal in terms of build time, attach them to the first
361
+ # input for now.
362
+ chosen_input = inputs[0]
363
+
364
+ # Add it there.
365
+ if chosen_input not in actions_dict:
366
+ actions_dict[chosen_input] = []
367
+ actions_dict[chosen_input].append(action)
368
+
369
+
370
+ def _AddCustomBuildToolForMSVS(p, spec, primary_input,
371
+ inputs, outputs, description, cmd):
372
+ """Add a custom build tool to execute something.
373
+
374
+ Arguments:
375
+ p: the target project
376
+ spec: the target project dict
377
+ primary_input: input file to attach the build tool to
378
+ inputs: list of inputs
379
+ outputs: list of outputs
380
+ description: description of the action
381
+ cmd: command line to execute
382
+ """
383
+ inputs = _FixPaths(inputs)
384
+ outputs = _FixPaths(outputs)
385
+ tool = MSVSProject.Tool(
386
+ 'VCCustomBuildTool',
387
+ {'Description': description,
388
+ 'AdditionalDependencies': ';'.join(inputs),
389
+ 'Outputs': ';'.join(outputs),
390
+ 'CommandLine': cmd,
391
+ })
392
+ # Add to the properties of primary input for each config.
393
+ for config_name, c_data in spec['configurations'].iteritems():
394
+ p.AddFileConfig(_FixPath(primary_input),
395
+ _ConfigFullName(config_name, c_data), tools=[tool])
396
+
397
+
398
+ def _AddAccumulatedActionsToMSVS(p, spec, actions_dict):
399
+ """Add actions accumulated into an actions_dict, merging as needed.
400
+
401
+ Arguments:
402
+ p: the target project
403
+ spec: the target project dict
404
+ actions_dict: dictionary keyed on input name, which maps to a list of
405
+ dicts describing the actions attached to that input file.
406
+ """
407
+ for primary_input in actions_dict:
408
+ inputs = set()
409
+ outputs = set()
410
+ descriptions = []
411
+ commands = []
412
+ for action in actions_dict[primary_input]:
413
+ inputs.update(set(action['inputs']))
414
+ outputs.update(set(action['outputs']))
415
+ descriptions.append(action['description'])
416
+ commands.append(action['command'])
417
+ # Add the custom build step for one input file.
418
+ description = ', and also '.join(descriptions)
419
+ command = '\r\n'.join(commands)
420
+ _AddCustomBuildToolForMSVS(p, spec,
421
+ primary_input=primary_input,
422
+ inputs=inputs,
423
+ outputs=outputs,
424
+ description=description,
425
+ cmd=command)
426
+
427
+
428
+ def _RuleExpandPath(path, input_file):
429
+ """Given the input file to which a rule applied, string substitute a path.
430
+
431
+ Arguments:
432
+ path: a path to string expand
433
+ input_file: the file to which the rule applied.
434
+ Returns:
435
+ The string substituted path.
436
+ """
437
+ path = path.replace('$(InputName)',
438
+ os.path.splitext(os.path.split(input_file)[1])[0])
439
+ path = path.replace('$(InputDir)', os.path.dirname(input_file))
440
+ path = path.replace('$(InputExt)',
441
+ os.path.splitext(os.path.split(input_file)[1])[1])
442
+ path = path.replace('$(InputFileName)', os.path.split(input_file)[1])
443
+ path = path.replace('$(InputPath)', input_file)
444
+ return path
445
+
446
+
447
+ def _FindRuleTriggerFiles(rule, sources):
448
+ """Find the list of files which a particular rule applies to.
449
+
450
+ Arguments:
451
+ rule: the rule in question
452
+ sources: the set of all known source files for this project
453
+ Returns:
454
+ The list of sources that trigger a particular rule.
455
+ """
456
+ rule_ext = rule['extension']
457
+ return [s for s in sources if s.endswith('.' + rule_ext)]
458
+
459
+
460
+ def _RuleInputsAndOutputs(rule, trigger_file):
461
+ """Find the inputs and outputs generated by a rule.
462
+
463
+ Arguments:
464
+ rule: the rule in question.
465
+ trigger_file: the main trigger for this rule.
466
+ Returns:
467
+ The pair of (inputs, outputs) involved in this rule.
468
+ """
469
+ raw_inputs = _FixPaths(rule.get('inputs', []))
470
+ raw_outputs = _FixPaths(rule.get('outputs', []))
471
+ inputs = set()
472
+ outputs = set()
473
+ inputs.add(trigger_file)
474
+ for i in raw_inputs:
475
+ inputs.add(_RuleExpandPath(i, trigger_file))
476
+ for o in raw_outputs:
477
+ outputs.add(_RuleExpandPath(o, trigger_file))
478
+ return (inputs, outputs)
479
+
480
+
481
+ def _GenerateNativeRulesForMSVS(p, rules, output_dir, spec, options):
482
+ """Generate a native rules file.
483
+
484
+ Arguments:
485
+ p: the target project
486
+ rules: the set of rules to include
487
+ output_dir: the directory in which the project/gyp resides
488
+ spec: the project dict
489
+ options: global generator options
490
+ """
491
+ rules_filename = '%s%s.rules' % (spec['target_name'],
492
+ options.suffix)
493
+ rules_file = MSVSToolFile.Writer(os.path.join(output_dir, rules_filename),
494
+ spec['target_name'])
495
+ # Add each rule.
496
+ for r in rules:
497
+ rule_name = r['rule_name']
498
+ rule_ext = r['extension']
499
+ inputs = _FixPaths(r.get('inputs', []))
500
+ outputs = _FixPaths(r.get('outputs', []))
501
+ # Skip a rule with no action and no inputs.
502
+ if 'action' not in r and not r.get('rule_sources', []):
503
+ continue
504
+ cmd = _BuildCommandLineForRule(spec, r, has_input_path=True,
505
+ do_setup_env=True)
506
+ rules_file.AddCustomBuildRule(name=rule_name,
507
+ description=r.get('message', rule_name),
508
+ extensions=[rule_ext],
509
+ additional_dependencies=inputs,
510
+ outputs=outputs,
511
+ cmd=cmd)
512
+ # Write out rules file.
513
+ rules_file.WriteIfChanged()
514
+
515
+ # Add rules file to project.
516
+ p.AddToolFile(rules_filename)
517
+
518
+
519
+ def _Cygwinify(path):
520
+ path = path.replace('$(OutDir)', '$(OutDirCygwin)')
521
+ path = path.replace('$(IntDir)', '$(IntDirCygwin)')
522
+ return path
523
+
524
+
525
+ def _GenerateExternalRules(rules, output_dir, spec,
526
+ sources, options, actions_to_add):
527
+ """Generate an external makefile to do a set of rules.
528
+
529
+ Arguments:
530
+ rules: the list of rules to include
531
+ output_dir: path containing project and gyp files
532
+ spec: project specification data
533
+ sources: set of sources known
534
+ options: global generator options
535
+ actions_to_add: The list of actions we will add to.
536
+ """
537
+ filename = '%s_rules%s.mk' % (spec['target_name'], options.suffix)
538
+ mk_file = gyp.common.WriteOnDiff(os.path.join(output_dir, filename))
539
+ # Find cygwin style versions of some paths.
540
+ mk_file.write('OutDirCygwin:=$(shell cygpath -u "$(OutDir)")\n')
541
+ mk_file.write('IntDirCygwin:=$(shell cygpath -u "$(IntDir)")\n')
542
+ # Gather stuff needed to emit all: target.
543
+ all_inputs = set()
544
+ all_outputs = set()
545
+ all_output_dirs = set()
546
+ first_outputs = []
547
+ for rule in rules:
548
+ trigger_files = _FindRuleTriggerFiles(rule, sources)
549
+ for tf in trigger_files:
550
+ inputs, outputs = _RuleInputsAndOutputs(rule, tf)
551
+ all_inputs.update(set(inputs))
552
+ all_outputs.update(set(outputs))
553
+ # Only use one target from each rule as the dependency for
554
+ # 'all' so we don't try to build each rule multiple times.
555
+ first_outputs.append(list(outputs)[0])
556
+ # Get the unique output directories for this rule.
557
+ output_dirs = [os.path.split(i)[0] for i in outputs]
558
+ for od in output_dirs:
559
+ all_output_dirs.add(od)
560
+ first_outputs_cyg = [_Cygwinify(i) for i in first_outputs]
561
+ # Write out all: target, including mkdir for each output directory.
562
+ mk_file.write('all: %s\n' % ' '.join(first_outputs_cyg))
563
+ for od in all_output_dirs:
564
+ if od:
565
+ mk_file.write('\tmkdir -p `cygpath -u "%s"`\n' % od)
566
+ mk_file.write('\n')
567
+ # Define how each output is generated.
568
+ for rule in rules:
569
+ trigger_files = _FindRuleTriggerFiles(rule, sources)
570
+ for tf in trigger_files:
571
+ # Get all the inputs and outputs for this rule for this trigger file.
572
+ inputs, outputs = _RuleInputsAndOutputs(rule, tf)
573
+ inputs = [_Cygwinify(i) for i in inputs]
574
+ outputs = [_Cygwinify(i) for i in outputs]
575
+ # Prepare the command line for this rule.
576
+ cmd = [_RuleExpandPath(c, tf) for c in rule['action']]
577
+ cmd = ['"%s"' % i for i in cmd]
578
+ cmd = ' '.join(cmd)
579
+ # Add it to the makefile.
580
+ mk_file.write('%s: %s\n' % (' '.join(outputs), ' '.join(inputs)))
581
+ mk_file.write('\t%s\n\n' % cmd)
582
+ # Close up the file.
583
+ mk_file.close()
584
+
585
+ # Add makefile to list of sources.
586
+ sources.add(filename)
587
+ # Add a build action to call makefile.
588
+ cmd = ['make',
589
+ 'OutDir=$(OutDir)',
590
+ 'IntDir=$(IntDir)',
591
+ '-j', '${NUMBER_OF_PROCESSORS_PLUS_1}',
592
+ '-f', filename]
593
+ cmd = _BuildCommandLineForRuleRaw(spec, cmd, True, False, True, True)
594
+ # Insert makefile as 0'th input, so it gets the action attached there,
595
+ # as this is easier to understand from in the IDE.
596
+ all_inputs = list(all_inputs)
597
+ all_inputs.insert(0, filename)
598
+ _AddActionStep(actions_to_add,
599
+ inputs=_FixPaths(all_inputs),
600
+ outputs=_FixPaths(all_outputs),
601
+ description='Running external rules for %s' %
602
+ spec['target_name'],
603
+ command=cmd)
604
+
605
+
606
+ def _EscapeEnvironmentVariableExpansion(s):
607
+ """Escapes % characters.
608
+
609
+ Escapes any % characters so that Windows-style environment variable
610
+ expansions will leave them alone.
611
+ See http://connect.microsoft.com/VisualStudio/feedback/details/106127/cl-d-name-text-containing-percentage-characters-doesnt-compile
612
+ to understand why we have to do this.
613
+
614
+ Args:
615
+ s: The string to be escaped.
616
+
617
+ Returns:
618
+ The escaped string.
619
+ """
620
+ s = s.replace('%', '%%')
621
+ return s
622
+
623
+
624
+ quote_replacer_regex = re.compile(r'(\\*)"')
625
+
626
+
627
+ def _EscapeCommandLineArgumentForMSVS(s):
628
+ """Escapes a Windows command-line argument.
629
+
630
+ So that the Win32 CommandLineToArgv function will turn the escaped result back
631
+ into the original string.
632
+ See http://msdn.microsoft.com/en-us/library/17w5ykft.aspx
633
+ ("Parsing C++ Command-Line Arguments") to understand why we have to do
634
+ this.
635
+
636
+ Args:
637
+ s: the string to be escaped.
638
+ Returns:
639
+ the escaped string.
640
+ """
641
+
642
+ def _Replace(match):
643
+ # For a literal quote, CommandLineToArgv requires an odd number of
644
+ # backslashes preceding it, and it produces half as many literal backslashes
645
+ # (rounded down). So we need to produce 2n+1 backslashes.
646
+ return 2 * match.group(1) + '\\"'
647
+
648
+ # Escape all quotes so that they are interpreted literally.
649
+ s = quote_replacer_regex.sub(_Replace, s)
650
+ # Now add unescaped quotes so that any whitespace is interpreted literally.
651
+ s = '"' + s + '"'
652
+ return s
653
+
654
+
655
+ delimiters_replacer_regex = re.compile(r'(\\*)([,;]+)')
656
+
657
+
658
+ def _EscapeVCProjCommandLineArgListItem(s):
659
+ """Escapes command line arguments for MSVS.
660
+
661
+ The VCProj format stores string lists in a single string using commas and
662
+ semi-colons as separators, which must be quoted if they are to be
663
+ interpreted literally. However, command-line arguments may already have
664
+ quotes, and the VCProj parser is ignorant of the backslash escaping
665
+ convention used by CommandLineToArgv, so the command-line quotes and the
666
+ VCProj quotes may not be the same quotes. So to store a general
667
+ command-line argument in a VCProj list, we need to parse the existing
668
+ quoting according to VCProj's convention and quote any delimiters that are
669
+ not already quoted by that convention. The quotes that we add will also be
670
+ seen by CommandLineToArgv, so if backslashes precede them then we also have
671
+ to escape those backslashes according to the CommandLineToArgv
672
+ convention.
673
+
674
+ Args:
675
+ s: the string to be escaped.
676
+ Returns:
677
+ the escaped string.
678
+ """
679
+
680
+ def _Replace(match):
681
+ # For a non-literal quote, CommandLineToArgv requires an even number of
682
+ # backslashes preceding it, and it produces half as many literal
683
+ # backslashes. So we need to produce 2n backslashes.
684
+ return 2 * match.group(1) + '"' + match.group(2) + '"'
685
+
686
+ segments = s.split('"')
687
+ # The unquoted segments are at the even-numbered indices.
688
+ for i in range(0, len(segments), 2):
689
+ segments[i] = delimiters_replacer_regex.sub(_Replace, segments[i])
690
+ # Concatenate back into a single string
691
+ s = '"'.join(segments)
692
+ if len(segments) % 2 == 0:
693
+ # String ends while still quoted according to VCProj's convention. This
694
+ # means the delimiter and the next list item that follow this one in the
695
+ # .vcproj file will be misinterpreted as part of this item. There is nothing
696
+ # we can do about this. Adding an extra quote would correct the problem in
697
+ # the VCProj but cause the same problem on the final command-line. Moving
698
+ # the item to the end of the list does works, but that's only possible if
699
+ # there's only one such item. Let's just warn the user.
700
+ print >> sys.stderr, ('Warning: MSVS may misinterpret the odd number of ' +
701
+ 'quotes in ' + s)
702
+ return s
703
+
704
+
705
+ def _EscapeCppDefineForMSVS(s):
706
+ """Escapes a CPP define so that it will reach the compiler unaltered."""
707
+ s = _EscapeEnvironmentVariableExpansion(s)
708
+ s = _EscapeCommandLineArgumentForMSVS(s)
709
+ s = _EscapeVCProjCommandLineArgListItem(s)
710
+ # cl.exe replaces literal # characters with = in preprocesor definitions for
711
+ # some reason. Octal-encode to work around that.
712
+ s = s.replace('#', '\\%03o' % ord('#'))
713
+ return s
714
+
715
+
716
+ quote_replacer_regex2 = re.compile(r'(\\+)"')
717
+
718
+
719
+ def _EscapeCommandLineArgumentForMSBuild(s):
720
+ """Escapes a Windows command-line argument for use by MSBuild."""
721
+
722
+ def _Replace(match):
723
+ return (len(match.group(1))/2*4)*'\\' + '\\"'
724
+
725
+ # Escape all quotes so that they are interpreted literally.
726
+ s = quote_replacer_regex2.sub(_Replace, s)
727
+ return s
728
+
729
+
730
+ def _EscapeMSBuildSpecialCharacters(s):
731
+ escape_dictionary = {
732
+ '%': '%25',
733
+ '$': '%24',
734
+ '@': '%40',
735
+ "'": '%27',
736
+ ';': '%3B',
737
+ '?': '%3F',
738
+ '*': '%2A'
739
+ }
740
+ result = ''.join([escape_dictionary.get(c, c) for c in s])
741
+ return result
742
+
743
+
744
+ def _EscapeCppDefineForMSBuild(s):
745
+ """Escapes a CPP define so that it will reach the compiler unaltered."""
746
+ s = _EscapeEnvironmentVariableExpansion(s)
747
+ s = _EscapeCommandLineArgumentForMSBuild(s)
748
+ s = _EscapeMSBuildSpecialCharacters(s)
749
+ # cl.exe replaces literal # characters with = in preprocesor definitions for
750
+ # some reason. Octal-encode to work around that.
751
+ s = s.replace('#', '\\%03o' % ord('#'))
752
+ return s
753
+
754
+
755
+ def _GenerateRulesForMSVS(p, output_dir, options, spec,
756
+ sources, excluded_sources,
757
+ actions_to_add):
758
+ """Generate all the rules for a particular project.
759
+
760
+ Arguments:
761
+ p: the project
762
+ output_dir: directory to emit rules to
763
+ options: global options passed to the generator
764
+ spec: the specification for this project
765
+ sources: the set of all known source files in this project
766
+ excluded_sources: the set of sources excluded from normal processing
767
+ actions_to_add: deferred list of actions to add in
768
+ """
769
+ rules = spec.get('rules', [])
770
+ rules_native = [r for r in rules if not int(r.get('msvs_external_rule', 0))]
771
+ rules_external = [r for r in rules if int(r.get('msvs_external_rule', 0))]
772
+
773
+ # Handle rules that use a native rules file.
774
+ if rules_native:
775
+ _GenerateNativeRulesForMSVS(p, rules_native, output_dir, spec, options)
776
+
777
+ # Handle external rules (non-native rules).
778
+ if rules_external:
779
+ _GenerateExternalRules(rules_external, output_dir, spec,
780
+ sources, options, actions_to_add)
781
+ _AdjustSourcesForRules(rules, sources, excluded_sources)
782
+
783
+
784
+ def _AdjustSourcesForRules(rules, sources, excluded_sources):
785
+ # Add outputs generated by each rule (if applicable).
786
+ for rule in rules:
787
+ # Done if not processing outputs as sources.
788
+ if int(rule.get('process_outputs_as_sources', False)):
789
+ # Add in the outputs from this rule.
790
+ trigger_files = _FindRuleTriggerFiles(rule, sources)
791
+ for trigger_file in trigger_files:
792
+ inputs, outputs = _RuleInputsAndOutputs(rule, trigger_file)
793
+ inputs = set(_FixPaths(inputs))
794
+ outputs = set(_FixPaths(outputs))
795
+ inputs.remove(_FixPath(trigger_file))
796
+ sources.update(inputs)
797
+ excluded_sources.update(inputs)
798
+ sources.update(outputs)
799
+
800
+
801
+ def _FilterActionsFromExcluded(excluded_sources, actions_to_add):
802
+ """Take inputs with actions attached out of the list of exclusions.
803
+
804
+ Arguments:
805
+ excluded_sources: list of source files not to be built.
806
+ actions_to_add: dict of actions keyed on source file they're attached to.
807
+ Returns:
808
+ excluded_sources with files that have actions attached removed.
809
+ """
810
+ must_keep = set(_FixPaths(actions_to_add.keys()))
811
+ return [s for s in excluded_sources if s not in must_keep]
812
+
813
+
814
+ def _GetDefaultConfiguration(spec):
815
+ return spec['configurations'][spec['default_configuration']]
816
+
817
+
818
+ def _GetGuidOfProject(proj_path, spec):
819
+ """Get the guid for the project.
820
+
821
+ Arguments:
822
+ proj_path: Path of the vcproj or vcxproj file to generate.
823
+ spec: The target dictionary containing the properties of the target.
824
+ Returns:
825
+ the guid.
826
+ Raises:
827
+ ValueError: if the specified GUID is invalid.
828
+ """
829
+ # Pluck out the default configuration.
830
+ default_config = _GetDefaultConfiguration(spec)
831
+ # Decide the guid of the project.
832
+ guid = default_config.get('msvs_guid')
833
+ if guid:
834
+ if VALID_MSVS_GUID_CHARS.match(guid) is None:
835
+ raise ValueError('Invalid MSVS guid: "%s". Must match regex: "%s".' %
836
+ (guid, VALID_MSVS_GUID_CHARS.pattern))
837
+ guid = '{%s}' % guid
838
+ guid = guid or MSVSNew.MakeGuid(proj_path)
839
+ return guid
840
+
841
+
842
+ def _GetMsbuildToolsetOfProject(proj_path, spec, version):
843
+ """Get the platform toolset for the project.
844
+
845
+ Arguments:
846
+ proj_path: Path of the vcproj or vcxproj file to generate.
847
+ spec: The target dictionary containing the properties of the target.
848
+ version: The MSVSVersion object.
849
+ Returns:
850
+ the platform toolset string or None.
851
+ """
852
+ # Pluck out the default configuration.
853
+ default_config = _GetDefaultConfiguration(spec)
854
+ toolset = default_config.get('msbuild_toolset')
855
+ if not toolset and version.DefaultToolset():
856
+ toolset = version.DefaultToolset()
857
+ return toolset
858
+
859
+
860
+ def _GenerateProject(project, options, version, generator_flags):
861
+ """Generates a vcproj file.
862
+
863
+ Arguments:
864
+ project: the MSVSProject object.
865
+ options: global generator options.
866
+ version: the MSVSVersion object.
867
+ generator_flags: dict of generator-specific flags.
868
+ Returns:
869
+ A list of source files that cannot be found on disk.
870
+ """
871
+ default_config = _GetDefaultConfiguration(project.spec)
872
+
873
+ # Skip emitting anything if told to with msvs_existing_vcproj option.
874
+ if default_config.get('msvs_existing_vcproj'):
875
+ return []
876
+
877
+ if version.UsesVcxproj():
878
+ return _GenerateMSBuildProject(project, options, version, generator_flags)
879
+ else:
880
+ return _GenerateMSVSProject(project, options, version, generator_flags)
881
+
882
+
883
+ def _GenerateMSVSProject(project, options, version, generator_flags):
884
+ """Generates a .vcproj file. It may create .rules and .user files too.
885
+
886
+ Arguments:
887
+ project: The project object we will generate the file for.
888
+ options: Global options passed to the generator.
889
+ version: The VisualStudioVersion object.
890
+ generator_flags: dict of generator-specific flags.
891
+ """
892
+ spec = project.spec
893
+ vcproj_dir = os.path.dirname(project.path)
894
+ if vcproj_dir and not os.path.exists(vcproj_dir):
895
+ os.makedirs(vcproj_dir)
896
+
897
+ platforms = _GetUniquePlatforms(spec)
898
+ p = MSVSProject.Writer(project.path, version, spec['target_name'],
899
+ project.guid, platforms)
900
+
901
+ # Get directory project file is in.
902
+ project_dir = os.path.split(project.path)[0]
903
+ gyp_path = _NormalizedSource(project.build_file)
904
+ relative_path_of_gyp_file = gyp.common.RelativePath(gyp_path, project_dir)
905
+
906
+ config_type = _GetMSVSConfigurationType(spec, project.build_file)
907
+ for config_name, config in spec['configurations'].iteritems():
908
+ _AddConfigurationToMSVSProject(p, spec, config_type, config_name, config)
909
+
910
+ # Prepare list of sources and excluded sources.
911
+ gyp_file = os.path.split(project.build_file)[1]
912
+ sources, excluded_sources = _PrepareListOfSources(spec, generator_flags,
913
+ gyp_file)
914
+
915
+ # Add rules.
916
+ actions_to_add = {}
917
+ _GenerateRulesForMSVS(p, project_dir, options, spec,
918
+ sources, excluded_sources,
919
+ actions_to_add)
920
+ list_excluded = generator_flags.get('msvs_list_excluded_files', True)
921
+ sources, excluded_sources, excluded_idl = (
922
+ _AdjustSourcesAndConvertToFilterHierarchy(
923
+ spec, options, project_dir, sources, excluded_sources, list_excluded))
924
+
925
+ # Add in files.
926
+ missing_sources = _VerifySourcesExist(sources, project_dir)
927
+ p.AddFiles(sources)
928
+
929
+ _AddToolFilesToMSVS(p, spec)
930
+ _HandlePreCompiledHeaders(p, sources, spec)
931
+ _AddActions(actions_to_add, spec, relative_path_of_gyp_file)
932
+ _AddCopies(actions_to_add, spec)
933
+ _WriteMSVSUserFile(project.path, version, spec)
934
+
935
+ # NOTE: this stanza must appear after all actions have been decided.
936
+ # Don't excluded sources with actions attached, or they won't run.
937
+ excluded_sources = _FilterActionsFromExcluded(
938
+ excluded_sources, actions_to_add)
939
+ _ExcludeFilesFromBeingBuilt(p, spec, excluded_sources, excluded_idl,
940
+ list_excluded)
941
+ _AddAccumulatedActionsToMSVS(p, spec, actions_to_add)
942
+
943
+ # Write it out.
944
+ p.WriteIfChanged()
945
+
946
+ return missing_sources
947
+
948
+
949
+ def _GetUniquePlatforms(spec):
950
+ """Returns the list of unique platforms for this spec, e.g ['win32', ...].
951
+
952
+ Arguments:
953
+ spec: The target dictionary containing the properties of the target.
954
+ Returns:
955
+ The MSVSUserFile object created.
956
+ """
957
+ # Gather list of unique platforms.
958
+ platforms = set()
959
+ for configuration in spec['configurations']:
960
+ platforms.add(_ConfigPlatform(spec['configurations'][configuration]))
961
+ platforms = list(platforms)
962
+ return platforms
963
+
964
+
965
+ def _CreateMSVSUserFile(proj_path, version, spec):
966
+ """Generates a .user file for the user running this Gyp program.
967
+
968
+ Arguments:
969
+ proj_path: The path of the project file being created. The .user file
970
+ shares the same path (with an appropriate suffix).
971
+ version: The VisualStudioVersion object.
972
+ spec: The target dictionary containing the properties of the target.
973
+ Returns:
974
+ The MSVSUserFile object created.
975
+ """
976
+ (domain, username) = _GetDomainAndUserName()
977
+ vcuser_filename = '.'.join([proj_path, domain, username, 'user'])
978
+ user_file = MSVSUserFile.Writer(vcuser_filename, version,
979
+ spec['target_name'])
980
+ return user_file
981
+
982
+
983
+ def _GetMSVSConfigurationType(spec, build_file):
984
+ """Returns the configuration type for this project.
985
+
986
+ It's a number defined by Microsoft. May raise an exception.
987
+
988
+ Args:
989
+ spec: The target dictionary containing the properties of the target.
990
+ build_file: The path of the gyp file.
991
+ Returns:
992
+ An integer, the configuration type.
993
+ """
994
+ try:
995
+ config_type = {
996
+ 'executable': '1', # .exe
997
+ 'shared_library': '2', # .dll
998
+ 'loadable_module': '2', # .dll
999
+ 'static_library': '4', # .lib
1000
+ 'none': '10', # Utility type
1001
+ }[spec['type']]
1002
+ except KeyError:
1003
+ if spec.get('type'):
1004
+ raise Exception('Target type %s is not a valid target type for '
1005
+ 'target %s in %s.' %
1006
+ (spec['type'], spec['target_name'], build_file))
1007
+ else:
1008
+ raise Exception('Missing type field for target %s in %s.' %
1009
+ (spec['target_name'], build_file))
1010
+ return config_type
1011
+
1012
+
1013
+ def _AddConfigurationToMSVSProject(p, spec, config_type, config_name, config):
1014
+ """Adds a configuration to the MSVS project.
1015
+
1016
+ Many settings in a vcproj file are specific to a configuration. This
1017
+ function the main part of the vcproj file that's configuration specific.
1018
+
1019
+ Arguments:
1020
+ p: The target project being generated.
1021
+ spec: The target dictionary containing the properties of the target.
1022
+ config_type: The configuration type, a number as defined by Microsoft.
1023
+ config_name: The name of the configuration.
1024
+ config: The dictionnary that defines the special processing to be done
1025
+ for this configuration.
1026
+ """
1027
+ # Get the information for this configuration
1028
+ include_dirs, resource_include_dirs = _GetIncludeDirs(config)
1029
+ libraries = _GetLibraries(spec)
1030
+ out_file, vc_tool, _ = _GetOutputFilePathAndTool(spec, msbuild=False)
1031
+ defines = _GetDefines(config)
1032
+ defines = [_EscapeCppDefineForMSVS(d) for d in defines]
1033
+ disabled_warnings = _GetDisabledWarnings(config)
1034
+ prebuild = config.get('msvs_prebuild')
1035
+ postbuild = config.get('msvs_postbuild')
1036
+ def_file = _GetModuleDefinition(spec)
1037
+ precompiled_header = config.get('msvs_precompiled_header')
1038
+
1039
+ # Prepare the list of tools as a dictionary.
1040
+ tools = dict()
1041
+ # Add in user specified msvs_settings.
1042
+ msvs_settings = config.get('msvs_settings', {})
1043
+ MSVSSettings.ValidateMSVSSettings(msvs_settings)
1044
+ for tool in msvs_settings:
1045
+ settings = config['msvs_settings'][tool]
1046
+ for setting in settings:
1047
+ _ToolAppend(tools, tool, setting, settings[setting])
1048
+ # Add the information to the appropriate tool
1049
+ _ToolAppend(tools, 'VCCLCompilerTool',
1050
+ 'AdditionalIncludeDirectories', include_dirs)
1051
+ _ToolAppend(tools, 'VCResourceCompilerTool',
1052
+ 'AdditionalIncludeDirectories', resource_include_dirs)
1053
+ # Add in libraries.
1054
+ _ToolAppend(tools, 'VCLinkerTool', 'AdditionalDependencies', libraries)
1055
+ if out_file:
1056
+ _ToolAppend(tools, vc_tool, 'OutputFile', out_file, only_if_unset=True)
1057
+ # Add defines.
1058
+ _ToolAppend(tools, 'VCCLCompilerTool', 'PreprocessorDefinitions', defines)
1059
+ _ToolAppend(tools, 'VCResourceCompilerTool', 'PreprocessorDefinitions',
1060
+ defines)
1061
+ # Change program database directory to prevent collisions.
1062
+ _ToolAppend(tools, 'VCCLCompilerTool', 'ProgramDataBaseFileName',
1063
+ '$(IntDir)$(ProjectName)\\vc80.pdb', only_if_unset=True)
1064
+ # Add disabled warnings.
1065
+ _ToolAppend(tools, 'VCCLCompilerTool',
1066
+ 'DisableSpecificWarnings', disabled_warnings)
1067
+ # Add Pre-build.
1068
+ _ToolAppend(tools, 'VCPreBuildEventTool', 'CommandLine', prebuild)
1069
+ # Add Post-build.
1070
+ _ToolAppend(tools, 'VCPostBuildEventTool', 'CommandLine', postbuild)
1071
+ # Turn on precompiled headers if appropriate.
1072
+ if precompiled_header:
1073
+ precompiled_header = os.path.split(precompiled_header)[1]
1074
+ _ToolAppend(tools, 'VCCLCompilerTool', 'UsePrecompiledHeader', '2')
1075
+ _ToolAppend(tools, 'VCCLCompilerTool',
1076
+ 'PrecompiledHeaderThrough', precompiled_header)
1077
+ _ToolAppend(tools, 'VCCLCompilerTool',
1078
+ 'ForcedIncludeFiles', precompiled_header)
1079
+ # Loadable modules don't generate import libraries;
1080
+ # tell dependent projects to not expect one.
1081
+ if spec['type'] == 'loadable_module':
1082
+ _ToolAppend(tools, 'VCLinkerTool', 'IgnoreImportLibrary', 'true')
1083
+ # Set the module definition file if any.
1084
+ if def_file:
1085
+ _ToolAppend(tools, 'VCLinkerTool', 'ModuleDefinitionFile', def_file)
1086
+
1087
+ _AddConfigurationToMSVS(p, spec, tools, config, config_type, config_name)
1088
+
1089
+
1090
+ def _GetIncludeDirs(config):
1091
+ """Returns the list of directories to be used for #include directives.
1092
+
1093
+ Arguments:
1094
+ config: The dictionnary that defines the special processing to be done
1095
+ for this configuration.
1096
+ Returns:
1097
+ The list of directory paths.
1098
+ """
1099
+ # TODO(bradnelson): include_dirs should really be flexible enough not to
1100
+ # require this sort of thing.
1101
+ include_dirs = (
1102
+ config.get('include_dirs', []) +
1103
+ config.get('msvs_system_include_dirs', []))
1104
+ resource_include_dirs = config.get('resource_include_dirs', include_dirs)
1105
+ include_dirs = _FixPaths(include_dirs)
1106
+ resource_include_dirs = _FixPaths(resource_include_dirs)
1107
+ return include_dirs, resource_include_dirs
1108
+
1109
+
1110
+ def _GetLibraries(spec):
1111
+ """Returns the list of libraries for this configuration.
1112
+
1113
+ Arguments:
1114
+ spec: The target dictionary containing the properties of the target.
1115
+ Returns:
1116
+ The list of directory paths.
1117
+ """
1118
+ libraries = spec.get('libraries', [])
1119
+ # Strip out -l, as it is not used on windows (but is needed so we can pass
1120
+ # in libraries that are assumed to be in the default library path).
1121
+ # Also remove duplicate entries, leaving only the last duplicate, while
1122
+ # preserving order.
1123
+ found = set()
1124
+ unique_libraries_list = []
1125
+ for entry in reversed(libraries):
1126
+ library = re.sub('^\-l', '', entry)
1127
+ if library not in found:
1128
+ found.add(library)
1129
+ unique_libraries_list.append(library)
1130
+ unique_libraries_list.reverse()
1131
+ return unique_libraries_list
1132
+
1133
+
1134
+ def _GetOutputFilePathAndTool(spec, msbuild):
1135
+ """Returns the path and tool to use for this target.
1136
+
1137
+ Figures out the path of the file this spec will create and the name of
1138
+ the VC tool that will create it.
1139
+
1140
+ Arguments:
1141
+ spec: The target dictionary containing the properties of the target.
1142
+ Returns:
1143
+ A triple of (file path, name of the vc tool, name of the msbuild tool)
1144
+ """
1145
+ # Select a name for the output file.
1146
+ out_file = ''
1147
+ vc_tool = ''
1148
+ msbuild_tool = ''
1149
+ output_file_map = {
1150
+ 'executable': ('VCLinkerTool', 'Link', '$(OutDir)', '.exe'),
1151
+ 'shared_library': ('VCLinkerTool', 'Link', '$(OutDir)', '.dll'),
1152
+ 'loadable_module': ('VCLinkerTool', 'Link', '$(OutDir)', '.dll'),
1153
+ 'static_library': ('VCLibrarianTool', 'Lib', '$(OutDir)lib\\', '.lib'),
1154
+ }
1155
+ output_file_props = output_file_map.get(spec['type'])
1156
+ if output_file_props and int(spec.get('msvs_auto_output_file', 1)):
1157
+ vc_tool, msbuild_tool, out_dir, suffix = output_file_props
1158
+ out_dir = spec.get('product_dir', out_dir)
1159
+ product_extension = spec.get('product_extension')
1160
+ if product_extension:
1161
+ suffix = '.' + product_extension
1162
+ elif msbuild:
1163
+ suffix = '$(TargetExt)'
1164
+ prefix = spec.get('product_prefix', '')
1165
+ product_name = spec.get('product_name', '$(ProjectName)')
1166
+ out_file = ntpath.join(out_dir, prefix + product_name + suffix)
1167
+ return out_file, vc_tool, msbuild_tool
1168
+
1169
+
1170
+ def _GetDefines(config):
1171
+ """Returns the list of preprocessor definitions for this configuation.
1172
+
1173
+ Arguments:
1174
+ config: The dictionnary that defines the special processing to be done
1175
+ for this configuration.
1176
+ Returns:
1177
+ The list of preprocessor definitions.
1178
+ """
1179
+ defines = []
1180
+ for d in config.get('defines', []):
1181
+ if type(d) == list:
1182
+ fd = '='.join([str(dpart) for dpart in d])
1183
+ else:
1184
+ fd = str(d)
1185
+ defines.append(fd)
1186
+ return defines
1187
+
1188
+
1189
+ def _GetDisabledWarnings(config):
1190
+ return [str(i) for i in config.get('msvs_disabled_warnings', [])]
1191
+
1192
+
1193
+ def _GetModuleDefinition(spec):
1194
+ def_file = ''
1195
+ if spec['type'] in ['shared_library', 'loadable_module', 'executable']:
1196
+ def_files = [s for s in spec.get('sources', []) if s.endswith('.def')]
1197
+ if len(def_files) == 1:
1198
+ def_file = _FixPath(def_files[0])
1199
+ elif def_files:
1200
+ raise ValueError(
1201
+ 'Multiple module definition files in one target, target %s lists '
1202
+ 'multiple .def files: %s' % (
1203
+ spec['target_name'], ' '.join(def_files)))
1204
+ return def_file
1205
+
1206
+
1207
+ def _ConvertToolsToExpectedForm(tools):
1208
+ """Convert tools to a form expected by Visual Studio.
1209
+
1210
+ Arguments:
1211
+ tools: A dictionnary of settings; the tool name is the key.
1212
+ Returns:
1213
+ A list of Tool objects.
1214
+ """
1215
+ tool_list = []
1216
+ for tool, settings in tools.iteritems():
1217
+ # Collapse settings with lists.
1218
+ settings_fixed = {}
1219
+ for setting, value in settings.iteritems():
1220
+ if type(value) == list:
1221
+ if ((tool == 'VCLinkerTool' and
1222
+ setting == 'AdditionalDependencies') or
1223
+ setting == 'AdditionalOptions'):
1224
+ settings_fixed[setting] = ' '.join(value)
1225
+ else:
1226
+ settings_fixed[setting] = ';'.join(value)
1227
+ else:
1228
+ settings_fixed[setting] = value
1229
+ # Add in this tool.
1230
+ tool_list.append(MSVSProject.Tool(tool, settings_fixed))
1231
+ return tool_list
1232
+
1233
+
1234
+ def _AddConfigurationToMSVS(p, spec, tools, config, config_type, config_name):
1235
+ """Add to the project file the configuration specified by config.
1236
+
1237
+ Arguments:
1238
+ p: The target project being generated.
1239
+ spec: the target project dict.
1240
+ tools: A dictionnary of settings; the tool name is the key.
1241
+ config: The dictionnary that defines the special processing to be done
1242
+ for this configuration.
1243
+ config_type: The configuration type, a number as defined by Microsoft.
1244
+ config_name: The name of the configuration.
1245
+ """
1246
+ attributes = _GetMSVSAttributes(spec, config, config_type)
1247
+ # Add in this configuration.
1248
+ tool_list = _ConvertToolsToExpectedForm(tools)
1249
+ p.AddConfig(_ConfigFullName(config_name, config),
1250
+ attrs=attributes, tools=tool_list)
1251
+
1252
+
1253
+ def _GetMSVSAttributes(spec, config, config_type):
1254
+ # Prepare configuration attributes.
1255
+ prepared_attrs = {}
1256
+ source_attrs = config.get('msvs_configuration_attributes', {})
1257
+ for a in source_attrs:
1258
+ prepared_attrs[a] = source_attrs[a]
1259
+ # Add props files.
1260
+ vsprops_dirs = config.get('msvs_props', [])
1261
+ vsprops_dirs = _FixPaths(vsprops_dirs)
1262
+ if vsprops_dirs:
1263
+ prepared_attrs['InheritedPropertySheets'] = ';'.join(vsprops_dirs)
1264
+ # Set configuration type.
1265
+ prepared_attrs['ConfigurationType'] = config_type
1266
+ output_dir = prepared_attrs.get('OutputDirectory',
1267
+ '$(SolutionDir)$(ConfigurationName)')
1268
+ prepared_attrs['OutputDirectory'] = _FixPath(output_dir) + '\\'
1269
+ if 'IntermediateDirectory' not in prepared_attrs:
1270
+ intermediate = '$(ConfigurationName)\\obj\\$(ProjectName)'
1271
+ prepared_attrs['IntermediateDirectory'] = _FixPath(intermediate) + '\\'
1272
+ else:
1273
+ intermediate = _FixPath(prepared_attrs['IntermediateDirectory']) + '\\'
1274
+ intermediate = MSVSSettings.FixVCMacroSlashes(intermediate)
1275
+ prepared_attrs['IntermediateDirectory'] = intermediate
1276
+ return prepared_attrs
1277
+
1278
+
1279
+ def _AddNormalizedSources(sources_set, sources_array):
1280
+ sources = [_NormalizedSource(s) for s in sources_array]
1281
+ sources_set.update(set(sources))
1282
+
1283
+
1284
+ def _PrepareListOfSources(spec, generator_flags, gyp_file):
1285
+ """Prepare list of sources and excluded sources.
1286
+
1287
+ Besides the sources specified directly in the spec, adds the gyp file so
1288
+ that a change to it will cause a re-compile. Also adds appropriate sources
1289
+ for actions and copies. Assumes later stage will un-exclude files which
1290
+ have custom build steps attached.
1291
+
1292
+ Arguments:
1293
+ spec: The target dictionary containing the properties of the target.
1294
+ gyp_file: The name of the gyp file.
1295
+ Returns:
1296
+ A pair of (list of sources, list of excluded sources).
1297
+ The sources will be relative to the gyp file.
1298
+ """
1299
+ sources = set()
1300
+ _AddNormalizedSources(sources, spec.get('sources', []))
1301
+ excluded_sources = set()
1302
+ # Add in the gyp file.
1303
+ if not generator_flags.get('standalone'):
1304
+ sources.add(gyp_file)
1305
+
1306
+ # Add in 'action' inputs and outputs.
1307
+ for a in spec.get('actions', []):
1308
+ inputs = a['inputs']
1309
+ inputs = [_NormalizedSource(i) for i in inputs]
1310
+ # Add all inputs to sources and excluded sources.
1311
+ inputs = set(inputs)
1312
+ sources.update(inputs)
1313
+ excluded_sources.update(inputs)
1314
+ if int(a.get('process_outputs_as_sources', False)):
1315
+ _AddNormalizedSources(sources, a.get('outputs', []))
1316
+ # Add in 'copies' inputs and outputs.
1317
+ for cpy in spec.get('copies', []):
1318
+ _AddNormalizedSources(sources, cpy.get('files', []))
1319
+ return (sources, excluded_sources)
1320
+
1321
+
1322
+ def _AdjustSourcesAndConvertToFilterHierarchy(
1323
+ spec, options, gyp_dir, sources, excluded_sources, list_excluded):
1324
+ """Adjusts the list of sources and excluded sources.
1325
+
1326
+ Also converts the sets to lists.
1327
+
1328
+ Arguments:
1329
+ spec: The target dictionary containing the properties of the target.
1330
+ options: Global generator options.
1331
+ gyp_dir: The path to the gyp file being processed.
1332
+ sources: A set of sources to be included for this project.
1333
+ excluded_sources: A set of sources to be excluded for this project.
1334
+ Returns:
1335
+ A trio of (list of sources, list of excluded sources,
1336
+ path of excluded IDL file)
1337
+ """
1338
+ # Exclude excluded sources coming into the generator.
1339
+ excluded_sources.update(set(spec.get('sources_excluded', [])))
1340
+ # Add excluded sources into sources for good measure.
1341
+ sources.update(excluded_sources)
1342
+ # Convert to proper windows form.
1343
+ # NOTE: sources goes from being a set to a list here.
1344
+ # NOTE: excluded_sources goes from being a set to a list here.
1345
+ sources = _FixPaths(sources)
1346
+ # Convert to proper windows form.
1347
+ excluded_sources = _FixPaths(excluded_sources)
1348
+
1349
+ excluded_idl = _IdlFilesHandledNonNatively(spec, sources)
1350
+
1351
+ precompiled_related = _GetPrecompileRelatedFiles(spec)
1352
+ # Find the excluded ones, minus the precompiled header related ones.
1353
+ fully_excluded = [i for i in excluded_sources if i not in precompiled_related]
1354
+
1355
+ # Convert to folders and the right slashes.
1356
+ sources = [i.split('\\') for i in sources]
1357
+ sources = _ConvertSourcesToFilterHierarchy(sources, excluded=fully_excluded,
1358
+ list_excluded=list_excluded)
1359
+
1360
+ return sources, excluded_sources, excluded_idl
1361
+
1362
+
1363
+ def _IdlFilesHandledNonNatively(spec, sources):
1364
+ # If any non-native rules use 'idl' as an extension exclude idl files.
1365
+ # Gather a list here to use later.
1366
+ using_idl = False
1367
+ for rule in spec.get('rules', []):
1368
+ if rule['extension'] == 'idl' and int(rule.get('msvs_external_rule', 0)):
1369
+ using_idl = True
1370
+ break
1371
+ if using_idl:
1372
+ excluded_idl = [i for i in sources if i.endswith('.idl')]
1373
+ else:
1374
+ excluded_idl = []
1375
+ return excluded_idl
1376
+
1377
+
1378
+ def _GetPrecompileRelatedFiles(spec):
1379
+ # Gather a list of precompiled header related sources.
1380
+ precompiled_related = []
1381
+ for _, config in spec['configurations'].iteritems():
1382
+ for k in precomp_keys:
1383
+ f = config.get(k)
1384
+ if f:
1385
+ precompiled_related.append(_FixPath(f))
1386
+ return precompiled_related
1387
+
1388
+
1389
+ def _ExcludeFilesFromBeingBuilt(p, spec, excluded_sources, excluded_idl,
1390
+ list_excluded):
1391
+ exclusions = _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_idl)
1392
+ for file_name, excluded_configs in exclusions.iteritems():
1393
+ if (not list_excluded and
1394
+ len(excluded_configs) == len(spec['configurations'])):
1395
+ # If we're not listing excluded files, then they won't appear in the
1396
+ # project, so don't try to configure them to be excluded.
1397
+ pass
1398
+ else:
1399
+ for config_name, config in excluded_configs:
1400
+ p.AddFileConfig(file_name, _ConfigFullName(config_name, config),
1401
+ {'ExcludedFromBuild': 'true'})
1402
+
1403
+
1404
+ def _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_idl):
1405
+ exclusions = {}
1406
+ # Exclude excluded sources from being built.
1407
+ for f in excluded_sources:
1408
+ excluded_configs = []
1409
+ for config_name, config in spec['configurations'].iteritems():
1410
+ precomped = [_FixPath(config.get(i, '')) for i in precomp_keys]
1411
+ # Don't do this for ones that are precompiled header related.
1412
+ if f not in precomped:
1413
+ excluded_configs.append((config_name, config))
1414
+ exclusions[f] = excluded_configs
1415
+ # If any non-native rules use 'idl' as an extension exclude idl files.
1416
+ # Exclude them now.
1417
+ for f in excluded_idl:
1418
+ excluded_configs = []
1419
+ for config_name, config in spec['configurations'].iteritems():
1420
+ excluded_configs.append((config_name, config))
1421
+ exclusions[f] = excluded_configs
1422
+ return exclusions
1423
+
1424
+
1425
+ def _AddToolFilesToMSVS(p, spec):
1426
+ # Add in tool files (rules).
1427
+ tool_files = set()
1428
+ for _, config in spec['configurations'].iteritems():
1429
+ for f in config.get('msvs_tool_files', []):
1430
+ tool_files.add(f)
1431
+ for f in tool_files:
1432
+ p.AddToolFile(f)
1433
+
1434
+
1435
+ def _HandlePreCompiledHeaders(p, sources, spec):
1436
+ # Pre-compiled header source stubs need a different compiler flag
1437
+ # (generate precompiled header) and any source file not of the same
1438
+ # kind (i.e. C vs. C++) as the precompiled header source stub needs
1439
+ # to have use of precompiled headers disabled.
1440
+ extensions_excluded_from_precompile = []
1441
+ for config_name, config in spec['configurations'].iteritems():
1442
+ source = config.get('msvs_precompiled_source')
1443
+ if source:
1444
+ source = _FixPath(source)
1445
+ # UsePrecompiledHeader=1 for if using precompiled headers.
1446
+ tool = MSVSProject.Tool('VCCLCompilerTool',
1447
+ {'UsePrecompiledHeader': '1'})
1448
+ p.AddFileConfig(source, _ConfigFullName(config_name, config),
1449
+ {}, tools=[tool])
1450
+ basename, extension = os.path.splitext(source)
1451
+ if extension == '.c':
1452
+ extensions_excluded_from_precompile = ['.cc', '.cpp', '.cxx']
1453
+ else:
1454
+ extensions_excluded_from_precompile = ['.c']
1455
+ def DisableForSourceTree(source_tree):
1456
+ for source in source_tree:
1457
+ if isinstance(source, MSVSProject.Filter):
1458
+ DisableForSourceTree(source.contents)
1459
+ else:
1460
+ basename, extension = os.path.splitext(source)
1461
+ if extension in extensions_excluded_from_precompile:
1462
+ for config_name, config in spec['configurations'].iteritems():
1463
+ tool = MSVSProject.Tool('VCCLCompilerTool',
1464
+ {'UsePrecompiledHeader': '0',
1465
+ 'ForcedIncludeFiles': '$(NOINHERIT)'})
1466
+ p.AddFileConfig(_FixPath(source),
1467
+ _ConfigFullName(config_name, config),
1468
+ {}, tools=[tool])
1469
+ # Do nothing if there was no precompiled source.
1470
+ if extensions_excluded_from_precompile:
1471
+ DisableForSourceTree(sources)
1472
+
1473
+
1474
+ def _AddActions(actions_to_add, spec, relative_path_of_gyp_file):
1475
+ # Add actions.
1476
+ actions = spec.get('actions', [])
1477
+ # Don't setup_env every time. When all the actions are run together in one
1478
+ # batch file in VS, the PATH will grow too long.
1479
+ # Membership in this set means that the cygwin environment has been set up,
1480
+ # and does not need to be set up again.
1481
+ have_setup_env = set()
1482
+ for a in actions:
1483
+ # Attach actions to the gyp file if nothing else is there.
1484
+ inputs = a.get('inputs') or [relative_path_of_gyp_file]
1485
+ attached_to = inputs[0]
1486
+ need_setup_env = attached_to not in have_setup_env
1487
+ cmd = _BuildCommandLineForRule(spec, a, has_input_path=False,
1488
+ do_setup_env=need_setup_env)
1489
+ have_setup_env.add(attached_to)
1490
+ # Add the action.
1491
+ _AddActionStep(actions_to_add,
1492
+ inputs=inputs,
1493
+ outputs=a.get('outputs', []),
1494
+ description=a.get('message', a['action_name']),
1495
+ command=cmd)
1496
+
1497
+
1498
+ def _WriteMSVSUserFile(project_path, version, spec):
1499
+ # Add run_as and test targets.
1500
+ if 'run_as' in spec:
1501
+ run_as = spec['run_as']
1502
+ action = run_as.get('action', [])
1503
+ environment = run_as.get('environment', [])
1504
+ working_directory = run_as.get('working_directory', '.')
1505
+ elif int(spec.get('test', 0)):
1506
+ action = ['$(TargetPath)', '--gtest_print_time']
1507
+ environment = []
1508
+ working_directory = '.'
1509
+ else:
1510
+ return # Nothing to add
1511
+ # Write out the user file.
1512
+ user_file = _CreateMSVSUserFile(project_path, version, spec)
1513
+ for config_name, c_data in spec['configurations'].iteritems():
1514
+ user_file.AddDebugSettings(_ConfigFullName(config_name, c_data),
1515
+ action, environment, working_directory)
1516
+ user_file.WriteIfChanged()
1517
+
1518
+
1519
+ def _AddCopies(actions_to_add, spec):
1520
+ copies = _GetCopies(spec)
1521
+ for inputs, outputs, cmd, description in copies:
1522
+ _AddActionStep(actions_to_add, inputs=inputs, outputs=outputs,
1523
+ description=description, command=cmd)
1524
+
1525
+
1526
+ def _GetCopies(spec):
1527
+ copies = []
1528
+ # Add copies.
1529
+ for cpy in spec.get('copies', []):
1530
+ for src in cpy.get('files', []):
1531
+ dst = os.path.join(cpy['destination'], os.path.basename(src))
1532
+ # _AddCustomBuildToolForMSVS() will call _FixPath() on the inputs and
1533
+ # outputs, so do the same for our generated command line.
1534
+ if src.endswith('/'):
1535
+ src_bare = src[:-1]
1536
+ base_dir = posixpath.split(src_bare)[0]
1537
+ outer_dir = posixpath.split(src_bare)[1]
1538
+ cmd = 'cd "%s" && xcopy /e /f /y "%s" "%s\\%s\\"' % (
1539
+ _FixPath(base_dir), outer_dir, _FixPath(dst), outer_dir)
1540
+ copies.append(([src], ['dummy_copies', dst], cmd,
1541
+ 'Copying %s to %s' % (src, dst)))
1542
+ else:
1543
+ cmd = 'mkdir "%s" 2>nul & set ERRORLEVEL=0 & copy /Y "%s" "%s"' % (
1544
+ _FixPath(cpy['destination']), _FixPath(src), _FixPath(dst))
1545
+ copies.append(([src], [dst], cmd, 'Copying %s to %s' % (src, dst)))
1546
+ return copies
1547
+
1548
+
1549
+ def _GetPathDict(root, path):
1550
+ # |path| will eventually be empty (in the recursive calls) if it was initially
1551
+ # relative; otherwise it will eventually end up as '\', 'D:\', etc.
1552
+ if not path or path.endswith(os.sep):
1553
+ return root
1554
+ parent, folder = os.path.split(path)
1555
+ parent_dict = _GetPathDict(root, parent)
1556
+ if folder not in parent_dict:
1557
+ parent_dict[folder] = dict()
1558
+ return parent_dict[folder]
1559
+
1560
+
1561
+ def _DictsToFolders(base_path, bucket, flat):
1562
+ # Convert to folders recursively.
1563
+ children = []
1564
+ for folder, contents in bucket.iteritems():
1565
+ if type(contents) == dict:
1566
+ folder_children = _DictsToFolders(os.path.join(base_path, folder),
1567
+ contents, flat)
1568
+ if flat:
1569
+ children += folder_children
1570
+ else:
1571
+ folder_children = MSVSNew.MSVSFolder(os.path.join(base_path, folder),
1572
+ name='(' + folder + ')',
1573
+ entries=folder_children)
1574
+ children.append(folder_children)
1575
+ else:
1576
+ children.append(contents)
1577
+ return children
1578
+
1579
+
1580
+ def _CollapseSingles(parent, node):
1581
+ # Recursively explorer the tree of dicts looking for projects which are
1582
+ # the sole item in a folder which has the same name as the project. Bring
1583
+ # such projects up one level.
1584
+ if (type(node) == dict and
1585
+ len(node) == 1 and
1586
+ node.keys()[0] == parent + '.vcproj'):
1587
+ return node[node.keys()[0]]
1588
+ if type(node) != dict:
1589
+ return node
1590
+ for child in node:
1591
+ node[child] = _CollapseSingles(child, node[child])
1592
+ return node
1593
+
1594
+
1595
+ def _GatherSolutionFolders(sln_projects, project_objects, flat):
1596
+ root = {}
1597
+ # Convert into a tree of dicts on path.
1598
+ for p in sln_projects:
1599
+ gyp_file, target = gyp.common.ParseQualifiedTarget(p)[0:2]
1600
+ gyp_dir = os.path.dirname(gyp_file)
1601
+ path_dict = _GetPathDict(root, gyp_dir)
1602
+ path_dict[target + '.vcproj'] = project_objects[p]
1603
+ # Walk down from the top until we hit a folder that has more than one entry.
1604
+ # In practice, this strips the top-level "src/" dir from the hierarchy in
1605
+ # the solution.
1606
+ while len(root) == 1 and type(root[root.keys()[0]]) == dict:
1607
+ root = root[root.keys()[0]]
1608
+ # Collapse singles.
1609
+ root = _CollapseSingles('', root)
1610
+ # Merge buckets until everything is a root entry.
1611
+ return _DictsToFolders('', root, flat)
1612
+
1613
+
1614
+ def _GetPathOfProject(qualified_target, spec, options, msvs_version):
1615
+ default_config = _GetDefaultConfiguration(spec)
1616
+ proj_filename = default_config.get('msvs_existing_vcproj')
1617
+ if not proj_filename:
1618
+ proj_filename = (spec['target_name'] + options.suffix +
1619
+ msvs_version.ProjectExtension())
1620
+
1621
+ build_file = gyp.common.BuildFile(qualified_target)
1622
+ proj_path = os.path.join(os.path.dirname(build_file), proj_filename)
1623
+ fix_prefix = None
1624
+ if options.generator_output:
1625
+ project_dir_path = os.path.dirname(os.path.abspath(proj_path))
1626
+ proj_path = os.path.join(options.generator_output, proj_path)
1627
+ fix_prefix = gyp.common.RelativePath(project_dir_path,
1628
+ os.path.dirname(proj_path))
1629
+ return proj_path, fix_prefix
1630
+
1631
+
1632
+ def _GetPlatformOverridesOfProject(spec):
1633
+ # Prepare a dict indicating which project configurations are used for which
1634
+ # solution configurations for this target.
1635
+ config_platform_overrides = {}
1636
+ for config_name, c in spec['configurations'].iteritems():
1637
+ config_fullname = _ConfigFullName(config_name, c)
1638
+ platform = c.get('msvs_target_platform', _ConfigPlatform(c))
1639
+ fixed_config_fullname = '%s|%s' % (
1640
+ _ConfigBaseName(config_name, _ConfigPlatform(c)), platform)
1641
+ config_platform_overrides[config_fullname] = fixed_config_fullname
1642
+ return config_platform_overrides
1643
+
1644
+
1645
+ def _CreateProjectObjects(target_list, target_dicts, options, msvs_version):
1646
+ """Create a MSVSProject object for the targets found in target list.
1647
+
1648
+ Arguments:
1649
+ target_list: the list of targets to generate project objects for.
1650
+ target_dicts: the dictionary of specifications.
1651
+ options: global generator options.
1652
+ msvs_version: the MSVSVersion object.
1653
+ Returns:
1654
+ A set of created projects, keyed by target.
1655
+ """
1656
+ global fixpath_prefix
1657
+ # Generate each project.
1658
+ projects = {}
1659
+ for qualified_target in target_list:
1660
+ spec = target_dicts[qualified_target]
1661
+ if spec['toolset'] != 'target':
1662
+ raise Exception(
1663
+ 'Multiple toolsets not supported in msvs build (target %s)' %
1664
+ qualified_target)
1665
+ proj_path, fixpath_prefix = _GetPathOfProject(qualified_target, spec,
1666
+ options, msvs_version)
1667
+ guid = _GetGuidOfProject(proj_path, spec)
1668
+ overrides = _GetPlatformOverridesOfProject(spec)
1669
+ build_file = gyp.common.BuildFile(qualified_target)
1670
+ # Create object for this project.
1671
+ obj = MSVSNew.MSVSProject(
1672
+ proj_path,
1673
+ name=spec['target_name'],
1674
+ guid=guid,
1675
+ spec=spec,
1676
+ build_file=build_file,
1677
+ config_platform_overrides=overrides,
1678
+ fixpath_prefix=fixpath_prefix)
1679
+ # Set project toolset if any (MS build only)
1680
+ if msvs_version.UsesVcxproj():
1681
+ obj.set_msbuild_toolset(
1682
+ _GetMsbuildToolsetOfProject(proj_path, spec, msvs_version))
1683
+ projects[qualified_target] = obj
1684
+ # Set all the dependencies
1685
+ for project in projects.values():
1686
+ deps = project.spec.get('dependencies', [])
1687
+ deps = [projects[d] for d in deps]
1688
+ project.set_dependencies(deps)
1689
+ return projects
1690
+
1691
+
1692
+ def CalculateVariables(default_variables, params):
1693
+ """Generated variables that require params to be known."""
1694
+
1695
+ generator_flags = params.get('generator_flags', {})
1696
+
1697
+ # Select project file format version (if unset, default to auto detecting).
1698
+ msvs_version = MSVSVersion.SelectVisualStudioVersion(
1699
+ generator_flags.get('msvs_version', 'auto'))
1700
+ # Stash msvs_version for later (so we don't have to probe the system twice).
1701
+ params['msvs_version'] = msvs_version
1702
+
1703
+ # Set a variable so conditions can be based on msvs_version.
1704
+ default_variables['MSVS_VERSION'] = msvs_version.ShortName()
1705
+
1706
+ # To determine processor word size on Windows, in addition to checking
1707
+ # PROCESSOR_ARCHITECTURE (which reflects the word size of the current
1708
+ # process), it is also necessary to check PROCESSOR_ARCITEW6432 (which
1709
+ # contains the actual word size of the system when running thru WOW64).
1710
+ if (os.environ.get('PROCESSOR_ARCHITECTURE', '').find('64') >= 0 or
1711
+ os.environ.get('PROCESSOR_ARCHITEW6432', '').find('64') >= 0):
1712
+ default_variables['MSVS_OS_BITS'] = 64
1713
+ else:
1714
+ default_variables['MSVS_OS_BITS'] = 32
1715
+
1716
+
1717
+ def _ShardName(name, number):
1718
+ """Add a shard number to the end of a target.
1719
+
1720
+ Arguments:
1721
+ name: name of the target (foo#target)
1722
+ number: shard number
1723
+ Returns:
1724
+ Target name with shard added (foo_1#target)
1725
+ """
1726
+ parts = name.rsplit('#', 1)
1727
+ parts[0] = '%s_%d' % (parts[0], number)
1728
+ return '#'.join(parts)
1729
+
1730
+
1731
+ def _ShardTargets(target_list, target_dicts):
1732
+ """Shard some targets apart to work around the linkers limits.
1733
+
1734
+ Arguments:
1735
+ target_list: List of target pairs: 'base/base.gyp:base'.
1736
+ target_dicts: Dict of target properties keyed on target pair.
1737
+ Returns:
1738
+ Tuple of the new sharded versions of the inputs.
1739
+ """
1740
+ # Gather the targets to shard, and how many pieces.
1741
+ targets_to_shard = {}
1742
+ for t in target_dicts:
1743
+ shards = int(target_dicts[t].get('msvs_shard', 0))
1744
+ if shards:
1745
+ targets_to_shard[t] = shards
1746
+ # Shard target_list.
1747
+ new_target_list = []
1748
+ for t in target_list:
1749
+ if t in targets_to_shard:
1750
+ for i in range(targets_to_shard[t]):
1751
+ new_target_list.append(_ShardName(t, i))
1752
+ else:
1753
+ new_target_list.append(t)
1754
+ # Shard target_dict.
1755
+ new_target_dicts = {}
1756
+ for t in target_dicts:
1757
+ if t in targets_to_shard:
1758
+ for i in range(targets_to_shard[t]):
1759
+ name = _ShardName(t, i)
1760
+ new_target_dicts[name] = copy.copy(target_dicts[t])
1761
+ new_target_dicts[name]['target_name'] = _ShardName(
1762
+ new_target_dicts[name]['target_name'], i)
1763
+ sources = new_target_dicts[name].get('sources', [])
1764
+ new_sources = []
1765
+ for pos in range(i, len(sources), targets_to_shard[t]):
1766
+ new_sources.append(sources[pos])
1767
+ new_target_dicts[name]['sources'] = new_sources
1768
+ else:
1769
+ new_target_dicts[t] = target_dicts[t]
1770
+ # Shard dependencies.
1771
+ for t in new_target_dicts:
1772
+ dependencies = copy.copy(new_target_dicts[t].get('dependencies', []))
1773
+ new_dependencies = []
1774
+ for d in dependencies:
1775
+ if d in targets_to_shard:
1776
+ for i in range(targets_to_shard[d]):
1777
+ new_dependencies.append(_ShardName(d, i))
1778
+ else:
1779
+ new_dependencies.append(d)
1780
+ new_target_dicts[t]['dependencies'] = new_dependencies
1781
+
1782
+ return (new_target_list, new_target_dicts)
1783
+
1784
+
1785
+ def PerformBuild(data, configurations, params):
1786
+ options = params['options']
1787
+ msvs_version = params['msvs_version']
1788
+ devenv = os.path.join(msvs_version.path, 'Common7', 'IDE', 'devenv.com')
1789
+
1790
+ for build_file, build_file_dict in data.iteritems():
1791
+ (build_file_root, build_file_ext) = os.path.splitext(build_file)
1792
+ if build_file_ext != '.gyp':
1793
+ continue
1794
+ sln_path = build_file_root + options.suffix + '.sln'
1795
+ if options.generator_output:
1796
+ sln_path = os.path.join(options.generator_output, sln_path)
1797
+
1798
+ for config in configurations:
1799
+ arguments = [devenv, sln_path, '/Build', config]
1800
+ print 'Building [%s]: %s' % (config, arguments)
1801
+ rtn = subprocess.check_call(arguments)
1802
+
1803
+
1804
+ def GenerateOutput(target_list, target_dicts, data, params):
1805
+ """Generate .sln and .vcproj files.
1806
+
1807
+ This is the entry point for this generator.
1808
+ Arguments:
1809
+ target_list: List of target pairs: 'base/base.gyp:base'.
1810
+ target_dicts: Dict of target properties keyed on target pair.
1811
+ data: Dictionary containing per .gyp data.
1812
+ """
1813
+ global fixpath_prefix
1814
+
1815
+ options = params['options']
1816
+
1817
+ # Get the project file format version back out of where we stashed it in
1818
+ # GeneratorCalculatedVariables.
1819
+ msvs_version = params['msvs_version']
1820
+
1821
+ generator_flags = params.get('generator_flags', {})
1822
+
1823
+ # Optionally shard targets marked with 'msvs_shard': SHARD_COUNT.
1824
+ (target_list, target_dicts) = _ShardTargets(target_list, target_dicts)
1825
+
1826
+ # Prepare the set of configurations.
1827
+ configs = set()
1828
+ for qualified_target in target_list:
1829
+ spec = target_dicts[qualified_target]
1830
+ for config_name, config in spec['configurations'].iteritems():
1831
+ configs.add(_ConfigFullName(config_name, config))
1832
+ configs = list(configs)
1833
+
1834
+ # Figure out all the projects that will be generated and their guids
1835
+ project_objects = _CreateProjectObjects(target_list, target_dicts, options,
1836
+ msvs_version)
1837
+
1838
+ # Generate each project.
1839
+ missing_sources = []
1840
+ for project in project_objects.values():
1841
+ fixpath_prefix = project.fixpath_prefix
1842
+ missing_sources.extend(_GenerateProject(project, options, msvs_version,
1843
+ generator_flags))
1844
+ fixpath_prefix = None
1845
+
1846
+ for build_file in data:
1847
+ # Validate build_file extension
1848
+ if not build_file.endswith('.gyp'):
1849
+ continue
1850
+ sln_path = os.path.splitext(build_file)[0] + options.suffix + '.sln'
1851
+ if options.generator_output:
1852
+ sln_path = os.path.join(options.generator_output, sln_path)
1853
+ # Get projects in the solution, and their dependents.
1854
+ sln_projects = gyp.common.BuildFileTargets(target_list, build_file)
1855
+ sln_projects += gyp.common.DeepDependencyTargets(target_dicts, sln_projects)
1856
+ # Create folder hierarchy.
1857
+ root_entries = _GatherSolutionFolders(
1858
+ sln_projects, project_objects, flat=msvs_version.FlatSolution())
1859
+ # Create solution.
1860
+ sln = MSVSNew.MSVSSolution(sln_path,
1861
+ entries=root_entries,
1862
+ variants=configs,
1863
+ websiteProperties=False,
1864
+ version=msvs_version)
1865
+ sln.Write()
1866
+
1867
+ if missing_sources:
1868
+ error_message = "Missing input files:\n" + \
1869
+ '\n'.join(set(missing_sources))
1870
+ if generator_flags.get('msvs_error_on_missing_sources', False):
1871
+ raise Exception(error_message)
1872
+ else:
1873
+ print >>sys.stdout, "Warning: " + error_message
1874
+
1875
+
1876
+ def _GenerateMSBuildFiltersFile(filters_path, source_files,
1877
+ extension_to_rule_name):
1878
+ """Generate the filters file.
1879
+
1880
+ This file is used by Visual Studio to organize the presentation of source
1881
+ files into folders.
1882
+
1883
+ Arguments:
1884
+ filters_path: The path of the file to be created.
1885
+ source_files: The hierarchical structure of all the sources.
1886
+ extension_to_rule_name: A dictionary mapping file extensions to rules.
1887
+ """
1888
+ filter_group = []
1889
+ source_group = []
1890
+ _AppendFiltersForMSBuild('', source_files, extension_to_rule_name,
1891
+ filter_group, source_group)
1892
+ if filter_group:
1893
+ content = ['Project',
1894
+ {'ToolsVersion': '4.0',
1895
+ 'xmlns': 'http://schemas.microsoft.com/developer/msbuild/2003'
1896
+ },
1897
+ ['ItemGroup'] + filter_group,
1898
+ ['ItemGroup'] + source_group
1899
+ ]
1900
+ easy_xml.WriteXmlIfChanged(content, filters_path, pretty=True, win32=True)
1901
+ elif os.path.exists(filters_path):
1902
+ # We don't need this filter anymore. Delete the old filter file.
1903
+ os.unlink(filters_path)
1904
+
1905
+
1906
+ def _AppendFiltersForMSBuild(parent_filter_name, sources,
1907
+ extension_to_rule_name,
1908
+ filter_group, source_group):
1909
+ """Creates the list of filters and sources to be added in the filter file.
1910
+
1911
+ Args:
1912
+ parent_filter_name: The name of the filter under which the sources are
1913
+ found.
1914
+ sources: The hierarchy of filters and sources to process.
1915
+ extension_to_rule_name: A dictionary mapping file extensions to rules.
1916
+ filter_group: The list to which filter entries will be appended.
1917
+ source_group: The list to which source entries will be appeneded.
1918
+ """
1919
+ for source in sources:
1920
+ if isinstance(source, MSVSProject.Filter):
1921
+ # We have a sub-filter. Create the name of that sub-filter.
1922
+ if not parent_filter_name:
1923
+ filter_name = source.name
1924
+ else:
1925
+ filter_name = '%s\\%s' % (parent_filter_name, source.name)
1926
+ # Add the filter to the group.
1927
+ filter_group.append(
1928
+ ['Filter', {'Include': filter_name},
1929
+ ['UniqueIdentifier', MSVSNew.MakeGuid(source.name)]])
1930
+ # Recurse and add its dependents.
1931
+ _AppendFiltersForMSBuild(filter_name, source.contents,
1932
+ extension_to_rule_name,
1933
+ filter_group, source_group)
1934
+ else:
1935
+ # It's a source. Create a source entry.
1936
+ _, element = _MapFileToMsBuildSourceType(source, extension_to_rule_name)
1937
+ source_entry = [element, {'Include': source}]
1938
+ # Specify the filter it is part of, if any.
1939
+ if parent_filter_name:
1940
+ source_entry.append(['Filter', parent_filter_name])
1941
+ source_group.append(source_entry)
1942
+
1943
+
1944
+ def _MapFileToMsBuildSourceType(source, extension_to_rule_name):
1945
+ """Returns the group and element type of the source file.
1946
+
1947
+ Arguments:
1948
+ source: The source file name.
1949
+ extension_to_rule_name: A dictionary mapping file extensions to rules.
1950
+
1951
+ Returns:
1952
+ A pair of (group this file should be part of, the label of element)
1953
+ """
1954
+ _, ext = os.path.splitext(source)
1955
+ if ext in extension_to_rule_name:
1956
+ group = 'rule'
1957
+ element = extension_to_rule_name[ext]
1958
+ elif ext in ['.cc', '.cpp', '.c', '.cxx']:
1959
+ group = 'compile'
1960
+ element = 'ClCompile'
1961
+ elif ext in ['.h', '.hxx']:
1962
+ group = 'include'
1963
+ element = 'ClInclude'
1964
+ elif ext == '.rc':
1965
+ group = 'resource'
1966
+ element = 'ResourceCompile'
1967
+ elif ext == '.idl':
1968
+ group = 'midl'
1969
+ element = 'Midl'
1970
+ else:
1971
+ group = 'none'
1972
+ element = 'None'
1973
+ return (group, element)
1974
+
1975
+
1976
+ def _GenerateRulesForMSBuild(output_dir, options, spec,
1977
+ sources, excluded_sources,
1978
+ props_files_of_rules, targets_files_of_rules,
1979
+ actions_to_add, extension_to_rule_name):
1980
+ # MSBuild rules are implemented using three files: an XML file, a .targets
1981
+ # file and a .props file.
1982
+ # See http://blogs.msdn.com/b/vcblog/archive/2010/04/21/quick-help-on-vs2010-custom-build-rule.aspx
1983
+ # for more details.
1984
+ rules = spec.get('rules', [])
1985
+ rules_native = [r for r in rules if not int(r.get('msvs_external_rule', 0))]
1986
+ rules_external = [r for r in rules if int(r.get('msvs_external_rule', 0))]
1987
+
1988
+ msbuild_rules = []
1989
+ for rule in rules_native:
1990
+ # Skip a rule with no action and no inputs.
1991
+ if 'action' not in rule and not rule.get('rule_sources', []):
1992
+ continue
1993
+ msbuild_rule = MSBuildRule(rule, spec)
1994
+ msbuild_rules.append(msbuild_rule)
1995
+ extension_to_rule_name[msbuild_rule.extension] = msbuild_rule.rule_name
1996
+ if msbuild_rules:
1997
+ base = spec['target_name'] + options.suffix
1998
+ props_name = base + '.props'
1999
+ targets_name = base + '.targets'
2000
+ xml_name = base + '.xml'
2001
+
2002
+ props_files_of_rules.add(props_name)
2003
+ targets_files_of_rules.add(targets_name)
2004
+
2005
+ props_path = os.path.join(output_dir, props_name)
2006
+ targets_path = os.path.join(output_dir, targets_name)
2007
+ xml_path = os.path.join(output_dir, xml_name)
2008
+
2009
+ _GenerateMSBuildRulePropsFile(props_path, msbuild_rules)
2010
+ _GenerateMSBuildRuleTargetsFile(targets_path, msbuild_rules)
2011
+ _GenerateMSBuildRuleXmlFile(xml_path, msbuild_rules)
2012
+
2013
+ if rules_external:
2014
+ _GenerateExternalRules(rules_external, output_dir, spec,
2015
+ sources, options, actions_to_add)
2016
+ _AdjustSourcesForRules(rules, sources, excluded_sources)
2017
+
2018
+
2019
+ class MSBuildRule(object):
2020
+ """Used to store information used to generate an MSBuild rule.
2021
+
2022
+ Attributes:
2023
+ rule_name: The rule name, sanitized to use in XML.
2024
+ target_name: The name of the target.
2025
+ after_targets: The name of the AfterTargets element.
2026
+ before_targets: The name of the BeforeTargets element.
2027
+ depends_on: The name of the DependsOn element.
2028
+ compute_output: The name of the ComputeOutput element.
2029
+ dirs_to_make: The name of the DirsToMake element.
2030
+ inputs: The name of the _inputs element.
2031
+ tlog: The name of the _tlog element.
2032
+ extension: The extension this rule applies to.
2033
+ description: The message displayed when this rule is invoked.
2034
+ additional_dependencies: A string listing additional dependencies.
2035
+ outputs: The outputs of this rule.
2036
+ command: The command used to run the rule.
2037
+ """
2038
+
2039
+ def __init__(self, rule, spec):
2040
+ self.display_name = rule['rule_name']
2041
+ # Assure that the rule name is only characters and numbers
2042
+ self.rule_name = re.sub(r'\W', '_', self.display_name)
2043
+ # Create the various element names, following the example set by the
2044
+ # Visual Studio 2008 to 2010 conversion. I don't know if VS2010
2045
+ # is sensitive to the exact names.
2046
+ self.target_name = '_' + self.rule_name
2047
+ self.after_targets = self.rule_name + 'AfterTargets'
2048
+ self.before_targets = self.rule_name + 'BeforeTargets'
2049
+ self.depends_on = self.rule_name + 'DependsOn'
2050
+ self.compute_output = 'Compute%sOutput' % self.rule_name
2051
+ self.dirs_to_make = self.rule_name + 'DirsToMake'
2052
+ self.inputs = self.rule_name + '_inputs'
2053
+ self.tlog = self.rule_name + '_tlog'
2054
+ self.extension = rule['extension']
2055
+ if not self.extension.startswith('.'):
2056
+ self.extension = '.' + self.extension
2057
+
2058
+ self.description = MSVSSettings.ConvertVCMacrosToMSBuild(
2059
+ rule.get('message', self.rule_name))
2060
+ old_additional_dependencies = _FixPaths(rule.get('inputs', []))
2061
+ self.additional_dependencies = (
2062
+ ';'.join([MSVSSettings.ConvertVCMacrosToMSBuild(i)
2063
+ for i in old_additional_dependencies]))
2064
+ old_outputs = _FixPaths(rule.get('outputs', []))
2065
+ self.outputs = ';'.join([MSVSSettings.ConvertVCMacrosToMSBuild(i)
2066
+ for i in old_outputs])
2067
+ old_command = _BuildCommandLineForRule(spec, rule, has_input_path=True,
2068
+ do_setup_env=True)
2069
+ self.command = MSVSSettings.ConvertVCMacrosToMSBuild(old_command)
2070
+
2071
+
2072
+ def _GenerateMSBuildRulePropsFile(props_path, msbuild_rules):
2073
+ """Generate the .props file."""
2074
+ content = ['Project',
2075
+ {'xmlns': 'http://schemas.microsoft.com/developer/msbuild/2003'}]
2076
+ for rule in msbuild_rules:
2077
+ content.extend([
2078
+ ['PropertyGroup',
2079
+ {'Condition': "'$(%s)' == '' and '$(%s)' == '' and "
2080
+ "'$(ConfigurationType)' != 'Makefile'" % (rule.before_targets,
2081
+ rule.after_targets)
2082
+ },
2083
+ [rule.before_targets, 'Midl'],
2084
+ [rule.after_targets, 'CustomBuild'],
2085
+ ],
2086
+ ['PropertyGroup',
2087
+ [rule.depends_on,
2088
+ {'Condition': "'$(ConfigurationType)' != 'Makefile'"},
2089
+ '_SelectedFiles;$(%s)' % rule.depends_on
2090
+ ],
2091
+ ],
2092
+ ['ItemDefinitionGroup',
2093
+ [rule.rule_name,
2094
+ ['CommandLineTemplate', rule.command],
2095
+ ['Outputs', rule.outputs],
2096
+ ['ExecutionDescription', rule.description],
2097
+ ['AdditionalDependencies', rule.additional_dependencies],
2098
+ ],
2099
+ ]
2100
+ ])
2101
+ easy_xml.WriteXmlIfChanged(content, props_path, pretty=True, win32=True)
2102
+
2103
+
2104
+ def _GenerateMSBuildRuleTargetsFile(targets_path, msbuild_rules):
2105
+ """Generate the .targets file."""
2106
+ content = ['Project',
2107
+ {'xmlns': 'http://schemas.microsoft.com/developer/msbuild/2003'
2108
+ }
2109
+ ]
2110
+ item_group = [
2111
+ 'ItemGroup',
2112
+ ['PropertyPageSchema',
2113
+ {'Include': '$(MSBuildThisFileDirectory)$(MSBuildThisFileName).xml'}
2114
+ ]
2115
+ ]
2116
+ for rule in msbuild_rules:
2117
+ item_group.append(
2118
+ ['AvailableItemName',
2119
+ {'Include': rule.rule_name},
2120
+ ['Targets', rule.target_name],
2121
+ ])
2122
+ content.append(item_group)
2123
+
2124
+ for rule in msbuild_rules:
2125
+ content.append(
2126
+ ['UsingTask',
2127
+ {'TaskName': rule.rule_name,
2128
+ 'TaskFactory': 'XamlTaskFactory',
2129
+ 'AssemblyName': 'Microsoft.Build.Tasks.v4.0'
2130
+ },
2131
+ ['Task', '$(MSBuildThisFileDirectory)$(MSBuildThisFileName).xml'],
2132
+ ])
2133
+ for rule in msbuild_rules:
2134
+ rule_name = rule.rule_name
2135
+ target_outputs = '%%(%s.Outputs)' % rule_name
2136
+ target_inputs = ('%%(%s.Identity);%%(%s.AdditionalDependencies);'
2137
+ '$(MSBuildProjectFile)') % (rule_name, rule_name)
2138
+ rule_inputs = '%%(%s.Identity)' % rule_name
2139
+ extension_condition = ("'%(Extension)'=='.obj' or "
2140
+ "'%(Extension)'=='.res' or "
2141
+ "'%(Extension)'=='.rsc' or "
2142
+ "'%(Extension)'=='.lib'")
2143
+ remove_section = [
2144
+ 'ItemGroup',
2145
+ {'Condition': "'@(SelectedFiles)' != ''"},
2146
+ [rule_name,
2147
+ {'Remove': '@(%s)' % rule_name,
2148
+ 'Condition': "'%(Identity)' != '@(SelectedFiles)'"
2149
+ }
2150
+ ]
2151
+ ]
2152
+ inputs_section = [
2153
+ 'ItemGroup',
2154
+ [rule.inputs, {'Include': '%%(%s.AdditionalDependencies)' % rule_name}]
2155
+ ]
2156
+ logging_section = [
2157
+ 'ItemGroup',
2158
+ [rule.tlog,
2159
+ {'Include': '%%(%s.Outputs)' % rule_name,
2160
+ 'Condition': ("'%%(%s.Outputs)' != '' and "
2161
+ "'%%(%s.ExcludedFromBuild)' != 'true'" %
2162
+ (rule_name, rule_name))
2163
+ },
2164
+ ['Source', "@(%s, '|')" % rule_name],
2165
+ ['Inputs', "@(%s -> '%%(Fullpath)', ';')" % rule.inputs],
2166
+ ],
2167
+ ]
2168
+ message_section = [
2169
+ 'Message',
2170
+ {'Importance': 'High',
2171
+ 'Text': '%%(%s.ExecutionDescription)' % rule_name
2172
+ }
2173
+ ]
2174
+ write_tlog_section = [
2175
+ 'WriteLinesToFile',
2176
+ {'Condition': "'@(%s)' != '' and '%%(%s.ExcludedFromBuild)' != "
2177
+ "'true'" % (rule.tlog, rule.tlog),
2178
+ 'File': '$(IntDir)$(ProjectName).write.1.tlog',
2179
+ 'Lines': "^%%(%s.Source);@(%s->'%%(Fullpath)')" % (rule.tlog,
2180
+ rule.tlog)
2181
+ }
2182
+ ]
2183
+ read_tlog_section = [
2184
+ 'WriteLinesToFile',
2185
+ {'Condition': "'@(%s)' != '' and '%%(%s.ExcludedFromBuild)' != "
2186
+ "'true'" % (rule.tlog, rule.tlog),
2187
+ 'File': '$(IntDir)$(ProjectName).read.1.tlog',
2188
+ 'Lines': "^%%(%s.Source);%%(%s.Inputs)" % (rule.tlog, rule.tlog)
2189
+ }
2190
+ ]
2191
+ command_and_input_section = [
2192
+ rule_name,
2193
+ {'Condition': "'@(%s)' != '' and '%%(%s.ExcludedFromBuild)' != "
2194
+ "'true'" % (rule_name, rule_name),
2195
+ 'CommandLineTemplate': '%%(%s.CommandLineTemplate)' % rule_name,
2196
+ 'AdditionalOptions': '%%(%s.AdditionalOptions)' % rule_name,
2197
+ 'Inputs': rule_inputs
2198
+ }
2199
+ ]
2200
+ content.extend([
2201
+ ['Target',
2202
+ {'Name': rule.target_name,
2203
+ 'BeforeTargets': '$(%s)' % rule.before_targets,
2204
+ 'AfterTargets': '$(%s)' % rule.after_targets,
2205
+ 'Condition': "'@(%s)' != ''" % rule_name,
2206
+ 'DependsOnTargets': '$(%s);%s' % (rule.depends_on,
2207
+ rule.compute_output),
2208
+ 'Outputs': target_outputs,
2209
+ 'Inputs': target_inputs
2210
+ },
2211
+ remove_section,
2212
+ inputs_section,
2213
+ logging_section,
2214
+ message_section,
2215
+ write_tlog_section,
2216
+ read_tlog_section,
2217
+ command_and_input_section,
2218
+ ],
2219
+ ['PropertyGroup',
2220
+ ['ComputeLinkInputsTargets',
2221
+ '$(ComputeLinkInputsTargets);',
2222
+ '%s;' % rule.compute_output
2223
+ ],
2224
+ ['ComputeLibInputsTargets',
2225
+ '$(ComputeLibInputsTargets);',
2226
+ '%s;' % rule.compute_output
2227
+ ],
2228
+ ],
2229
+ ['Target',
2230
+ {'Name': rule.compute_output,
2231
+ 'Condition': "'@(%s)' != ''" % rule_name
2232
+ },
2233
+ ['ItemGroup',
2234
+ [rule.dirs_to_make,
2235
+ {'Condition': "'@(%s)' != '' and "
2236
+ "'%%(%s.ExcludedFromBuild)' != 'true'" % (rule_name, rule_name),
2237
+ 'Include': '%%(%s.Outputs)' % rule_name
2238
+ }
2239
+ ],
2240
+ ['Link',
2241
+ {'Include': '%%(%s.Identity)' % rule.dirs_to_make,
2242
+ 'Condition': extension_condition
2243
+ }
2244
+ ],
2245
+ ['Lib',
2246
+ {'Include': '%%(%s.Identity)' % rule.dirs_to_make,
2247
+ 'Condition': extension_condition
2248
+ }
2249
+ ],
2250
+ ['ImpLib',
2251
+ {'Include': '%%(%s.Identity)' % rule.dirs_to_make,
2252
+ 'Condition': extension_condition
2253
+ }
2254
+ ],
2255
+ ],
2256
+ ['MakeDir',
2257
+ {'Directories': ("@(%s->'%%(RootDir)%%(Directory)')" %
2258
+ rule.dirs_to_make)
2259
+ }
2260
+ ]
2261
+ ],
2262
+ ])
2263
+ easy_xml.WriteXmlIfChanged(content, targets_path, pretty=True, win32=True)
2264
+
2265
+
2266
+ def _GenerateMSBuildRuleXmlFile(xml_path, msbuild_rules):
2267
+ # Generate the .xml file
2268
+ content = [
2269
+ 'ProjectSchemaDefinitions',
2270
+ {'xmlns': ('clr-namespace:Microsoft.Build.Framework.XamlTypes;'
2271
+ 'assembly=Microsoft.Build.Framework'),
2272
+ 'xmlns:x': 'http://schemas.microsoft.com/winfx/2006/xaml',
2273
+ 'xmlns:sys': 'clr-namespace:System;assembly=mscorlib',
2274
+ 'xmlns:transformCallback':
2275
+ 'Microsoft.Cpp.Dev10.ConvertPropertyCallback'
2276
+ }
2277
+ ]
2278
+ for rule in msbuild_rules:
2279
+ content.extend([
2280
+ ['Rule',
2281
+ {'Name': rule.rule_name,
2282
+ 'PageTemplate': 'tool',
2283
+ 'DisplayName': rule.display_name,
2284
+ 'Order': '200'
2285
+ },
2286
+ ['Rule.DataSource',
2287
+ ['DataSource',
2288
+ {'Persistence': 'ProjectFile',
2289
+ 'ItemType': rule.rule_name
2290
+ }
2291
+ ]
2292
+ ],
2293
+ ['Rule.Categories',
2294
+ ['Category',
2295
+ {'Name': 'General'},
2296
+ ['Category.DisplayName',
2297
+ ['sys:String', 'General'],
2298
+ ],
2299
+ ],
2300
+ ['Category',
2301
+ {'Name': 'Command Line',
2302
+ 'Subtype': 'CommandLine'
2303
+ },
2304
+ ['Category.DisplayName',
2305
+ ['sys:String', 'Command Line'],
2306
+ ],
2307
+ ],
2308
+ ],
2309
+ ['StringListProperty',
2310
+ {'Name': 'Inputs',
2311
+ 'Category': 'Command Line',
2312
+ 'IsRequired': 'true',
2313
+ 'Switch': ' '
2314
+ },
2315
+ ['StringListProperty.DataSource',
2316
+ ['DataSource',
2317
+ {'Persistence': 'ProjectFile',
2318
+ 'ItemType': rule.rule_name,
2319
+ 'SourceType': 'Item'
2320
+ }
2321
+ ]
2322
+ ],
2323
+ ],
2324
+ ['StringProperty',
2325
+ {'Name': 'CommandLineTemplate',
2326
+ 'DisplayName': 'Command Line',
2327
+ 'Visible': 'False',
2328
+ 'IncludeInCommandLine': 'False'
2329
+ }
2330
+ ],
2331
+ ['DynamicEnumProperty',
2332
+ {'Name': rule.before_targets,
2333
+ 'Category': 'General',
2334
+ 'EnumProvider': 'Targets',
2335
+ 'IncludeInCommandLine': 'False'
2336
+ },
2337
+ ['DynamicEnumProperty.DisplayName',
2338
+ ['sys:String', 'Execute Before'],
2339
+ ],
2340
+ ['DynamicEnumProperty.Description',
2341
+ ['sys:String', 'Specifies the targets for the build customization'
2342
+ ' to run before.'
2343
+ ],
2344
+ ],
2345
+ ['DynamicEnumProperty.ProviderSettings',
2346
+ ['NameValuePair',
2347
+ {'Name': 'Exclude',
2348
+ 'Value': '^%s|^Compute' % rule.before_targets
2349
+ }
2350
+ ]
2351
+ ],
2352
+ ['DynamicEnumProperty.DataSource',
2353
+ ['DataSource',
2354
+ {'Persistence': 'ProjectFile',
2355
+ 'HasConfigurationCondition': 'true'
2356
+ }
2357
+ ]
2358
+ ],
2359
+ ],
2360
+ ['DynamicEnumProperty',
2361
+ {'Name': rule.after_targets,
2362
+ 'Category': 'General',
2363
+ 'EnumProvider': 'Targets',
2364
+ 'IncludeInCommandLine': 'False'
2365
+ },
2366
+ ['DynamicEnumProperty.DisplayName',
2367
+ ['sys:String', 'Execute After'],
2368
+ ],
2369
+ ['DynamicEnumProperty.Description',
2370
+ ['sys:String', ('Specifies the targets for the build customization'
2371
+ ' to run after.')
2372
+ ],
2373
+ ],
2374
+ ['DynamicEnumProperty.ProviderSettings',
2375
+ ['NameValuePair',
2376
+ {'Name': 'Exclude',
2377
+ 'Value': '^%s|^Compute' % rule.after_targets
2378
+ }
2379
+ ]
2380
+ ],
2381
+ ['DynamicEnumProperty.DataSource',
2382
+ ['DataSource',
2383
+ {'Persistence': 'ProjectFile',
2384
+ 'ItemType': '',
2385
+ 'HasConfigurationCondition': 'true'
2386
+ }
2387
+ ]
2388
+ ],
2389
+ ],
2390
+ ['StringListProperty',
2391
+ {'Name': 'Outputs',
2392
+ 'DisplayName': 'Outputs',
2393
+ 'Visible': 'False',
2394
+ 'IncludeInCommandLine': 'False'
2395
+ }
2396
+ ],
2397
+ ['StringProperty',
2398
+ {'Name': 'ExecutionDescription',
2399
+ 'DisplayName': 'Execution Description',
2400
+ 'Visible': 'False',
2401
+ 'IncludeInCommandLine': 'False'
2402
+ }
2403
+ ],
2404
+ ['StringListProperty',
2405
+ {'Name': 'AdditionalDependencies',
2406
+ 'DisplayName': 'Additional Dependencies',
2407
+ 'IncludeInCommandLine': 'False',
2408
+ 'Visible': 'false'
2409
+ }
2410
+ ],
2411
+ ['StringProperty',
2412
+ {'Subtype': 'AdditionalOptions',
2413
+ 'Name': 'AdditionalOptions',
2414
+ 'Category': 'Command Line'
2415
+ },
2416
+ ['StringProperty.DisplayName',
2417
+ ['sys:String', 'Additional Options'],
2418
+ ],
2419
+ ['StringProperty.Description',
2420
+ ['sys:String', 'Additional Options'],
2421
+ ],
2422
+ ],
2423
+ ],
2424
+ ['ItemType',
2425
+ {'Name': rule.rule_name,
2426
+ 'DisplayName': rule.display_name
2427
+ }
2428
+ ],
2429
+ ['FileExtension',
2430
+ {'Name': '*' + rule.extension,
2431
+ 'ContentType': rule.rule_name
2432
+ }
2433
+ ],
2434
+ ['ContentType',
2435
+ {'Name': rule.rule_name,
2436
+ 'DisplayName': '',
2437
+ 'ItemType': rule.rule_name
2438
+ }
2439
+ ]
2440
+ ])
2441
+ easy_xml.WriteXmlIfChanged(content, xml_path, pretty=True, win32=True)
2442
+
2443
+
2444
+ def _GetConfigurationAndPlatform(name, settings):
2445
+ configuration = name.rsplit('_', 1)[0]
2446
+ platform = settings.get('msvs_configuration_platform', 'Win32')
2447
+ return (configuration, platform)
2448
+
2449
+
2450
+ def _GetConfigurationCondition(name, settings):
2451
+ return (r"'$(Configuration)|$(Platform)'=='%s|%s'" %
2452
+ _GetConfigurationAndPlatform(name, settings))
2453
+
2454
+
2455
+ def _GetMSBuildProjectConfigurations(configurations):
2456
+ group = ['ItemGroup', {'Label': 'ProjectConfigurations'}]
2457
+ for (name, settings) in sorted(configurations.iteritems()):
2458
+ configuration, platform = _GetConfigurationAndPlatform(name, settings)
2459
+ designation = '%s|%s' % (configuration, platform)
2460
+ group.append(
2461
+ ['ProjectConfiguration', {'Include': designation},
2462
+ ['Configuration', configuration],
2463
+ ['Platform', platform]])
2464
+ return [group]
2465
+
2466
+
2467
+ def _GetMSBuildGlobalProperties(spec, guid, gyp_file_name):
2468
+ namespace = os.path.splitext(gyp_file_name)[0]
2469
+ return [
2470
+ ['PropertyGroup', {'Label': 'Globals'},
2471
+ ['ProjectGuid', guid],
2472
+ ['Keyword', 'Win32Proj'],
2473
+ ['RootNamespace', namespace],
2474
+ ]
2475
+ ]
2476
+
2477
+
2478
+ def _GetMSBuildConfigurationDetails(spec, build_file):
2479
+ properties = {}
2480
+ for name, settings in spec['configurations'].iteritems():
2481
+ msbuild_attributes = _GetMSBuildAttributes(spec, settings, build_file)
2482
+ condition = _GetConfigurationCondition(name, settings)
2483
+ character_set = msbuild_attributes.get('CharacterSet')
2484
+ _AddConditionalProperty(properties, condition, 'ConfigurationType',
2485
+ msbuild_attributes['ConfigurationType'])
2486
+ if character_set:
2487
+ _AddConditionalProperty(properties, condition, 'CharacterSet',
2488
+ character_set)
2489
+ return _GetMSBuildPropertyGroup(spec, 'Configuration', properties)
2490
+
2491
+
2492
+ def _GetMSBuildLocalProperties(msbuild_toolset):
2493
+ # Currently the only local property we support is PlatformToolset
2494
+ properties = {}
2495
+ if msbuild_toolset:
2496
+ properties = [
2497
+ ['PropertyGroup', {'Label': 'Locals'},
2498
+ ['PlatformToolset', msbuild_toolset],
2499
+ ]
2500
+ ]
2501
+ return properties
2502
+
2503
+
2504
+ def _GetMSBuildPropertySheets(configurations):
2505
+ user_props = r'$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props'
2506
+ additional_props = {}
2507
+ props_specified = False
2508
+ for name, settings in sorted(configurations.iteritems()):
2509
+ configuration = _GetConfigurationCondition(name, settings)
2510
+ if settings.has_key('msbuild_props'):
2511
+ additional_props[configuration] = _FixPaths(settings['msbuild_props'])
2512
+ props_specified = True
2513
+ else:
2514
+ additional_props[configuration] = ''
2515
+
2516
+ if not props_specified:
2517
+ return [
2518
+ ['ImportGroup',
2519
+ {'Label': 'PropertySheets'},
2520
+ ['Import',
2521
+ {'Project': user_props,
2522
+ 'Condition': "exists('%s')" % user_props,
2523
+ 'Label': 'LocalAppDataPlatform'
2524
+ }
2525
+ ]
2526
+ ]
2527
+ ]
2528
+ else:
2529
+ sheets = []
2530
+ for condition, props in additional_props.iteritems():
2531
+ import_group = [
2532
+ 'ImportGroup',
2533
+ {'Label': 'PropertySheets',
2534
+ 'Condition': condition
2535
+ },
2536
+ ['Import',
2537
+ {'Project': user_props,
2538
+ 'Condition': "exists('%s')" % user_props,
2539
+ 'Label': 'LocalAppDataPlatform'
2540
+ }
2541
+ ]
2542
+ ]
2543
+ for props_file in props:
2544
+ import_group.append(['Import', {'Project':props_file}])
2545
+ sheets.append(import_group)
2546
+ return sheets
2547
+
2548
+ def _ConvertMSVSBuildAttributes(spec, config, build_file):
2549
+ config_type = _GetMSVSConfigurationType(spec, build_file)
2550
+ msvs_attributes = _GetMSVSAttributes(spec, config, config_type)
2551
+ msbuild_attributes = {}
2552
+ for a in msvs_attributes:
2553
+ if a in ['IntermediateDirectory', 'OutputDirectory']:
2554
+ directory = MSVSSettings.ConvertVCMacrosToMSBuild(msvs_attributes[a])
2555
+ if not directory.endswith('\\'):
2556
+ directory += '\\'
2557
+ msbuild_attributes[a] = directory
2558
+ elif a == 'CharacterSet':
2559
+ msbuild_attributes[a] = _ConvertMSVSCharacterSet(msvs_attributes[a])
2560
+ elif a == 'ConfigurationType':
2561
+ msbuild_attributes[a] = _ConvertMSVSConfigurationType(msvs_attributes[a])
2562
+ else:
2563
+ print 'Warning: Do not know how to convert MSVS attribute ' + a
2564
+ return msbuild_attributes
2565
+
2566
+
2567
+ def _ConvertMSVSCharacterSet(char_set):
2568
+ if char_set.isdigit():
2569
+ char_set = {
2570
+ '0': 'MultiByte',
2571
+ '1': 'Unicode',
2572
+ '2': 'MultiByte',
2573
+ }[char_set]
2574
+ return char_set
2575
+
2576
+
2577
+ def _ConvertMSVSConfigurationType(config_type):
2578
+ if config_type.isdigit():
2579
+ config_type = {
2580
+ '1': 'Application',
2581
+ '2': 'DynamicLibrary',
2582
+ '4': 'StaticLibrary',
2583
+ '10': 'Utility'
2584
+ }[config_type]
2585
+ return config_type
2586
+
2587
+
2588
+ def _GetMSBuildAttributes(spec, config, build_file):
2589
+ if 'msbuild_configuration_attributes' not in config:
2590
+ msbuild_attributes = _ConvertMSVSBuildAttributes(spec, config, build_file)
2591
+
2592
+ else:
2593
+ config_type = _GetMSVSConfigurationType(spec, build_file)
2594
+ config_type = _ConvertMSVSConfigurationType(config_type)
2595
+ msbuild_attributes = config.get('msbuild_configuration_attributes', {})
2596
+ msbuild_attributes.setdefault('ConfigurationType', config_type)
2597
+ output_dir = msbuild_attributes.get('OutputDirectory',
2598
+ '$(SolutionDir)$(Configuration)')
2599
+ msbuild_attributes['OutputDirectory'] = _FixPath(output_dir) + '\\'
2600
+ if 'IntermediateDirectory' not in msbuild_attributes:
2601
+ intermediate = _FixPath('$(Configuration)') + '\\'
2602
+ msbuild_attributes['IntermediateDirectory'] = intermediate
2603
+ if 'CharacterSet' in msbuild_attributes:
2604
+ msbuild_attributes['CharacterSet'] = _ConvertMSVSCharacterSet(
2605
+ msbuild_attributes['CharacterSet'])
2606
+ if 'TargetName' not in msbuild_attributes:
2607
+ prefix = spec.get('product_prefix', '')
2608
+ product_name = spec.get('product_name', '$(ProjectName)')
2609
+ target_name = prefix + product_name
2610
+ msbuild_attributes['TargetName'] = target_name
2611
+
2612
+ # Make sure that 'TargetPath' matches 'Lib.OutputFile' or 'Link.OutputFile'
2613
+ # (depending on the tool used) to avoid MSB8012 warning.
2614
+ msbuild_tool_map = {
2615
+ 'executable': 'Link',
2616
+ 'shared_library': 'Link',
2617
+ 'loadable_module': 'Link',
2618
+ 'static_library': 'Lib',
2619
+ }
2620
+ msbuild_tool = msbuild_tool_map.get(spec['type'])
2621
+ if msbuild_tool:
2622
+ msbuild_settings = config['finalized_msbuild_settings']
2623
+ out_file = msbuild_settings[msbuild_tool].get('OutputFile')
2624
+ if out_file:
2625
+ msbuild_attributes['TargetPath'] = _FixPath(out_file)
2626
+
2627
+ return msbuild_attributes
2628
+
2629
+
2630
+ def _GetMSBuildConfigurationGlobalProperties(spec, configurations, build_file):
2631
+ # TODO(jeanluc) We could optimize out the following and do it only if
2632
+ # there are actions.
2633
+ # TODO(jeanluc) Handle the equivalent of setting 'CYGWIN=nontsec'.
2634
+ new_paths = []
2635
+ cygwin_dirs = spec.get('msvs_cygwin_dirs', ['.'])[0]
2636
+ if cygwin_dirs:
2637
+ cyg_path = '$(MSBuildProjectDirectory)\\%s\\bin\\' % _FixPath(cygwin_dirs)
2638
+ new_paths.append(cyg_path)
2639
+ # TODO(jeanluc) Change the convention to have both a cygwin_dir and a
2640
+ # python_dir.
2641
+ python_path = cyg_path.replace('cygwin\\bin', 'python_26')
2642
+ new_paths.append(python_path)
2643
+ if new_paths:
2644
+ new_paths = '$(ExecutablePath);' + ';'.join(new_paths)
2645
+
2646
+ properties = {}
2647
+ for (name, configuration) in sorted(configurations.iteritems()):
2648
+ condition = _GetConfigurationCondition(name, configuration)
2649
+ attributes = _GetMSBuildAttributes(spec, configuration, build_file)
2650
+ msbuild_settings = configuration['finalized_msbuild_settings']
2651
+ _AddConditionalProperty(properties, condition, 'IntDir',
2652
+ attributes['IntermediateDirectory'])
2653
+ _AddConditionalProperty(properties, condition, 'OutDir',
2654
+ attributes['OutputDirectory'])
2655
+ _AddConditionalProperty(properties, condition, 'TargetName',
2656
+ attributes['TargetName'])
2657
+
2658
+ if attributes.get('TargetPath'):
2659
+ _AddConditionalProperty(properties, condition, 'TargetPath',
2660
+ attributes['TargetPath'])
2661
+
2662
+ if new_paths:
2663
+ _AddConditionalProperty(properties, condition, 'ExecutablePath',
2664
+ new_paths)
2665
+ tool_settings = msbuild_settings.get('', {})
2666
+ for name, value in sorted(tool_settings.iteritems()):
2667
+ formatted_value = _GetValueFormattedForMSBuild('', name, value)
2668
+ _AddConditionalProperty(properties, condition, name, formatted_value)
2669
+ return _GetMSBuildPropertyGroup(spec, None, properties)
2670
+
2671
+
2672
+ def _AddConditionalProperty(properties, condition, name, value):
2673
+ """Adds a property / conditional value pair to a dictionary.
2674
+
2675
+ Arguments:
2676
+ properties: The dictionary to be modified. The key is the name of the
2677
+ property. The value is itself a dictionary; its key is the value and
2678
+ the value a list of condition for which this value is true.
2679
+ condition: The condition under which the named property has the value.
2680
+ name: The name of the property.
2681
+ value: The value of the property.
2682
+ """
2683
+ if name not in properties:
2684
+ properties[name] = {}
2685
+ values = properties[name]
2686
+ if value not in values:
2687
+ values[value] = []
2688
+ conditions = values[value]
2689
+ conditions.append(condition)
2690
+
2691
+
2692
+ # Regex for msvs variable references ( i.e. $(FOO) ).
2693
+ MSVS_VARIABLE_REFERENCE = re.compile('\$\(([a-zA-Z_][a-zA-Z0-9_]*)\)')
2694
+
2695
+
2696
+ def _GetMSBuildPropertyGroup(spec, label, properties):
2697
+ """Returns a PropertyGroup definition for the specified properties.
2698
+
2699
+ Arguments:
2700
+ spec: The target project dict.
2701
+ label: An optional label for the PropertyGroup.
2702
+ properties: The dictionary to be converted. The key is the name of the
2703
+ property. The value is itself a dictionary; its key is the value and
2704
+ the value a list of condition for which this value is true.
2705
+ """
2706
+ group = ['PropertyGroup']
2707
+ if label:
2708
+ group.append({'Label': label})
2709
+ num_configurations = len(spec['configurations'])
2710
+ def GetEdges(node):
2711
+ # Use a definition of edges such that user_of_variable -> used_varible.
2712
+ # This happens to be easier in this case, since a variable's
2713
+ # definition contains all variables it references in a single string.
2714
+ edges = set()
2715
+ for value in sorted(properties[node].keys()):
2716
+ # Add to edges all $(...) references to variables.
2717
+ #
2718
+ # Variable references that refer to names not in properties are excluded
2719
+ # These can exist for instance to refer built in definitions like
2720
+ # $(SolutionDir).
2721
+ #
2722
+ # Self references are ignored. Self reference is used in a few places to
2723
+ # append to the default value. I.e. PATH=$(PATH);other_path
2724
+ edges.update(set([v for v in MSVS_VARIABLE_REFERENCE.findall(value)
2725
+ if v in properties and v != node]))
2726
+ return edges
2727
+ properties_ordered = gyp.common.TopologicallySorted(
2728
+ properties.keys(), GetEdges)
2729
+ # Walk properties in the reverse of a topological sort on
2730
+ # user_of_variable -> used_variable as this ensures variables are
2731
+ # defined before they are used.
2732
+ # NOTE: reverse(topsort(DAG)) = topsort(reverse_edges(DAG))
2733
+ for name in reversed(properties_ordered):
2734
+ values = properties[name]
2735
+ for value, conditions in sorted(values.iteritems()):
2736
+ if len(conditions) == num_configurations:
2737
+ # If the value is the same all configurations,
2738
+ # just add one unconditional entry.
2739
+ group.append([name, value])
2740
+ else:
2741
+ for condition in conditions:
2742
+ group.append([name, {'Condition': condition}, value])
2743
+ return [group]
2744
+
2745
+
2746
+ def _GetMSBuildToolSettingsSections(spec, configurations):
2747
+ groups = []
2748
+ for (name, configuration) in sorted(configurations.iteritems()):
2749
+ msbuild_settings = configuration['finalized_msbuild_settings']
2750
+ group = ['ItemDefinitionGroup',
2751
+ {'Condition': _GetConfigurationCondition(name, configuration)}
2752
+ ]
2753
+ for tool_name, tool_settings in sorted(msbuild_settings.iteritems()):
2754
+ # Skip the tool named '' which is a holder of global settings handled
2755
+ # by _GetMSBuildConfigurationGlobalProperties.
2756
+ if tool_name:
2757
+ if tool_settings:
2758
+ tool = [tool_name]
2759
+ for name, value in sorted(tool_settings.iteritems()):
2760
+ formatted_value = _GetValueFormattedForMSBuild(tool_name, name,
2761
+ value)
2762
+ tool.append([name, formatted_value])
2763
+ group.append(tool)
2764
+ groups.append(group)
2765
+ return groups
2766
+
2767
+
2768
+ def _FinalizeMSBuildSettings(spec, configuration):
2769
+ if 'msbuild_settings' in configuration:
2770
+ converted = False
2771
+ msbuild_settings = configuration['msbuild_settings']
2772
+ MSVSSettings.ValidateMSBuildSettings(msbuild_settings)
2773
+ else:
2774
+ converted = True
2775
+ msvs_settings = configuration.get('msvs_settings', {})
2776
+ msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(msvs_settings)
2777
+ include_dirs, resource_include_dirs = _GetIncludeDirs(configuration)
2778
+ libraries = _GetLibraries(spec)
2779
+ out_file, _, msbuild_tool = _GetOutputFilePathAndTool(spec, msbuild=True)
2780
+ defines = _GetDefines(configuration)
2781
+ if converted:
2782
+ # Visual Studio 2010 has TR1
2783
+ defines = [d for d in defines if d != '_HAS_TR1=0']
2784
+ # Warn of ignored settings
2785
+ ignored_settings = ['msvs_prebuild', 'msvs_postbuild', 'msvs_tool_files']
2786
+ for ignored_setting in ignored_settings:
2787
+ value = configuration.get(ignored_setting)
2788
+ if value:
2789
+ print ('Warning: The automatic conversion to MSBuild does not handle '
2790
+ '%s. Ignoring setting of %s' % (ignored_setting, str(value)))
2791
+
2792
+ defines = [_EscapeCppDefineForMSBuild(d) for d in defines]
2793
+ disabled_warnings = _GetDisabledWarnings(configuration)
2794
+ # TODO(jeanluc) Validate & warn that we don't translate
2795
+ # prebuild = configuration.get('msvs_prebuild')
2796
+ # postbuild = configuration.get('msvs_postbuild')
2797
+ def_file = _GetModuleDefinition(spec)
2798
+ precompiled_header = configuration.get('msvs_precompiled_header')
2799
+
2800
+ # Add the information to the appropriate tool
2801
+ # TODO(jeanluc) We could optimize and generate these settings only if
2802
+ # the corresponding files are found, e.g. don't generate ResourceCompile
2803
+ # if you don't have any resources.
2804
+ _ToolAppend(msbuild_settings, 'ClCompile',
2805
+ 'AdditionalIncludeDirectories', include_dirs)
2806
+ _ToolAppend(msbuild_settings, 'ResourceCompile',
2807
+ 'AdditionalIncludeDirectories', resource_include_dirs)
2808
+ # Add in libraries.
2809
+ _ToolAppend(msbuild_settings, 'Link', 'AdditionalDependencies', libraries)
2810
+ if out_file:
2811
+ _ToolAppend(msbuild_settings, msbuild_tool, 'OutputFile', out_file,
2812
+ only_if_unset=True)
2813
+ # Add defines.
2814
+ _ToolAppend(msbuild_settings, 'ClCompile',
2815
+ 'PreprocessorDefinitions', defines)
2816
+ _ToolAppend(msbuild_settings, 'ResourceCompile',
2817
+ 'PreprocessorDefinitions', defines)
2818
+ # Add disabled warnings.
2819
+ _ToolAppend(msbuild_settings, 'ClCompile',
2820
+ 'DisableSpecificWarnings', disabled_warnings)
2821
+ # Turn on precompiled headers if appropriate.
2822
+ if precompiled_header:
2823
+ precompiled_header = os.path.split(precompiled_header)[1]
2824
+ _ToolAppend(msbuild_settings, 'ClCompile', 'PrecompiledHeader', 'Use')
2825
+ _ToolAppend(msbuild_settings, 'ClCompile',
2826
+ 'PrecompiledHeaderFile', precompiled_header)
2827
+ _ToolAppend(msbuild_settings, 'ClCompile',
2828
+ 'ForcedIncludeFiles', precompiled_header)
2829
+ # Loadable modules don't generate import libraries;
2830
+ # tell dependent projects to not expect one.
2831
+ if spec['type'] == 'loadable_module':
2832
+ _ToolAppend(msbuild_settings, '', 'IgnoreImportLibrary', 'true')
2833
+ # Set the module definition file if any.
2834
+ if def_file:
2835
+ _ToolAppend(msbuild_settings, 'Link', 'ModuleDefinitionFile', def_file)
2836
+ configuration['finalized_msbuild_settings'] = msbuild_settings
2837
+
2838
+
2839
+ def _GetValueFormattedForMSBuild(tool_name, name, value):
2840
+ if type(value) == list:
2841
+ # For some settings, VS2010 does not automatically extends the settings
2842
+ # TODO(jeanluc) Is this what we want?
2843
+ if name in ['AdditionalDependencies',
2844
+ 'AdditionalIncludeDirectories',
2845
+ 'AdditionalLibraryDirectories',
2846
+ 'AdditionalOptions',
2847
+ 'DelayLoadDLLs',
2848
+ 'DisableSpecificWarnings',
2849
+ 'PreprocessorDefinitions']:
2850
+ value.append('%%(%s)' % name)
2851
+ # For most tools, entries in a list should be separated with ';' but some
2852
+ # settings use a space. Check for those first.
2853
+ exceptions = {
2854
+ 'ClCompile': ['AdditionalOptions'],
2855
+ 'Link': ['AdditionalOptions'],
2856
+ 'Lib': ['AdditionalOptions']}
2857
+ if tool_name in exceptions and name in exceptions[tool_name]:
2858
+ char = ' '
2859
+ else:
2860
+ char = ';'
2861
+ formatted_value = char.join(
2862
+ [MSVSSettings.ConvertVCMacrosToMSBuild(i) for i in value])
2863
+ else:
2864
+ formatted_value = MSVSSettings.ConvertVCMacrosToMSBuild(value)
2865
+ return formatted_value
2866
+
2867
+
2868
+ def _VerifySourcesExist(sources, root_dir):
2869
+ """Verifies that all source files exist on disk.
2870
+
2871
+ Checks that all regular source files, i.e. not created at run time,
2872
+ exist on disk. Missing files cause needless recompilation but no otherwise
2873
+ visible errors.
2874
+
2875
+ Arguments:
2876
+ sources: A recursive list of Filter/file names.
2877
+ root_dir: The root directory for the relative path names.
2878
+ Returns:
2879
+ A list of source files that cannot be found on disk.
2880
+ """
2881
+ missing_sources = []
2882
+ for source in sources:
2883
+ if isinstance(source, MSVSProject.Filter):
2884
+ missing_sources.extend(_VerifySourcesExist(source.contents, root_dir))
2885
+ else:
2886
+ if '$' not in source:
2887
+ full_path = os.path.join(root_dir, source)
2888
+ if not os.path.exists(full_path):
2889
+ missing_sources.append(full_path)
2890
+ return missing_sources
2891
+
2892
+
2893
+ def _GetMSBuildSources(spec, sources, exclusions, extension_to_rule_name,
2894
+ actions_spec, sources_handled_by_action, list_excluded):
2895
+ groups = ['none', 'midl', 'include', 'compile', 'resource', 'rule']
2896
+ grouped_sources = {}
2897
+ for g in groups:
2898
+ grouped_sources[g] = []
2899
+
2900
+ _AddSources2(spec, sources, exclusions, grouped_sources,
2901
+ extension_to_rule_name, sources_handled_by_action, list_excluded)
2902
+ sources = []
2903
+ for g in groups:
2904
+ if grouped_sources[g]:
2905
+ sources.append(['ItemGroup'] + grouped_sources[g])
2906
+ if actions_spec:
2907
+ sources.append(['ItemGroup'] + actions_spec)
2908
+ return sources
2909
+
2910
+
2911
+ def _AddSources2(spec, sources, exclusions, grouped_sources,
2912
+ extension_to_rule_name, sources_handled_by_action,
2913
+ list_excluded):
2914
+ extensions_excluded_from_precompile = []
2915
+ for source in sources:
2916
+ if isinstance(source, MSVSProject.Filter):
2917
+ _AddSources2(spec, source.contents, exclusions, grouped_sources,
2918
+ extension_to_rule_name, sources_handled_by_action,
2919
+ list_excluded)
2920
+ else:
2921
+ if not source in sources_handled_by_action:
2922
+ detail = []
2923
+ excluded_configurations = exclusions.get(source, [])
2924
+ if len(excluded_configurations) == len(spec['configurations']):
2925
+ detail.append(['ExcludedFromBuild', 'true'])
2926
+ else:
2927
+ for config_name, configuration in sorted(excluded_configurations):
2928
+ condition = _GetConfigurationCondition(config_name, configuration)
2929
+ detail.append(['ExcludedFromBuild',
2930
+ {'Condition': condition},
2931
+ 'true'])
2932
+ # Add precompile if needed
2933
+ for config_name, configuration in spec['configurations'].iteritems():
2934
+ precompiled_source = configuration.get('msvs_precompiled_source', '')
2935
+ if precompiled_source != '':
2936
+ precompiled_source = _FixPath(precompiled_source)
2937
+ if not extensions_excluded_from_precompile:
2938
+ # If the precompiled header is generated by a C source, we must
2939
+ # not try to use it for C++ sources, and vice versa.
2940
+ basename, extension = os.path.splitext(precompiled_source)
2941
+ if extension == '.c':
2942
+ extensions_excluded_from_precompile = ['.cc', '.cpp', '.cxx']
2943
+ else:
2944
+ extensions_excluded_from_precompile = ['.c']
2945
+
2946
+ if precompiled_source == source:
2947
+ condition = _GetConfigurationCondition(config_name, configuration)
2948
+ detail.append(['PrecompiledHeader',
2949
+ {'Condition': condition},
2950
+ 'Create'
2951
+ ])
2952
+ else:
2953
+ # Turn off precompiled header usage for source files of a
2954
+ # different type than the file that generated the
2955
+ # precompiled header.
2956
+ for extension in extensions_excluded_from_precompile:
2957
+ if source.endswith(extension):
2958
+ detail.append(['PrecompiledHeader', ''])
2959
+ detail.append(['ForcedIncludeFiles', ''])
2960
+
2961
+ group, element = _MapFileToMsBuildSourceType(source,
2962
+ extension_to_rule_name)
2963
+ grouped_sources[group].append([element, {'Include': source}] + detail)
2964
+
2965
+
2966
+ def _GetMSBuildProjectReferences(project):
2967
+ references = []
2968
+ if project.dependencies:
2969
+ group = ['ItemGroup']
2970
+ for dependency in project.dependencies:
2971
+ guid = dependency.guid
2972
+ project_dir = os.path.split(project.path)[0]
2973
+ relative_path = gyp.common.RelativePath(dependency.path, project_dir)
2974
+ project_ref = ['ProjectReference',
2975
+ {'Include': relative_path},
2976
+ ['Project', guid],
2977
+ ['ReferenceOutputAssembly', 'false']
2978
+ ]
2979
+ for config in dependency.spec.get('configurations', {}).itervalues():
2980
+ # If it's disabled in any config, turn it off in the reference.
2981
+ if config.get('msvs_2010_disable_uldi_when_referenced', 0):
2982
+ project_ref.append(['UseLibraryDependencyInputs', 'false'])
2983
+ break
2984
+ group.append(project_ref)
2985
+ references.append(group)
2986
+ return references
2987
+
2988
+
2989
+ def _GenerateMSBuildProject(project, options, version, generator_flags):
2990
+ spec = project.spec
2991
+ configurations = spec['configurations']
2992
+ project_dir, project_file_name = os.path.split(project.path)
2993
+ msbuildproj_dir = os.path.dirname(project.path)
2994
+ if msbuildproj_dir and not os.path.exists(msbuildproj_dir):
2995
+ os.makedirs(msbuildproj_dir)
2996
+ # Prepare list of sources and excluded sources.
2997
+ gyp_path = _NormalizedSource(project.build_file)
2998
+ relative_path_of_gyp_file = gyp.common.RelativePath(gyp_path, project_dir)
2999
+
3000
+ gyp_file = os.path.split(project.build_file)[1]
3001
+ sources, excluded_sources = _PrepareListOfSources(spec, generator_flags,
3002
+ gyp_file)
3003
+ # Add rules.
3004
+ actions_to_add = {}
3005
+ props_files_of_rules = set()
3006
+ targets_files_of_rules = set()
3007
+ extension_to_rule_name = {}
3008
+ list_excluded = generator_flags.get('msvs_list_excluded_files', True)
3009
+ _GenerateRulesForMSBuild(project_dir, options, spec,
3010
+ sources, excluded_sources,
3011
+ props_files_of_rules, targets_files_of_rules,
3012
+ actions_to_add, extension_to_rule_name)
3013
+ sources, excluded_sources, excluded_idl = (
3014
+ _AdjustSourcesAndConvertToFilterHierarchy(spec, options,
3015
+ project_dir, sources,
3016
+ excluded_sources,
3017
+ list_excluded))
3018
+ _AddActions(actions_to_add, spec, project.build_file)
3019
+ _AddCopies(actions_to_add, spec)
3020
+
3021
+ # NOTE: this stanza must appear after all actions have been decided.
3022
+ # Don't excluded sources with actions attached, or they won't run.
3023
+ excluded_sources = _FilterActionsFromExcluded(
3024
+ excluded_sources, actions_to_add)
3025
+
3026
+ exclusions = _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_idl)
3027
+ actions_spec, sources_handled_by_action = _GenerateActionsForMSBuild(
3028
+ spec, actions_to_add)
3029
+
3030
+ _GenerateMSBuildFiltersFile(project.path + '.filters', sources,
3031
+ extension_to_rule_name)
3032
+ missing_sources = _VerifySourcesExist(sources, project_dir)
3033
+
3034
+ for configuration in configurations.itervalues():
3035
+ _FinalizeMSBuildSettings(spec, configuration)
3036
+
3037
+ # Add attributes to root element
3038
+
3039
+ import_default_section = [
3040
+ ['Import', {'Project': r'$(VCTargetsPath)\Microsoft.Cpp.Default.props'}]]
3041
+ import_cpp_props_section = [
3042
+ ['Import', {'Project': r'$(VCTargetsPath)\Microsoft.Cpp.props'}]]
3043
+ import_cpp_targets_section = [
3044
+ ['Import', {'Project': r'$(VCTargetsPath)\Microsoft.Cpp.targets'}]]
3045
+ macro_section = [['PropertyGroup', {'Label': 'UserMacros'}]]
3046
+
3047
+ content = [
3048
+ 'Project',
3049
+ {'xmlns': 'http://schemas.microsoft.com/developer/msbuild/2003',
3050
+ 'ToolsVersion': version.ProjectVersion(),
3051
+ 'DefaultTargets': 'Build'
3052
+ }]
3053
+
3054
+ content += _GetMSBuildProjectConfigurations(configurations)
3055
+ content += _GetMSBuildGlobalProperties(spec, project.guid, project_file_name)
3056
+ content += import_default_section
3057
+ content += _GetMSBuildConfigurationDetails(spec, project.build_file)
3058
+ content += _GetMSBuildLocalProperties(project.msbuild_toolset)
3059
+ content += import_cpp_props_section
3060
+ content += _GetMSBuildExtensions(props_files_of_rules)
3061
+ content += _GetMSBuildPropertySheets(configurations)
3062
+ content += macro_section
3063
+ content += _GetMSBuildConfigurationGlobalProperties(spec, configurations,
3064
+ project.build_file)
3065
+ content += _GetMSBuildToolSettingsSections(spec, configurations)
3066
+ content += _GetMSBuildSources(
3067
+ spec, sources, exclusions, extension_to_rule_name, actions_spec,
3068
+ sources_handled_by_action, list_excluded)
3069
+ content += _GetMSBuildProjectReferences(project)
3070
+ content += import_cpp_targets_section
3071
+ content += _GetMSBuildExtensionTargets(targets_files_of_rules)
3072
+
3073
+ # TODO(jeanluc) File a bug to get rid of runas. We had in MSVS:
3074
+ # has_run_as = _WriteMSVSUserFile(project.path, version, spec)
3075
+
3076
+ easy_xml.WriteXmlIfChanged(content, project.path, pretty=True, win32=True)
3077
+
3078
+ return missing_sources
3079
+
3080
+
3081
+ def _GetMSBuildExtensions(props_files_of_rules):
3082
+ extensions = ['ImportGroup', {'Label': 'ExtensionSettings'}]
3083
+ for props_file in props_files_of_rules:
3084
+ extensions.append(['Import', {'Project': props_file}])
3085
+ return [extensions]
3086
+
3087
+
3088
+ def _GetMSBuildExtensionTargets(targets_files_of_rules):
3089
+ targets_node = ['ImportGroup', {'Label': 'ExtensionTargets'}]
3090
+ for targets_file in sorted(targets_files_of_rules):
3091
+ targets_node.append(['Import', {'Project': targets_file}])
3092
+ return [targets_node]
3093
+
3094
+
3095
+ def _GenerateActionsForMSBuild(spec, actions_to_add):
3096
+ """Add actions accumulated into an actions_to_add, merging as needed.
3097
+
3098
+ Arguments:
3099
+ spec: the target project dict
3100
+ actions_to_add: dictionary keyed on input name, which maps to a list of
3101
+ dicts describing the actions attached to that input file.
3102
+
3103
+ Returns:
3104
+ A pair of (action specification, the sources handled by this action).
3105
+ """
3106
+ sources_handled_by_action = set()
3107
+ actions_spec = []
3108
+ for primary_input, actions in actions_to_add.iteritems():
3109
+ inputs = set()
3110
+ outputs = set()
3111
+ descriptions = []
3112
+ commands = []
3113
+ for action in actions:
3114
+ inputs.update(set(action['inputs']))
3115
+ outputs.update(set(action['outputs']))
3116
+ descriptions.append(action['description'])
3117
+ cmd = action['command']
3118
+ # For most actions, add 'call' so that actions that invoke batch files
3119
+ # return and continue executing. msbuild_use_call provides a way to
3120
+ # disable this but I have not seen any adverse effect from doing that
3121
+ # for everything.
3122
+ if action.get('msbuild_use_call', True):
3123
+ cmd = 'call ' + cmd
3124
+ commands.append(cmd)
3125
+ # Add the custom build action for one input file.
3126
+ description = ', and also '.join(descriptions)
3127
+
3128
+ # We can't join the commands simply with && because the command line will
3129
+ # get too long. See also _AddActions: cygwin's setup_env mustn't be called
3130
+ # for every invocation or the command that sets the PATH will grow too
3131
+ # long.
3132
+ command = (
3133
+ '\r\nif %errorlevel% neq 0 exit /b %errorlevel%\r\n'.join(commands))
3134
+ _AddMSBuildAction(spec,
3135
+ primary_input,
3136
+ inputs,
3137
+ outputs,
3138
+ command,
3139
+ description,
3140
+ sources_handled_by_action,
3141
+ actions_spec)
3142
+ return actions_spec, sources_handled_by_action
3143
+
3144
+
3145
+ def _AddMSBuildAction(spec, primary_input, inputs, outputs, cmd, description,
3146
+ sources_handled_by_action, actions_spec):
3147
+ command = MSVSSettings.ConvertVCMacrosToMSBuild(cmd)
3148
+ primary_input = _FixPath(primary_input)
3149
+ inputs_array = _FixPaths(inputs)
3150
+ outputs_array = _FixPaths(outputs)
3151
+ additional_inputs = ';'.join([i for i in inputs_array
3152
+ if i != primary_input])
3153
+ outputs = ';'.join(outputs_array)
3154
+ sources_handled_by_action.add(primary_input)
3155
+ action_spec = ['CustomBuild', {'Include': primary_input}]
3156
+ action_spec.extend(
3157
+ # TODO(jeanluc) 'Document' for all or just if as_sources?
3158
+ [['FileType', 'Document'],
3159
+ ['Command', command],
3160
+ ['Message', description],
3161
+ ['Outputs', outputs]
3162
+ ])
3163
+ if additional_inputs:
3164
+ action_spec.append(['AdditionalInputs', additional_inputs])
3165
+ actions_spec.append(action_spec)