origen 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (336) hide show
  1. checksums.yaml +4 -4
  2. data/bin/ctags +0 -0
  3. data/bin/origen +165 -1
  4. data/bin/rgen +2 -0
  5. data/config/application.rb +141 -0
  6. data/config/commands.rb +72 -0
  7. data/config/development.rb +7 -0
  8. data/config/environment.rb +0 -0
  9. data/config/rgen.policy +7 -0
  10. data/config/rubocop/easy.yml +620 -0
  11. data/config/rubocop/easy_disabled.yml +271 -0
  12. data/config/rubocop/easy_enabled.yml +731 -0
  13. data/config/rubocop/strict.yml +620 -0
  14. data/config/rubocop/strict_disabled.yml +247 -0
  15. data/config/rubocop/strict_enabled.yml +755 -0
  16. data/config/users.rb +20 -0
  17. data/config/version.rb +1 -1
  18. data/helpers/url.rb +68 -0
  19. data/lib/c99/doc_interface.rb +56 -0
  20. data/lib/c99/j750_interface.rb +85 -0
  21. data/lib/c99/nvm.rb +89 -0
  22. data/lib/c99/target/mock2.rb +1 -0
  23. data/lib/c99/target/subdir/mock3.rb +1 -0
  24. data/lib/option_parser/optparse.rb +12 -0
  25. data/lib/origen/acronyms.rb +60 -0
  26. data/lib/origen/application/command_dispatcher.rb +12 -0
  27. data/lib/origen/application/configuration.rb +206 -0
  28. data/lib/origen/application/configuration_manager.rb +78 -0
  29. data/lib/origen/application/deployer.rb +367 -0
  30. data/lib/origen/application/environment.rb +186 -0
  31. data/lib/origen/application/lsf.rb +145 -0
  32. data/lib/origen/application/lsf_manager.rb +657 -0
  33. data/lib/origen/application/plugins_manager.rb +280 -0
  34. data/lib/origen/application/release.rb +359 -0
  35. data/lib/origen/application/runner.rb +246 -0
  36. data/lib/origen/application/statistics.rb +191 -0
  37. data/lib/origen/application/target.rb +374 -0
  38. data/lib/origen/application/version_tracker.rb +59 -0
  39. data/lib/origen/application/workspace_manager.rb +151 -0
  40. data/lib/origen/application.rb +746 -0
  41. data/lib/origen/bugs/bug.rb +36 -0
  42. data/lib/origen/bugs.rb +45 -0
  43. data/lib/origen/callbacks.rb +35 -0
  44. data/lib/origen/chip_mode.rb +118 -0
  45. data/lib/origen/chip_package.rb +461 -0
  46. data/lib/origen/client.rb +87 -0
  47. data/lib/origen/code_generators/actions.rb +258 -0
  48. data/lib/origen/code_generators/base.rb +57 -0
  49. data/lib/origen/code_generators/bundler.rb +17 -0
  50. data/lib/origen/code_generators/gem_setup.rb +49 -0
  51. data/lib/origen/code_generators/rake.rb +13 -0
  52. data/lib/origen/code_generators/rspec.rb +12 -0
  53. data/lib/origen/code_generators/semver.rb +39 -0
  54. data/lib/origen/code_generators/timever.rb +37 -0
  55. data/lib/origen/code_generators.rb +111 -0
  56. data/lib/origen/commands/add.rb +12 -0
  57. data/lib/origen/commands/compile.rb +62 -0
  58. data/lib/origen/commands/ctags.rb +9 -0
  59. data/lib/origen/commands/dispatch.rb +22 -0
  60. data/lib/origen/commands/environment.rb +11 -0
  61. data/lib/origen/commands/fetch.rb +63 -0
  62. data/lib/origen/commands/generate.rb +130 -0
  63. data/lib/origen/commands/interactive.rb +73 -0
  64. data/lib/origen/commands/lint.rb +82 -0
  65. data/lib/origen/commands/lsf.rb +93 -0
  66. data/lib/origen/commands/merge.rb +55 -0
  67. data/lib/origen/commands/modifications.rb +12 -0
  68. data/lib/origen/commands/new.rb +113 -0
  69. data/lib/origen/commands/plugin.rb +105 -0
  70. data/lib/origen/commands/program.rb +70 -0
  71. data/lib/origen/commands/rc.rb +442 -0
  72. data/lib/origen/commands/save.rb +56 -0
  73. data/lib/origen/commands/target.rb +27 -0
  74. data/lib/origen/commands/time.rb +127 -0
  75. data/lib/origen/commands/version.rb +17 -0
  76. data/lib/origen/commands/web.rb +221 -0
  77. data/lib/origen/commands.rb +272 -0
  78. data/lib/origen/commands_global.rb +76 -0
  79. data/lib/origen/controller.rb +94 -0
  80. data/lib/origen/core_ext/array.rb +23 -0
  81. data/lib/origen/core_ext/bignum.rb +36 -0
  82. data/lib/origen/core_ext/enumerable.rb +76 -0
  83. data/lib/origen/core_ext/fixnum.rb +46 -0
  84. data/lib/origen/core_ext/hash.rb +52 -0
  85. data/lib/origen/core_ext/module.rb +14 -0
  86. data/lib/origen/core_ext/numeric.rb +126 -0
  87. data/lib/origen/core_ext/object.rb +13 -0
  88. data/lib/origen/core_ext/range.rb +7 -0
  89. data/lib/origen/core_ext/string.rb +124 -0
  90. data/lib/origen/core_ext.rb +10 -0
  91. data/lib/origen/database/key_value_store.rb +111 -0
  92. data/lib/origen/database/key_value_stores.rb +108 -0
  93. data/lib/origen/database.rb +6 -0
  94. data/lib/origen/encodings.rb +102 -0
  95. data/lib/origen/features/feature.rb +22 -0
  96. data/lib/origen/features.rb +104 -0
  97. data/lib/origen/file_handler.rb +429 -0
  98. data/lib/origen/generator/comparator.rb +56 -0
  99. data/lib/origen/generator/compiler.rb +277 -0
  100. data/lib/origen/generator/flow.rb +49 -0
  101. data/lib/origen/generator/job.rb +131 -0
  102. data/lib/origen/generator/pattern.rb +356 -0
  103. data/lib/origen/generator/pattern_finder.rb +155 -0
  104. data/lib/origen/generator/pattern_iterator.rb +55 -0
  105. data/lib/origen/generator/renderer.rb +113 -0
  106. data/lib/origen/generator/resources.rb +40 -0
  107. data/lib/origen/generator/stage.rb +89 -0
  108. data/lib/origen/generator.rb +85 -0
  109. data/lib/origen/global_methods.rb +205 -0
  110. data/lib/origen/import_manager.rb +596 -0
  111. data/lib/origen/location/base.rb +116 -0
  112. data/lib/origen/location/map.rb +83 -0
  113. data/lib/origen/location.rb +6 -0
  114. data/lib/origen/log.rb +217 -0
  115. data/lib/origen/logger_methods.rb +56 -0
  116. data/lib/origen/mode.rb +61 -0
  117. data/lib/origen/model.rb +267 -0
  118. data/lib/origen/model_initializer.rb +45 -0
  119. data/lib/origen/nvm/block_array.rb +72 -0
  120. data/lib/origen/nvm.rb +6 -0
  121. data/lib/origen/parameters/live.rb +22 -0
  122. data/lib/origen/parameters/missing.rb +28 -0
  123. data/lib/origen/parameters/set.rb +144 -0
  124. data/lib/origen/parameters.rb +107 -0
  125. data/lib/origen/pdm.rb +218 -0
  126. data/lib/origen/pins/function_proxy.rb +36 -0
  127. data/lib/origen/pins/ground_pin.rb +6 -0
  128. data/lib/origen/pins/pin.rb +860 -0
  129. data/lib/origen/pins/pin_bank.rb +349 -0
  130. data/lib/origen/pins/pin_clock.rb +124 -0
  131. data/lib/origen/pins/pin_collection.rb +492 -0
  132. data/lib/origen/pins/pin_common.rb +206 -0
  133. data/lib/origen/pins/port.rb +268 -0
  134. data/lib/origen/pins/power_pin.rb +30 -0
  135. data/lib/origen/pins.rb +696 -0
  136. data/lib/origen/registers/bit.rb +562 -0
  137. data/lib/origen/registers/bit_collection.rb +787 -0
  138. data/lib/origen/registers/container.rb +288 -0
  139. data/lib/origen/registers/domain.rb +16 -0
  140. data/lib/origen/registers/reg.rb +1406 -0
  141. data/lib/origen/registers/reg_collection.rb +24 -0
  142. data/lib/origen/registers.rb +652 -0
  143. data/lib/origen/regression_manager.rb +251 -0
  144. data/lib/origen/remote_manager.rb +340 -0
  145. data/lib/origen/revision_control/base.rb +257 -0
  146. data/lib/origen/revision_control/design_sync.rb +276 -0
  147. data/lib/origen/revision_control/git.rb +243 -0
  148. data/lib/origen/revision_control/subversion.rb +6 -0
  149. data/lib/origen/revision_control.rb +44 -0
  150. data/lib/origen/ruby_version_check.rb +131 -0
  151. data/lib/origen/site_config.rb +61 -0
  152. data/lib/origen/specs/checkers.rb +103 -0
  153. data/lib/origen/specs/creation_info.rb +17 -0
  154. data/lib/origen/specs/doc_resource.rb +91 -0
  155. data/lib/origen/specs/exhibit.rb +17 -0
  156. data/lib/origen/specs/mode_select.rb +16 -0
  157. data/lib/origen/specs/note.rb +17 -0
  158. data/lib/origen/specs/override.rb +21 -0
  159. data/lib/origen/specs/power_supply.rb +13 -0
  160. data/lib/origen/specs/spec.rb +226 -0
  161. data/lib/origen/specs/version_history.rb +14 -0
  162. data/lib/origen/specs.rb +552 -0
  163. data/lib/origen/sub_blocks.rb +298 -0
  164. data/lib/origen/tester/api.rb +277 -0
  165. data/lib/origen/tester/bdm/bdm.rb +25 -0
  166. data/lib/origen/tester/command_based_tester.rb +46 -0
  167. data/lib/origen/tester/doc/doc.rb +226 -0
  168. data/lib/origen/tester/doc/generator/flow.rb +71 -0
  169. data/lib/origen/tester/doc/generator/flow_line.rb +203 -0
  170. data/lib/origen/tester/doc/generator/test.rb +68 -0
  171. data/lib/origen/tester/doc/generator/test_group.rb +66 -0
  172. data/lib/origen/tester/doc/generator/tests.rb +47 -0
  173. data/lib/origen/tester/doc/generator.rb +126 -0
  174. data/lib/origen/tester/doc/model.rb +162 -0
  175. data/lib/origen/tester/generator/flow_control_api.rb +606 -0
  176. data/lib/origen/tester/generator/identity_map.rb +25 -0
  177. data/lib/origen/tester/generator/placeholder.rb +13 -0
  178. data/lib/origen/tester/generator/test_numberer.rb +25 -0
  179. data/lib/origen/tester/generator.rb +271 -0
  180. data/lib/origen/tester/interface.rb +154 -0
  181. data/lib/origen/tester/j750/files.rb +45 -0
  182. data/lib/origen/tester/j750/generator/flow.rb +123 -0
  183. data/lib/origen/tester/j750/generator/flow_line.rb +288 -0
  184. data/lib/origen/tester/j750/generator/patgroup.rb +111 -0
  185. data/lib/origen/tester/j750/generator/patgroups.rb +41 -0
  186. data/lib/origen/tester/j750/generator/patset.rb +111 -0
  187. data/lib/origen/tester/j750/generator/patsets.rb +41 -0
  188. data/lib/origen/tester/j750/generator/templates/flow.txt.erb +9 -0
  189. data/lib/origen/tester/j750/generator/templates/instances.txt.erb +16 -0
  190. data/lib/origen/tester/j750/generator/templates/patgroups.txt.erb +8 -0
  191. data/lib/origen/tester/j750/generator/templates/patsets.txt.erb +10 -0
  192. data/lib/origen/tester/j750/generator/test_instance.rb +846 -0
  193. data/lib/origen/tester/j750/generator/test_instance_group.rb +60 -0
  194. data/lib/origen/tester/j750/generator/test_instances.rb +182 -0
  195. data/lib/origen/tester/j750/generator.rb +203 -0
  196. data/lib/origen/tester/j750/j750.rb +845 -0
  197. data/lib/origen/tester/j750/j750_hpt.rb +35 -0
  198. data/lib/origen/tester/j750/parser/ac_spec.rb +11 -0
  199. data/lib/origen/tester/j750/parser/ac_specs.rb +0 -0
  200. data/lib/origen/tester/j750/parser/dc_spec.rb +36 -0
  201. data/lib/origen/tester/j750/parser/dc_specs.rb +50 -0
  202. data/lib/origen/tester/j750/parser/descriptions.rb +340 -0
  203. data/lib/origen/tester/j750/parser/flow.rb +111 -0
  204. data/lib/origen/tester/j750/parser/flow_line.rb +207 -0
  205. data/lib/origen/tester/j750/parser/flows.rb +23 -0
  206. data/lib/origen/tester/j750/parser/pattern_set.rb +94 -0
  207. data/lib/origen/tester/j750/parser/pattern_sets.rb +33 -0
  208. data/lib/origen/tester/j750/parser/test_instance.rb +322 -0
  209. data/lib/origen/tester/j750/parser/test_instances.rb +26 -0
  210. data/lib/origen/tester/j750/parser/timeset.rb +15 -0
  211. data/lib/origen/tester/j750/parser/timesets.rb +0 -0
  212. data/lib/origen/tester/j750/parser.rb +104 -0
  213. data/lib/origen/tester/jlink/jlink.rb +33 -0
  214. data/lib/origen/tester/parser/description_lookup.rb +64 -0
  215. data/lib/origen/tester/parser/searchable_array.rb +32 -0
  216. data/lib/origen/tester/parser/searchable_hash.rb +32 -0
  217. data/lib/origen/tester/parser.rb +24 -0
  218. data/lib/origen/tester/time.rb +338 -0
  219. data/lib/origen/tester/timing.rb +253 -0
  220. data/lib/origen/tester/ultraflex/files.rb +45 -0
  221. data/lib/origen/tester/ultraflex/generator/flow.rb +119 -0
  222. data/lib/origen/tester/ultraflex/generator/flow_line.rb +269 -0
  223. data/lib/origen/tester/ultraflex/generator/patgroup.rb +111 -0
  224. data/lib/origen/tester/ultraflex/generator/patgroups.rb +41 -0
  225. data/lib/origen/tester/ultraflex/generator/patset.rb +111 -0
  226. data/lib/origen/tester/ultraflex/generator/patsets.rb +41 -0
  227. data/lib/origen/tester/ultraflex/generator/templates/flow.txt.erb +9 -0
  228. data/lib/origen/tester/ultraflex/generator/templates/instances.txt.erb +16 -0
  229. data/lib/origen/tester/ultraflex/generator/templates/patgroups.txt.erb +8 -0
  230. data/lib/origen/tester/ultraflex/generator/templates/patsets.txt.erb +10 -0
  231. data/lib/origen/tester/ultraflex/generator/test_instance.rb +622 -0
  232. data/lib/origen/tester/ultraflex/generator/test_instance_group.rb +60 -0
  233. data/lib/origen/tester/ultraflex/generator/test_instances.rb +174 -0
  234. data/lib/origen/tester/ultraflex/generator.rb +200 -0
  235. data/lib/origen/tester/ultraflex/parser/ac_spec.rb +11 -0
  236. data/lib/origen/tester/ultraflex/parser/ac_specs.rb +0 -0
  237. data/lib/origen/tester/ultraflex/parser/dc_spec.rb +36 -0
  238. data/lib/origen/tester/ultraflex/parser/dc_specs.rb +50 -0
  239. data/lib/origen/tester/ultraflex/parser/descriptions.rb +342 -0
  240. data/lib/origen/tester/ultraflex/parser/flow.rb +111 -0
  241. data/lib/origen/tester/ultraflex/parser/flow_line.rb +207 -0
  242. data/lib/origen/tester/ultraflex/parser/flows.rb +23 -0
  243. data/lib/origen/tester/ultraflex/parser/pattern_set.rb +94 -0
  244. data/lib/origen/tester/ultraflex/parser/pattern_sets.rb +33 -0
  245. data/lib/origen/tester/ultraflex/parser/test_instance.rb +262 -0
  246. data/lib/origen/tester/ultraflex/parser/test_instances.rb +26 -0
  247. data/lib/origen/tester/ultraflex/parser/timeset.rb +15 -0
  248. data/lib/origen/tester/ultraflex/parser/timesets.rb +0 -0
  249. data/lib/origen/tester/ultraflex/parser.rb +104 -0
  250. data/lib/origen/tester/ultraflex/ultraflex.rb +759 -0
  251. data/lib/origen/tester/v93k/generator/flow.rb +63 -0
  252. data/lib/origen/tester/v93k/generator/flow_node/print.rb +10 -0
  253. data/lib/origen/tester/v93k/generator/flow_node.rb +17 -0
  254. data/lib/origen/tester/v93k/generator/pattern.rb +16 -0
  255. data/lib/origen/tester/v93k/generator/pattern_master.rb +54 -0
  256. data/lib/origen/tester/v93k/generator/templates/_test_method.txt.erb +6 -0
  257. data/lib/origen/tester/v93k/generator/templates/_test_suite.txt.erb +11 -0
  258. data/lib/origen/tester/v93k/generator/templates/template.flow.erb +121 -0
  259. data/lib/origen/tester/v93k/generator/templates/template.pmfl.erb +9 -0
  260. data/lib/origen/tester/v93k/generator/test_function.rb +103 -0
  261. data/lib/origen/tester/v93k/generator/test_functions.rb +79 -0
  262. data/lib/origen/tester/v93k/generator/test_method.rb +46 -0
  263. data/lib/origen/tester/v93k/generator/test_methods.rb +75 -0
  264. data/lib/origen/tester/v93k/generator/test_suite.rb +54 -0
  265. data/lib/origen/tester/v93k/generator/test_suites.rb +65 -0
  266. data/lib/origen/tester/v93k/generator.rb +80 -0
  267. data/lib/origen/tester/v93k/v93k.rb +420 -0
  268. data/lib/origen/tester/vector.rb +86 -0
  269. data/lib/origen/tester/vector_generator.rb +633 -0
  270. data/lib/origen/tester/vector_pipeline.rb +150 -0
  271. data/lib/origen/tester.rb +56 -0
  272. data/lib/origen/top_level.rb +134 -0
  273. data/lib/origen/users/ldap.rb +65 -0
  274. data/lib/origen/users/user.rb +149 -0
  275. data/lib/origen/users.rb +30 -0
  276. data/lib/origen/utility/block_args.rb +93 -0
  277. data/lib/origen/utility/csv_data.rb +110 -0
  278. data/lib/origen/utility/design_sync.rb +494 -0
  279. data/lib/origen/utility/diff.rb +158 -0
  280. data/lib/origen/utility/input_capture.rb +121 -0
  281. data/lib/origen/utility/mailer.rb +143 -0
  282. data/lib/origen/utility/s_record.rb +205 -0
  283. data/lib/origen/utility/time_and_date.rb +30 -0
  284. data/lib/origen/utility.rb +12 -0
  285. data/lib/origen/version_checker.rb +117 -0
  286. data/lib/origen/version_string.rb +356 -0
  287. data/lib/origen.rb +648 -0
  288. data/lib/tasks/gem.rake +27 -22
  289. data/origen_site_config.yml +36 -0
  290. data/source_setup +17 -0
  291. data/spec/format/rgen_formatter.rb +14 -0
  292. data/templates/api_doc/README.txt.erb +24 -0
  293. data/templates/code_generators/gemfile_app.rb +4 -0
  294. data/templates/code_generators/gemfile_plugin.rb +6 -0
  295. data/templates/code_generators/gemspec.rb +33 -0
  296. data/templates/code_generators/rakefile.rb +10 -0
  297. data/templates/code_generators/spec_helper.rb +49 -0
  298. data/templates/code_generators/version.rb +8 -0
  299. data/templates/code_generators/version_time.rb +3 -0
  300. data/templates/git/gitignore.erb +33 -0
  301. data/templates/j750/_vt_flow.txt.erb +8 -0
  302. data/templates/j750/_vt_instances.txt.erb +4 -0
  303. data/templates/j750/program_sheet.txt.erb +9 -0
  304. data/templates/nanoc/Rules +74 -0
  305. data/templates/nanoc/config.yaml +77 -0
  306. data/templates/nanoc/content/favicon.ico +0 -0
  307. data/templates/nanoc/layouts/bootstrap.html.erb +63 -0
  308. data/templates/nanoc/layouts/bootstrap3.html.erb +71 -0
  309. data/templates/nanoc/layouts/freescale.html.erb +79 -0
  310. data/templates/nanoc/lib/bootstrap_filter.rb +49 -0
  311. data/templates/nanoc/lib/codeblocks_filter.rb +41 -0
  312. data/templates/nanoc/lib/default.rb +2 -0
  313. data/templates/nanoc/lib/gzip_filter.rb +16 -0
  314. data/templates/nanoc/lib/haml_code_filter.rb +41 -0
  315. data/templates/nanoc/lib/helpers.rb +1 -0
  316. data/templates/nanoc/lib/search_filter.rb +62 -0
  317. data/templates/nanoc_dynamic/content/search.js.erb +92 -0
  318. data/templates/shared/web/_logo.html +10 -0
  319. data/templates/test/_inline_sub.txt.erb +2 -0
  320. data/templates/test/environment.txt.erb +1 -0
  321. data/templates/test/inline.txt.erb +11 -0
  322. data/templates/test/inspections.txt.erb +19 -0
  323. data/templates/test/set1/_sub1.txt.erb +12 -0
  324. data/templates/test/set1/_sub4.txt.erb +1 -0
  325. data/templates/test/set1/_sub5.txt.erb +1 -0
  326. data/templates/test/set1/main.txt.erb +53 -0
  327. data/templates/test/set1/sub_dir/_sub2.txt.erb +20 -0
  328. data/templates/test/set1/sub_dir/_sub3.txt.erb +12 -0
  329. data/templates/test/set1/sub_dir/main2.txt.erb +4 -0
  330. data/templates/test/set2/template_with_no_erb_1.txt +9 -0
  331. data/templates/test/set2/template_with_no_erb_2.txt +9 -0
  332. data/templates/test/set3/_layout.html.erb +4 -0
  333. data/templates/test/set3/content.html.erb +6 -0
  334. data/templates/time/filter.rb.erb +15 -0
  335. data/templates/time/rules.rb.erb +45 -0
  336. metadata +639 -5
