lounge_lizard 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (348) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.gitmodules +3 -0
  4. data/.rspec +2 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +4 -0
  7. data/Guardfile +33 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +50 -0
  10. data/Rakefile +43 -0
  11. data/bin/console +14 -0
  12. data/bin/setup +8 -0
  13. data/circle.yml +14 -0
  14. data/ext/drafter/CHANGELOG.md +278 -0
  15. data/ext/drafter/Dockerfile +17 -0
  16. data/ext/drafter/Makefile +62 -0
  17. data/ext/drafter/appveyor.yml +17 -0
  18. data/ext/drafter/bin/drafter +0 -0
  19. data/ext/drafter/build/Makefile +387 -0
  20. data/ext/drafter/build/drafter.Makefile +6 -0
  21. data/ext/drafter/build/drafter.target.mk +159 -0
  22. data/ext/drafter/build/ext/snowcrash/libmarkdownparser.target.mk +141 -0
  23. data/ext/drafter/build/ext/snowcrash/libsnowcrash.target.mk +154 -0
  24. data/ext/drafter/build/ext/snowcrash/libsundown.target.mk +149 -0
  25. data/ext/drafter/build/ext/snowcrash/perf-libsnowcrash.target.mk +147 -0
  26. data/ext/drafter/build/ext/snowcrash/snowcrash.Makefile +6 -0
  27. data/ext/drafter/build/gyp-mac-tool +606 -0
  28. data/ext/drafter/build/libdrafter.target.mk +186 -0
  29. data/ext/drafter/build/libsos.target.mk +137 -0
  30. data/ext/drafter/build/out/Release/drafter +0 -0
  31. data/ext/drafter/build/out/Release/libdrafter.dylib +0 -0
  32. data/ext/drafter/build/out/Release/libmarkdownparser.a +0 -0
  33. data/ext/drafter/build/out/Release/libsnowcrash.a +0 -0
  34. data/ext/drafter/build/out/Release/libsos.a +0 -0
  35. data/ext/drafter/build/out/Release/libsundown.a +0 -0
  36. data/ext/drafter/build/out/Release/obj.target/drafter/src/config.o +0 -0
  37. data/ext/drafter/build/out/Release/obj.target/drafter/src/main.o +0 -0
  38. data/ext/drafter/build/out/Release/obj.target/drafter/src/reporting.o +0 -0
  39. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/ConversionContext.o +0 -0
  40. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/NamedTypesRegistry.o +0 -0
  41. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/RefractAPI.o +0 -0
  42. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/RefractDataStructure.o +0 -0
  43. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/RefractElementFactory.o +0 -0
  44. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/RefractSourceMap.o +0 -0
  45. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/Render.o +0 -0
  46. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/Serialize.o +0 -0
  47. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/SerializeAST.o +0 -0
  48. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/SerializeResult.o +0 -0
  49. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/SerializeSourcemap.o +0 -0
  50. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/drafter.o +0 -0
  51. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/drafter_private.o +0 -0
  52. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/ComparableVisitor.o +0 -0
  53. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/Element.o +0 -0
  54. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/ExpandVisitor.o +0 -0
  55. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/IsExpandableVisitor.o +0 -0
  56. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/JSONSchemaVisitor.o +0 -0
  57. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/PrintVisitor.o +0 -0
  58. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/Query.o +0 -0
  59. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/Registry.o +0 -0
  60. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/RenderJSONVisitor.o +0 -0
  61. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/SerializeCompactVisitor.o +0 -0
  62. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/SerializeVisitor.o +0 -0
  63. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/TypeQueryVisitor.o +0 -0
  64. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/VisitorUtils.o +0 -0
  65. data/ext/drafter/build/out/Release/obj.target/libmarkdownparser/ext/snowcrash/ext/markdown-parser/src/ByteBuffer.o +0 -0
  66. data/ext/drafter/build/out/Release/obj.target/libmarkdownparser/ext/snowcrash/ext/markdown-parser/src/MarkdownNode.o +0 -0
  67. data/ext/drafter/build/out/Release/obj.target/libmarkdownparser/ext/snowcrash/ext/markdown-parser/src/MarkdownParser.o +0 -0
  68. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/Blueprint.o +0 -0
  69. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/BlueprintSourcemap.o +0 -0
  70. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/HTTP.o +0 -0
  71. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/HeadersParser.o +0 -0
  72. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/MSON.o +0 -0
  73. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/MSONOneOfParser.o +0 -0
  74. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/MSONSourcemap.o +0 -0
  75. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/MSONTypeSectionParser.o +0 -0
  76. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/MSONValueMemberParser.o +0 -0
  77. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/Section.o +0 -0
  78. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/Signature.o +0 -0
  79. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/UriTemplateParser.o +0 -0
  80. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/posix/RegexMatch.o +0 -0
  81. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/snowcrash.o +0 -0
  82. data/ext/drafter/build/out/Release/obj.target/libsos/ext/sos/src/sos.o +0 -0
  83. data/ext/drafter/build/out/Release/obj.target/libsundown/ext/snowcrash/ext/markdown-parser/ext/sundown/html/houdini_href_e.o +0 -0
  84. data/ext/drafter/build/out/Release/obj.target/libsundown/ext/snowcrash/ext/markdown-parser/ext/sundown/html/houdini_html_e.o +0 -0
  85. data/ext/drafter/build/out/Release/obj.target/libsundown/ext/snowcrash/ext/markdown-parser/ext/sundown/html/html.o +0 -0
  86. data/ext/drafter/build/out/Release/obj.target/libsundown/ext/snowcrash/ext/markdown-parser/ext/sundown/html/html_smartypants.o +0 -0
  87. data/ext/drafter/build/out/Release/obj.target/libsundown/ext/snowcrash/ext/markdown-parser/ext/sundown/src/autolink.o +0 -0
  88. data/ext/drafter/build/out/Release/obj.target/libsundown/ext/snowcrash/ext/markdown-parser/ext/sundown/src/buffer.o +0 -0
  89. data/ext/drafter/build/out/Release/obj.target/libsundown/ext/snowcrash/ext/markdown-parser/ext/sundown/src/markdown.o +0 -0
  90. data/ext/drafter/build/out/Release/obj.target/libsundown/ext/snowcrash/ext/markdown-parser/ext/sundown/src/src_map.o +0 -0
  91. data/ext/drafter/build/out/Release/obj.target/libsundown/ext/snowcrash/ext/markdown-parser/ext/sundown/src/stack.o +0 -0
  92. data/ext/drafter/circle.yml +32 -0
  93. data/ext/drafter/config.gypi +10 -0
  94. data/ext/drafter/config.mk +5 -0
  95. data/ext/drafter/configure +224 -0
  96. data/ext/drafter/drafter.gyp +189 -0
  97. data/ext/drafter/drafter.xcworkspace/contents.xcworkspacedata +13 -0
  98. data/ext/drafter/ext/snowcrash/Makefile +58 -0
  99. data/ext/drafter/ext/snowcrash/appveyor.yml +7 -0
  100. data/ext/drafter/ext/snowcrash/common.gypi +165 -0
  101. data/ext/drafter/ext/snowcrash/configure +197 -0
  102. data/ext/drafter/ext/snowcrash/ext/markdown-parser/Makefile +90 -0
  103. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/CONTRIBUTING.md +10 -0
  104. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/Makefile +84 -0
  105. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/Makefile.win +33 -0
  106. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/examples/smartypants.c +72 -0
  107. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/examples/sundown.c +80 -0
  108. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/html/houdini.h +37 -0
  109. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/html/houdini_href_e.c +108 -0
  110. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/html/houdini_html_e.c +84 -0
  111. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/html/html.c +647 -0
  112. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/html/html.h +77 -0
  113. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/html/html_smartypants.c +389 -0
  114. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/html_block_names.txt +25 -0
  115. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/autolink.c +297 -0
  116. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/autolink.h +51 -0
  117. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/buffer.c +225 -0
  118. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/buffer.h +96 -0
  119. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/html_blocks.h +206 -0
  120. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/markdown.c +2726 -0
  121. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/markdown.h +147 -0
  122. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/src_map.c +204 -0
  123. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/src_map.h +58 -0
  124. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/stack.c +81 -0
  125. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/stack.h +29 -0
  126. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/sundown.def +20 -0
  127. data/ext/drafter/ext/snowcrash/ext/markdown-parser/msvc/markdown/markdown.vcproj +188 -0
  128. data/ext/drafter/ext/snowcrash/ext/markdown-parser/msvc/msvc.sln +38 -0
  129. data/ext/drafter/ext/snowcrash/ext/markdown-parser/msvc/sundown/sundown.vcproj +206 -0
  130. data/ext/drafter/ext/snowcrash/ext/markdown-parser/src/ByteBuffer.cc +160 -0
  131. data/ext/drafter/ext/snowcrash/ext/markdown-parser/src/ByteBuffer.h +90 -0
  132. data/ext/drafter/ext/snowcrash/ext/markdown-parser/src/MarkdownNode.cc +152 -0
  133. data/ext/drafter/ext/snowcrash/ext/markdown-parser/src/MarkdownNode.h +103 -0
  134. data/ext/drafter/ext/snowcrash/ext/markdown-parser/src/MarkdownParser.cc +388 -0
  135. data/ext/drafter/ext/snowcrash/ext/markdown-parser/src/MarkdownParser.h +106 -0
  136. data/ext/drafter/ext/snowcrash/snowcrash.gyp +196 -0
  137. data/ext/drafter/ext/snowcrash/src/ActionParser.h +560 -0
  138. data/ext/drafter/ext/snowcrash/src/AssetParser.h +123 -0
  139. data/ext/drafter/ext/snowcrash/src/AttributesParser.h +123 -0
  140. data/ext/drafter/ext/snowcrash/src/Blueprint.cc +90 -0
  141. data/ext/drafter/ext/snowcrash/src/Blueprint.h +489 -0
  142. data/ext/drafter/ext/snowcrash/src/BlueprintParser.h +845 -0
  143. data/ext/drafter/ext/snowcrash/src/BlueprintSourcemap.cc +81 -0
  144. data/ext/drafter/ext/snowcrash/src/BlueprintSourcemap.h +345 -0
  145. data/ext/drafter/ext/snowcrash/src/BlueprintUtility.h +111 -0
  146. data/ext/drafter/ext/snowcrash/src/CodeBlockUtility.h +276 -0
  147. data/ext/drafter/ext/snowcrash/src/DataStructureGroupParser.h +157 -0
  148. data/ext/drafter/ext/snowcrash/src/HTTP.cc +49 -0
  149. data/ext/drafter/ext/snowcrash/src/HTTP.h +108 -0
  150. data/ext/drafter/ext/snowcrash/src/HeadersParser.cc +117 -0
  151. data/ext/drafter/ext/snowcrash/src/HeadersParser.h +377 -0
  152. data/ext/drafter/ext/snowcrash/src/MSON.cc +272 -0
  153. data/ext/drafter/ext/snowcrash/src/MSON.h +405 -0
  154. data/ext/drafter/ext/snowcrash/src/MSONMixinParser.h +103 -0
  155. data/ext/drafter/ext/snowcrash/src/MSONNamedTypeParser.h +135 -0
  156. data/ext/drafter/ext/snowcrash/src/MSONOneOfParser.cc +132 -0
  157. data/ext/drafter/ext/snowcrash/src/MSONOneOfParser.h +80 -0
  158. data/ext/drafter/ext/snowcrash/src/MSONParameterParser.h +166 -0
  159. data/ext/drafter/ext/snowcrash/src/MSONPropertyMemberParser.h +106 -0
  160. data/ext/drafter/ext/snowcrash/src/MSONSourcemap.cc +141 -0
  161. data/ext/drafter/ext/snowcrash/src/MSONSourcemap.h +181 -0
  162. data/ext/drafter/ext/snowcrash/src/MSONTypeSectionParser.cc +209 -0
  163. data/ext/drafter/ext/snowcrash/src/MSONTypeSectionParser.h +213 -0
  164. data/ext/drafter/ext/snowcrash/src/MSONUtility.h +506 -0
  165. data/ext/drafter/ext/snowcrash/src/MSONValueMemberParser.cc +214 -0
  166. data/ext/drafter/ext/snowcrash/src/MSONValueMemberParser.h +390 -0
  167. data/ext/drafter/ext/snowcrash/src/ModelTable.h +87 -0
  168. data/ext/drafter/ext/snowcrash/src/ParameterParser.h +516 -0
  169. data/ext/drafter/ext/snowcrash/src/ParametersParser.h +222 -0
  170. data/ext/drafter/ext/snowcrash/src/PayloadParser.h +733 -0
  171. data/ext/drafter/ext/snowcrash/src/Platform.h +33 -0
  172. data/ext/drafter/ext/snowcrash/src/RegexMatch.h +32 -0
  173. data/ext/drafter/ext/snowcrash/src/RelationParser.h +87 -0
  174. data/ext/drafter/ext/snowcrash/src/ResourceGroupParser.h +297 -0
  175. data/ext/drafter/ext/snowcrash/src/ResourceParser.h +536 -0
  176. data/ext/drafter/ext/snowcrash/src/Section.cc +48 -0
  177. data/ext/drafter/ext/snowcrash/src/Section.h +60 -0
  178. data/ext/drafter/ext/snowcrash/src/SectionParser.h +246 -0
  179. data/ext/drafter/ext/snowcrash/src/SectionParserData.h +109 -0
  180. data/ext/drafter/ext/snowcrash/src/SectionProcessor.h +299 -0
  181. data/ext/drafter/ext/snowcrash/src/Signature.cc +75 -0
  182. data/ext/drafter/ext/snowcrash/src/Signature.h +103 -0
  183. data/ext/drafter/ext/snowcrash/src/SignatureSectionProcessor.h +442 -0
  184. data/ext/drafter/ext/snowcrash/src/SourceAnnotation.h +166 -0
  185. data/ext/drafter/ext/snowcrash/src/StringUtility.h +323 -0
  186. data/ext/drafter/ext/snowcrash/src/UriTemplateParser.cc +195 -0
  187. data/ext/drafter/ext/snowcrash/src/UriTemplateParser.h +240 -0
  188. data/ext/drafter/ext/snowcrash/src/ValuesParser.h +111 -0
  189. data/ext/drafter/ext/snowcrash/src/posix/RegexMatch.cc +99 -0
  190. data/ext/drafter/ext/snowcrash/src/snowcrash.cc +90 -0
  191. data/ext/drafter/ext/snowcrash/src/snowcrash.h +44 -0
  192. data/ext/drafter/ext/snowcrash/src/win/RegexMatch.cc +78 -0
  193. data/ext/drafter/ext/snowcrash/tools/gyp/AUTHORS +12 -0
  194. data/ext/drafter/ext/snowcrash/tools/gyp/DEPS +23 -0
  195. data/ext/drafter/ext/snowcrash/tools/gyp/OWNERS +1 -0
  196. data/ext/drafter/ext/snowcrash/tools/gyp/PRESUBMIT.py +137 -0
  197. data/ext/drafter/ext/snowcrash/tools/gyp/buildbot/buildbot_run.py +136 -0
  198. data/ext/drafter/ext/snowcrash/tools/gyp/buildbot/commit_queue/OWNERS +6 -0
  199. data/ext/drafter/ext/snowcrash/tools/gyp/buildbot/commit_queue/cq_config.json +15 -0
  200. data/ext/drafter/ext/snowcrash/tools/gyp/codereview.settings +10 -0
  201. data/ext/drafter/ext/snowcrash/tools/gyp/data/win/large-pdb-shim.cc +12 -0
  202. data/ext/drafter/ext/snowcrash/tools/gyp/gyp +8 -0
  203. data/ext/drafter/ext/snowcrash/tools/gyp/gyp.bat +5 -0
  204. data/ext/drafter/ext/snowcrash/tools/gyp/gyp_main.py +16 -0
  205. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/MSVSNew.py +340 -0
  206. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/MSVSProject.py +208 -0
  207. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/MSVSSettings.py +1096 -0
  208. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/MSVSToolFile.py +58 -0
  209. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/MSVSUserFile.py +147 -0
  210. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/MSVSUtil.py +270 -0
  211. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/MSVSUtil.pyc +0 -0
  212. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/MSVSVersion.py +445 -0
  213. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/MSVSVersion.pyc +0 -0
  214. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/__init__.py +548 -0
  215. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/__init__.pyc +0 -0
  216. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/common.py +608 -0
  217. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/common.pyc +0 -0
  218. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/easy_xml.py +157 -0
  219. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/flock_tool.py +54 -0
  220. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/__init__.py +0 -0
  221. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/__init__.pyc +0 -0
  222. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/analyzer.py +741 -0
  223. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/android.py +1069 -0
  224. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/cmake.py +1248 -0
  225. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/dump_dependency_json.py +99 -0
  226. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/eclipse.py +425 -0
  227. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/gypd.py +94 -0
  228. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/gypsh.py +56 -0
  229. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/make.py +2218 -0
  230. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/make.pyc +0 -0
  231. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/msvs.py +3467 -0
  232. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/ninja.py +2427 -0
  233. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/ninja.pyc +0 -0
  234. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/xcode.py +1300 -0
  235. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/xcode.pyc +0 -0
  236. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/input.py +2899 -0
  237. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/input.pyc +0 -0
  238. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/mac_tool.py +605 -0
  239. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/msvs_emulation.py +1093 -0
  240. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/msvs_emulation.pyc +0 -0
  241. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/ninja_syntax.py +160 -0
  242. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/ninja_syntax.pyc +0 -0
  243. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/ordered_dict.py +289 -0
  244. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/simple_copy.py +46 -0
  245. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/simple_copy.pyc +0 -0
  246. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/win_tool.py +314 -0
  247. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/xcode_emulation.py +1664 -0
  248. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/xcode_emulation.pyc +0 -0
  249. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/xcode_ninja.py +276 -0
  250. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/xcode_ninja.pyc +0 -0
  251. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/xcodeproj_file.py +2927 -0
  252. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/xcodeproj_file.pyc +0 -0
  253. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/xml_fix.py +69 -0
  254. data/ext/drafter/ext/snowcrash/tools/gyp/pylintrc +307 -0
  255. data/ext/drafter/ext/snowcrash/tools/gyp/samples/samples +81 -0
  256. data/ext/drafter/ext/snowcrash/tools/gyp/samples/samples.bat +5 -0
  257. data/ext/drafter/ext/snowcrash/tools/gyp/setup.py +19 -0
  258. data/ext/drafter/ext/snowcrash/tools/gyp/tools/Xcode/Specifications/gyp.pbfilespec +27 -0
  259. data/ext/drafter/ext/snowcrash/tools/gyp/tools/Xcode/Specifications/gyp.xclangspec +226 -0
  260. data/ext/drafter/ext/snowcrash/tools/gyp/tools/emacs/gyp.el +275 -0
  261. data/ext/drafter/ext/snowcrash/tools/gyp/tools/graphviz.py +100 -0
  262. data/ext/drafter/ext/snowcrash/tools/gyp/tools/pretty_gyp.py +155 -0
  263. data/ext/drafter/ext/snowcrash/tools/gyp/tools/pretty_sln.py +169 -0
  264. data/ext/drafter/ext/snowcrash/tools/gyp/tools/pretty_vcproj.py +329 -0
  265. data/ext/drafter/ext/snowcrash/vcbuild.bat +139 -0
  266. data/ext/drafter/ext/sos/Makefile +62 -0
  267. data/ext/drafter/ext/sos/src/sos.cc +235 -0
  268. data/ext/drafter/ext/sos/src/sos.h +188 -0
  269. data/ext/drafter/ext/sos/src/sosJSON.h +121 -0
  270. data/ext/drafter/ext/sos/src/sosYAML.h +105 -0
  271. data/ext/drafter/src/ConversionContext.cc +39 -0
  272. data/ext/drafter/src/ConversionContext.h +34 -0
  273. data/ext/drafter/src/NamedTypesRegistry.cc +405 -0
  274. data/ext/drafter/src/NamedTypesRegistry.h +28 -0
  275. data/ext/drafter/src/NodeInfo.h +143 -0
  276. data/ext/drafter/src/RefractAPI.cc +579 -0
  277. data/ext/drafter/src/RefractAPI.h +28 -0
  278. data/ext/drafter/src/RefractDataStructure.cc +1199 -0
  279. data/ext/drafter/src/RefractDataStructure.h +26 -0
  280. data/ext/drafter/src/RefractElementFactory.cc +107 -0
  281. data/ext/drafter/src/RefractElementFactory.h +67 -0
  282. data/ext/drafter/src/RefractSourceMap.cc +29 -0
  283. data/ext/drafter/src/RefractSourceMap.h +57 -0
  284. data/ext/drafter/src/Render.cc +157 -0
  285. data/ext/drafter/src/Render.h +40 -0
  286. data/ext/drafter/src/Serialize.cc +160 -0
  287. data/ext/drafter/src/Serialize.h +289 -0
  288. data/ext/drafter/src/SerializeAST.cc +507 -0
  289. data/ext/drafter/src/SerializeAST.h +29 -0
  290. data/ext/drafter/src/SerializeResult.cc +170 -0
  291. data/ext/drafter/src/SerializeResult.h +34 -0
  292. data/ext/drafter/src/SerializeSourcemap.cc +331 -0
  293. data/ext/drafter/src/SerializeSourcemap.h +21 -0
  294. data/ext/drafter/src/Version.h +40 -0
  295. data/ext/drafter/src/config.cc +91 -0
  296. data/ext/drafter/src/config.h +38 -0
  297. data/ext/drafter/src/drafter.cc +137 -0
  298. data/ext/drafter/src/drafter.h +102 -0
  299. data/ext/drafter/src/drafter_private.cc +85 -0
  300. data/ext/drafter/src/drafter_private.h +34 -0
  301. data/ext/drafter/src/main.cc +137 -0
  302. data/ext/drafter/src/refract/AppendDecorator.h +58 -0
  303. data/ext/drafter/src/refract/Build.h +67 -0
  304. data/ext/drafter/src/refract/ComparableVisitor.cc +43 -0
  305. data/ext/drafter/src/refract/ComparableVisitor.h +62 -0
  306. data/ext/drafter/src/refract/Element.cc +409 -0
  307. data/ext/drafter/src/refract/Element.h +656 -0
  308. data/ext/drafter/src/refract/ElementFwd.h +37 -0
  309. data/ext/drafter/src/refract/ElementInserter.h +59 -0
  310. data/ext/drafter/src/refract/Exception.h +31 -0
  311. data/ext/drafter/src/refract/ExpandVisitor.cc +359 -0
  312. data/ext/drafter/src/refract/ExpandVisitor.h +58 -0
  313. data/ext/drafter/src/refract/FilterVisitor.h +52 -0
  314. data/ext/drafter/src/refract/IsExpandableVisitor.cc +140 -0
  315. data/ext/drafter/src/refract/IsExpandableVisitor.h +31 -0
  316. data/ext/drafter/src/refract/Iterate.h +160 -0
  317. data/ext/drafter/src/refract/JSONSchemaVisitor.cc +675 -0
  318. data/ext/drafter/src/refract/JSONSchemaVisitor.h +73 -0
  319. data/ext/drafter/src/refract/PrintVisitor.cc +164 -0
  320. data/ext/drafter/src/refract/PrintVisitor.h +50 -0
  321. data/ext/drafter/src/refract/Query.cc +13 -0
  322. data/ext/drafter/src/refract/Query.h +38 -0
  323. data/ext/drafter/src/refract/Registry.cc +114 -0
  324. data/ext/drafter/src/refract/Registry.h +43 -0
  325. data/ext/drafter/src/refract/RenderJSONVisitor.cc +255 -0
  326. data/ext/drafter/src/refract/RenderJSONVisitor.h +51 -0
  327. data/ext/drafter/src/refract/SerializeCompactVisitor.cc +167 -0
  328. data/ext/drafter/src/refract/SerializeCompactVisitor.h +56 -0
  329. data/ext/drafter/src/refract/SerializeVisitor.cc +214 -0
  330. data/ext/drafter/src/refract/SerializeVisitor.h +55 -0
  331. data/ext/drafter/src/refract/TypeQueryVisitor.cc +46 -0
  332. data/ext/drafter/src/refract/TypeQueryVisitor.h +110 -0
  333. data/ext/drafter/src/refract/Visitor.h +126 -0
  334. data/ext/drafter/src/refract/VisitorUtils.cc +63 -0
  335. data/ext/drafter/src/refract/VisitorUtils.h +231 -0
  336. data/ext/drafter/src/reporting.cc +263 -0
  337. data/ext/drafter/src/reporting.h +39 -0
  338. data/ext/drafter/src/stream.h +148 -0
  339. data/ext/drafter/tools/homebrew/drafter.rb +18 -0
  340. data/ext/drafter/tools/make-tarball.sh +39 -0
  341. data/ext/drafter/tools/refract-filter.py +96 -0
  342. data/ext/drafter/tools/release.sh +17 -0
  343. data/ext/drafter/vcbuild.bat +203 -0
  344. data/lib/lounge_lizard/binding.rb +29 -0
  345. data/lib/lounge_lizard/version.rb +3 -0
  346. data/lib/lounge_lizard.rb +18 -0
  347. data/lounge_lizard.gemspec +37 -0
  348. metadata +547 -0
