lounge_lizard 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
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,605 @@
1
+ #!/usr/bin/env python
2
+ # Copyright (c) 2012 Google Inc. All rights reserved.
3
+ # Use of this source code is governed by a BSD-style license that can be
4
+ # found in the LICENSE file.
5
+
6
+ """Utility functions to perform Xcode-style build steps.
7
+
8
+ These functions are executed via gyp-mac-tool when using the Makefile generator.
9
+ """
10
+
11
+ import fcntl
12
+ import fnmatch
13
+ import glob
14
+ import json
15
+ import os
16
+ import plistlib
17
+ import re
18
+ import shutil
19
+ import string
20
+ import subprocess
21
+ import sys
22
+ import tempfile
23
+
24
+
25
+ def main(args):
26
+ executor = MacTool()
27
+ exit_code = executor.Dispatch(args)
28
+ if exit_code is not None:
29
+ sys.exit(exit_code)
30
+
31
+
32
+ class MacTool(object):
33
+ """This class performs all the Mac tooling steps. The methods can either be
34
+ executed directly, or dispatched from an argument list."""
35
+
36
+ def Dispatch(self, args):
37
+ """Dispatches a string command to a method."""
38
+ if len(args) < 1:
39
+ raise Exception("Not enough arguments")
40
+
41
+ method = "Exec%s" % self._CommandifyName(args[0])
42
+ return getattr(self, method)(*args[1:])
43
+
44
+ def _CommandifyName(self, name_string):
45
+ """Transforms a tool name like copy-info-plist to CopyInfoPlist"""
46
+ return name_string.title().replace('-', '')
47
+
48
+ def ExecCopyBundleResource(self, source, dest, convert_to_binary):
49
+ """Copies a resource file to the bundle/Resources directory, performing any
50
+ necessary compilation on each resource."""
51
+ extension = os.path.splitext(source)[1].lower()
52
+ if os.path.isdir(source):
53
+ # Copy tree.
54
+ # TODO(thakis): This copies file attributes like mtime, while the
55
+ # single-file branch below doesn't. This should probably be changed to
56
+ # be consistent with the single-file branch.
57
+ if os.path.exists(dest):
58
+ shutil.rmtree(dest)
59
+ shutil.copytree(source, dest)
60
+ elif extension == '.xib':
61
+ return self._CopyXIBFile(source, dest)
62
+ elif extension == '.storyboard':
63
+ return self._CopyXIBFile(source, dest)
64
+ elif extension == '.strings':
65
+ self._CopyStringsFile(source, dest)
66
+ else:
67
+ shutil.copy(source, dest)
68
+
69
+ if extension in ('.plist', '.strings') and convert_to_binary == 'True':
70
+ self._ConvertToBinary(dest)
71
+
72
+ def _CopyXIBFile(self, source, dest):
73
+ """Compiles a XIB file with ibtool into a binary plist in the bundle."""
74
+
75
+ # ibtool sometimes crashes with relative paths. See crbug.com/314728.
76
+ base = os.path.dirname(os.path.realpath(__file__))
77
+ if os.path.relpath(source):
78
+ source = os.path.join(base, source)
79
+ if os.path.relpath(dest):
80
+ dest = os.path.join(base, dest)
81
+
82
+ args = ['xcrun', 'ibtool', '--errors', '--warnings', '--notices']
83
+
84
+ if os.environ['XCODE_VERSION_ACTUAL'] > '0700':
85
+ args.extend(['--auto-activate-custom-fonts'])
86
+ if 'IPHONEOS_DEPLOYMENT_TARGET' in os.environ:
87
+ args.extend([
88
+ '--target-device', 'iphone', '--target-device', 'ipad',
89
+ '--minimum-deployment-target',
90
+ os.environ['IPHONEOS_DEPLOYMENT_TARGET'],
91
+ ])
92
+ else:
93
+ args.extend([
94
+ '--target-device', 'mac',
95
+ '--minimum-deployment-target',
96
+ os.environ['MACOSX_DEPLOYMENT_TARGET'],
97
+ ])
98
+
99
+ args.extend(['--output-format', 'human-readable-text', '--compile', dest,
100
+ source])
101
+
102
+ ibtool_section_re = re.compile(r'/\*.*\*/')
103
+ ibtool_re = re.compile(r'.*note:.*is clipping its content')
104
+ ibtoolout = subprocess.Popen(args, stdout=subprocess.PIPE)
105
+ current_section_header = None
106
+ for line in ibtoolout.stdout:
107
+ if ibtool_section_re.match(line):
108
+ current_section_header = line
109
+ elif not ibtool_re.match(line):
110
+ if current_section_header:
111
+ sys.stdout.write(current_section_header)
112
+ current_section_header = None
113
+ sys.stdout.write(line)
114
+ return ibtoolout.returncode
115
+
116
+ def _ConvertToBinary(self, dest):
117
+ subprocess.check_call([
118
+ 'xcrun', 'plutil', '-convert', 'binary1', '-o', dest, dest])
119
+
120
+ def _CopyStringsFile(self, source, dest):
121
+ """Copies a .strings file using iconv to reconvert the input into UTF-16."""
122
+ input_code = self._DetectInputEncoding(source) or "UTF-8"
123
+
124
+ # Xcode's CpyCopyStringsFile / builtin-copyStrings seems to call
125
+ # CFPropertyListCreateFromXMLData() behind the scenes; at least it prints
126
+ # CFPropertyListCreateFromXMLData(): Old-style plist parser: missing
127
+ # semicolon in dictionary.
128
+ # on invalid files. Do the same kind of validation.
129
+ import CoreFoundation
130
+ s = open(source, 'rb').read()
131
+ d = CoreFoundation.CFDataCreate(None, s, len(s))
132
+ _, error = CoreFoundation.CFPropertyListCreateFromXMLData(None, d, 0, None)
133
+ if error:
134
+ return
135
+
136
+ fp = open(dest, 'wb')
137
+ fp.write(s.decode(input_code).encode('UTF-16'))
138
+ fp.close()
139
+
140
+ def _DetectInputEncoding(self, file_name):
141
+ """Reads the first few bytes from file_name and tries to guess the text
142
+ encoding. Returns None as a guess if it can't detect it."""
143
+ fp = open(file_name, 'rb')
144
+ try:
145
+ header = fp.read(3)
146
+ except e:
147
+ fp.close()
148
+ return None
149
+ fp.close()
150
+ if header.startswith("\xFE\xFF"):
151
+ return "UTF-16"
152
+ elif header.startswith("\xFF\xFE"):
153
+ return "UTF-16"
154
+ elif header.startswith("\xEF\xBB\xBF"):
155
+ return "UTF-8"
156
+ else:
157
+ return None
158
+
159
+ def ExecCopyInfoPlist(self, source, dest, convert_to_binary, *keys):
160
+ """Copies the |source| Info.plist to the destination directory |dest|."""
161
+ # Read the source Info.plist into memory.
162
+ fd = open(source, 'r')
163
+ lines = fd.read()
164
+ fd.close()
165
+
166
+ # Insert synthesized key/value pairs (e.g. BuildMachineOSBuild).
167
+ plist = plistlib.readPlistFromString(lines)
168
+ if keys:
169
+ plist = dict(plist.items() + json.loads(keys[0]).items())
170
+ lines = plistlib.writePlistToString(plist)
171
+
172
+ # Go through all the environment variables and replace them as variables in
173
+ # the file.
174
+ IDENT_RE = re.compile(r'[/\s]')
175
+ for key in os.environ:
176
+ if key.startswith('_'):
177
+ continue
178
+ evar = '${%s}' % key
179
+ evalue = os.environ[key]
180
+ lines = string.replace(lines, evar, evalue)
181
+
182
+ # Xcode supports various suffices on environment variables, which are
183
+ # all undocumented. :rfc1034identifier is used in the standard project
184
+ # template these days, and :identifier was used earlier. They are used to
185
+ # convert non-url characters into things that look like valid urls --
186
+ # except that the replacement character for :identifier, '_' isn't valid
187
+ # in a URL either -- oops, hence :rfc1034identifier was born.
188
+ evar = '${%s:identifier}' % key
189
+ evalue = IDENT_RE.sub('_', os.environ[key])
190
+ lines = string.replace(lines, evar, evalue)
191
+
192
+ evar = '${%s:rfc1034identifier}' % key
193
+ evalue = IDENT_RE.sub('-', os.environ[key])
194
+ lines = string.replace(lines, evar, evalue)
195
+
196
+ # Remove any keys with values that haven't been replaced.
197
+ lines = lines.split('\n')
198
+ for i in range(len(lines)):
199
+ if lines[i].strip().startswith("<string>${"):
200
+ lines[i] = None
201
+ lines[i - 1] = None
202
+ lines = '\n'.join(filter(lambda x: x is not None, lines))
203
+
204
+ # Write out the file with variables replaced.
205
+ fd = open(dest, 'w')
206
+ fd.write(lines)
207
+ fd.close()
208
+
209
+ # Now write out PkgInfo file now that the Info.plist file has been
210
+ # "compiled".
211
+ self._WritePkgInfo(dest)
212
+
213
+ if convert_to_binary == 'True':
214
+ self._ConvertToBinary(dest)
215
+
216
+ def _WritePkgInfo(self, info_plist):
217
+ """This writes the PkgInfo file from the data stored in Info.plist."""
218
+ plist = plistlib.readPlist(info_plist)
219
+ if not plist:
220
+ return
221
+
222
+ # Only create PkgInfo for executable types.
223
+ package_type = plist['CFBundlePackageType']
224
+ if package_type != 'APPL':
225
+ return
226
+
227
+ # The format of PkgInfo is eight characters, representing the bundle type
228
+ # and bundle signature, each four characters. If that is missing, four
229
+ # '?' characters are used instead.
230
+ signature_code = plist.get('CFBundleSignature', '????')
231
+ if len(signature_code) != 4: # Wrong length resets everything, too.
232
+ signature_code = '?' * 4
233
+
234
+ dest = os.path.join(os.path.dirname(info_plist), 'PkgInfo')
235
+ fp = open(dest, 'w')
236
+ fp.write('%s%s' % (package_type, signature_code))
237
+ fp.close()
238
+
239
+ def ExecFlock(self, lockfile, *cmd_list):
240
+ """Emulates the most basic behavior of Linux's flock(1)."""
241
+ # Rely on exception handling to report errors.
242
+ fd = os.open(lockfile, os.O_RDONLY|os.O_NOCTTY|os.O_CREAT, 0o666)
243
+ fcntl.flock(fd, fcntl.LOCK_EX)
244
+ return subprocess.call(cmd_list)
245
+
246
+ def ExecFilterLibtool(self, *cmd_list):
247
+ """Calls libtool and filters out '/path/to/libtool: file: foo.o has no
248
+ symbols'."""
249
+ libtool_re = re.compile(r'^.*libtool: (?:for architecture: \S* )?'
250
+ r'file: .* has no symbols$')
251
+ libtool_re5 = re.compile(
252
+ r'^.*libtool: warning for library: ' +
253
+ r'.* the table of contents is empty ' +
254
+ r'\(no object file members in the library define global symbols\)$')
255
+ env = os.environ.copy()
256
+ # Ref:
257
+ # http://www.opensource.apple.com/source/cctools/cctools-809/misc/libtool.c
258
+ # The problem with this flag is that it resets the file mtime on the file to
259
+ # epoch=0, e.g. 1970-1-1 or 1969-12-31 depending on timezone.
260
+ env['ZERO_AR_DATE'] = '1'
261
+ libtoolout = subprocess.Popen(cmd_list, stderr=subprocess.PIPE, env=env)
262
+ _, err = libtoolout.communicate()
263
+ for line in err.splitlines():
264
+ if not libtool_re.match(line) and not libtool_re5.match(line):
265
+ print >>sys.stderr, line
266
+ # Unconditionally touch the output .a file on the command line if present
267
+ # and the command succeeded. A bit hacky.
268
+ if not libtoolout.returncode:
269
+ for i in range(len(cmd_list) - 1):
270
+ if cmd_list[i] == "-o" and cmd_list[i+1].endswith('.a'):
271
+ os.utime(cmd_list[i+1], None)
272
+ break
273
+ return libtoolout.returncode
274
+
275
+ def ExecPackageFramework(self, framework, version):
276
+ """Takes a path to Something.framework and the Current version of that and
277
+ sets up all the symlinks."""
278
+ # Find the name of the binary based on the part before the ".framework".
279
+ binary = os.path.basename(framework).split('.')[0]
280
+
281
+ CURRENT = 'Current'
282
+ RESOURCES = 'Resources'
283
+ VERSIONS = 'Versions'
284
+
285
+ if not os.path.exists(os.path.join(framework, VERSIONS, version, binary)):
286
+ # Binary-less frameworks don't seem to contain symlinks (see e.g.
287
+ # chromium's out/Debug/org.chromium.Chromium.manifest/ bundle).
288
+ return
289
+
290
+ # Move into the framework directory to set the symlinks correctly.
291
+ pwd = os.getcwd()
292
+ os.chdir(framework)
293
+
294
+ # Set up the Current version.
295
+ self._Relink(version, os.path.join(VERSIONS, CURRENT))
296
+
297
+ # Set up the root symlinks.
298
+ self._Relink(os.path.join(VERSIONS, CURRENT, binary), binary)
299
+ self._Relink(os.path.join(VERSIONS, CURRENT, RESOURCES), RESOURCES)
300
+
301
+ # Back to where we were before!
302
+ os.chdir(pwd)
303
+
304
+ def _Relink(self, dest, link):
305
+ """Creates a symlink to |dest| named |link|. If |link| already exists,
306
+ it is overwritten."""
307
+ if os.path.lexists(link):
308
+ os.remove(link)
309
+ os.symlink(dest, link)
310
+
311
+ def ExecCompileXcassets(self, keys, *inputs):
312
+ """Compiles multiple .xcassets files into a single .car file.
313
+
314
+ This invokes 'actool' to compile all the inputs .xcassets files. The
315
+ |keys| arguments is a json-encoded dictionary of extra arguments to
316
+ pass to 'actool' when the asset catalogs contains an application icon
317
+ or a launch image.
318
+
319
+ Note that 'actool' does not create the Assets.car file if the asset
320
+ catalogs does not contains imageset.
321
+ """
322
+ command_line = [
323
+ 'xcrun', 'actool', '--output-format', 'human-readable-text',
324
+ '--compress-pngs', '--notices', '--warnings', '--errors',
325
+ ]
326
+ is_iphone_target = 'IPHONEOS_DEPLOYMENT_TARGET' in os.environ
327
+ if is_iphone_target:
328
+ platform = os.environ['CONFIGURATION'].split('-')[-1]
329
+ if platform not in ('iphoneos', 'iphonesimulator'):
330
+ platform = 'iphonesimulator'
331
+ command_line.extend([
332
+ '--platform', platform, '--target-device', 'iphone',
333
+ '--target-device', 'ipad', '--minimum-deployment-target',
334
+ os.environ['IPHONEOS_DEPLOYMENT_TARGET'], '--compile',
335
+ os.path.abspath(os.environ['CONTENTS_FOLDER_PATH']),
336
+ ])
337
+ else:
338
+ command_line.extend([
339
+ '--platform', 'macosx', '--target-device', 'mac',
340
+ '--minimum-deployment-target', os.environ['MACOSX_DEPLOYMENT_TARGET'],
341
+ '--compile',
342
+ os.path.abspath(os.environ['UNLOCALIZED_RESOURCES_FOLDER_PATH']),
343
+ ])
344
+ if keys:
345
+ keys = json.loads(keys)
346
+ for key, value in keys.iteritems():
347
+ arg_name = '--' + key
348
+ if isinstance(value, bool):
349
+ if value:
350
+ command_line.append(arg_name)
351
+ elif isinstance(value, list):
352
+ for v in value:
353
+ command_line.append(arg_name)
354
+ command_line.append(str(v))
355
+ else:
356
+ command_line.append(arg_name)
357
+ command_line.append(str(value))
358
+ # Note: actool crashes if inputs path are relative, so use os.path.abspath
359
+ # to get absolute path name for inputs.
360
+ command_line.extend(map(os.path.abspath, inputs))
361
+ subprocess.check_call(command_line)
362
+
363
+ def ExecMergeInfoPlist(self, output, *inputs):
364
+ """Merge multiple .plist files into a single .plist file."""
365
+ merged_plist = {}
366
+ for path in inputs:
367
+ plist = self._LoadPlistMaybeBinary(path)
368
+ self._MergePlist(merged_plist, plist)
369
+ plistlib.writePlist(merged_plist, output)
370
+
371
+ def ExecCodeSignBundle(self, key, entitlements, provisioning):
372
+ """Code sign a bundle.
373
+
374
+ This function tries to code sign an iOS bundle, following the same
375
+ algorithm as Xcode:
376
+ 1. pick the provisioning profile that best match the bundle identifier,
377
+ and copy it into the bundle as embedded.mobileprovision,
378
+ 2. copy Entitlements.plist from user or SDK next to the bundle,
379
+ 3. code sign the bundle.
380
+ """
381
+ substitutions, overrides = self._InstallProvisioningProfile(
382
+ provisioning, self._GetCFBundleIdentifier())
383
+ entitlements_path = self._InstallEntitlements(
384
+ entitlements, substitutions, overrides)
385
+ subprocess.check_call([
386
+ 'codesign', '--force', '--sign', key, '--entitlements',
387
+ entitlements_path, '--timestamp=none', os.path.join(
388
+ os.environ['TARGET_BUILD_DIR'],
389
+ os.environ['FULL_PRODUCT_NAME'])])
390
+
391
+ def _InstallProvisioningProfile(self, profile, bundle_identifier):
392
+ """Installs embedded.mobileprovision into the bundle.
393
+
394
+ Args:
395
+ profile: string, optional, short name of the .mobileprovision file
396
+ to use, if empty or the file is missing, the best file installed
397
+ will be used
398
+ bundle_identifier: string, value of CFBundleIdentifier from Info.plist
399
+
400
+ Returns:
401
+ A tuple containing two dictionary: variables substitutions and values
402
+ to overrides when generating the entitlements file.
403
+ """
404
+ source_path, provisioning_data, team_id = self._FindProvisioningProfile(
405
+ profile, bundle_identifier)
406
+ target_path = os.path.join(
407
+ os.environ['BUILT_PRODUCTS_DIR'],
408
+ os.environ['CONTENTS_FOLDER_PATH'],
409
+ 'embedded.mobileprovision')
410
+ shutil.copy2(source_path, target_path)
411
+ substitutions = self._GetSubstitutions(bundle_identifier, team_id + '.')
412
+ return substitutions, provisioning_data['Entitlements']
413
+
414
+ def _FindProvisioningProfile(self, profile, bundle_identifier):
415
+ """Finds the .mobileprovision file to use for signing the bundle.
416
+
417
+ Checks all the installed provisioning profiles (or if the user specified
418
+ the PROVISIONING_PROFILE variable, only consult it) and select the most
419
+ specific that correspond to the bundle identifier.
420
+
421
+ Args:
422
+ profile: string, optional, short name of the .mobileprovision file
423
+ to use, if empty or the file is missing, the best file installed
424
+ will be used
425
+ bundle_identifier: string, value of CFBundleIdentifier from Info.plist
426
+
427
+ Returns:
428
+ A tuple of the path to the selected provisioning profile, the data of
429
+ the embedded plist in the provisioning profile and the team identifier
430
+ to use for code signing.
431
+
432
+ Raises:
433
+ SystemExit: if no .mobileprovision can be used to sign the bundle.
434
+ """
435
+ profiles_dir = os.path.join(
436
+ os.environ['HOME'], 'Library', 'MobileDevice', 'Provisioning Profiles')
437
+ if not os.path.isdir(profiles_dir):
438
+ print >>sys.stderr, (
439
+ 'cannot find mobile provisioning for %s' % bundle_identifier)
440
+ sys.exit(1)
441
+ provisioning_profiles = None
442
+ if profile:
443
+ profile_path = os.path.join(profiles_dir, profile + '.mobileprovision')
444
+ if os.path.exists(profile_path):
445
+ provisioning_profiles = [profile_path]
446
+ if not provisioning_profiles:
447
+ provisioning_profiles = glob.glob(
448
+ os.path.join(profiles_dir, '*.mobileprovision'))
449
+ valid_provisioning_profiles = {}
450
+ for profile_path in provisioning_profiles:
451
+ profile_data = self._LoadProvisioningProfile(profile_path)
452
+ app_id_pattern = profile_data.get(
453
+ 'Entitlements', {}).get('application-identifier', '')
454
+ for team_identifier in profile_data.get('TeamIdentifier', []):
455
+ app_id = '%s.%s' % (team_identifier, bundle_identifier)
456
+ if fnmatch.fnmatch(app_id, app_id_pattern):
457
+ valid_provisioning_profiles[app_id_pattern] = (
458
+ profile_path, profile_data, team_identifier)
459
+ if not valid_provisioning_profiles:
460
+ print >>sys.stderr, (
461
+ 'cannot find mobile provisioning for %s' % bundle_identifier)
462
+ sys.exit(1)
463
+ # If the user has multiple provisioning profiles installed that can be
464
+ # used for ${bundle_identifier}, pick the most specific one (ie. the
465
+ # provisioning profile whose pattern is the longest).
466
+ selected_key = max(valid_provisioning_profiles, key=lambda v: len(v))
467
+ return valid_provisioning_profiles[selected_key]
468
+
469
+ def _LoadProvisioningProfile(self, profile_path):
470
+ """Extracts the plist embedded in a provisioning profile.
471
+
472
+ Args:
473
+ profile_path: string, path to the .mobileprovision file
474
+
475
+ Returns:
476
+ Content of the plist embedded in the provisioning profile as a dictionary.
477
+ """
478
+ with tempfile.NamedTemporaryFile() as temp:
479
+ subprocess.check_call([
480
+ 'security', 'cms', '-D', '-i', profile_path, '-o', temp.name])
481
+ return self._LoadPlistMaybeBinary(temp.name)
482
+
483
+ def _MergePlist(self, merged_plist, plist):
484
+ """Merge |plist| into |merged_plist|."""
485
+ for key, value in plist.iteritems():
486
+ if isinstance(value, dict):
487
+ merged_value = merged_plist.get(key, {})
488
+ if isinstance(merged_value, dict):
489
+ self._MergePlist(merged_value, value)
490
+ merged_plist[key] = merged_value
491
+ else:
492
+ merged_plist[key] = value
493
+ else:
494
+ merged_plist[key] = value
495
+
496
+ def _LoadPlistMaybeBinary(self, plist_path):
497
+ """Loads into a memory a plist possibly encoded in binary format.
498
+
499
+ This is a wrapper around plistlib.readPlist that tries to convert the
500
+ plist to the XML format if it can't be parsed (assuming that it is in
501
+ the binary format).
502
+
503
+ Args:
504
+ plist_path: string, path to a plist file, in XML or binary format
505
+
506
+ Returns:
507
+ Content of the plist as a dictionary.
508
+ """
509
+ try:
510
+ # First, try to read the file using plistlib that only supports XML,
511
+ # and if an exception is raised, convert a temporary copy to XML and
512
+ # load that copy.
513
+ return plistlib.readPlist(plist_path)
514
+ except:
515
+ pass
516
+ with tempfile.NamedTemporaryFile() as temp:
517
+ shutil.copy2(plist_path, temp.name)
518
+ subprocess.check_call(['plutil', '-convert', 'xml1', temp.name])
519
+ return plistlib.readPlist(temp.name)
520
+
521
+ def _GetSubstitutions(self, bundle_identifier, app_identifier_prefix):
522
+ """Constructs a dictionary of variable substitutions for Entitlements.plist.
523
+
524
+ Args:
525
+ bundle_identifier: string, value of CFBundleIdentifier from Info.plist
526
+ app_identifier_prefix: string, value for AppIdentifierPrefix
527
+
528
+ Returns:
529
+ Dictionary of substitutions to apply when generating Entitlements.plist.
530
+ """
531
+ return {
532
+ 'CFBundleIdentifier': bundle_identifier,
533
+ 'AppIdentifierPrefix': app_identifier_prefix,
534
+ }
535
+
536
+ def _GetCFBundleIdentifier(self):
537
+ """Extracts CFBundleIdentifier value from Info.plist in the bundle.
538
+
539
+ Returns:
540
+ Value of CFBundleIdentifier in the Info.plist located in the bundle.
541
+ """
542
+ info_plist_path = os.path.join(
543
+ os.environ['TARGET_BUILD_DIR'],
544
+ os.environ['INFOPLIST_PATH'])
545
+ info_plist_data = self._LoadPlistMaybeBinary(info_plist_path)
546
+ return info_plist_data['CFBundleIdentifier']
547
+
548
+ def _InstallEntitlements(self, entitlements, substitutions, overrides):
549
+ """Generates and install the ${BundleName}.xcent entitlements file.
550
+
551
+ Expands variables "$(variable)" pattern in the source entitlements file,
552
+ add extra entitlements defined in the .mobileprovision file and the copy
553
+ the generated plist to "${BundlePath}.xcent".
554
+
555
+ Args:
556
+ entitlements: string, optional, path to the Entitlements.plist template
557
+ to use, defaults to "${SDKROOT}/Entitlements.plist"
558
+ substitutions: dictionary, variable substitutions
559
+ overrides: dictionary, values to add to the entitlements
560
+
561
+ Returns:
562
+ Path to the generated entitlements file.
563
+ """
564
+ source_path = entitlements
565
+ target_path = os.path.join(
566
+ os.environ['BUILT_PRODUCTS_DIR'],
567
+ os.environ['PRODUCT_NAME'] + '.xcent')
568
+ if not source_path:
569
+ source_path = os.path.join(
570
+ os.environ['SDKROOT'],
571
+ 'Entitlements.plist')
572
+ shutil.copy2(source_path, target_path)
573
+ data = self._LoadPlistMaybeBinary(target_path)
574
+ data = self._ExpandVariables(data, substitutions)
575
+ if overrides:
576
+ for key in overrides:
577
+ if key not in data:
578
+ data[key] = overrides[key]
579
+ plistlib.writePlist(data, target_path)
580
+ return target_path
581
+
582
+ def _ExpandVariables(self, data, substitutions):
583
+ """Expands variables "$(variable)" in data.
584
+
585
+ Args:
586
+ data: object, can be either string, list or dictionary
587
+ substitutions: dictionary, variable substitutions to perform
588
+
589
+ Returns:
590
+ Copy of data where each references to "$(variable)" has been replaced
591
+ by the corresponding value found in substitutions, or left intact if
592
+ the key was not found.
593
+ """
594
+ if isinstance(data, str):
595
+ for key, value in substitutions.iteritems():
596
+ data = data.replace('$(%s)' % key, value)
597
+ return data
598
+ if isinstance(data, list):
599
+ return [self._ExpandVariables(v, substitutions) for v in data]
600
+ if isinstance(data, dict):
601
+ return {k: self._ExpandVariables(data[k], substitutions) for k in data}
602
+ return data
603
+
604
+ if __name__ == '__main__':
605
+ sys.exit(main(sys.argv[1:]))