@@ -0,0 +1,257 @@
1
+ require 'open3'
2
+ module Origen
3
+ module RevisionControl
4
+ # Base class of all revision control system drivers,
5
+ # all drivers should support the API methods defined here.
6
+ #
7
+ # Each instance of this class represents the concept of mapping a local directory to
8
+ # a remote repository.
9
+ #
10
+ # Origen.app.rc will return an instance of this class for the revision control system used
11
+ # by the current application, the :local attribute will be automatically set to
12
+ # Origen.root and the :remote attribute will be set per the revision control attributes
13
+ # defined in config/application.rb.
14
+ class Base
15
+ # Returns a pointer to the remote location (a Pathname object)
16
+ attr_reader :remote
17
+ # Returns a pointer to the local location (a Pathname object)
18
+ attr_reader :local
19
+
20
+ # rubocop:disable Lint/UnusedMethodArgument
21
+
22
+ # All revision control instances represent a remote server mapping
23
+ # to a local directory, :remote and :local options are required
24
+ def initialize(options = {})
25
+ unless options[:remote] && options[:local]
26
+ fail ':remote and :local options must be supplied when instantiating a new RevisionControl object'
27
+ end
28
+ @remote = Pathname.new(options[:remote])
29
+ @local = Pathname.new(options[:local]).expand_path
30
+ initialize_local_dir
31
+ end
32
+
33
+ # Build the local workspace for the first time.
34
+ #
35
+ # This is roughly equivalent to running the checkout command, but should be used in the case where
36
+ # the local workspace is being setup for the first time.
37
+ def build(options = {})
38
+ fail "The #{self.class} driver does not support the build method!"
39
+ end
40
+
41
+ # Checkout the given file or directory, it returns a path to the local file.
42
+ #
43
+ # The path argument is optional and when not supplied the entire directory will be checked out.
44
+ #
45
+ # @param [String, Pathname] path
46
+ # The path to the remote item to checkout, this can be a pointer to a file or directory
47
+ # and it can either be a relative path or absolute path to either the local or remote locations.
48
+ # Multiple values can be supplied and should be separated by a space.
49
+ # @param [Hash] options Options to customize the operation
50
+ # @option options [Boolean] :force (false) Force overwrite of any existing local copy
51
+ # @option options [String] :version (nil) A specific version to checkout, will get latest if
52
+ # not supplied
53
+ # @option options [Boolean] :verbose (true) When true will show the command being executed and
54
+ # the raw output from the underlying revision control tool. When false will show nothing, but
55
+ # will still raise an error if the underlying command fails.
56
+ def checkout(path = nil, options = {})
57
+ fail "The #{self.class} driver does not support the checkout method!"
58
+ end
59
+
60
+ # Checkin the given file or directory, it returns a path to the local file.
61
+ #
62
+ # The path argument is optional and when not supplied the entire directory will be checked in.
63
+ #
64
+ # @param [String, Pathname] path
65
+ # The path to the remote item to checkout, this can be a pointer to a file or directory
66
+ # and it can either be a relative path or absolute path to either the local or remote locations.
67
+ # Multiple values can be supplied and should be separated by a space.
68
+ # @param [Hash] options Options to customize the operation
69
+ # @option options [Boolean] :force (false) Force overwrite of any newer version of the file that may
70
+ # exist, i.e. force checkin the current version to become the latest.
71
+ # @option options [Boolean] :unmanaged (false) Include files matching the given path that are not currently
72
+ # managed by the revision control system.
73
+ # @option options [Boolean] :comment (nil) Optionally supply a checkin comment.
74
+ # @option options [Boolean] :verbose (true) When true will show the command being executed and
75
+ # the raw output from the underlying revision control tool. When false will show nothing, but
76
+ # will still raise an error if the underlying command fails.
77
+ def checkin(path = nil, options = {})
78
+ fail "The #{self.class} driver does not support the checkin method!"
79
+ end
80
+
81
+ # Returns a hash containing the list of files that have changes compared to the given tag
82
+ # or compared to the latest version (on the server).
83
+ #
84
+ # {
85
+ # :added => [], # Paths to files that have been added since the previous tag
86
+ # :removed => [], # Paths to files that have been removed since the previous tag
87
+ # :changed => [], # Paths to files that have changed since the previous tag
88
+ # :present => true/false, # Convenience attribute for the caller to check if there are any changes, when
89
+ # # true at least one of the other arrays will contain a value
90
+ # }
91
+ #
92
+ # The dir argument is optional and when not supplied the entire directory will be checked for
93
+ # changes.
94
+ #
95
+ # Note that added files only refers to those files which have been checked into revision control
96
+ # since the compared to version, it does not refer to unmanaged files in the workspace.
97
+ # Use the unmanaged method to get a list of those.
98
+ #
99
+ # Note also that while a file is considered added or removed depends on the chronological
100
+ # relationship between the current version (the user's workspace) and the reference version.
101
+ # If the reference version is older than the current version (i.e. an earlier tag), then an added
102
+ # file means a file that the current version has and the reference (previous) version did not have.
103
+ #
104
+ # However if the reference version is newer than the current version (e.g. when comparing to a newer
105
+ # tag or the latest version on the server), then an added file means a file that the current
106
+ # version does not have and which has been added in a newer version of the remote directory.
107
+ #
108
+ # @param [String, Pathname] dir
109
+ # The path to a sub-directory to check for changes, it can either be a relative path or an
110
+ # absolute path to either the local or remote locations.
111
+ # @param [Hash] options Options to customize the operation
112
+ # @option options [String] :version (nil) A specific version to compare against, will compare to
113
+ # latest if not supplied
114
+ # @option options [Boolean] :verbose (false) When true will show the command being executed and
115
+ # the raw output from the underlying revision control tool. When false will show nothing. False
116
+ # is the default as with this command the user is more concerned with seeing the organized
117
+ # summary that is returned from this method.
118
+ def changes(dir = nil, options = {})
119
+ fail "The #{self.class} driver does not support the changes method!"
120
+ end
121
+
122
+ # Returns an array containing the files that have un-committed local changes.
123
+ #
124
+ # The dir argument is optional and when not supplied the entire directory will be checked for
125
+ # changes.
126
+ #
127
+ # @param [String, Pathname] dir
128
+ # The path to a sub-directory to check for changes, it can either be a relative path or an
129
+ # absolute path to either the local or remote locations.
130
+ # @param [Hash] options Options to customize the operation
131
+ # @option options [Boolean] :verbose (false) When true will show the command being executed and
132
+ # the raw output from the underlying revision control tool. When false will show nothing. False
133
+ # is the default as with this command the user is more concerned with seeing the organized
134
+ # summary that is returned from this method.
135
+ def local_modifications(dir = nil, options = {})
136
+ fail "The #{self.class} driver does not support the local_modifications method!"
137
+ end
138
+
139
+ # Returns an array containing the list of files that are present in the given directory but
140
+ # which are not managed by the revision control system.
141
+ #
142
+ # The dir argument is optional and when not supplied the entire directory will be checked for
143
+ # unmanaged files.
144
+ #
145
+ # @param [String, Pathname] dir
146
+ # The path to a sub-directory to check for unmanaged files, it can either be a relative path or an
147
+ # absolute path to either the local or remote locations.
148
+ # @param [Hash] options Options to customize the operation
149
+ # @option options [Boolean] :verbose (false) When true will show the command being executed and
150
+ # the raw output from the underlying revision control tool. When false will show nothing. False
151
+ # is the default as with this command the user is more concerned with seeing the organized
152
+ # summary that is returned from this method.
153
+ def unmanaged(dir = nil, options = {})
154
+ fail "The #{self.class} driver does not support the unmanaged method!"
155
+ end
156
+
157
+ # Returns the command the user must run to execute a diff of the current version of the given file
158
+ # against the given version of it.
159
+ #
160
+ # @param [String, Pathname] file
161
+ # The local path to the file to be compared.
162
+ # @param [String] version
163
+ # The version of the file to compare to.
164
+ def diff_cmd(file, version)
165
+ fail "The #{self.class} driver does not support the diff_cmd method!"
166
+ end
167
+
168
+ # Returns what is considered to be the top-level root directory by the revision control system.
169
+ #
170
+ # In the case of an application's revision controller (returned by Origen.app.rc) this method will often
171
+ # return the same directory as Origen.root. However in some cases an application owner may choose to store
172
+ # their application in a sub directory of a larger project entity that is revision controlled. In that
173
+ # case Origen.root will return the sub directory and this method will return the top-level directory
174
+ # of the wider project.
175
+ def root
176
+ fail "The #{self.class} driver does not support the root method!"
177
+ end
178
+
179
+ # Returns the name of the current branch in the local workspace
180
+ def current_branch
181
+ fail "The #{self.class} driver does not support the current_branch method!"
182
+ end
183
+
184
+ # Returns true if the revision controller object uses Design Sync
185
+ def dssc?
186
+ is_a?(DesignSync)
187
+ end
188
+ alias_method :design_sync?, :dssc?
189
+
190
+ # Returns true if the revision controller object uses Git
191
+ def git?
192
+ is_a?(Git) # :-)
193
+ end
194
+
195
+ # Returns true if the revision controller object uses Subversion
196
+ def svn?
197
+ is_a?(Subversion) # :-)
198
+ end
199
+ alias_method :subversion?, :svn?
200
+
201
+ # rubocop:enable Lint/UnusedMethodArgument
202
+
203
+ private
204
+
205
+ def clean_path(path = nil, options = {})
206
+ path, options = nil, path if path.is_a?(Hash)
207
+ if path
208
+ paths = to_local(path)
209
+ else
210
+ paths = [local.to_s]
211
+ end
212
+ [paths, options]
213
+ end
214
+
215
+ # Converts a given path string to files/directories to an array of absolute paths to the
216
+ # resources within the local directory.
217
+ # The input can either contain a path to the local directory, or the remote.
218
+ #
219
+ # @example
220
+ # to_local("config/application.rb sync://sync-15088:15088/Projects/common_tester_blocks/origen/lib")
221
+ # # => ["/home/r49409/origen/config/application.rb", "/home/r49409/origen/lib"]
222
+ def to_local(path)
223
+ local_abs_paths = []
224
+ path.to_s.split(/\s+/).each do |p|
225
+ if p =~ /^#{remote}/
226
+ p.sub!(/^#{remote}/, '')
227
+ p.slice!(0) if p =~ /^\//
228
+ p = "#{local}/#{p}"
229
+ else
230
+ if Pathname.new(p).absolute?
231
+ # No action required
232
+ else
233
+ p = "#{local}/#{p}"
234
+ end
235
+ end
236
+ local_abs_paths << p
237
+ end
238
+ local_abs_paths
239
+ end
240
+
241
+ # If the supplied tag looks like a semantic version number, then make sure it has the
242
+ # 'v' prefix
243
+ def prefix_tag(tag)
244
+ tag = Origen::VersionString.new(tag)
245
+ if tag.semantic?
246
+ tag.prefixed
247
+ else
248
+ tag
249
+ end
250
+ end
251
+
252
+ def initialize_local_dir
253
+ FileUtils.mkdir_p(local.to_s) unless local.exist?
254
+ end
255
+ end
256
+ end
257
+ end
@@ -0,0 +1,276 @@
1
+ module Origen
2
+ module RevisionControl
3
+ class DesignSync < Base
4
+ # Check in the contents of the given directory to a remote vault location, meaning a vault location
5
+ # that is not necessarily associated with the current workspace that the given files are in.
6
+ #
7
+ # Anything found in the given directory will be checked in, even files which are not currently under
8
+ # revision control.
9
+ #
10
+ # No attempt will be made to merge the current vault contents with the local data, the local data
11
+ # will always be checked in as latest.
12
+ #
13
+ # A tag can be optionally supplied and if present will be applied to the files post check in.
14
+ #
15
+ # @example
16
+ #
17
+ # Origen::RevisionControl::DesignSync.remote_check_in("#{Origen.root}/output/j750", vault: "sync://sync-15088:15088/Projects/common_tester_blocks/origen_training/j750", tag: Origen.app.version)
18
+ def self.remote_check_in(dir, options = {})
19
+ options = {
20
+ force: true
21
+ }.merge(options)
22
+
23
+ dir = Pathname.new(dir)
24
+ fail "Directory does not exist: #{dir}" unless dir.exist?
25
+ fail "Only directories are supported by remote_check_in, this is not a directory: #{dir}" unless dir.directory?
26
+ fail 'No vault option supplied to remote_check_in!' unless options[:vault]
27
+ scratch = Pathname.new("#{Origen.app.workspace_manager.imports_directory}/design_sync/scratch")
28
+ FileUtils.rm_rf(scratch) if scratch.exist?
29
+ FileUtils.mkdir_p(scratch)
30
+ FileUtils.cp_r("#{dir}/.", scratch)
31
+ remove_dot_syncs!(scratch)
32
+ ds = new(remote: options[:vault], local: scratch)
33
+ ds.checkin(options)
34
+ ds.tag(options[:tag], options) if options[:tag]
35
+ FileUtils.rm_rf(scratch)
36
+ end
37
+
38
+ # Recursively remove all .SYNC directories from the given directory
39
+ def self.remove_dot_syncs!(dir, options = {})
40
+ dir = Pathname.new(dir)
41
+ fail "Directory does not exist: #{dir}" unless dir.exist?
42
+ fail "Only directories are supported by remove_dot_syncs, this is not a directory: #{dir}" unless dir.directory?
43
+ Dir.glob("#{dir}/**/.SYNC").sort.each do |dot_sync|
44
+ FileUtils.rm_rf(dot_sync)
45
+ end
46
+ end
47
+
48
+ def build
49
+ checkout
50
+ end
51
+
52
+ def checkout(path = nil, options = {})
53
+ paths, options = clean_path(path, options)
54
+ cmd = 'pop'
55
+ cmd += ' -rec -get -uni'
56
+ cmd += ' -force' if options[:force]
57
+ if options[:version]
58
+ cmd += " -version #{prefix_tag(options[:version])}"
59
+ else
60
+ cmd += ' -merge' unless options[:force]
61
+ end
62
+ paths = paths.join(' ')
63
+ dssc("#{cmd} #{paths}", options)
64
+ # Design sync can be funny and even with -get it can leave unwritable files, so let's fix that
65
+ `chmod a+w -R #{paths}`
66
+ paths
67
+ end
68
+
69
+ def checkin(path = nil, options = {})
70
+ paths, options = clean_path(path, options)
71
+ cmd = 'ci'
72
+ cmd += ' -rec -keep'
73
+ cmd += ' -skip' if options[:force]
74
+ cmd += ' -new' if options[:unmanaged] || options[:force]
75
+ if options[:comment] && !options[:comment].strip.empty?
76
+ cmd += " -com \"#{options[:comment].strip}\""
77
+ else
78
+ # cmd += ' -nocom' # DO NOT USE nocom option with DesignSync, doesn't always work
79
+ cmd += ' -com None'
80
+ end
81
+ paths = paths.join(' ')
82
+ dssc("#{cmd} #{paths}", options)
83
+ # Make sure the file is still writable
84
+ `chmod a+w -R #{paths}`
85
+ paths
86
+ end
87
+
88
+ def changes(dir = nil, options = {})
89
+ paths, options = clean_path(dir, options)
90
+ options = {
91
+ verbose: false
92
+ }.merge(options)
93
+
94
+ cmd = 'compare -rec -path -report silent'
95
+ if options[:version]
96
+ cmd += " -selector #{prefix_tag(options[:version])}"
97
+ end
98
+ cmd += " #{paths.first}"
99
+
100
+ objects = {
101
+ added: [], removed: [], changed: []
102
+ }
103
+ dssc(cmd, options).each do |line|
104
+ # We need to parse the following data from the output, ignore everything else
105
+ # which will mostly refer to un-managed files.
106
+ #
107
+ # Added since previous version...
108
+ # 1.12 First only source_setup
109
+ # Removed since previous version...
110
+ # 1.13 Second only lib/history
111
+ # Modified since previous version...
112
+ # 1.32 1.31 Different versions lib/origen/application.rb
113
+ # Modified since previous version including a local edit...
114
+ # 1.7 (Locally Modified) 1.7 Different states lib/origen/commands/rc.rb
115
+ unless line =~ /Unmanaged/
116
+ # http://www.rubular.com/r/GoNYB75upB
117
+ if line =~ /\s*(\S+)\s+First only\s+(\S+)\s*/
118
+ objects[:added] << Regexp.last_match[2]
119
+ # http://www.rubular.com/r/Xvh32Lm4hS
120
+ elsif line =~ /\s*(\S+)\s+Second only\s+(\S+)\s*/
121
+ objects[:removed] << Regexp.last_match[2]
122
+ # http://www.rubular.com/r/tvTHod9Mye
123
+ elsif line =~ /\s*\S+\s+(\(Locally Modified\))?\s*(\S+)\s+Different (versions|states)\s+(\S+)\s*/
124
+ objects[:changed] << Regexp.last_match[4]
125
+ end
126
+ end
127
+ end
128
+ objects[:present] = !objects[:added].empty? || !objects[:removed].empty? || !objects[:changed].empty?
129
+ objects[:added].map! { |i| "#{paths.first}/" + i }
130
+ objects[:removed].map! { |i| "#{paths.first}/" + i }
131
+ objects[:changed].map! { |i| "#{paths.first}/" + i }
132
+ objects
133
+ end
134
+
135
+ def local_modifications(dir = nil, options = {})
136
+ paths, options = clean_path(dir, options)
137
+ options = {
138
+ verbose: false
139
+ }.merge(options)
140
+
141
+ cmd = 'ls -rec -managed -path -report N -modified -format text'
142
+ cmd += " #{paths.first}"
143
+
144
+ files = dssc(cmd, options).reject do |item|
145
+ item.strip.empty? ||
146
+ item =~ /^(Name|Directory|---)/
147
+ end
148
+ files.map! do |file|
149
+ file.strip! # Strip off any whitespace from all objects
150
+ file.sub!(/^#{full_path_prefix}/, '')
151
+ file.sub('|', ':')
152
+ file.sub!(/^/, "#{paths.first}/")
153
+ end
154
+ end
155
+
156
+ def unmanaged(dir = nil, options = {})
157
+ paths, options = clean_path(dir, options)
158
+ options = {
159
+ verbose: false
160
+ }.merge(options)
161
+ cmd = 'ls -rec -unmanaged -fullpath -report N -modified -format text'
162
+ cmd += " #{paths.first}"
163
+ files = dssc(cmd, options).reject do |item|
164
+ # removes extraneous lines
165
+ item =~ /^(Name|Directory|---)/ || item.strip.empty?
166
+ end
167
+ files.map! do |file|
168
+ file.strip! # Strip off any whitespace from all objects
169
+ file.sub!(/^#{full_path_prefix}/, '')
170
+ file.sub('|', ':')
171
+ end
172
+ end
173
+
174
+ def diff_cmd(file, version)
175
+ "dssc diff -gui -ver #{prefix_tag(version)} #{file}"
176
+ end
177
+
178
+ def tag(id, options = {})
179
+ id = VersionString.new(id)
180
+ id = id.prefixed if id.semantic?
181
+ replace = options[:force] ? '-replace' : ''
182
+ dssc "tag #{id} -rec #{replace} *"
183
+ # Applying this rule recursively seems to cause havoc, so running on its own.
184
+ # This hits any dot files in the root directory, any dot files in sub directories
185
+ # already get hit by the above tag job.
186
+ dssc "tag #{id} #{replace} .*"
187
+ end
188
+
189
+ def root
190
+ # This is an expensive operation the way it is currently implemented, so
191
+ # cache the result for future calls
192
+ Origen.app.session.dssc["root-#{local}"] ||= begin
193
+ root = local
194
+ resolved = false
195
+ vault = dssc("url vault #{root}").first
196
+ until resolved || root.root?
197
+ parent = root.parent
198
+ if File.exist?("#{parent}/.SYNC")
199
+ parent_vault = dssc("url vault #{parent}").first
200
+ if vault.to_s =~ /^#{parent_vault}/
201
+ root = parent
202
+ else
203
+ resolved = true
204
+ end
205
+ else
206
+ resolved = true
207
+ end
208
+ end
209
+ root
210
+ end
211
+ end
212
+
213
+ def current_branch
214
+ dssc("url selector #{local}", verbose: false).first
215
+ end
216
+
217
+ private
218
+
219
+ def full_path_prefix
220
+ @full_path_prefix ||= begin
221
+ if Origen.running_on_windows?
222
+ 'file:///'
223
+ else
224
+ 'file://'
225
+ end
226
+ end
227
+ end
228
+
229
+ def initialize_local_dir
230
+ super
231
+ unless initialized?
232
+ Origen.log.debug "Initializing DSSC workspace at #{local}"
233
+ dssc "setvault #{remote} ."
234
+ end
235
+ end
236
+
237
+ def initialized?
238
+ File.exist?("#{local}/.SYNC")
239
+ end
240
+
241
+ # Execute a dssc operation, the resultant output is returned in an array
242
+ def dssc(command, options = {})
243
+ options = {
244
+ check_errors: true,
245
+ verbose: true
246
+ }.merge(options)
247
+ output = []
248
+ if options[:verbose]
249
+ Origen.log.info "dssc #{command}"
250
+ Origen.log.info ''
251
+ end
252
+ Dir.chdir local do
253
+ Open3.popen2e("dssc #{command}") do |_stdin, stdout_err, wait_thr|
254
+ while line = stdout_err.gets
255
+ Origen.log.info line.strip if options[:verbose]
256
+ # Screen out common redundant output
257
+ unless line =~ /^Logging/ || line == '' ||
258
+ line =~ /V(\d+\.\d+-\d+|\d.\d+)/ || # Screen out something like "V5.1-1205" or "V6R2010"
259
+ line.strip.empty?
260
+ output << line.strip
261
+ end
262
+ end
263
+
264
+ exit_status = wait_thr.value
265
+ unless exit_status.success?
266
+ if options[:check_errors]
267
+ fail DesignSyncError, "This command failed: 'dssc #{command}'"
268
+ end
269
+ end
270
+ end
271
+ end
272
+ output
273
+ end
274
+ end
275
+ end
276
+ end