@@ -0,0 +1,1664 @@
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
+ """
6
+ This module contains classes that help to emulate xcodebuild behavior on top of
7
+ other build systems, such as make and ninja.
8
+ """
9
+
10
+ import copy
11
+ import gyp.common
12
+ import os
13
+ import os.path
14
+ import re
15
+ import shlex
16
+ import subprocess
17
+ import sys
18
+ import tempfile
19
+ from gyp.common import GypError
20
+
21
+ # Populated lazily by XcodeVersion, for efficiency, and to fix an issue when
22
+ # "xcodebuild" is called too quickly (it has been found to return incorrect
23
+ # version number).
24
+ XCODE_VERSION_CACHE = None
25
+
26
+ # Populated lazily by GetXcodeArchsDefault, to an |XcodeArchsDefault| instance
27
+ # corresponding to the installed version of Xcode.
28
+ XCODE_ARCHS_DEFAULT_CACHE = None
29
+
30
+
31
+ def XcodeArchsVariableMapping(archs, archs_including_64_bit=None):
32
+ """Constructs a dictionary with expansion for $(ARCHS_STANDARD) variable,
33
+ and optionally for $(ARCHS_STANDARD_INCLUDING_64_BIT)."""
34
+ mapping = {'$(ARCHS_STANDARD)': archs}
35
+ if archs_including_64_bit:
36
+ mapping['$(ARCHS_STANDARD_INCLUDING_64_BIT)'] = archs_including_64_bit
37
+ return mapping
38
+
39
+ class XcodeArchsDefault(object):
40
+ """A class to resolve ARCHS variable from xcode_settings, resolving Xcode
41
+ macros and implementing filtering by VALID_ARCHS. The expansion of macros
42
+ depends on the SDKROOT used ("macosx", "iphoneos", "iphonesimulator") and
43
+ on the version of Xcode.
44
+ """
45
+
46
+ # Match variable like $(ARCHS_STANDARD).
47
+ variable_pattern = re.compile(r'\$\([a-zA-Z_][a-zA-Z0-9_]*\)$')
48
+
49
+ def __init__(self, default, mac, iphonesimulator, iphoneos):
50
+ self._default = (default,)
51
+ self._archs = {'mac': mac, 'ios': iphoneos, 'iossim': iphonesimulator}
52
+
53
+ def _VariableMapping(self, sdkroot):
54
+ """Returns the dictionary of variable mapping depending on the SDKROOT."""
55
+ sdkroot = sdkroot.lower()
56
+ if 'iphoneos' in sdkroot:
57
+ return self._archs['ios']
58
+ elif 'iphonesimulator' in sdkroot:
59
+ return self._archs['iossim']
60
+ else:
61
+ return self._archs['mac']
62
+
63
+ def _ExpandArchs(self, archs, sdkroot):
64
+ """Expands variables references in ARCHS, and remove duplicates."""
65
+ variable_mapping = self._VariableMapping(sdkroot)
66
+ expanded_archs = []
67
+ for arch in archs:
68
+ if self.variable_pattern.match(arch):
69
+ variable = arch
70
+ try:
71
+ variable_expansion = variable_mapping[variable]
72
+ for arch in variable_expansion:
73
+ if arch not in expanded_archs:
74
+ expanded_archs.append(arch)
75
+ except KeyError as e:
76
+ print 'Warning: Ignoring unsupported variable "%s".' % variable
77
+ elif arch not in expanded_archs:
78
+ expanded_archs.append(arch)
79
+ return expanded_archs
80
+
81
+ def ActiveArchs(self, archs, valid_archs, sdkroot):
82
+ """Expands variables references in ARCHS, and filter by VALID_ARCHS if it
83
+ is defined (if not set, Xcode accept any value in ARCHS, otherwise, only
84
+ values present in VALID_ARCHS are kept)."""
85
+ expanded_archs = self._ExpandArchs(archs or self._default, sdkroot or '')
86
+ if valid_archs:
87
+ filtered_archs = []
88
+ for arch in expanded_archs:
89
+ if arch in valid_archs:
90
+ filtered_archs.append(arch)
91
+ expanded_archs = filtered_archs
92
+ return expanded_archs
93
+
94
+
95
+ def GetXcodeArchsDefault():
96
+ """Returns the |XcodeArchsDefault| object to use to expand ARCHS for the
97
+ installed version of Xcode. The default values used by Xcode for ARCHS
98
+ and the expansion of the variables depends on the version of Xcode used.
99
+
100
+ For all version anterior to Xcode 5.0 or posterior to Xcode 5.1 included
101
+ uses $(ARCHS_STANDARD) if ARCHS is unset, while Xcode 5.0 to 5.0.2 uses
102
+ $(ARCHS_STANDARD_INCLUDING_64_BIT). This variable was added to Xcode 5.0
103
+ and deprecated with Xcode 5.1.
104
+
105
+ For "macosx" SDKROOT, all version starting with Xcode 5.0 includes 64-bit
106
+ architecture as part of $(ARCHS_STANDARD) and default to only building it.
107
+
108
+ For "iphoneos" and "iphonesimulator" SDKROOT, 64-bit architectures are part
109
+ of $(ARCHS_STANDARD_INCLUDING_64_BIT) from Xcode 5.0. From Xcode 5.1, they
110
+ are also part of $(ARCHS_STANDARD).
111
+
112
+ All thoses rules are coded in the construction of the |XcodeArchsDefault|
113
+ object to use depending on the version of Xcode detected. The object is
114
+ for performance reason."""
115
+ global XCODE_ARCHS_DEFAULT_CACHE
116
+ if XCODE_ARCHS_DEFAULT_CACHE:
117
+ return XCODE_ARCHS_DEFAULT_CACHE
118
+ xcode_version, _ = XcodeVersion()
119
+ if xcode_version < '0500':
120
+ XCODE_ARCHS_DEFAULT_CACHE = XcodeArchsDefault(
121
+ '$(ARCHS_STANDARD)',
122
+ XcodeArchsVariableMapping(['i386']),
123
+ XcodeArchsVariableMapping(['i386']),
124
+ XcodeArchsVariableMapping(['armv7']))
125
+ elif xcode_version < '0510':
126
+ XCODE_ARCHS_DEFAULT_CACHE = XcodeArchsDefault(
127
+ '$(ARCHS_STANDARD_INCLUDING_64_BIT)',
128
+ XcodeArchsVariableMapping(['x86_64'], ['x86_64']),
129
+ XcodeArchsVariableMapping(['i386'], ['i386', 'x86_64']),
130
+ XcodeArchsVariableMapping(
131
+ ['armv7', 'armv7s'],
132
+ ['armv7', 'armv7s', 'arm64']))
133
+ else:
134
+ XCODE_ARCHS_DEFAULT_CACHE = XcodeArchsDefault(
135
+ '$(ARCHS_STANDARD)',
136
+ XcodeArchsVariableMapping(['x86_64'], ['x86_64']),
137
+ XcodeArchsVariableMapping(['i386', 'x86_64'], ['i386', 'x86_64']),
138
+ XcodeArchsVariableMapping(
139
+ ['armv7', 'armv7s', 'arm64'],
140
+ ['armv7', 'armv7s', 'arm64']))
141
+ return XCODE_ARCHS_DEFAULT_CACHE
142
+
143
+
144
+ class XcodeSettings(object):
145
+ """A class that understands the gyp 'xcode_settings' object."""
146
+
147
+ # Populated lazily by _SdkPath(). Shared by all XcodeSettings, so cached
148
+ # at class-level for efficiency.
149
+ _sdk_path_cache = {}
150
+ _platform_path_cache = {}
151
+ _sdk_root_cache = {}
152
+
153
+ # Populated lazily by GetExtraPlistItems(). Shared by all XcodeSettings, so
154
+ # cached at class-level for efficiency.
155
+ _plist_cache = {}
156
+
157
+ # Populated lazily by GetIOSPostbuilds. Shared by all XcodeSettings, so
158
+ # cached at class-level for efficiency.
159
+ _codesigning_key_cache = {}
160
+
161
+ def __init__(self, spec):
162
+ self.spec = spec
163
+
164
+ self.isIOS = False
165
+
166
+ # Per-target 'xcode_settings' are pushed down into configs earlier by gyp.
167
+ # This means self.xcode_settings[config] always contains all settings
168
+ # for that config -- the per-target settings as well. Settings that are
169
+ # the same for all configs are implicitly per-target settings.
170
+ self.xcode_settings = {}
171
+ configs = spec['configurations']
172
+ for configname, config in configs.iteritems():
173
+ self.xcode_settings[configname] = config.get('xcode_settings', {})
174
+ self._ConvertConditionalKeys(configname)
175
+ if self.xcode_settings[configname].get('IPHONEOS_DEPLOYMENT_TARGET',
176
+ None):
177
+ self.isIOS = True
178
+
179
+ # This is only non-None temporarily during the execution of some methods.
180
+ self.configname = None
181
+
182
+ # Used by _AdjustLibrary to match .a and .dylib entries in libraries.
183
+ self.library_re = re.compile(r'^lib([^/]+)\.(a|dylib)$')
184
+
185
+ def _ConvertConditionalKeys(self, configname):
186
+ """Converts or warns on conditional keys. Xcode supports conditional keys,
187
+ such as CODE_SIGN_IDENTITY[sdk=iphoneos*]. This is a partial implementation
188
+ with some keys converted while the rest force a warning."""
189
+ settings = self.xcode_settings[configname]
190
+ conditional_keys = [key for key in settings if key.endswith(']')]
191
+ for key in conditional_keys:
192
+ # If you need more, speak up at http://crbug.com/122592
193
+ if key.endswith("[sdk=iphoneos*]"):
194
+ if configname.endswith("iphoneos"):
195
+ new_key = key.split("[")[0]
196
+ settings[new_key] = settings[key]
197
+ else:
198
+ print 'Warning: Conditional keys not implemented, ignoring:', \
199
+ ' '.join(conditional_keys)
200
+ del settings[key]
201
+
202
+ def _Settings(self):
203
+ assert self.configname
204
+ return self.xcode_settings[self.configname]
205
+
206
+ def _Test(self, test_key, cond_key, default):
207
+ return self._Settings().get(test_key, default) == cond_key
208
+
209
+ def _Appendf(self, lst, test_key, format_str, default=None):
210
+ if test_key in self._Settings():
211
+ lst.append(format_str % str(self._Settings()[test_key]))
212
+ elif default:
213
+ lst.append(format_str % str(default))
214
+
215
+ def _WarnUnimplemented(self, test_key):
216
+ if test_key in self._Settings():
217
+ print 'Warning: Ignoring not yet implemented key "%s".' % test_key
218
+
219
+ def IsBinaryOutputFormat(self, configname):
220
+ default = "binary" if self.isIOS else "xml"
221
+ format = self.xcode_settings[configname].get('INFOPLIST_OUTPUT_FORMAT',
222
+ default)
223
+ return format == "binary"
224
+
225
+ def _IsBundle(self):
226
+ return int(self.spec.get('mac_bundle', 0)) != 0 or self._IsXCTest()
227
+
228
+ def _IsXCTest(self):
229
+ return int(self.spec.get('mac_xctest_bundle', 0)) != 0
230
+
231
+ def _IsIosAppExtension(self):
232
+ return int(self.spec.get('ios_app_extension', 0)) != 0
233
+
234
+ def _IsIosWatchKitExtension(self):
235
+ return int(self.spec.get('ios_watchkit_extension', 0)) != 0
236
+
237
+ def _IsIosWatchApp(self):
238
+ return int(self.spec.get('ios_watch_app', 0)) != 0
239
+
240
+ def GetFrameworkVersion(self):
241
+ """Returns the framework version of the current target. Only valid for
242
+ bundles."""
243
+ assert self._IsBundle()
244
+ return self.GetPerTargetSetting('FRAMEWORK_VERSION', default='A')
245
+
246
+ def GetWrapperExtension(self):
247
+ """Returns the bundle extension (.app, .framework, .plugin, etc). Only
248
+ valid for bundles."""
249
+ assert self._IsBundle()
250
+ if self.spec['type'] in ('loadable_module', 'shared_library'):
251
+ default_wrapper_extension = {
252
+ 'loadable_module': 'bundle',
253
+ 'shared_library': 'framework',
254
+ }[self.spec['type']]
255
+ wrapper_extension = self.GetPerTargetSetting(
256
+ 'WRAPPER_EXTENSION', default=default_wrapper_extension)
257
+ return '.' + self.spec.get('product_extension', wrapper_extension)
258
+ elif self.spec['type'] == 'executable':
259
+ if self._IsIosAppExtension() or self._IsIosWatchKitExtension():
260
+ return '.' + self.spec.get('product_extension', 'appex')
261
+ else:
262
+ return '.' + self.spec.get('product_extension', 'app')
263
+ else:
264
+ assert False, "Don't know extension for '%s', target '%s'" % (
265
+ self.spec['type'], self.spec['target_name'])
266
+
267
+ def GetProductName(self):
268
+ """Returns PRODUCT_NAME."""
269
+ return self.spec.get('product_name', self.spec['target_name'])
270
+
271
+ def GetFullProductName(self):
272
+ """Returns FULL_PRODUCT_NAME."""
273
+ if self._IsBundle():
274
+ return self.GetWrapperName()
275
+ else:
276
+ return self._GetStandaloneBinaryPath()
277
+
278
+ def GetWrapperName(self):
279
+ """Returns the directory name of the bundle represented by this target.
280
+ Only valid for bundles."""
281
+ assert self._IsBundle()
282
+ return self.GetProductName() + self.GetWrapperExtension()
283
+
284
+ def GetBundleContentsFolderPath(self):
285
+ """Returns the qualified path to the bundle's contents folder. E.g.
286
+ Chromium.app/Contents or Foo.bundle/Versions/A. Only valid for bundles."""
287
+ if self.isIOS:
288
+ return self.GetWrapperName()
289
+ assert self._IsBundle()
290
+ if self.spec['type'] == 'shared_library':
291
+ return os.path.join(
292
+ self.GetWrapperName(), 'Versions', self.GetFrameworkVersion())
293
+ else:
294
+ # loadable_modules have a 'Contents' folder like executables.
295
+ return os.path.join(self.GetWrapperName(), 'Contents')
296
+
297
+ def GetBundleResourceFolder(self):
298
+ """Returns the qualified path to the bundle's resource folder. E.g.
299
+ Chromium.app/Contents/Resources. Only valid for bundles."""
300
+ assert self._IsBundle()
301
+ if self.isIOS:
302
+ return self.GetBundleContentsFolderPath()
303
+ return os.path.join(self.GetBundleContentsFolderPath(), 'Resources')
304
+
305
+ def GetBundlePlistPath(self):
306
+ """Returns the qualified path to the bundle's plist file. E.g.
307
+ Chromium.app/Contents/Info.plist. Only valid for bundles."""
308
+ assert self._IsBundle()
309
+ if self.spec['type'] in ('executable', 'loadable_module'):
310
+ return os.path.join(self.GetBundleContentsFolderPath(), 'Info.plist')
311
+ else:
312
+ return os.path.join(self.GetBundleContentsFolderPath(),
313
+ 'Resources', 'Info.plist')
314
+
315
+ def GetProductType(self):
316
+ """Returns the PRODUCT_TYPE of this target."""
317
+ if self._IsIosAppExtension():
318
+ assert self._IsBundle(), ('ios_app_extension flag requires mac_bundle '
319
+ '(target %s)' % self.spec['target_name'])
320
+ return 'com.apple.product-type.app-extension'
321
+ if self._IsIosWatchKitExtension():
322
+ assert self._IsBundle(), ('ios_watchkit_extension flag requires '
323
+ 'mac_bundle (target %s)' % self.spec['target_name'])
324
+ return 'com.apple.product-type.watchkit-extension'
325
+ if self._IsIosWatchApp():
326
+ assert self._IsBundle(), ('ios_watch_app flag requires mac_bundle '
327
+ '(target %s)' % self.spec['target_name'])
328
+ return 'com.apple.product-type.application.watchapp'
329
+ if self._IsBundle():
330
+ return {
331
+ 'executable': 'com.apple.product-type.application',
332
+ 'loadable_module': 'com.apple.product-type.bundle',
333
+ 'shared_library': 'com.apple.product-type.framework',
334
+ }[self.spec['type']]
335
+ else:
336
+ return {
337
+ 'executable': 'com.apple.product-type.tool',
338
+ 'loadable_module': 'com.apple.product-type.library.dynamic',
339
+ 'shared_library': 'com.apple.product-type.library.dynamic',
340
+ 'static_library': 'com.apple.product-type.library.static',
341
+ }[self.spec['type']]
342
+
343
+ def GetMachOType(self):
344
+ """Returns the MACH_O_TYPE of this target."""
345
+ # Weird, but matches Xcode.
346
+ if not self._IsBundle() and self.spec['type'] == 'executable':
347
+ return ''
348
+ return {
349
+ 'executable': 'mh_execute',
350
+ 'static_library': 'staticlib',
351
+ 'shared_library': 'mh_dylib',
352
+ 'loadable_module': 'mh_bundle',
353
+ }[self.spec['type']]
354
+
355
+ def _GetBundleBinaryPath(self):
356
+ """Returns the name of the bundle binary of by this target.
357
+ E.g. Chromium.app/Contents/MacOS/Chromium. Only valid for bundles."""
358
+ assert self._IsBundle()
359
+ if self.spec['type'] in ('shared_library') or self.isIOS:
360
+ path = self.GetBundleContentsFolderPath()
361
+ elif self.spec['type'] in ('executable', 'loadable_module'):
362
+ path = os.path.join(self.GetBundleContentsFolderPath(), 'MacOS')
363
+ return os.path.join(path, self.GetExecutableName())
364
+
365
+ def _GetStandaloneExecutableSuffix(self):
366
+ if 'product_extension' in self.spec:
367
+ return '.' + self.spec['product_extension']
368
+ return {
369
+ 'executable': '',
370
+ 'static_library': '.a',
371
+ 'shared_library': '.dylib',
372
+ 'loadable_module': '.so',
373
+ }[self.spec['type']]
374
+
375
+ def _GetStandaloneExecutablePrefix(self):
376
+ return self.spec.get('product_prefix', {
377
+ 'executable': '',
378
+ 'static_library': 'lib',
379
+ 'shared_library': 'lib',
380
+ # Non-bundled loadable_modules are called foo.so for some reason
381
+ # (that is, .so and no prefix) with the xcode build -- match that.
382
+ 'loadable_module': '',
383
+ }[self.spec['type']])
384
+
385
+ def _GetStandaloneBinaryPath(self):
386
+ """Returns the name of the non-bundle binary represented by this target.
387
+ E.g. hello_world. Only valid for non-bundles."""
388
+ assert not self._IsBundle()
389
+ assert self.spec['type'] in (
390
+ 'executable', 'shared_library', 'static_library', 'loadable_module'), (
391
+ 'Unexpected type %s' % self.spec['type'])
392
+ target = self.spec['target_name']
393
+ if self.spec['type'] == 'static_library':
394
+ if target[:3] == 'lib':
395
+ target = target[3:]
396
+ elif self.spec['type'] in ('loadable_module', 'shared_library'):
397
+ if target[:3] == 'lib':
398
+ target = target[3:]
399
+
400
+ target_prefix = self._GetStandaloneExecutablePrefix()
401
+ target = self.spec.get('product_name', target)
402
+ target_ext = self._GetStandaloneExecutableSuffix()
403
+ return target_prefix + target + target_ext
404
+
405
+ def GetExecutableName(self):
406
+ """Returns the executable name of the bundle represented by this target.
407
+ E.g. Chromium."""
408
+ if self._IsBundle():
409
+ return self.spec.get('product_name', self.spec['target_name'])
410
+ else:
411
+ return self._GetStandaloneBinaryPath()
412
+
413
+ def GetExecutablePath(self):
414
+ """Returns the directory name of the bundle represented by this target. E.g.
415
+ Chromium.app/Contents/MacOS/Chromium."""
416
+ if self._IsBundle():
417
+ return self._GetBundleBinaryPath()
418
+ else:
419
+ return self._GetStandaloneBinaryPath()
420
+
421
+ def GetActiveArchs(self, configname):
422
+ """Returns the architectures this target should be built for."""
423
+ config_settings = self.xcode_settings[configname]
424
+ xcode_archs_default = GetXcodeArchsDefault()
425
+ return xcode_archs_default.ActiveArchs(
426
+ config_settings.get('ARCHS'),
427
+ config_settings.get('VALID_ARCHS'),
428
+ config_settings.get('SDKROOT'))
429
+
430
+ def _GetSdkVersionInfoItem(self, sdk, infoitem):
431
+ # xcodebuild requires Xcode and can't run on Command Line Tools-only
432
+ # systems from 10.7 onward.
433
+ # Since the CLT has no SDK paths anyway, returning None is the
434
+ # most sensible route and should still do the right thing.
435
+ try:
436
+ return GetStdout(['xcrun', '--sdk', sdk, infoitem])
437
+ except:
438
+ pass
439
+
440
+ def _SdkRoot(self, configname):
441
+ if configname is None:
442
+ configname = self.configname
443
+ return self.GetPerConfigSetting('SDKROOT', configname, default='')
444
+
445
+ def _XcodePlatformPath(self, configname=None):
446
+ sdk_root = self._SdkRoot(configname)
447
+ if sdk_root not in XcodeSettings._platform_path_cache:
448
+ platform_path = self._GetSdkVersionInfoItem(sdk_root,
449
+ '--show-sdk-platform-path')
450
+ XcodeSettings._platform_path_cache[sdk_root] = platform_path
451
+ return XcodeSettings._platform_path_cache[sdk_root]
452
+
453
+ def _SdkPath(self, configname=None):
454
+ sdk_root = self._SdkRoot(configname)
455
+ if sdk_root.startswith('/'):
456
+ return sdk_root
457
+ return self._XcodeSdkPath(sdk_root)
458
+
459
+ def _XcodeSdkPath(self, sdk_root):
460
+ if sdk_root not in XcodeSettings._sdk_path_cache:
461
+ sdk_path = self._GetSdkVersionInfoItem(sdk_root, '--show-sdk-path')
462
+ XcodeSettings._sdk_path_cache[sdk_root] = sdk_path
463
+ if sdk_root:
464
+ XcodeSettings._sdk_root_cache[sdk_path] = sdk_root
465
+ return XcodeSettings._sdk_path_cache[sdk_root]
466
+
467
+ def _AppendPlatformVersionMinFlags(self, lst):
468
+ self._Appendf(lst, 'MACOSX_DEPLOYMENT_TARGET', '-mmacosx-version-min=%s')
469
+ if 'IPHONEOS_DEPLOYMENT_TARGET' in self._Settings():
470
+ # TODO: Implement this better?
471
+ sdk_path_basename = os.path.basename(self._SdkPath())
472
+ if sdk_path_basename.lower().startswith('iphonesimulator'):
473
+ self._Appendf(lst, 'IPHONEOS_DEPLOYMENT_TARGET',
474
+ '-mios-simulator-version-min=%s')
475
+ else:
476
+ self._Appendf(lst, 'IPHONEOS_DEPLOYMENT_TARGET',
477
+ '-miphoneos-version-min=%s')
478
+
479
+ def GetCflags(self, configname, arch=None):
480
+ """Returns flags that need to be added to .c, .cc, .m, and .mm
481
+ compilations."""
482
+ # This functions (and the similar ones below) do not offer complete
483
+ # emulation of all xcode_settings keys. They're implemented on demand.
484
+
485
+ self.configname = configname
486
+ cflags = []
487
+
488
+ sdk_root = self._SdkPath()
489
+ if 'SDKROOT' in self._Settings() and sdk_root:
490
+ cflags.append('-isysroot %s' % sdk_root)
491
+
492
+ if self._Test('CLANG_WARN_CONSTANT_CONVERSION', 'YES', default='NO'):
493
+ cflags.append('-Wconstant-conversion')
494
+
495
+ if self._Test('GCC_CHAR_IS_UNSIGNED_CHAR', 'YES', default='NO'):
496
+ cflags.append('-funsigned-char')
497
+
498
+ if self._Test('GCC_CW_ASM_SYNTAX', 'YES', default='YES'):
499
+ cflags.append('-fasm-blocks')
500
+
501
+ if 'GCC_DYNAMIC_NO_PIC' in self._Settings():
502
+ if self._Settings()['GCC_DYNAMIC_NO_PIC'] == 'YES':
503
+ cflags.append('-mdynamic-no-pic')
504
+ else:
505
+ pass
506
+ # TODO: In this case, it depends on the target. xcode passes
507
+ # mdynamic-no-pic by default for executable and possibly static lib
508
+ # according to mento
509
+
510
+ if self._Test('GCC_ENABLE_PASCAL_STRINGS', 'YES', default='YES'):
511
+ cflags.append('-mpascal-strings')
512
+
513
+ self._Appendf(cflags, 'GCC_OPTIMIZATION_LEVEL', '-O%s', default='s')
514
+
515
+ if self._Test('GCC_GENERATE_DEBUGGING_SYMBOLS', 'YES', default='YES'):
516
+ dbg_format = self._Settings().get('DEBUG_INFORMATION_FORMAT', 'dwarf')
517
+ if dbg_format == 'dwarf':
518
+ cflags.append('-gdwarf-2')
519
+ elif dbg_format == 'stabs':
520
+ raise NotImplementedError('stabs debug format is not supported yet.')
521
+ elif dbg_format == 'dwarf-with-dsym':
522
+ cflags.append('-gdwarf-2')
523
+ else:
524
+ raise NotImplementedError('Unknown debug format %s' % dbg_format)
525
+
526
+ if self._Settings().get('GCC_STRICT_ALIASING') == 'YES':
527
+ cflags.append('-fstrict-aliasing')
528
+ elif self._Settings().get('GCC_STRICT_ALIASING') == 'NO':
529
+ cflags.append('-fno-strict-aliasing')
530
+
531
+ if self._Test('GCC_SYMBOLS_PRIVATE_EXTERN', 'YES', default='NO'):
532
+ cflags.append('-fvisibility=hidden')
533
+
534
+ if self._Test('GCC_TREAT_WARNINGS_AS_ERRORS', 'YES', default='NO'):
535
+ cflags.append('-Werror')
536
+
537
+ if self._Test('GCC_WARN_ABOUT_MISSING_NEWLINE', 'YES', default='NO'):
538
+ cflags.append('-Wnewline-eof')
539
+
540
+ # In Xcode, this is only activated when GCC_COMPILER_VERSION is clang or
541
+ # llvm-gcc. It also requires a fairly recent libtool, and
542
+ # if the system clang isn't used, DYLD_LIBRARY_PATH needs to contain the
543
+ # path to the libLTO.dylib that matches the used clang.
544
+ if self._Test('LLVM_LTO', 'YES', default='NO'):
545
+ cflags.append('-flto')
546
+
547
+ self._AppendPlatformVersionMinFlags(cflags)
548
+
549
+ # TODO:
550
+ if self._Test('COPY_PHASE_STRIP', 'YES', default='NO'):
551
+ self._WarnUnimplemented('COPY_PHASE_STRIP')
552
+ self._WarnUnimplemented('GCC_DEBUGGING_SYMBOLS')
553
+ self._WarnUnimplemented('GCC_ENABLE_OBJC_EXCEPTIONS')
554
+
555
+ # TODO: This is exported correctly, but assigning to it is not supported.
556
+ self._WarnUnimplemented('MACH_O_TYPE')
557
+ self._WarnUnimplemented('PRODUCT_TYPE')
558
+
559
+ if arch is not None:
560
+ archs = [arch]
561
+ else:
562
+ assert self.configname
563
+ archs = self.GetActiveArchs(self.configname)
564
+ if len(archs) != 1:
565
+ # TODO: Supporting fat binaries will be annoying.
566
+ self._WarnUnimplemented('ARCHS')
567
+ archs = ['i386']
568
+ cflags.append('-arch ' + archs[0])
569
+
570
+ if archs[0] in ('i386', 'x86_64'):
571
+ if self._Test('GCC_ENABLE_SSE3_EXTENSIONS', 'YES', default='NO'):
572
+ cflags.append('-msse3')
573
+ if self._Test('GCC_ENABLE_SUPPLEMENTAL_SSE3_INSTRUCTIONS', 'YES',
574
+ default='NO'):
575
+ cflags.append('-mssse3') # Note 3rd 's'.
576
+ if self._Test('GCC_ENABLE_SSE41_EXTENSIONS', 'YES', default='NO'):
577
+ cflags.append('-msse4.1')
578
+ if self._Test('GCC_ENABLE_SSE42_EXTENSIONS', 'YES', default='NO'):
579
+ cflags.append('-msse4.2')
580
+
581
+ cflags += self._Settings().get('WARNING_CFLAGS', [])
582
+
583
+ platform_root = self._XcodePlatformPath(configname)
584
+ if platform_root and self._IsXCTest():
585
+ cflags.append('-F' + platform_root + '/Developer/Library/Frameworks/')
586
+
587
+ if sdk_root:
588
+ framework_root = sdk_root
589
+ else:
590
+ framework_root = ''
591
+ config = self.spec['configurations'][self.configname]
592
+ framework_dirs = config.get('mac_framework_dirs', [])
593
+ for directory in framework_dirs:
594
+ cflags.append('-F' + directory.replace('$(SDKROOT)', framework_root))
595
+
596
+ self.configname = None
597
+ return cflags
598
+
599
+ def GetCflagsC(self, configname):
600
+ """Returns flags that need to be added to .c, and .m compilations."""
601
+ self.configname = configname
602
+ cflags_c = []
603
+ if self._Settings().get('GCC_C_LANGUAGE_STANDARD', '') == 'ansi':
604
+ cflags_c.append('-ansi')
605
+ else:
606
+ self._Appendf(cflags_c, 'GCC_C_LANGUAGE_STANDARD', '-std=%s')
607
+ cflags_c += self._Settings().get('OTHER_CFLAGS', [])
608
+ self.configname = None
609
+ return cflags_c
610
+
611
+ def GetCflagsCC(self, configname):
612
+ """Returns flags that need to be added to .cc, and .mm compilations."""
613
+ self.configname = configname
614
+ cflags_cc = []
615
+
616
+ clang_cxx_language_standard = self._Settings().get(
617
+ 'CLANG_CXX_LANGUAGE_STANDARD')
618
+ # Note: Don't make c++0x to c++11 so that c++0x can be used with older
619
+ # clangs that don't understand c++11 yet (like Xcode 4.2's).
620
+ if clang_cxx_language_standard:
621
+ cflags_cc.append('-std=%s' % clang_cxx_language_standard)
622
+
623
+ self._Appendf(cflags_cc, 'CLANG_CXX_LIBRARY', '-stdlib=%s')
624
+
625
+ if self._Test('GCC_ENABLE_CPP_RTTI', 'NO', default='YES'):
626
+ cflags_cc.append('-fno-rtti')
627
+ if self._Test('GCC_ENABLE_CPP_EXCEPTIONS', 'NO', default='YES'):
628
+ cflags_cc.append('-fno-exceptions')
629
+ if self._Test('GCC_INLINES_ARE_PRIVATE_EXTERN', 'YES', default='NO'):
630
+ cflags_cc.append('-fvisibility-inlines-hidden')
631
+ if self._Test('GCC_THREADSAFE_STATICS', 'NO', default='YES'):
632
+ cflags_cc.append('-fno-threadsafe-statics')
633
+ # Note: This flag is a no-op for clang, it only has an effect for gcc.
634
+ if self._Test('GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO', 'NO', default='YES'):
635
+ cflags_cc.append('-Wno-invalid-offsetof')
636
+
637
+ other_ccflags = []
638
+
639
+ for flag in self._Settings().get('OTHER_CPLUSPLUSFLAGS', ['$(inherited)']):
640
+ # TODO: More general variable expansion. Missing in many other places too.
641
+ if flag in ('$inherited', '$(inherited)', '${inherited}'):
642
+ flag = '$OTHER_CFLAGS'
643
+ if flag in ('$OTHER_CFLAGS', '$(OTHER_CFLAGS)', '${OTHER_CFLAGS}'):
644
+ other_ccflags += self._Settings().get('OTHER_CFLAGS', [])
645
+ else:
646
+ other_ccflags.append(flag)
647
+ cflags_cc += other_ccflags
648
+
649
+ self.configname = None
650
+ return cflags_cc
651
+
652
+ def _AddObjectiveCGarbageCollectionFlags(self, flags):
653
+ gc_policy = self._Settings().get('GCC_ENABLE_OBJC_GC', 'unsupported')
654
+ if gc_policy == 'supported':
655
+ flags.append('-fobjc-gc')
656
+ elif gc_policy == 'required':
657
+ flags.append('-fobjc-gc-only')
658
+
659
+ def _AddObjectiveCARCFlags(self, flags):
660
+ if self._Test('CLANG_ENABLE_OBJC_ARC', 'YES', default='NO'):
661
+ flags.append('-fobjc-arc')
662
+
663
+ def _AddObjectiveCMissingPropertySynthesisFlags(self, flags):
664
+ if self._Test('CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS',
665
+ 'YES', default='NO'):
666
+ flags.append('-Wobjc-missing-property-synthesis')
667
+
668
+ def GetCflagsObjC(self, configname):
669
+ """Returns flags that need to be added to .m compilations."""
670
+ self.configname = configname
671
+ cflags_objc = []
672
+ self._AddObjectiveCGarbageCollectionFlags(cflags_objc)
673
+ self._AddObjectiveCARCFlags(cflags_objc)
674
+ self._AddObjectiveCMissingPropertySynthesisFlags(cflags_objc)
675
+ self.configname = None
676
+ return cflags_objc
677
+
678
+ def GetCflagsObjCC(self, configname):
679
+ """Returns flags that need to be added to .mm compilations."""
680
+ self.configname = configname
681
+ cflags_objcc = []
682
+ self._AddObjectiveCGarbageCollectionFlags(cflags_objcc)
683
+ self._AddObjectiveCARCFlags(cflags_objcc)
684
+ self._AddObjectiveCMissingPropertySynthesisFlags(cflags_objcc)
685
+ if self._Test('GCC_OBJC_CALL_CXX_CDTORS', 'YES', default='NO'):
686
+ cflags_objcc.append('-fobjc-call-cxx-cdtors')
687
+ self.configname = None
688
+ return cflags_objcc
689
+
690
+ def GetInstallNameBase(self):
691
+ """Return DYLIB_INSTALL_NAME_BASE for this target."""
692
+ # Xcode sets this for shared_libraries, and for nonbundled loadable_modules.
693
+ if (self.spec['type'] != 'shared_library' and
694
+ (self.spec['type'] != 'loadable_module' or self._IsBundle())):
695
+ return None
696
+ install_base = self.GetPerTargetSetting(
697
+ 'DYLIB_INSTALL_NAME_BASE',
698
+ default='/Library/Frameworks' if self._IsBundle() else '/usr/local/lib')
699
+ return install_base
700
+
701
+ def _StandardizePath(self, path):
702
+ """Do :standardizepath processing for path."""
703
+ # I'm not quite sure what :standardizepath does. Just call normpath(),
704
+ # but don't let @executable_path/../foo collapse to foo.
705
+ if '/' in path:
706
+ prefix, rest = '', path
707
+ if path.startswith('@'):
708
+ prefix, rest = path.split('/', 1)
709
+ rest = os.path.normpath(rest) # :standardizepath
710
+ path = os.path.join(prefix, rest)
711
+ return path
712
+
713
+ def GetInstallName(self):
714
+ """Return LD_DYLIB_INSTALL_NAME for this target."""
715
+ # Xcode sets this for shared_libraries, and for nonbundled loadable_modules.
716
+ if (self.spec['type'] != 'shared_library' and
717
+ (self.spec['type'] != 'loadable_module' or self._IsBundle())):
718
+ return None
719
+
720
+ default_install_name = \
721
+ '$(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH)'
722
+ install_name = self.GetPerTargetSetting(
723
+ 'LD_DYLIB_INSTALL_NAME', default=default_install_name)
724
+
725
+ # Hardcode support for the variables used in chromium for now, to
726
+ # unblock people using the make build.
727
+ if '$' in install_name:
728
+ assert install_name in ('$(DYLIB_INSTALL_NAME_BASE:standardizepath)/'
729
+ '$(WRAPPER_NAME)/$(PRODUCT_NAME)', default_install_name), (
730
+ 'Variables in LD_DYLIB_INSTALL_NAME are not generally supported '
731
+ 'yet in target \'%s\' (got \'%s\')' %
732
+ (self.spec['target_name'], install_name))
733
+
734
+ install_name = install_name.replace(
735
+ '$(DYLIB_INSTALL_NAME_BASE:standardizepath)',
736
+ self._StandardizePath(self.GetInstallNameBase()))
737
+ if self._IsBundle():
738
+ # These are only valid for bundles, hence the |if|.
739
+ install_name = install_name.replace(
740
+ '$(WRAPPER_NAME)', self.GetWrapperName())
741
+ install_name = install_name.replace(
742
+ '$(PRODUCT_NAME)', self.GetProductName())
743
+ else:
744
+ assert '$(WRAPPER_NAME)' not in install_name
745
+ assert '$(PRODUCT_NAME)' not in install_name
746
+
747
+ install_name = install_name.replace(
748
+ '$(EXECUTABLE_PATH)', self.GetExecutablePath())
749
+ return install_name
750
+
751
+ def _MapLinkerFlagFilename(self, ldflag, gyp_to_build_path):
752
+ """Checks if ldflag contains a filename and if so remaps it from
753
+ gyp-directory-relative to build-directory-relative."""
754
+ # This list is expanded on demand.
755
+ # They get matched as:
756
+ # -exported_symbols_list file
757
+ # -Wl,exported_symbols_list file
758
+ # -Wl,exported_symbols_list,file
759
+ LINKER_FILE = r'(\S+)'
760
+ WORD = r'\S+'
761
+ linker_flags = [
762
+ ['-exported_symbols_list', LINKER_FILE], # Needed for NaCl.
763
+ ['-unexported_symbols_list', LINKER_FILE],
764
+ ['-reexported_symbols_list', LINKER_FILE],
765
+ ['-sectcreate', WORD, WORD, LINKER_FILE], # Needed for remoting.
766
+ ]
767
+ for flag_pattern in linker_flags:
768
+ regex = re.compile('(?:-Wl,)?' + '[ ,]'.join(flag_pattern))
769
+ m = regex.match(ldflag)
770
+ if m:
771
+ ldflag = ldflag[:m.start(1)] + gyp_to_build_path(m.group(1)) + \
772
+ ldflag[m.end(1):]
773
+ # Required for ffmpeg (no idea why they don't use LIBRARY_SEARCH_PATHS,
774
+ # TODO(thakis): Update ffmpeg.gyp):
775
+ if ldflag.startswith('-L'):
776
+ ldflag = '-L' + gyp_to_build_path(ldflag[len('-L'):])
777
+ return ldflag
778
+
779
+ def GetLdflags(self, configname, product_dir, gyp_to_build_path, arch=None):
780
+ """Returns flags that need to be passed to the linker.
781
+
782
+ Args:
783
+ configname: The name of the configuration to get ld flags for.
784
+ product_dir: The directory where products such static and dynamic
785
+ libraries are placed. This is added to the library search path.
786
+ gyp_to_build_path: A function that converts paths relative to the
787
+ current gyp file to paths relative to the build direcotry.
788
+ """
789
+ self.configname = configname
790
+ ldflags = []
791
+
792
+ # The xcode build is relative to a gyp file's directory, and OTHER_LDFLAGS
793
+ # can contain entries that depend on this. Explicitly absolutify these.
794
+ for ldflag in self._Settings().get('OTHER_LDFLAGS', []):
795
+ ldflags.append(self._MapLinkerFlagFilename(ldflag, gyp_to_build_path))
796
+
797
+ if self._Test('DEAD_CODE_STRIPPING', 'YES', default='NO'):
798
+ ldflags.append('-Wl,-dead_strip')
799
+
800
+ if self._Test('PREBINDING', 'YES', default='NO'):
801
+ ldflags.append('-Wl,-prebind')
802
+
803
+ self._Appendf(
804
+ ldflags, 'DYLIB_COMPATIBILITY_VERSION', '-compatibility_version %s')
805
+ self._Appendf(
806
+ ldflags, 'DYLIB_CURRENT_VERSION', '-current_version %s')
807
+
808
+ self._AppendPlatformVersionMinFlags(ldflags)
809
+
810
+ if 'SDKROOT' in self._Settings() and self._SdkPath():
811
+ ldflags.append('-isysroot ' + self._SdkPath())
812
+
813
+ for library_path in self._Settings().get('LIBRARY_SEARCH_PATHS', []):
814
+ ldflags.append('-L' + gyp_to_build_path(library_path))
815
+
816
+ if 'ORDER_FILE' in self._Settings():
817
+ ldflags.append('-Wl,-order_file ' +
818
+ '-Wl,' + gyp_to_build_path(
819
+ self._Settings()['ORDER_FILE']))
820
+
821
+ if arch is not None:
822
+ archs = [arch]
823
+ else:
824
+ assert self.configname
825
+ archs = self.GetActiveArchs(self.configname)
826
+ if len(archs) != 1:
827
+ # TODO: Supporting fat binaries will be annoying.
828
+ self._WarnUnimplemented('ARCHS')
829
+ archs = ['i386']
830
+ ldflags.append('-arch ' + archs[0])
831
+
832
+ # Xcode adds the product directory by default.
833
+ ldflags.append('-L' + product_dir)
834
+
835
+ install_name = self.GetInstallName()
836
+ if install_name and self.spec['type'] != 'loadable_module':
837
+ ldflags.append('-install_name ' + install_name.replace(' ', r'\ '))
838
+
839
+ for rpath in self._Settings().get('LD_RUNPATH_SEARCH_PATHS', []):
840
+ ldflags.append('-Wl,-rpath,' + rpath)
841
+
842
+ sdk_root = self._SdkPath()
843
+ if not sdk_root:
844
+ sdk_root = ''
845
+ config = self.spec['configurations'][self.configname]
846
+ framework_dirs = config.get('mac_framework_dirs', [])
847
+ for directory in framework_dirs:
848
+ ldflags.append('-F' + directory.replace('$(SDKROOT)', sdk_root))
849
+
850
+ platform_root = self._XcodePlatformPath(configname)
851
+ if sdk_root and platform_root and self._IsXCTest():
852
+ ldflags.append('-F' + platform_root + '/Developer/Library/Frameworks/')
853
+ ldflags.append('-framework XCTest')
854
+
855
+ is_extension = self._IsIosAppExtension() or self._IsIosWatchKitExtension()
856
+ if sdk_root and is_extension:
857
+ # Adds the link flags for extensions. These flags are common for all
858
+ # extensions and provide loader and main function.
859
+ # These flags reflect the compilation options used by xcode to compile
860
+ # extensions.
861
+ if XcodeVersion() < '0900':
862
+ ldflags.append('-lpkstart')
863
+ ldflags.append(sdk_root +
864
+ '/System/Library/PrivateFrameworks/PlugInKit.framework/PlugInKit')
865
+ else:
866
+ ldflags.append('-e _NSExtensionMain')
867
+ ldflags.append('-fapplication-extension')
868
+
869
+ self._Appendf(ldflags, 'CLANG_CXX_LIBRARY', '-stdlib=%s')
870
+
871
+ self.configname = None
872
+ return ldflags
873
+
874
+ def GetLibtoolflags(self, configname):
875
+ """Returns flags that need to be passed to the static linker.
876
+
877
+ Args:
878
+ configname: The name of the configuration to get ld flags for.
879
+ """
880
+ self.configname = configname
881
+ libtoolflags = []
882
+
883
+ for libtoolflag in self._Settings().get('OTHER_LDFLAGS', []):
884
+ libtoolflags.append(libtoolflag)
885
+ # TODO(thakis): ARCHS?
886
+
887
+ self.configname = None
888
+ return libtoolflags
889
+
890
+ def GetPerTargetSettings(self):
891
+ """Gets a list of all the per-target settings. This will only fetch keys
892
+ whose values are the same across all configurations."""
893
+ first_pass = True
894
+ result = {}
895
+ for configname in sorted(self.xcode_settings.keys()):
896
+ if first_pass:
897
+ result = dict(self.xcode_settings[configname])
898
+ first_pass = False
899
+ else:
900
+ for key, value in self.xcode_settings[configname].iteritems():
901
+ if key not in result:
902
+ continue
903
+ elif result[key] != value:
904
+ del result[key]
905
+ return result
906
+
907
+ def GetPerConfigSetting(self, setting, configname, default=None):
908
+ if configname in self.xcode_settings:
909
+ return self.xcode_settings[configname].get(setting, default)
910
+ else:
911
+ return self.GetPerTargetSetting(setting, default)
912
+
913
+ def GetPerTargetSetting(self, setting, default=None):
914
+ """Tries to get xcode_settings.setting from spec. Assumes that the setting
915
+ has the same value in all configurations and throws otherwise."""
916
+ is_first_pass = True
917
+ result = None
918
+ for configname in sorted(self.xcode_settings.keys()):
919
+ if is_first_pass:
920
+ result = self.xcode_settings[configname].get(setting, None)
921
+ is_first_pass = False
922
+ else:
923
+ assert result == self.xcode_settings[configname].get(setting, None), (
924
+ "Expected per-target setting for '%s', got per-config setting "
925
+ "(target %s)" % (setting, self.spec['target_name']))
926
+ if result is None:
927
+ return default
928
+ return result
929
+
930
+ def _GetStripPostbuilds(self, configname, output_binary, quiet):
931
+ """Returns a list of shell commands that contain the shell commands
932
+ neccessary to strip this target's binary. These should be run as postbuilds
933
+ before the actual postbuilds run."""
934
+ self.configname = configname
935
+
936
+ result = []
937
+ if (self._Test('DEPLOYMENT_POSTPROCESSING', 'YES', default='NO') and
938
+ self._Test('STRIP_INSTALLED_PRODUCT', 'YES', default='NO')):
939
+
940
+ default_strip_style = 'debugging'
941
+ if ((self.spec['type'] == 'loadable_module' or self._IsIosAppExtension())
942
+ and self._IsBundle()):
943
+ default_strip_style = 'non-global'
944
+ elif self.spec['type'] == 'executable':
945
+ default_strip_style = 'all'
946
+
947
+ strip_style = self._Settings().get('STRIP_STYLE', default_strip_style)
948
+ strip_flags = {
949
+ 'all': '',
950
+ 'non-global': '-x',
951
+ 'debugging': '-S',
952
+ }[strip_style]
953
+
954
+ explicit_strip_flags = self._Settings().get('STRIPFLAGS', '')
955
+ if explicit_strip_flags:
956
+ strip_flags += ' ' + _NormalizeEnvVarReferences(explicit_strip_flags)
957
+
958
+ if not quiet:
959
+ result.append('echo STRIP\\(%s\\)' % self.spec['target_name'])
960
+ result.append('strip %s %s' % (strip_flags, output_binary))
961
+
962
+ self.configname = None
963
+ return result
964
+
965
+ def _GetDebugInfoPostbuilds(self, configname, output, output_binary, quiet):
966
+ """Returns a list of shell commands that contain the shell commands
967
+ neccessary to massage this target's debug information. These should be run
968
+ as postbuilds before the actual postbuilds run."""
969
+ self.configname = configname
970
+
971
+ # For static libraries, no dSYMs are created.
972
+ result = []
973
+ if (self._Test('GCC_GENERATE_DEBUGGING_SYMBOLS', 'YES', default='YES') and
974
+ self._Test(
975
+ 'DEBUG_INFORMATION_FORMAT', 'dwarf-with-dsym', default='dwarf') and
976
+ self.spec['type'] != 'static_library'):
977
+ if not quiet:
978
+ result.append('echo DSYMUTIL\\(%s\\)' % self.spec['target_name'])
979
+ result.append('dsymutil %s -o %s' % (output_binary, output + '.dSYM'))
980
+
981
+ self.configname = None
982
+ return result
983
+
984
+ def _GetTargetPostbuilds(self, configname, output, output_binary,
985
+ quiet=False):
986
+ """Returns a list of shell commands that contain the shell commands
987
+ to run as postbuilds for this target, before the actual postbuilds."""
988
+ # dSYMs need to build before stripping happens.
989
+ return (
990
+ self._GetDebugInfoPostbuilds(configname, output, output_binary, quiet) +
991
+ self._GetStripPostbuilds(configname, output_binary, quiet))
992
+
993
+ def _GetIOSPostbuilds(self, configname, output_binary):
994
+ """Return a shell command to codesign the iOS output binary so it can
995
+ be deployed to a device. This should be run as the very last step of the
996
+ build."""
997
+ if not (self.isIOS and
998
+ (self.spec['type'] == 'executable' or self._IsXCTest())):
999
+ return []
1000
+
1001
+ settings = self.xcode_settings[configname]
1002
+ key = self._GetIOSCodeSignIdentityKey(settings)
1003
+ if not key:
1004
+ return []
1005
+
1006
+ # Warn for any unimplemented signing xcode keys.
1007
+ unimpl = ['OTHER_CODE_SIGN_FLAGS']
1008
+ unimpl = set(unimpl) & set(self.xcode_settings[configname].keys())
1009
+ if unimpl:
1010
+ print 'Warning: Some codesign keys not implemented, ignoring: %s' % (
1011
+ ', '.join(sorted(unimpl)))
1012
+
1013
+ return ['%s code-sign-bundle "%s" "%s" "%s"' % (
1014
+ os.path.join('${TARGET_BUILD_DIR}', 'gyp-mac-tool'), key,
1015
+ settings.get('CODE_SIGN_ENTITLEMENTS', ''),
1016
+ settings.get('PROVISIONING_PROFILE', ''))
1017
+ ]
1018
+
1019
+ def _GetIOSCodeSignIdentityKey(self, settings):
1020
+ identity = settings.get('CODE_SIGN_IDENTITY')
1021
+ if not identity:
1022
+ return None
1023
+ if identity not in XcodeSettings._codesigning_key_cache:
1024
+ output = subprocess.check_output(
1025
+ ['security', 'find-identity', '-p', 'codesigning', '-v'])
1026
+ for line in output.splitlines():
1027
+ if identity in line:
1028
+ fingerprint = line.split()[1]
1029
+ cache = XcodeSettings._codesigning_key_cache
1030
+ assert identity not in cache or fingerprint == cache[identity], (
1031
+ "Multiple codesigning fingerprints for identity: %s" % identity)
1032
+ XcodeSettings._codesigning_key_cache[identity] = fingerprint
1033
+ return XcodeSettings._codesigning_key_cache.get(identity, '')
1034
+
1035
+ def AddImplicitPostbuilds(self, configname, output, output_binary,
1036
+ postbuilds=[], quiet=False):
1037
+ """Returns a list of shell commands that should run before and after
1038
+ |postbuilds|."""
1039
+ assert output_binary is not None
1040
+ pre = self._GetTargetPostbuilds(configname, output, output_binary, quiet)
1041
+ post = self._GetIOSPostbuilds(configname, output_binary)
1042
+ return pre + postbuilds + post
1043
+
1044
+ def _AdjustLibrary(self, library, config_name=None):
1045
+ if library.endswith('.framework'):
1046
+ l = '-framework ' + os.path.splitext(os.path.basename(library))[0]
1047
+ else:
1048
+ m = self.library_re.match(library)
1049
+ if m:
1050
+ l = '-l' + m.group(1)
1051
+ else:
1052
+ l = library
1053
+
1054
+ sdk_root = self._SdkPath(config_name)
1055
+ if not sdk_root:
1056
+ sdk_root = ''
1057
+ # Xcode 7 started shipping with ".tbd" (text based stubs) files instead of
1058
+ # ".dylib" without providing a real support for them. What it does, for
1059
+ # "/usr/lib" libraries, is do "-L/usr/lib -lname" which is dependent on the
1060
+ # library order and cause collision when building Chrome.
1061
+ #
1062
+ # Instead substitude ".tbd" to ".dylib" in the generated project when the
1063
+ # following conditions are both true:
1064
+ # - library is referenced in the gyp file as "$(SDKROOT)/**/*.dylib",
1065
+ # - the ".dylib" file does not exists but a ".tbd" file do.
1066
+ library = l.replace('$(SDKROOT)', sdk_root)
1067
+ if l.startswith('$(SDKROOT)'):
1068
+ basename, ext = os.path.splitext(library)
1069
+ if ext == '.dylib' and not os.path.exists(library):
1070
+ tbd_library = basename + '.tbd'
1071
+ if os.path.exists(tbd_library):
1072
+ library = tbd_library
1073
+ return library
1074
+
1075
+ def AdjustLibraries(self, libraries, config_name=None):
1076
+ """Transforms entries like 'Cocoa.framework' in libraries into entries like
1077
+ '-framework Cocoa', 'libcrypto.dylib' into '-lcrypto', etc.
1078
+ """
1079
+ libraries = [self._AdjustLibrary(library, config_name)
1080
+ for library in libraries]
1081
+ return libraries
1082
+
1083
+ def _BuildMachineOSBuild(self):
1084
+ return GetStdout(['sw_vers', '-buildVersion'])
1085
+
1086
+ def _XcodeIOSDeviceFamily(self, configname):
1087
+ family = self.xcode_settings[configname].get('TARGETED_DEVICE_FAMILY', '1')
1088
+ return [int(x) for x in family.split(',')]
1089
+
1090
+ def GetExtraPlistItems(self, configname=None):
1091
+ """Returns a dictionary with extra items to insert into Info.plist."""
1092
+ if configname not in XcodeSettings._plist_cache:
1093
+ cache = {}
1094
+ cache['BuildMachineOSBuild'] = self._BuildMachineOSBuild()
1095
+
1096
+ xcode, xcode_build = XcodeVersion()
1097
+ cache['DTXcode'] = xcode
1098
+ cache['DTXcodeBuild'] = xcode_build
1099
+ compiler = self.xcode_settings[configname].get('GCC_VERSION')
1100
+ if compiler is not None:
1101
+ cache['DTCompiler'] = compiler
1102
+
1103
+ sdk_root = self._SdkRoot(configname)
1104
+ if not sdk_root:
1105
+ sdk_root = self._DefaultSdkRoot()
1106
+ sdk_version = self._GetSdkVersionInfoItem(sdk_root, '--show-sdk-version')
1107
+ cache['DTSDKName'] = sdk_root + (sdk_version or '')
1108
+ if xcode >= '0720':
1109
+ cache['DTSDKBuild'] = self._GetSdkVersionInfoItem(
1110
+ sdk_root, '--show-sdk-build-version')
1111
+ elif xcode >= '0430':
1112
+ cache['DTSDKBuild'] = sdk_version
1113
+ else:
1114
+ cache['DTSDKBuild'] = cache['BuildMachineOSBuild']
1115
+
1116
+ if self.isIOS:
1117
+ cache['MinimumOSVersion'] = self.xcode_settings[configname].get(
1118
+ 'IPHONEOS_DEPLOYMENT_TARGET')
1119
+ cache['DTPlatformName'] = sdk_root
1120
+ cache['DTPlatformVersion'] = sdk_version
1121
+
1122
+ if configname.endswith("iphoneos"):
1123
+ cache['CFBundleSupportedPlatforms'] = ['iPhoneOS']
1124
+ cache['DTPlatformBuild'] = cache['DTSDKBuild']
1125
+ else:
1126
+ cache['CFBundleSupportedPlatforms'] = ['iPhoneSimulator']
1127
+ # This is weird, but Xcode sets DTPlatformBuild to an empty field
1128
+ # for simulator builds.
1129
+ cache['DTPlatformBuild'] = ""
1130
+ XcodeSettings._plist_cache[configname] = cache
1131
+
1132
+ # Include extra plist items that are per-target, not per global
1133
+ # XcodeSettings.
1134
+ items = dict(XcodeSettings._plist_cache[configname])
1135
+ if self.isIOS:
1136
+ items['UIDeviceFamily'] = self._XcodeIOSDeviceFamily(configname)
1137
+ return items
1138
+
1139
+ def _DefaultSdkRoot(self):
1140
+ """Returns the default SDKROOT to use.
1141
+
1142
+ Prior to version 5.0.0, if SDKROOT was not explicitly set in the Xcode
1143
+ project, then the environment variable was empty. Starting with this
1144
+ version, Xcode uses the name of the newest SDK installed.
1145
+ """
1146
+ xcode_version, xcode_build = XcodeVersion()
1147
+ if xcode_version < '0500':
1148
+ return ''
1149
+ default_sdk_path = self._XcodeSdkPath('')
1150
+ default_sdk_root = XcodeSettings._sdk_root_cache.get(default_sdk_path)
1151
+ if default_sdk_root:
1152
+ return default_sdk_root
1153
+ try:
1154
+ all_sdks = GetStdout(['xcodebuild', '-showsdks'])
1155
+ except:
1156
+ # If xcodebuild fails, there will be no valid SDKs
1157
+ return ''
1158
+ for line in all_sdks.splitlines():
1159
+ items = line.split()
1160
+ if len(items) >= 3 and items[-2] == '-sdk':
1161
+ sdk_root = items[-1]
1162
+ sdk_path = self._XcodeSdkPath(sdk_root)
1163
+ if sdk_path == default_sdk_path:
1164
+ return sdk_root
1165
+ return ''
1166
+
1167
+
1168
+ class MacPrefixHeader(object):
1169
+ """A class that helps with emulating Xcode's GCC_PREFIX_HEADER feature.
1170
+
1171
+ This feature consists of several pieces:
1172
+ * If GCC_PREFIX_HEADER is present, all compilations in that project get an
1173
+ additional |-include path_to_prefix_header| cflag.
1174
+ * If GCC_PRECOMPILE_PREFIX_HEADER is present too, then the prefix header is
1175
+ instead compiled, and all other compilations in the project get an
1176
+ additional |-include path_to_compiled_header| instead.
1177
+ + Compiled prefix headers have the extension gch. There is one gch file for
1178
+ every language used in the project (c, cc, m, mm), since gch files for
1179
+ different languages aren't compatible.
1180
+ + gch files themselves are built with the target's normal cflags, but they
1181
+ obviously don't get the |-include| flag. Instead, they need a -x flag that
1182
+ describes their language.
1183
+ + All o files in the target need to depend on the gch file, to make sure
1184
+ it's built before any o file is built.
1185
+
1186
+ This class helps with some of these tasks, but it needs help from the build
1187
+ system for writing dependencies to the gch files, for writing build commands
1188
+ for the gch files, and for figuring out the location of the gch files.
1189
+ """
1190
+ def __init__(self, xcode_settings,
1191
+ gyp_path_to_build_path, gyp_path_to_build_output):
1192
+ """If xcode_settings is None, all methods on this class are no-ops.
1193
+
1194
+ Args:
1195
+ gyp_path_to_build_path: A function that takes a gyp-relative path,
1196
+ and returns a path relative to the build directory.
1197
+ gyp_path_to_build_output: A function that takes a gyp-relative path and
1198
+ a language code ('c', 'cc', 'm', or 'mm'), and that returns a path
1199
+ to where the output of precompiling that path for that language
1200
+ should be placed (without the trailing '.gch').
1201
+ """
1202
+ # This doesn't support per-configuration prefix headers. Good enough
1203
+ # for now.
1204
+ self.header = None
1205
+ self.compile_headers = False
1206
+ if xcode_settings:
1207
+ self.header = xcode_settings.GetPerTargetSetting('GCC_PREFIX_HEADER')
1208
+ self.compile_headers = xcode_settings.GetPerTargetSetting(
1209
+ 'GCC_PRECOMPILE_PREFIX_HEADER', default='NO') != 'NO'
1210
+ self.compiled_headers = {}
1211
+ if self.header:
1212
+ if self.compile_headers:
1213
+ for lang in ['c', 'cc', 'm', 'mm']:
1214
+ self.compiled_headers[lang] = gyp_path_to_build_output(
1215
+ self.header, lang)
1216
+ self.header = gyp_path_to_build_path(self.header)
1217
+
1218
+ def _CompiledHeader(self, lang, arch):
1219
+ assert self.compile_headers
1220
+ h = self.compiled_headers[lang]
1221
+ if arch:
1222
+ h += '.' + arch
1223
+ return h
1224
+
1225
+ def GetInclude(self, lang, arch=None):
1226
+ """Gets the cflags to include the prefix header for language |lang|."""
1227
+ if self.compile_headers and lang in self.compiled_headers:
1228
+ return '-include %s' % self._CompiledHeader(lang, arch)
1229
+ elif self.header:
1230
+ return '-include %s' % self.header
1231
+ else:
1232
+ return ''
1233
+
1234
+ def _Gch(self, lang, arch):
1235
+ """Returns the actual file name of the prefix header for language |lang|."""
1236
+ assert self.compile_headers
1237
+ return self._CompiledHeader(lang, arch) + '.gch'
1238
+
1239
+ def GetObjDependencies(self, sources, objs, arch=None):
1240
+ """Given a list of source files and the corresponding object files, returns
1241
+ a list of (source, object, gch) tuples, where |gch| is the build-directory
1242
+ relative path to the gch file each object file depends on. |compilable[i]|
1243
+ has to be the source file belonging to |objs[i]|."""
1244
+ if not self.header or not self.compile_headers:
1245
+ return []
1246
+
1247
+ result = []
1248
+ for source, obj in zip(sources, objs):
1249
+ ext = os.path.splitext(source)[1]
1250
+ lang = {
1251
+ '.c': 'c',
1252
+ '.cpp': 'cc', '.cc': 'cc', '.cxx': 'cc',
1253
+ '.m': 'm',
1254
+ '.mm': 'mm',
1255
+ }.get(ext, None)
1256
+ if lang:
1257
+ result.append((source, obj, self._Gch(lang, arch)))
1258
+ return result
1259
+
1260
+ def GetPchBuildCommands(self, arch=None):
1261
+ """Returns [(path_to_gch, language_flag, language, header)].
1262
+ |path_to_gch| and |header| are relative to the build directory.
1263
+ """
1264
+ if not self.header or not self.compile_headers:
1265
+ return []
1266
+ return [
1267
+ (self._Gch('c', arch), '-x c-header', 'c', self.header),
1268
+ (self._Gch('cc', arch), '-x c++-header', 'cc', self.header),
1269
+ (self._Gch('m', arch), '-x objective-c-header', 'm', self.header),
1270
+ (self._Gch('mm', arch), '-x objective-c++-header', 'mm', self.header),
1271
+ ]
1272
+
1273
+
1274
+ def XcodeVersion():
1275
+ """Returns a tuple of version and build version of installed Xcode."""
1276
+ # `xcodebuild -version` output looks like
1277
+ # Xcode 4.6.3
1278
+ # Build version 4H1503
1279
+ # or like
1280
+ # Xcode 3.2.6
1281
+ # Component versions: DevToolsCore-1809.0; DevToolsSupport-1806.0
1282
+ # BuildVersion: 10M2518
1283
+ # Convert that to '0463', '4H1503'.
1284
+ global XCODE_VERSION_CACHE
1285
+ if XCODE_VERSION_CACHE:
1286
+ return XCODE_VERSION_CACHE
1287
+ try:
1288
+ version_list = GetStdout(['xcodebuild', '-version']).splitlines()
1289
+ # In some circumstances xcodebuild exits 0 but doesn't return
1290
+ # the right results; for example, a user on 10.7 or 10.8 with
1291
+ # a bogus path set via xcode-select
1292
+ # In that case this may be a CLT-only install so fall back to
1293
+ # checking that version.
1294
+ if len(version_list) < 2:
1295
+ raise GypError("xcodebuild returned unexpected results")
1296
+ except:
1297
+ version = CLTVersion()
1298
+ if version:
1299
+ version = re.match(r'(\d\.\d\.?\d*)', version).groups()[0]
1300
+ else:
1301
+ raise GypError("No Xcode or CLT version detected!")
1302
+ # The CLT has no build information, so we return an empty string.
1303
+ version_list = [version, '']
1304
+ version = version_list[0]
1305
+ build = version_list[-1]
1306
+ # Be careful to convert "4.2" to "0420":
1307
+ version = version.split()[-1].replace('.', '')
1308
+ version = (version + '0' * (3 - len(version))).zfill(4)
1309
+ if build:
1310
+ build = build.split()[-1]
1311
+ XCODE_VERSION_CACHE = (version, build)
1312
+ return XCODE_VERSION_CACHE
1313
+
1314
+
1315
+ # This function ported from the logic in Homebrew's CLT version check
1316
+ def CLTVersion():
1317
+ """Returns the version of command-line tools from pkgutil."""
1318
+ # pkgutil output looks like
1319
+ # package-id: com.apple.pkg.CLTools_Executables
1320
+ # version: 5.0.1.0.1.1382131676
1321
+ # volume: /
1322
+ # location: /
1323
+ # install-time: 1382544035
1324
+ # groups: com.apple.FindSystemFiles.pkg-group com.apple.DevToolsBoth.pkg-group com.apple.DevToolsNonRelocatableShared.pkg-group
1325
+ STANDALONE_PKG_ID = "com.apple.pkg.DeveloperToolsCLILeo"
1326
+ FROM_XCODE_PKG_ID = "com.apple.pkg.DeveloperToolsCLI"
1327
+ MAVERICKS_PKG_ID = "com.apple.pkg.CLTools_Executables"
1328
+
1329
+ regex = re.compile('version: (?P<version>.+)')
1330
+ for key in [MAVERICKS_PKG_ID, STANDALONE_PKG_ID, FROM_XCODE_PKG_ID]:
1331
+ try:
1332
+ output = GetStdout(['/usr/sbin/pkgutil', '--pkg-info', key])
1333
+ return re.search(regex, output).groupdict()['version']
1334
+ except:
1335
+ continue
1336
+
1337
+
1338
+ def GetStdout(cmdlist):
1339
+ """Returns the content of standard output returned by invoking |cmdlist|.
1340
+ Raises |GypError| if the command return with a non-zero return code."""
1341
+ job = subprocess.Popen(cmdlist, stdout=subprocess.PIPE)
1342
+ out = job.communicate()[0]
1343
+ if job.returncode != 0:
1344
+ sys.stderr.write(out + '\n')
1345
+ raise GypError('Error %d running %s' % (job.returncode, cmdlist[0]))
1346
+ return out.rstrip('\n')
1347
+
1348
+
1349
+ def MergeGlobalXcodeSettingsToSpec(global_dict, spec):
1350
+ """Merges the global xcode_settings dictionary into each configuration of the
1351
+ target represented by spec. For keys that are both in the global and the local
1352
+ xcode_settings dict, the local key gets precendence.
1353
+ """
1354
+ # The xcode generator special-cases global xcode_settings and does something
1355
+ # that amounts to merging in the global xcode_settings into each local
1356
+ # xcode_settings dict.
1357
+ global_xcode_settings = global_dict.get('xcode_settings', {})
1358
+ for config in spec['configurations'].values():
1359
+ if 'xcode_settings' in config:
1360
+ new_settings = global_xcode_settings.copy()
1361
+ new_settings.update(config['xcode_settings'])
1362
+ config['xcode_settings'] = new_settings
1363
+
1364
+
1365
+ def IsMacBundle(flavor, spec):
1366
+ """Returns if |spec| should be treated as a bundle.
1367
+
1368
+ Bundles are directories with a certain subdirectory structure, instead of
1369
+ just a single file. Bundle rules do not produce a binary but also package
1370
+ resources into that directory."""
1371
+ is_mac_bundle = int(spec.get('mac_xctest_bundle', 0)) != 0 or \
1372
+ (int(spec.get('mac_bundle', 0)) != 0 and flavor == 'mac')
1373
+
1374
+ if is_mac_bundle:
1375
+ assert spec['type'] != 'none', (
1376
+ 'mac_bundle targets cannot have type none (target "%s")' %
1377
+ spec['target_name'])
1378
+ return is_mac_bundle
1379
+
1380
+
1381
+ def GetMacBundleResources(product_dir, xcode_settings, resources):
1382
+ """Yields (output, resource) pairs for every resource in |resources|.
1383
+ Only call this for mac bundle targets.
1384
+
1385
+ Args:
1386
+ product_dir: Path to the directory containing the output bundle,
1387
+ relative to the build directory.
1388
+ xcode_settings: The XcodeSettings of the current target.
1389
+ resources: A list of bundle resources, relative to the build directory.
1390
+ """
1391
+ dest = os.path.join(product_dir,
1392
+ xcode_settings.GetBundleResourceFolder())
1393
+ for res in resources:
1394
+ output = dest
1395
+
1396
+ # The make generator doesn't support it, so forbid it everywhere
1397
+ # to keep the generators more interchangable.
1398
+ assert ' ' not in res, (
1399
+ "Spaces in resource filenames not supported (%s)" % res)
1400
+
1401
+ # Split into (path,file).
1402
+ res_parts = os.path.split(res)
1403
+
1404
+ # Now split the path into (prefix,maybe.lproj).
1405
+ lproj_parts = os.path.split(res_parts[0])
1406
+ # If the resource lives in a .lproj bundle, add that to the destination.
1407
+ if lproj_parts[1].endswith('.lproj'):
1408
+ output = os.path.join(output, lproj_parts[1])
1409
+
1410
+ output = os.path.join(output, res_parts[1])
1411
+ # Compiled XIB files are referred to by .nib.
1412
+ if output.endswith('.xib'):
1413
+ output = os.path.splitext(output)[0] + '.nib'
1414
+ # Compiled storyboard files are referred to by .storyboardc.
1415
+ if output.endswith('.storyboard'):
1416
+ output = os.path.splitext(output)[0] + '.storyboardc'
1417
+
1418
+ yield output, res
1419
+
1420
+
1421
+ def GetMacInfoPlist(product_dir, xcode_settings, gyp_path_to_build_path):
1422
+ """Returns (info_plist, dest_plist, defines, extra_env), where:
1423
+ * |info_plist| is the source plist path, relative to the
1424
+ build directory,
1425
+ * |dest_plist| is the destination plist path, relative to the
1426
+ build directory,
1427
+ * |defines| is a list of preprocessor defines (empty if the plist
1428
+ shouldn't be preprocessed,
1429
+ * |extra_env| is a dict of env variables that should be exported when
1430
+ invoking |mac_tool copy-info-plist|.
1431
+
1432
+ Only call this for mac bundle targets.
1433
+
1434
+ Args:
1435
+ product_dir: Path to the directory containing the output bundle,
1436
+ relative to the build directory.
1437
+ xcode_settings: The XcodeSettings of the current target.
1438
+ gyp_to_build_path: A function that converts paths relative to the
1439
+ current gyp file to paths relative to the build direcotry.
1440
+ """
1441
+ info_plist = xcode_settings.GetPerTargetSetting('INFOPLIST_FILE')
1442
+ if not info_plist:
1443
+ return None, None, [], {}
1444
+
1445
+ # The make generator doesn't support it, so forbid it everywhere
1446
+ # to keep the generators more interchangable.
1447
+ assert ' ' not in info_plist, (
1448
+ "Spaces in Info.plist filenames not supported (%s)" % info_plist)
1449
+
1450
+ info_plist = gyp_path_to_build_path(info_plist)
1451
+
1452
+ # If explicitly set to preprocess the plist, invoke the C preprocessor and
1453
+ # specify any defines as -D flags.
1454
+ if xcode_settings.GetPerTargetSetting(
1455
+ 'INFOPLIST_PREPROCESS', default='NO') == 'YES':
1456
+ # Create an intermediate file based on the path.
1457
+ defines = shlex.split(xcode_settings.GetPerTargetSetting(
1458
+ 'INFOPLIST_PREPROCESSOR_DEFINITIONS', default=''))
1459
+ else:
1460
+ defines = []
1461
+
1462
+ dest_plist = os.path.join(product_dir, xcode_settings.GetBundlePlistPath())
1463
+ extra_env = xcode_settings.GetPerTargetSettings()
1464
+
1465
+ return info_plist, dest_plist, defines, extra_env
1466
+
1467
+
1468
+ def _GetXcodeEnv(xcode_settings, built_products_dir, srcroot, configuration,
1469
+ additional_settings=None):
1470
+ """Return the environment variables that Xcode would set. See
1471
+ http://developer.apple.com/library/mac/#documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW153
1472
+ for a full list.
1473
+
1474
+ Args:
1475
+ xcode_settings: An XcodeSettings object. If this is None, this function
1476
+ returns an empty dict.
1477
+ built_products_dir: Absolute path to the built products dir.
1478
+ srcroot: Absolute path to the source root.
1479
+ configuration: The build configuration name.
1480
+ additional_settings: An optional dict with more values to add to the
1481
+ result.
1482
+ """
1483
+ if not xcode_settings: return {}
1484
+
1485
+ # This function is considered a friend of XcodeSettings, so let it reach into
1486
+ # its implementation details.
1487
+ spec = xcode_settings.spec
1488
+
1489
+ # These are filled in on a as-needed basis.
1490
+ env = {
1491
+ 'BUILT_FRAMEWORKS_DIR' : built_products_dir,
1492
+ 'BUILT_PRODUCTS_DIR' : built_products_dir,
1493
+ 'CONFIGURATION' : configuration,
1494
+ 'PRODUCT_NAME' : xcode_settings.GetProductName(),
1495
+ # See /Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Specifications/MacOSX\ Product\ Types.xcspec for FULL_PRODUCT_NAME
1496
+ 'SRCROOT' : srcroot,
1497
+ 'SOURCE_ROOT': '${SRCROOT}',
1498
+ # This is not true for static libraries, but currently the env is only
1499
+ # written for bundles:
1500
+ 'TARGET_BUILD_DIR' : built_products_dir,
1501
+ 'TEMP_DIR' : '${TMPDIR}',
1502
+ 'XCODE_VERSION_ACTUAL' : XcodeVersion()[0],
1503
+ }
1504
+ if xcode_settings.GetPerConfigSetting('SDKROOT', configuration):
1505
+ env['SDKROOT'] = xcode_settings._SdkPath(configuration)
1506
+ else:
1507
+ env['SDKROOT'] = ''
1508
+
1509
+ if spec['type'] in (
1510
+ 'executable', 'static_library', 'shared_library', 'loadable_module'):
1511
+ env['EXECUTABLE_NAME'] = xcode_settings.GetExecutableName()
1512
+ env['EXECUTABLE_PATH'] = xcode_settings.GetExecutablePath()
1513
+ env['FULL_PRODUCT_NAME'] = xcode_settings.GetFullProductName()
1514
+ mach_o_type = xcode_settings.GetMachOType()
1515
+ if mach_o_type:
1516
+ env['MACH_O_TYPE'] = mach_o_type
1517
+ env['PRODUCT_TYPE'] = xcode_settings.GetProductType()
1518
+ if xcode_settings._IsBundle():
1519
+ env['CONTENTS_FOLDER_PATH'] = \
1520
+ xcode_settings.GetBundleContentsFolderPath()
1521
+ env['UNLOCALIZED_RESOURCES_FOLDER_PATH'] = \
1522
+ xcode_settings.GetBundleResourceFolder()
1523
+ env['INFOPLIST_PATH'] = xcode_settings.GetBundlePlistPath()
1524
+ env['WRAPPER_NAME'] = xcode_settings.GetWrapperName()
1525
+
1526
+ install_name = xcode_settings.GetInstallName()
1527
+ if install_name:
1528
+ env['LD_DYLIB_INSTALL_NAME'] = install_name
1529
+ install_name_base = xcode_settings.GetInstallNameBase()
1530
+ if install_name_base:
1531
+ env['DYLIB_INSTALL_NAME_BASE'] = install_name_base
1532
+ if XcodeVersion() >= '0500' and not env.get('SDKROOT'):
1533
+ sdk_root = xcode_settings._SdkRoot(configuration)
1534
+ if not sdk_root:
1535
+ sdk_root = xcode_settings._XcodeSdkPath('')
1536
+ env['SDKROOT'] = sdk_root
1537
+
1538
+ if not additional_settings:
1539
+ additional_settings = {}
1540
+ else:
1541
+ # Flatten lists to strings.
1542
+ for k in additional_settings:
1543
+ if not isinstance(additional_settings[k], str):
1544
+ additional_settings[k] = ' '.join(additional_settings[k])
1545
+ additional_settings.update(env)
1546
+
1547
+ for k in additional_settings:
1548
+ additional_settings[k] = _NormalizeEnvVarReferences(additional_settings[k])
1549
+
1550
+ return additional_settings
1551
+
1552
+
1553
+ def _NormalizeEnvVarReferences(str):
1554
+ """Takes a string containing variable references in the form ${FOO}, $(FOO),
1555
+ or $FOO, and returns a string with all variable references in the form ${FOO}.
1556
+ """
1557
+ # $FOO -> ${FOO}
1558
+ str = re.sub(r'\$([a-zA-Z_][a-zA-Z0-9_]*)', r'${\1}', str)
1559
+
1560
+ # $(FOO) -> ${FOO}
1561
+ matches = re.findall(r'(\$\(([a-zA-Z0-9\-_]+)\))', str)
1562
+ for match in matches:
1563
+ to_replace, variable = match
1564
+ assert '$(' not in match, '$($(FOO)) variables not supported: ' + match
1565
+ str = str.replace(to_replace, '${' + variable + '}')
1566
+
1567
+ return str
1568
+
1569
+
1570
+ def ExpandEnvVars(string, expansions):
1571
+ """Expands ${VARIABLES}, $(VARIABLES), and $VARIABLES in string per the
1572
+ expansions list. If the variable expands to something that references
1573
+ another variable, this variable is expanded as well if it's in env --
1574
+ until no variables present in env are left."""
1575
+ for k, v in reversed(expansions):
1576
+ string = string.replace('${' + k + '}', v)
1577
+ string = string.replace('$(' + k + ')', v)
1578
+ string = string.replace('$' + k, v)
1579
+ return string
1580
+
1581
+
1582
+ def _TopologicallySortedEnvVarKeys(env):
1583
+ """Takes a dict |env| whose values are strings that can refer to other keys,
1584
+ for example env['foo'] = '$(bar) and $(baz)'. Returns a list L of all keys of
1585
+ env such that key2 is after key1 in L if env[key2] refers to env[key1].
1586
+
1587
+ Throws an Exception in case of dependency cycles.
1588
+ """
1589
+ # Since environment variables can refer to other variables, the evaluation
1590
+ # order is important. Below is the logic to compute the dependency graph
1591
+ # and sort it.
1592
+ regex = re.compile(r'\$\{([a-zA-Z0-9\-_]+)\}')
1593
+ def GetEdges(node):
1594
+ # Use a definition of edges such that user_of_variable -> used_varible.
1595
+ # This happens to be easier in this case, since a variable's
1596
+ # definition contains all variables it references in a single string.
1597
+ # We can then reverse the result of the topological sort at the end.
1598
+ # Since: reverse(topsort(DAG)) = topsort(reverse_edges(DAG))
1599
+ matches = set([v for v in regex.findall(env[node]) if v in env])
1600
+ for dependee in matches:
1601
+ assert '${' not in dependee, 'Nested variables not supported: ' + dependee
1602
+ return matches
1603
+
1604
+ try:
1605
+ # Topologically sort, and then reverse, because we used an edge definition
1606
+ # that's inverted from the expected result of this function (see comment
1607
+ # above).
1608
+ order = gyp.common.TopologicallySorted(env.keys(), GetEdges)
1609
+ order.reverse()
1610
+ return order
1611
+ except gyp.common.CycleError, e:
1612
+ raise GypError(
1613
+ 'Xcode environment variables are cyclically dependent: ' + str(e.nodes))
1614
+
1615
+
1616
+ def GetSortedXcodeEnv(xcode_settings, built_products_dir, srcroot,
1617
+ configuration, additional_settings=None):
1618
+ env = _GetXcodeEnv(xcode_settings, built_products_dir, srcroot, configuration,
1619
+ additional_settings)
1620
+ return [(key, env[key]) for key in _TopologicallySortedEnvVarKeys(env)]
1621
+
1622
+
1623
+ def GetSpecPostbuildCommands(spec, quiet=False):
1624
+ """Returns the list of postbuilds explicitly defined on |spec|, in a form
1625
+ executable by a shell."""
1626
+ postbuilds = []
1627
+ for postbuild in spec.get('postbuilds', []):
1628
+ if not quiet:
1629
+ postbuilds.append('echo POSTBUILD\\(%s\\) %s' % (
1630
+ spec['target_name'], postbuild['postbuild_name']))
1631
+ postbuilds.append(gyp.common.EncodePOSIXShellList(postbuild['action']))
1632
+ return postbuilds
1633
+
1634
+
1635
+ def _HasIOSTarget(targets):
1636
+ """Returns true if any target contains the iOS specific key
1637
+ IPHONEOS_DEPLOYMENT_TARGET."""
1638
+ for target_dict in targets.values():
1639
+ for config in target_dict['configurations'].values():
1640
+ if config.get('xcode_settings', {}).get('IPHONEOS_DEPLOYMENT_TARGET'):
1641
+ return True
1642
+ return False
1643
+
1644
+
1645
+ def _AddIOSDeviceConfigurations(targets):
1646
+ """Clone all targets and append -iphoneos to the name. Configure these targets
1647
+ to build for iOS devices and use correct architectures for those builds."""
1648
+ for target_dict in targets.itervalues():
1649
+ toolset = target_dict['toolset']
1650
+ configs = target_dict['configurations']
1651
+ for config_name, config_dict in dict(configs).iteritems():
1652
+ iphoneos_config_dict = copy.deepcopy(config_dict)
1653
+ configs[config_name + '-iphoneos'] = iphoneos_config_dict
1654
+ configs[config_name + '-iphonesimulator'] = config_dict
1655
+ if toolset == 'target':
1656
+ iphoneos_config_dict['xcode_settings']['SDKROOT'] = 'iphoneos'
1657
+ return targets
1658
+
1659
+ def CloneConfigurationForDeviceAndEmulator(target_dicts):
1660
+ """If |target_dicts| contains any iOS targets, automatically create -iphoneos
1661
+ targets for iOS device builds."""
1662
+ if _HasIOSTarget(target_dicts):
1663
+ return _AddIOSDeviceConfigurations(target_dicts)
1664
+ return target_dicts