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
data/lib/origen.rb ADDED
@@ -0,0 +1,648 @@
1
+ require 'English'
2
+ require 'pathname'
3
+ require 'fileutils'
4
+ require 'origen/core_ext'
5
+ require 'origen/acronyms'
6
+ require 'origen/callbacks'
7
+ require 'origen/top_level'
8
+ require 'origen/model'
9
+ require 'origen/ruby_version_check'
10
+ require 'origen/application'
11
+ require 'origen/import_manager'
12
+ require 'origen/remote_manager'
13
+ require 'origen/utility'
14
+ require 'origen/version_checker'
15
+ require 'origen/logger_methods'
16
+ require 'option_parser/optparse'
17
+ require 'bundler'
18
+ require 'origen/site_config'
19
+
20
+ module Origen
21
+ autoload :Features, 'origen/features'
22
+ autoload :Bugs, 'origen/bugs'
23
+ autoload :Generator, 'origen/generator'
24
+ autoload :Pins, 'origen/pins'
25
+ autoload :Registers, 'origen/registers'
26
+ autoload :Tester, 'origen/tester'
27
+ autoload :Users, 'origen/users'
28
+ autoload :FileHandler, 'origen/file_handler'
29
+ autoload :RegressionManager, 'origen/regression_manager'
30
+ autoload :NVM, 'origen/nvm'
31
+ autoload :Location, 'origen/location'
32
+ autoload :VersionString, 'origen/version_string'
33
+ autoload :Mode, 'origen/mode'
34
+ autoload :ChipMode, 'origen/chip_mode'
35
+ autoload :ChipPackage, 'origen/chip_package'
36
+ autoload :Client, 'origen/client'
37
+ autoload :SubBlocks, 'origen/sub_blocks'
38
+ autoload :SubBlock, 'origen/sub_blocks'
39
+ autoload :ModelInitializer, 'origen/model_initializer'
40
+ autoload :Controller, 'origen/controller'
41
+ autoload :Database, 'origen/database'
42
+ autoload :Parameters, 'origen/parameters'
43
+ autoload :RevisionControl, 'origen/revision_control'
44
+ autoload :Specs, 'origen/specs'
45
+ autoload :CodeGenerators, 'origen/code_generators'
46
+ autoload :Encodings, 'origen/encodings'
47
+ autoload :Log, 'origen/log'
48
+
49
+ APP_CONFIG = File.join('config', 'application.rb')
50
+
51
+ class OrigenError < StandardError
52
+ def self.status_code(code)
53
+ define_method(:status_code) { code }
54
+ end
55
+ end
56
+
57
+ class GitError < OrigenError; status_code(11); end
58
+ class DesignSyncError < OrigenError; status_code(12); end
59
+
60
+ class << self
61
+ include Origen::Utility::TimeAndDate
62
+
63
+ def enable_profiling
64
+ @profiling = true
65
+ end
66
+
67
+ def disable_profiling
68
+ @profiling = false
69
+ end
70
+
71
+ def profile(message)
72
+ if @profiling
73
+ caller[0] =~ /.*\/(\w+\.rb):(\d+).*/
74
+ if block_given?
75
+ start = Time.now
76
+ yield
77
+ duration_in_ms = ((Time.now - start) * 1000).round
78
+ puts "#{duration_in_ms}ms".ljust(10) + "#{Regexp.last_match[1]}:#{Regexp.last_match[2]} '#{message}'"
79
+ else
80
+ puts "#{Time.now} - #{Regexp.last_match[1]}:#{Regexp.last_match[2]} #{message}"
81
+ end
82
+ else
83
+ yield if block_given?
84
+ end
85
+ end
86
+
87
+ def register_application(app)
88
+ _applications_lookup[:name][app.name] = app
89
+ _applications_lookup[:root][app.root.to_s] = app
90
+ @plugins = nil
91
+ end
92
+
93
+ # Returns an array containing the application instances of all plugins
94
+ def plugins
95
+ @plugins ||= begin
96
+ top = Origen.app
97
+ plugins = []
98
+ Origen._applications_lookup[:name].each do |_name, app|
99
+ plugins << app unless app == top
100
+ end
101
+ plugins
102
+ end
103
+ end
104
+
105
+ def app_loaded?
106
+ @application_loaded
107
+ end
108
+
109
+ # Returns the current (top-level) application instance
110
+ def app(plugin = nil, _options = {})
111
+ plugin, options = nil, plugin if plugin.is_a?(Hash)
112
+ if plugin
113
+ load_application
114
+ app = _applications_lookup[:name][plugin.to_sym]
115
+ if app
116
+ app
117
+ else
118
+ puts "Couldn't find application instance called #{plugin}, known names are:"
119
+ puts " #{_applications_lookup[:name].keys.join(', ')}"
120
+ puts
121
+ fail 'Origen.root lookup error!'
122
+ end
123
+ else
124
+ load_application
125
+ end
126
+ end
127
+ alias_method :application, :app
128
+
129
+ # Equivalent to application except that if called from code in a plugin this
130
+ # will return that plugin's application instance
131
+ def app!
132
+ file = caller[0]
133
+ path = @current_source_dir || Pathname.new(file).dirname
134
+ until File.exist?(File.join(path, APP_CONFIG)) || path.root?
135
+ path = path.parent
136
+ end
137
+ if path.root?
138
+ fail "Something went wrong resoving Origen.app! from: #{caller[0]}"
139
+ end
140
+ find_app_by_root(path)
141
+ end
142
+ alias_method :application!, :app!
143
+
144
+ # @api private
145
+ def with_source_file(file)
146
+ @current_source_dir = Pathname.new(file).dirname
147
+ yield
148
+ @current_source_dir = nil
149
+ end
150
+
151
+ # Validates that when the current app is OrigenCore then the
152
+ # origen executable is coming from the same workspace
153
+ #
154
+ # @api private
155
+ def validate_origen_dev_configuration!
156
+ if Origen.app.name == :origen_core
157
+ if Origen.root != Origen.top
158
+ puts 'It looks like you are trying to develop Origen core, but you are running an Origen'
159
+ puts 'executable from another workspace!'
160
+ if Origen.running_on_windows?
161
+ puts 'To resolve this error you must add the following directory to your Windows PATH:'
162
+ puts " #{Origen.root}\\bin"
163
+ else
164
+ puts 'To resolve this error run:'
165
+ puts " cd #{Origen.root}"
166
+ puts ' source source_setup'
167
+ end
168
+ exit 1
169
+ end
170
+ end
171
+ end
172
+
173
+ # @api private
174
+ def _applications_lookup
175
+ @_applications_lookup ||= { name: {}, root: {} }
176
+ end
177
+
178
+ # Returns an instance of Origen::Users::LDAP which provides
179
+ # methods to query and authorize users against a company's LDAP-based employee directory
180
+ def ldap
181
+ @ldap ||= Origen::Users::LDAP.new
182
+ end
183
+
184
+ # Return the application instance from the given path
185
+ # to an Origen application workspace, i.e. Origen.app conventionally
186
+ # returns the current application instance, this method returns the
187
+ # same thing that would be returned from the given remote workspace.
188
+ #
189
+ # @api private
190
+ def find_app_by_root(path_to_origen_root, options = {})
191
+ app = _applications_lookup[:root][Pathname.new(path_to_origen_root).realpath.to_s]
192
+ if !app || options[:reload]
193
+ # If the application is already defined then un-define it, this is to allow it to
194
+ # be reloaded.
195
+ # This option feels like it doesn't belong here, but is part of the legacy import
196
+ # require system. When that has been removed in future so can this reload system, under
197
+ # bundler app versions will be resolved before loading them so there will be no need
198
+ # for this
199
+ if app
200
+ begin
201
+ Object.send(:remove_const, app.class.to_s)
202
+ rescue
203
+ # Nothing to do here
204
+ end
205
+ end
206
+ require File.join(path_to_origen_root, APP_CONFIG)
207
+ app = _applications_lookup[:root][Pathname.new(path_to_origen_root).realpath.to_s]
208
+ end
209
+ return app if app
210
+ puts "Couldn't find application instance with root #{path_to_origen_root}, known roots are:"
211
+ _applications_lookup[:root].keys.each do |key|
212
+ puts " #{key}"
213
+ end
214
+ puts
215
+ fail 'Application lookup error!'
216
+ end
217
+ alias_method :application_instance, :find_app_by_root
218
+ alias_method :app_instance, :find_app_by_root
219
+
220
+ def command_dispatcher
221
+ @command_dispatcher ||= Application::CommandDispatcher.new
222
+ end
223
+
224
+ def configuration
225
+ app.config
226
+ end
227
+ alias_method :config, :configuration
228
+
229
+ def mailer
230
+ application.mailer
231
+ end
232
+
233
+ def target
234
+ application.target
235
+ end
236
+
237
+ def load_target(t, options = {})
238
+ target.temporary = t
239
+ application.load_target!(options)
240
+ application.runner.prepare_and_validate_workspace
241
+ end
242
+
243
+ def environment
244
+ application.environment
245
+ end
246
+
247
+ # Returns true if Origen is running in an application workspace
248
+ def in_app_workspace?
249
+ path = Pathname.new(Dir.pwd)
250
+ until path.root? || File.exist?(File.join(path, APP_CONFIG))
251
+ path = path.parent
252
+ end
253
+ !path.root?
254
+ end
255
+
256
+ def root(plugin = nil)
257
+ if plugin
258
+ app(plugin).root
259
+ else
260
+ if @root_fudge_active
261
+ app.root
262
+ else
263
+ @root ||= begin
264
+ path = Pathname.new(Dir.pwd)
265
+ until path.root? || File.exist?(File.join(path, APP_CONFIG))
266
+ path = path.parent
267
+ end
268
+ if path.root?
269
+ fail 'Something went wrong resolving the application root!'
270
+ end
271
+ path
272
+ end
273
+ end
274
+ end
275
+ end
276
+ alias_method :app_root, :root
277
+
278
+ # Like Origen.root but this will return the plugin root if called by plugin code
279
+ def root!
280
+ file = caller[0]
281
+ path = Pathname.new(file).dirname
282
+ until path.root? || File.exist?(File.join(path, APP_CONFIG))
283
+ path = path.parent
284
+ end
285
+ if path.root?
286
+ fail "Something went wrong resolving Origen.root! from: #{caller[0]}"
287
+ end
288
+ path.realpath
289
+ end
290
+
291
+ # Ugly hack to force Origen.root references to the plugin's top-level when loading
292
+ # the environment.rb of the plugin
293
+ #
294
+ # References to Origen.root in a plugin environment.rb is deprecated and this will be
295
+ # removed in future once all plugins load through bundler
296
+ #
297
+ # @api private
298
+ def with_origen_root(path)
299
+ orig = app.root
300
+ @root_fudge_active = true
301
+ app.root = Pathname.new(path)
302
+ yield
303
+ app.root = orig
304
+ @root_fudge_active = false
305
+ end
306
+
307
+ # Turns off bundler and all plugins if the app is loaded within this block
308
+ # @api private
309
+ def with_boot_environment
310
+ @with_boot_environment = true
311
+ yield
312
+ @with_boot_environment = false
313
+ end
314
+
315
+ def with_disable_origen_version_check(*args, &block)
316
+ version_checker.with_disable_origen_version_check(*args, &block)
317
+ end
318
+ alias_method :disable_origen_version_check, :with_disable_origen_version_check
319
+
320
+ # This is the application-facing API for implementing custom callbacks,
321
+ # the top-level application, all plugin application instances, and any
322
+ # application objects that include the Origen::Callbacks module will be
323
+ # returned
324
+ #
325
+ # Origen system callbacks should use Origen.app.listeners_for instead, that
326
+ # version will return only the current plugin instance instead of them all
327
+ # (yes we need to make the API more obvious).
328
+ def listeners_for(*args)
329
+ callback = args.shift
330
+ max = args.first.is_a?(Numeric) ? args.shift : nil
331
+ listeners = [Origen.app] + Origen.plugins +
332
+ Origen.app.instantiated_callback_listeners
333
+ listeners = listeners.select { |l| l.respond_to?(callback) }
334
+ if max && listeners.size > max
335
+ fail "You can only define a #{callback} callback #{max > 1 ? (max.to_s + 'times') : 'once'}, however you have declared it #{listeners.size} times for instances of: #{listeners.map(&:class)}"
336
+ end
337
+ listeners
338
+ end
339
+
340
+ def generator
341
+ @generator ||= Generator.new
342
+ end
343
+
344
+ def client
345
+ @client ||= Client.new
346
+ end
347
+
348
+ def tester
349
+ application && application.tester
350
+ end
351
+
352
+ def pin_bank
353
+ @pin_bank ||= Pins::PinBank.new
354
+ end
355
+
356
+ def file_handler
357
+ @file_handler ||= FileHandler.new
358
+ end
359
+
360
+ def regression_manager
361
+ @regression_manager ||= RegressionManager.new
362
+ end
363
+
364
+ def import_manager
365
+ @import_manager ||= ImportManager.new
366
+ end
367
+ alias_method :imports_manager, :import_manager
368
+
369
+ def plugins_manager
370
+ application.plugins_manager
371
+ end
372
+ alias_method :plugin_manager, :plugins_manager
373
+ alias_method :current_plugin, :plugins_manager
374
+
375
+ def remote_manager
376
+ @remote_manager ||= RemoteManager.new
377
+ end
378
+ alias_method :remotes_manager, :remote_manager
379
+
380
+ def pattern
381
+ generator.pattern
382
+ end
383
+
384
+ def flow
385
+ generator.flow
386
+ end
387
+
388
+ def resources
389
+ generator.resources
390
+ end
391
+
392
+ def time
393
+ @time ||= Origen::Tester::Time.new
394
+ end
395
+
396
+ def controllers
397
+ @controllers ||= []
398
+ end
399
+
400
+ def version(options = {})
401
+ @version = nil if options[:refresh]
402
+ return @version if @version && !options[:refresh]
403
+ if options[:refresh] || !defined?(Origen::VERSION)
404
+ load File.join(Pathname.new(File.dirname(__FILE__)).parent, 'config', 'version.rb')
405
+ end
406
+ @version = Origen::VersionString.new(Origen::VERSION)
407
+ end
408
+
409
+ # Loads the top-level application and all of its plugins, but not the target
410
+ #
411
+ # In most cases this should never need to be called directly and will be called
412
+ # automatically the first time the application is referenced via Origen.app
413
+ def load_application(check_version = true)
414
+ @application ||= begin
415
+ # This flag is set so that when a thread starts with no app it remains with no app. This
416
+ # was an issue when building a new app with the fetch command and when the thread did a
417
+ # chdir to the new app directory (to fetch it) Origen.log would try to load the partial app.
418
+ @running_outside_an_app = true unless in_app_workspace?
419
+ return nil if @running_outside_an_app
420
+ require File.join(root, APP_CONFIG)
421
+ @application = _applications_lookup[:root][root.to_s]
422
+ if File.exist?(File.join(root, 'Gemfile')) && !@with_boot_environment
423
+ # Don't understand the rules here, belt and braces approach for now to make
424
+ # sure that all Origen plugins are auto-required (otherwise Origen won't know
425
+ # about them to plug them into the application)
426
+ Bundler.require
427
+ Bundler.require(:development)
428
+ Bundler.require(:runtime)
429
+ Bundler.require(:default)
430
+ end
431
+ if @with_boot_environment
432
+ @application.current_plugin.disable
433
+ else
434
+ Origen.import_manager.require!
435
+ Origen.remote_manager.require!
436
+ end
437
+ env = File.join(root, 'config', 'environment.rb')
438
+ require env if File.exist?(env)
439
+ dev = File.join(root, 'config', 'development.rb')
440
+ require dev if File.exist?(dev)
441
+ version_checker.check! if check_version
442
+ validate_origen_dev_configuration!
443
+ ([@application] + Origen.plugins).each(&:on_loaded)
444
+ @application_loaded = true
445
+ @application
446
+ end
447
+ end
448
+
449
+ def launch_time
450
+ @launch_time ||= time_now
451
+ end
452
+
453
+ # Returns an instance of Origen::VersionChecker
454
+ def version_checker
455
+ @version_checker ||= VersionChecker.new
456
+ end
457
+
458
+ # Returns the full path to the Origen core top-level directory
459
+ def top
460
+ @origen_top ||= Pathname.new(File.dirname(__FILE__)).parent
461
+ end
462
+
463
+ # Compile the given file and return the result as a string
464
+ def compile(file, options = {})
465
+ Origen::Generator::Compiler.new.compile_inline(file, options)
466
+ end
467
+
468
+ def interfaces
469
+ @interfaces ||= []
470
+ end
471
+
472
+ def add_interface(interface_class)
473
+ interfaces << interface_class
474
+ end
475
+
476
+ # Resets the tester interface (instantiates a new one). Any supplied options
477
+ # are passed to the interface initialization.
478
+ def reset_interface(options = {})
479
+ # The doc interface should in future be phased out, but for now assume that an explicitly
480
+ # declared interface is for the non-doc case
481
+ if options[:interface] && !Origen.tester.doc?
482
+ @interface = eval(options[:interface]).new(options)
483
+ else
484
+ int = interfaces.find { |i| i.supports?(Origen.tester) }
485
+ if int
486
+ @interface = int.new(options)
487
+ else
488
+ unless options.delete(:silence_no_interface_error)
489
+ fail "No interface has been defined for tester: #{Origen.tester.class}"
490
+ end
491
+ end
492
+ end
493
+ @interface._load_generator if @interface.respond_to?(:_load_generator)
494
+ if @interface.respond_to?(:at_flow_start)
495
+ @interface.at_flow_start
496
+ else
497
+ @interface.reset_globals if @interface.respond_to?(:reset_globals)
498
+ end
499
+ @interface
500
+ end
501
+
502
+ def interface_loaded?
503
+ !!@interface
504
+ end
505
+
506
+ # Returns the (application defined) test program interface for the given tester
507
+ # if one has been defined, otherwise returns nil
508
+ def interface(options = {})
509
+ @interface || reset_interface(options)
510
+ end
511
+
512
+ # Returns true if an interface is defined for the current tester
513
+ def interface_present?
514
+ !!interface(silence_no_interface_error: true)
515
+ end
516
+
517
+ # Use User.current to retrieve the current user, this is an internal API that will
518
+ # be cleaned up (removed) in future
519
+ # @api private
520
+ def current_user
521
+ if app_loaded? || in_app_workspace?
522
+ application.current_user
523
+ else
524
+ User.new(User.current_user_id)
525
+ end
526
+ end
527
+
528
+ def lsf
529
+ application.lsf_manager
530
+ end
531
+
532
+ def running_on_windows?
533
+ RUBY_PLATFORM == 'i386-mingw32'
534
+ end
535
+
536
+ def running_on_linux?
537
+ !running_on_windows?
538
+ end
539
+
540
+ def running_remotely?
541
+ @running_remotely
542
+ end
543
+ alias_method :running_remotely, :running_remotely?
544
+
545
+ def running_locally?
546
+ !running_remotely?
547
+ end
548
+
549
+ def running_remotely=(val)
550
+ @running_remotely = val
551
+ end
552
+
553
+ # Returns true if Origen is running with the -d or --debug switches enabled
554
+ def debug?
555
+ @debug || false
556
+ end
557
+ alias_method :debugger?, :debug?
558
+
559
+ def enable_debugger
560
+ @debug = true
561
+ end
562
+
563
+ def debugger_enabled?
564
+ @debug
565
+ end
566
+
567
+ def development?
568
+ # This should be integrated with Origen.config.mode in the future
569
+ @development
570
+ end
571
+
572
+ def set_development_mode
573
+ @development = true
574
+ end
575
+
576
+ # Returns an object tracking the Origen execution mode/configuration, an
577
+ # instance of Origen::Mode
578
+ def mode
579
+ application.config.mode
580
+ end
581
+
582
+ def mode=(val)
583
+ application.config.mode = val
584
+ end
585
+
586
+ # Returns the current top-level (DUT) object if one has been defined (by
587
+ # instantiating an object that includes Origen::TopLevel).
588
+ def top_level
589
+ # TODO: This is called a lot and should probably be cached and expired
590
+ # on before_target_load
591
+ application.top_level
592
+ end
593
+
594
+ def deprecate(*msgs)
595
+ _deprecate(*msgs)
596
+ if Origen.app
597
+ # If an app deprecation return the caller who called the deprecated method
598
+ if caller[0] =~ /#{Origen.root}/
599
+ c = caller[1]
600
+ # If an Origen deprecation then return the first caller from the current app
601
+ else
602
+ c = caller.find { |line| line =~ /#{Origen.root}/ }
603
+ end
604
+ else
605
+ c = caller[1]
606
+ end
607
+ c =~ /(.*):(\d+):.*/
608
+ begin
609
+ _deprecate "Called by #{Regexp.last_match[1]}:#{Regexp.last_match[2]}", options
610
+ rescue
611
+ # For this to fail it means the deprecated method was called by IRB or similar
612
+ # and in that case there is no point advising who called anyway
613
+ end
614
+ end
615
+ alias_method :deprecated, :deprecate
616
+
617
+ def log
618
+ @log ||= Log.new
619
+ end
620
+
621
+ # Returns the name of the currently executing Origen command (a String),
622
+ # e.g. 'generate', 'program', 'compile', etc.
623
+ def current_command
624
+ @current_command
625
+ end
626
+
627
+ private
628
+
629
+ def current_command=(val)
630
+ @current_command = val
631
+ end
632
+
633
+ def _deprecate(*lines)
634
+ options = lines.last.is_a?(Hash) ? lines.pop : {}
635
+ lines.flatten.each do |line|
636
+ line.split(/\n/).each do |line|
637
+ log.deprecate line
638
+ end
639
+ end
640
+ end
641
+ end
642
+ end
643
+
644
+ # This is already required by commands.rb, but also necessary here so
645
+ # that is included whenever rspec (or another 3rd party) loads Origen
646
+ # outside the scope of an Origen command
647
+ require 'origen/global_methods'
648
+ include Origen::GlobalMethods
data/lib/tasks/gem.rake CHANGED
@@ -1,32 +1,37 @@
1
1
  namespace 'gem' do
2
- root = File.expand_path('../../..', __FILE__)
2
+ GEM_SPEC = "#{Origen.root}/#{Origen.app.gem_name}.gemspec"
3
+ GEM_NAME = "#{Origen.app.gem_name}-#{Origen.app.version}.gem"
3
4
 
4
- require "#{root}/config/version"
5
+ if File.exist?(GEM_SPEC)
5
6
 
6
- GEM_SPEC = "#{root}/origen.gemspec"
7
- GEM_NAME = "origen-#{Origen::VERSION}.gem"
8
- GEM_SERVER = 'http://rgen-hub.am.freescale.net:9292'
7
+ built_gem_path = nil
9
8
 
10
- built_gem_path = nil
11
-
12
- desc "Build #{GEM_NAME} into the pkg directory"
13
- task :build do
14
- sh("gem build -V '#{GEM_SPEC}'") do |_ok, _res|
15
- outdir = File.join(root, 'pkg')
16
- FileUtils.mkdir_p(outdir)
17
- FileUtils.mv(GEM_NAME, outdir)
18
- built_gem_path = File.join(outdir, GEM_NAME)
19
- puts "Origen #{Origen::VERSION} built to pkg/#{GEM_NAME}"
9
+ desc "Build #{GEM_NAME} into the pkg directory"
10
+ task :build do
11
+ # Ensure all files are readable
12
+ sh("chmod a+r -R #{Origen.root}")
13
+ sh("gem build -V '#{GEM_SPEC}'") do |_ok, _res|
14
+ outdir = File.join(Origen.root, 'pkg')
15
+ FileUtils.mkdir_p(outdir)
16
+ FileUtils.mv(GEM_NAME, outdir)
17
+ built_gem_path = File.join(outdir, GEM_NAME)
18
+ puts "#{Origen.app.name} #{Origen.app.version} built to pkg/#{GEM_NAME}".green
19
+ end
20
20
  end
21
- end
22
21
 
23
- desc "Push #{GEM_NAME} to Rubygems"
24
- task release: [:build] do
25
- sh("gem push #{built_gem_path}") do |ok, _res|
26
- if ok
27
- puts "Origen #{Origen::VERSION} has been released successfully"
22
+ desc "Push #{GEM_NAME} to the Origen gem server"
23
+ task release: [:build] do
24
+ if Origen.app.config.release_externally
25
+ cmd = "gem push #{built_gem_path}"
28
26
  else
29
- puts 'Something went wrong!'
27
+ cmd = "gem inabox --host #{Origen.site_config.gem_server!} #{built_gem_path}"
28
+ end
29
+ sh(cmd) do |ok, _res|
30
+ if ok
31
+ puts "#{Origen.app.name} #{Origen.app.version} has been released successfully".green
32
+ else
33
+ puts "Something went wrong releasing #{Origen.app.name} to the gem server!".red
34
+ end
30
35
  end
31
36
  end
32
37
  end