origen 0.38.0 → 0.40.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/bin/origen +1 -236
  3. data/config/application.rb +10 -1
  4. data/config/version.rb +1 -1
  5. data/lib/origen/{boot_api.rb → boot/api.rb} +2 -2
  6. data/lib/origen/boot/app.rb +324 -0
  7. data/lib/origen/boot.rb +287 -0
  8. data/lib/origen/commands/archive.rb +175 -0
  9. data/lib/origen/commands/extract.rb +43 -0
  10. data/lib/origen/commands/new.rb +33 -23
  11. data/lib/origen/commands.rb +4 -1
  12. data/lib/origen/commands_global.rb +3 -2
  13. data/lib/origen/operating_systems.rb +4 -0
  14. data/lib/origen/revision_control.rb +1 -1
  15. data/lib/origen/site_config.rb +4 -1
  16. data/lib/origen.rb +3 -2
  17. data/origen_app_generators/Gemfile +16 -0
  18. data/origen_app_generators/Gemfile.lock +147 -0
  19. data/origen_app_generators/LICENSE +21 -0
  20. data/origen_app_generators/README.md +368 -0
  21. data/origen_app_generators/Rakefile +10 -0
  22. data/origen_app_generators/bin/boot.rb +37 -0
  23. data/{bin → origen_app_generators/bin}/fix_my_workspace +0 -0
  24. data/origen_app_generators/config/application.rb +153 -0
  25. data/origen_app_generators/config/boot.rb +1 -0
  26. data/origen_app_generators/config/commands.rb +63 -0
  27. data/origen_app_generators/config/shared_commands.rb +172 -0
  28. data/origen_app_generators/config/version.rb +8 -0
  29. data/origen_app_generators/doc/history +213 -0
  30. data/origen_app_generators/lib/origen_app_generators/application.rb +62 -0
  31. data/origen_app_generators/lib/origen_app_generators/base.rb +231 -0
  32. data/origen_app_generators/lib/origen_app_generators/empty_application.rb +15 -0
  33. data/origen_app_generators/lib/origen_app_generators/empty_plugin.rb +15 -0
  34. data/origen_app_generators/lib/origen_app_generators/new.rb +162 -0
  35. data/origen_app_generators/lib/origen_app_generators/origen_infrastructure/app_generator_plugin.rb +109 -0
  36. data/origen_app_generators/lib/origen_app_generators/plugin.rb +58 -0
  37. data/origen_app_generators/lib/origen_app_generators/sub_block_parser.rb +81 -0
  38. data/origen_app_generators/lib/origen_app_generators/test_engineering/stand_alone_application.rb +236 -0
  39. data/origen_app_generators/lib/origen_app_generators/test_engineering/test_block.rb +162 -0
  40. data/origen_app_generators/lib/origen_app_generators.rb +123 -0
  41. data/origen_app_generators/lib/tasks/app_generators.rake +6 -0
  42. data/origen_app_generators/lib/tasks/new_app_tests.rake +8 -0
  43. data/origen_app_generators/origen_app_generators.gemspec +33 -0
  44. data/origen_app_generators/spec/spec_helper.rb +49 -0
  45. data/origen_app_generators/spec/sub_block_spec.rb +36 -0
  46. data/origen_app_generators/target/debug.rb +8 -0
  47. data/origen_app_generators/target/default.rb +8 -0
  48. data/origen_app_generators/target/production.rb +0 -0
  49. data/origen_app_generators/templates/app_generators/application/Gemfile +19 -0
  50. data/origen_app_generators/templates/app_generators/application/Rakefile +7 -0
  51. data/origen_app_generators/templates/app_generators/application/config/application.rb +125 -0
  52. data/origen_app_generators/templates/app_generators/application/config/boot.rb +4 -0
  53. data/origen_app_generators/templates/app_generators/application/config/commands.rb +79 -0
  54. data/origen_app_generators/templates/app_generators/application/config/maillist_dev.txt +4 -0
  55. data/origen_app_generators/templates/app_generators/application/config/maillist_prod.txt +3 -0
  56. data/origen_app_generators/templates/app_generators/application/config/version.rb +8 -0
  57. data/origen_app_generators/templates/app_generators/application/doc/history +0 -0
  58. data/origen_app_generators/templates/app_generators/application/dot_keep +0 -0
  59. data/origen_app_generators/templates/app_generators/application/lib/app.rake +6 -0
  60. data/origen_app_generators/templates/app_generators/application/lib/module.rb +22 -0
  61. data/origen_app_generators/templates/app_generators/application/lib/top_level.rb +12 -0
  62. data/origen_app_generators/templates/app_generators/application/origen_core_session +2 -0
  63. data/origen_app_generators/templates/app_generators/application/spec/spec_helper.rb +44 -0
  64. data/origen_app_generators/templates/app_generators/application/target/debug.rb +8 -0
  65. data/origen_app_generators/templates/app_generators/application/target/default.rb +1 -0
  66. data/origen_app_generators/templates/app_generators/application/target/production.rb +4 -0
  67. data/origen_app_generators/templates/app_generators/application/templates/web/index.md.erb +19 -0
  68. data/origen_app_generators/templates/app_generators/application/templates/web/layouts/_basic.html.erb +13 -0
  69. data/origen_app_generators/templates/app_generators/application/templates/web/partials/_navbar.html.erb +20 -0
  70. data/origen_app_generators/templates/app_generators/application/templates/web/release_notes.md.erb +5 -0
  71. data/origen_app_generators/templates/app_generators/new/generator.rb +102 -0
  72. data/origen_app_generators/templates/app_generators/new/info.md.erb +9 -0
  73. data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/config/load_generators.rb +6 -0
  74. data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/lib/application.rb +54 -0
  75. data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/lib/base.rb +55 -0
  76. data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/lib/module.rb +28 -0
  77. data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/lib/plugin.rb +64 -0
  78. data/origen_app_generators/templates/app_generators/plugin/Gemfile +26 -0
  79. data/origen_app_generators/templates/app_generators/plugin/Rakefile +10 -0
  80. data/origen_app_generators/templates/app_generators/plugin/config/boot.rb +24 -0
  81. data/origen_app_generators/templates/app_generators/plugin/gemspec.rb +42 -0
  82. data/origen_app_generators/templates/app_generators/plugin/lib/README +4 -0
  83. data/origen_app_generators/templates/app_generators/plugin/lib_dev/README +5 -0
  84. data/origen_app_generators/templates/app_generators/plugin/templates/web/index.md.erb +37 -0
  85. data/origen_app_generators/templates/app_generators/plugin/templates/web/partials/_navbar_external.html.erb +20 -0
  86. data/origen_app_generators/templates/app_generators/plugin/templates/web/partials/_navbar_internal.html.erb +20 -0
  87. data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/Gemfile +23 -0
  88. data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/environment/j750.rb +1 -0
  89. data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/environment/jlink.rb +1 -0
  90. data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/environment/uflex.rb +1 -0
  91. data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/environment/v93k.rb +1 -0
  92. data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/lib/ip_block.rb +23 -0
  93. data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/lib/ip_block_controller.rb +5 -0
  94. data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/lib/top_level.rb +33 -0
  95. data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/lib/top_level_controller.rb +21 -0
  96. data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/pattern/example.rb +4 -0
  97. data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/target/top_level.rb +4 -0
  98. data/origen_app_generators/templates/app_generators/test_engineering/test_block/environment/j750.rb +2 -0
  99. data/origen_app_generators/templates/app_generators/test_engineering/test_block/environment/ultraflex.rb +2 -0
  100. data/origen_app_generators/templates/app_generators/test_engineering/test_block/environment/v93k.rb +2 -0
  101. data/origen_app_generators/templates/app_generators/test_engineering/test_block/lib/controller.rb +12 -0
  102. data/origen_app_generators/templates/app_generators/test_engineering/test_block/lib/interface.rb +21 -0
  103. data/origen_app_generators/templates/app_generators/test_engineering/test_block/lib/model.rb +18 -0
  104. data/origen_app_generators/templates/app_generators/test_engineering/test_block/lib_dev/dut.rb +27 -0
  105. data/origen_app_generators/templates/app_generators/test_engineering/test_block/lib_dev/dut_controller.rb +26 -0
  106. data/origen_app_generators/templates/app_generators/test_engineering/test_block/pattern/example.rb +5 -0
  107. data/origen_app_generators/templates/app_generators/test_engineering/test_block/program/prb1.rb +11 -0
  108. data/origen_app_generators/templates/app_generators/test_engineering/test_block/target/default.rb +2 -0
  109. data/origen_site_config.yml +13 -2
  110. data/templates/git/gitignore.erb +0 -1
  111. metadata +99 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9aa332ea30ff6e2185ef86ef42fb8ed6444b525555bd8509fed4f28a721596f0
4
- data.tar.gz: 9aa1c645c4a77f2b9ce18b0b406d7c18fef099f9dca71bfd45dd97361a18116c
3
+ metadata.gz: e95972bfda37704ac8411834e3428a6e68b01056b90ed2accae530ce7b97900d
4
+ data.tar.gz: e6e626d864f73a3b07014d8b43bbcae416d97884cb4c09bfff3c1b1fb05bef42
5
5
  SHA512:
6
- metadata.gz: c9aaf744fbb84e2e6fee05f7f53c148a36a789d7ff6c83ded3129f0762acb5afdd98c6ce872608105c35b129a5283b6027e501b571d8512279629ad026854bd9
7
- data.tar.gz: 3d0f7817ed9bf9c5098ac89effbc4cfbab473f6fb6572ee9bf3e39756f1fdf22925ca0a01104272ca6138964ba807804137c60cf31115a9ce915f161b3caee1c
6
+ metadata.gz: '090322751c0e38385385dcb0f8dbf6cfcf9f424aea3b49a423f3e3585c8a514cd4921811687197de7ca8a6954184ada52d148dc3648c7c451b51df2d27fb8ce1'
7
+ data.tar.gz: ab8292bb949e3dcd392f04b25ce2ca86ca6e48a0a80dfc7bb9d93599a937c253b506a23b11199cdb22a8eeae324ce26f6e42d59477e93ae752fd3c048b7d1cc5
data/bin/origen CHANGED
@@ -1,237 +1,2 @@
1
1
  #!/usr/bin/env ruby
2
- $VERBOSE = nil # Don't care about world writable dir warnings and the like
3
-
4
- require 'pathname'
5
- require 'fileutils'
6
- #require 'byebug' # Un-comment to debug this file
7
-
8
- class OrigenBootError < StandardError
9
- end
10
-
11
- # Keep a note of the pwd at the time when Origen was first loaded, this is initially used
12
- # by the site_config lookup.
13
- $_origen_invocation_pwd ||= Pathname.pwd
14
-
15
- load File.expand_path('../../lib/origen/operating_systems.rb', __FILE__)
16
- load File.expand_path('../../lib/origen/site_config.rb', __FILE__)
17
-
18
- # This will be referenced later in ruby_version_check, the origen used to launch
19
- # the process is different than the one that actually runs under bundler
20
- $origen_launch_root = Pathname.new(File.dirname(__FILE__)).parent
21
-
22
- # Override any influence from $LANG in the users environment
23
- Encoding.default_external = Encoding::UTF_8
24
- Encoding.default_internal = Encoding::UTF_8
25
- ENV['LC_ALL'] = nil
26
- ENV['LANG'] = nil
27
- ENV['LANG'] = 'en_US.UTF-8'
28
-
29
- # Work out what Origen.root is if we are running inside an Origen application, this will be
30
- # later used to execute from that app's bundle even if the origen executable lives somewhere
31
- # else (e.g. in the tools repository)
32
- app_config = File.join('config', 'application.rb')
33
- if File.exist?(app_config)
34
- origen_root = Dir.pwd
35
- else
36
- path = Pathname.new(Dir.pwd)
37
- until path.root? || origen_root
38
- if File.exist?(File.join(path, app_config))
39
- origen_root = path.to_s
40
- else
41
- path = path.parent
42
- end
43
- end
44
- end
45
-
46
- # If running inside an application workspace
47
- if origen_root
48
- # Force everyone to have a consistent way of installing gems with bundler
49
- ENV['BUNDLE_GEMFILE'] = File.join(origen_root, 'Gemfile')
50
- ENV['BUNDLE_PATH'] = File.expand_path(Origen.site_config.gem_install_dir)
51
- ENV['BUNDLE_BIN'] = File.join(origen_root, 'lbin')
52
-
53
- # If it looks like a bundled binstub of origen exists, and we have not been invoked through that,
54
- # then run that instead.
55
- if Origen.site_config.gem_manage_bundler && File.exist?("#{origen_root}/lbin/origen") && !ENV['BUNDLE_BIN_PATH'] &&
56
- File.exist?(File.expand_path(Origen.site_config.gem_install_dir))
57
- exec Gem.ruby, "#{origen_root}/lbin/origen", *ARGV
58
- exit 0
59
- end
60
-
61
- boot_app = true
62
-
63
- # If running outside an application and a user or central tool Origen bundle is to be used
64
- elsif Origen.site_config.gem_manage_bundler && (Origen.site_config.user_install_enable || Origen.site_config.tool_repo_install_dir)
65
- # Force everyone to have a consistent way of installing gems with bundler.
66
- # In this case, we aren't running from an Origen application, so build everything at Origen.home instead
67
- # Have two options here: if user_install_enable is true, use user_install_dir. Otherwise, use the tool_repo_install_dir
68
- Origen.site_config.user_install_enable ? origen_root = File.expand_path(Origen.site_config.user_install_dir) : origen_root = File.expand_path(Origen.site_config.tool_repo_install_dir)
69
- unless Dir.exists?(origen_root)
70
- load File.expand_path('../../lib/origen/utility/input_capture.rb', __FILE__)
71
- include Origen::Utility::InputCapture
72
-
73
- puts "Root directory '#{origen_root}' does not exist. Would you like to create it?"
74
- if get_text(confirm: :return_boolean)
75
- FileUtils.mkdir(origen_root)
76
- else
77
- puts "Exiting with creating Origen install"
78
- exit!
79
- end
80
- end
81
-
82
- gemfile = File.join(origen_root, 'Gemfile')
83
- unless File.exists?(gemfile)
84
- # Create a default Gemfile that can be further customized by the user.
85
- # Initial Gemfile only requires Origen. Nothing else. Essentially a blank installation.
86
- Dir.chdir(origen_root) do
87
- `bundle init`
88
- end
89
- # The above will give a general Gemfile from Bundler. We'll just append "gem 'origen' to the end.
90
- File.open(gemfile, 'a') do |f|
91
- f << "gem 'origen'\n"
92
- end
93
- end
94
- ENV['BUNDLE_GEMFILE'] = gemfile
95
- ENV['BUNDLE_PATH'] = File.expand_path(Origen.site_config.gem_install_dir)
96
- ENV['BUNDLE_BIN'] = File.join(origen_root, 'lbin')
97
-
98
- origen_exec = File.join(ENV['BUNDLE_BIN'], 'origen')
99
-
100
- # If the user/tool bundle already exists but we have not been invoked through that, abort this thread
101
- # and re-launch under the required bundler environment
102
- if File.exist?(origen_exec) && !ENV['BUNDLE_BIN_PATH'] && File.exist?(ENV['BUNDLE_PATH'])
103
- exec Gem.ruby, origen_exec, *ARGV
104
- exit 0
105
- else
106
- boot_app = false
107
- end
108
- end
109
-
110
- if origen_root && File.exist?(ENV['BUNDLE_GEMFILE']) && Origen.site_config.gem_manage_bundler && (boot_app || Origen.site_config.user_install_enable || Origen.site_config.tool_repo_install_dir)
111
- # Overriding bundler here so that bundle install can be automated as required
112
- require 'bundler/shared_helpers'
113
- if Bundler::SharedHelpers.in_bundle?
114
- require 'bundler'
115
- if STDOUT.tty?
116
- begin
117
- fail OrigenBootError unless File.exist?(ENV['BUNDLE_BIN'])
118
- Bundler.setup
119
- fail OrigenBootError unless File.exist?(ENV['BUNDLE_BIN'])
120
- rescue Gem::LoadError, Bundler::BundlerError, OrigenBootError => e
121
- cmd = "bundle install --gemfile #{ENV['BUNDLE_GEMFILE']} --binstubs #{ENV['BUNDLE_BIN']} --path #{ENV['BUNDLE_PATH']}"
122
- # puts cmd
123
- puts 'Installing required gems...'
124
- puts
125
- `chmod o-w #{origen_root}` # Stops some annoying world writable warnings during install
126
- `chmod o-w #{origen_root}/bin` if File.exist?("#{origen_root}/bin")
127
- `chmod o-w #{origen_root}/.bin` if File.exist?("#{origen_root}/.bin")
128
- result = false
129
-
130
- Bundler.with_clean_env do
131
- if Origen.os.unix?
132
- if Origen.site_config.gem_build_switches
133
- Origen.site_config.gem_build_switches.each do |switches|
134
- `bundle config build.#{switches}`
135
- end
136
- end
137
- end
138
- result = system(cmd)
139
- end
140
- `chmod o-w #{ENV['BUNDLE_BIN']}`
141
- # Make .bat versions of all executables, Bundler should really be doing this when running
142
- # on windows
143
- if Origen.os.windows?
144
- bat_present = File.exist? "#{origen_root}/lbin/origen.bat"
145
- Dir.glob("#{origen_root}/lbin/*").each do |bin|
146
- unless bin =~ /.bat$/
147
- bat = "#{bin}.bat"
148
- unless File.exist?(bat)
149
- File.open(bat, 'w') { |f| f.write('@"ruby.exe" "%~dpn0" %*') }
150
- end
151
- end
152
- end
153
- if !bat_present && !result
154
- puts 'Some Windows specific updates to your workspace were required, please re-run the last command'
155
- exit 0
156
- end
157
- end
158
- if result
159
- exec "origen #{ARGV.join(' ')}"
160
- exit 0
161
- else
162
- puts
163
- puts "If you have just updated a gem version and are now getting an error that Bundler cannot find compatible versions for it then first try running 'bundle update <gemname>'."
164
- puts "For example if you have just changed the version of origen_core run 'bundle update origen_core'."
165
- exit 1
166
- end
167
- end
168
- else
169
- Bundler.setup
170
- end
171
- end
172
- require 'bundler/setup'
173
- _exec_remote = ARGV.include?('--exec_remote') ? true : false
174
- if Origen.site_config.use_bootsnap && !Origen.os.windows? && !_exec_remote
175
- ENV["BOOTSNAP_CACHE_DIR"] ||= "#{origen_root}/tmp/cache"
176
- require 'bootsnap/setup'
177
- end
178
- require 'origen'
179
- else
180
- $LOAD_PATH.unshift "#{File.expand_path(File.dirname(__FILE__))}/../lib"
181
- require 'origen'
182
- end
183
-
184
- begin
185
- # If this script has been invoked from within an Origen application then open
186
- # up all commands, if not then only allow the command to create a new Origen
187
- # application.
188
- if origen_root && boot_app
189
- require 'origen/commands'
190
- else
191
- require 'origen/commands_global'
192
- end
193
- rescue Exception => e
194
- # A formatted stack dump will not be printed if the application ends via 'exit 0' or 'exit 1'. In that
195
- # case the application code is responsible for printing a helpful error message.
196
- # This will intercept all other exits, e.g. via 'fail "Something has done wrong"', and split the stack
197
- # dump to separate all in-application references from Origen core/plugin references.
198
- if e.is_a?(SystemExit)
199
- exit e.status
200
- else
201
- puts
202
- if Origen.app_loaded?
203
- puts 'COMPLETE CALL STACK'
204
- puts '-------------------'
205
- puts e.message unless e.is_a?(SystemExit)
206
- puts e.backtrace
207
-
208
- puts
209
- puts 'APPLICATION CALL STACK'
210
- puts '----------------------'
211
- puts e.message unless e.is_a?(SystemExit)
212
- # Only print out the application stack trace by default, if verbose logging is
213
- # enabled then output the full thing
214
- e.backtrace.each do |line|
215
- path = Pathname.new(line)
216
- if path.absolute?
217
- if line =~ /^#{Origen.root}/ && line !~ /^#{Origen.root}\/lbin/
218
- puts line
219
- end
220
- else
221
- puts line unless line =~ /^.\/lbin/
222
- end
223
- end
224
- else
225
- puts 'COMPLETE CALL STACK'
226
- puts '-------------------'
227
- puts e.message unless e.is_a?(SystemExit)
228
- puts e.backtrace
229
- end
230
- exit 1
231
- end
232
- ensure
233
- if Origen.app_loaded?
234
- Origen.app.listeners_for(:on_origen_shutdown).each(&:on_origen_shutdown)
235
- Origen.app.runner.shutdown
236
- end
237
- end
2
+ load File.expand_path('../../lib/origen/boot.rb', __FILE__)
@@ -38,7 +38,8 @@ class OrigenCoreApplication < Origen::Application
38
38
 
39
39
  #config.lsf.project = "origen core"
40
40
 
41
- config.web_directory = "git@github.com:Origen-SDK/Origen-SDK.github.io.git/origen"
41
+ #config.web_directory = "git@github.com:Origen-SDK/Origen-SDK.github.io.git/origen"
42
+ config.web_directory = "https://github.com/Origen-SDK/Origen-SDK.github.io.git/origen"
42
43
  config.web_domain = "http://origen-sdk.org/origen"
43
44
 
44
45
  config.pattern_prefix = "nvm"
@@ -119,6 +120,14 @@ class OrigenCoreApplication < Origen::Application
119
120
  end
120
121
  end
121
122
 
123
+ def before_release_gem
124
+ Dir.chdir Origen.root do
125
+ FileUtils.rm_rf('origen_app_generators') if File.exist?('origen_app_generators')
126
+ FileUtils.cp_r(Origen.app(:origen_app_generators).root, 'origen_app_generators')
127
+ FileUtils.rm_rf(File.join('origen_app_generators', '.git'))
128
+ end
129
+ end
130
+
122
131
  # Ensure that all tests pass before allowing a release to continue
123
132
  def validate_release
124
133
  if !system("origen specs") || !system("origen examples")
data/config/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Origen
2
2
  MAJOR = 0
3
- MINOR = 38
3
+ MINOR = 40
4
4
  BUGFIX = 0
5
5
  DEV = nil
6
6
 
@@ -1,10 +1,10 @@
1
1
  # Helper methods here and in the required files can be used by Origen during the bootup process.
2
2
  # (e.g., in site config ERB files)
3
3
  # This can be expanded as needed to provide more helpers.
4
-
5
4
  module Origen
5
+ # NOTE: Gems are not allowed to be required here, only Ruby stlibs
6
6
  require 'socket'
7
- require_relative './operating_systems'
7
+ require_relative '../operating_systems'
8
8
 
9
9
  # Platform independent means of retrieving the hostname
10
10
  def self.hostname
@@ -0,0 +1,324 @@
1
+ require 'fileutils'
2
+ module Origen
3
+ # Provides methods for setting up, booting and
4
+ # archiving an Origen application
5
+ module Boot
6
+ # Gem executables that Origen depends on [bin name, gem name]
7
+ BIN_DEPS = [%w(rspec rspec-core), %w(nanoc nanoc), %w(yard yard),
8
+ %w(rubocop rubocop), %w(rake rake)]
9
+
10
+ BUNDLER_WARNING = '
11
+ From Origen 0.40.0 onwards, a new way of launching Origen is supported and
12
+ you are seeing this message because your application is still setup to run
13
+ the old way.
14
+
15
+ The main difference is that Origen is now launched via an Origen-owned binstub
16
+ (./lbin/origen) rather than a Bundler-owned binstub. This means that Origen can
17
+ no longer be prevented from running due to a Bundler configuration issue within
18
+ your workspace and it should mean that Origen invocation becomes more reliable.
19
+
20
+ It is recommended that you follow these instructions to upgrade your application
21
+ to the new system.
22
+
23
+ If have already done this and you are seeing this message again, then Bundler has
24
+ overwritten the binstub at ./lbin/origen and you should perform the upgrade again.
25
+
26
+ To upgrade, run the following command:
27
+
28
+ origen setup
29
+
30
+ If you ever run the `bundle` or `bundle install` commands manually, never use
31
+ the --binstubs option or it will roll you back to the old system.
32
+
33
+ Under the new system, you should check the `./lbin` directory into your source
34
+ control system, so remove it from your `.gitignore` (or equivalent) and check
35
+ it in.
36
+
37
+ When you install a new gem whose executable you want to use in your app,
38
+ generate a binstub for it via the following command:
39
+
40
+ origen new binstub some-gem-name
41
+
42
+ ______________________________________________________________________________________
43
+
44
+ '
45
+
46
+ BUNDLER_SETUP = %q(
47
+ if Origen.site_config.gem_manage_bundler
48
+ FileUtils.mkdir_p(File.join(origen_root, '.bundle'))
49
+ File.open(File.join(origen_root, '.bundle', 'config'), 'w') do |f|
50
+ f.puts '# Origen is managing this file, any local edits will be overwritten'
51
+ f.puts '# IT SHOULD NOT BE CHECKED INTO REVISION CONTROL!'
52
+ f.puts '---'
53
+ f.puts 'BUNDLE_BIN: false'
54
+ # If gems have been installed to the app, always use them
55
+ bundle_path = File.join(origen_root, 'vendor', 'gems')
56
+ if File.exist?(bundle_path)
57
+ # Only keep the gems we actually need when installing to the application, but
58
+ # don't do this when installing outside since other apps might use them
59
+ f.puts 'BUNDLE_CLEAN: true'
60
+ else
61
+ bundle_path = File.expand_path(Origen.site_config.gem_install_dir)
62
+ end
63
+ f.puts "BUNDLE_PATH: \"#{bundle_path}\""
64
+ Array(Origen.site_config.gem_build_switches).each do |build_switches|
65
+ switches = build_switches.strip.split(' ')
66
+ gem = switches.shift
67
+ f.puts "BUNDLE_BUILD__#{gem.upcase}: \"#{switches.join(' ')}\""
68
+ end
69
+ end
70
+ end
71
+ )
72
+
73
+ UPDATER_WARNING = '
74
+ The bin/fix_my_workspace script is not compatible with the new way that Origen is
75
+ launched and you should remove it from your application.
76
+
77
+ Do this by deleting bin/fix_my_workspace and also remove the origen_updater gem from
78
+ your application.
79
+
80
+ The command `origen setup` can be used in place of fix_my_workspace under the
81
+ new system, however the new system should be more robust and such workspace repairs
82
+ should no longer be required.
83
+
84
+ ______________________________________________________________________________________
85
+
86
+ '
87
+
88
+ if Origen.os.windows?
89
+ PATH_WARNING = %q(
90
+ Warning, your PATH does not contain ./lbin which is expected by Origen.
91
+ You can correct this by editing your system's PATH environment variable via:
92
+
93
+ (right-click) My Computer -> Properties -> Advanced system settings -> Environment Variables
94
+
95
+ Path is under System variables and add the following value to it:
96
+
97
+ .\lbin
98
+
99
+ ______________________________________________________________________________________
100
+
101
+ )
102
+
103
+ else
104
+ PATH_WARNING = %q(
105
+ Warning, your PATH does not contain ./lbin which is expected by Origen.
106
+ You can correct this by adding one of the following lines to the end of your
107
+ environment setup file:
108
+
109
+ In ~/.bashrc or ~/.bashrc.user: export PATH="./lbin:$PATH"'
110
+ In ~/.tcshrc or ~/.tcshrc.user: setenv PATH "./lbin:$PATH"'
111
+
112
+ ______________________________________________________________________________________
113
+
114
+ )
115
+ end
116
+
117
+ BINSTUB =
118
+ "#!/usr/bin/env ruby
119
+ #
120
+ # This file was generated by Origen.
121
+ #
122
+
123
+ require 'rubygems'
124
+
125
+ origen_lib = File.expand_path('../../lib/origen', Gem.bin_path('origen', 'origen'))
126
+ boot = File.join(origen_lib, 'boot.rb')
127
+ ORIGEN_ROOT = File.expand_path('..', __dir__)
128
+ origen_root = ORIGEN_ROOT
129
+
130
+ # If the Origen version supports the new boot system then use it
131
+ if File.exist?(boot)
132
+ load boot
133
+
134
+ # Otherwise fall back to an (improved) old-style invocation via Bundler
135
+ else
136
+ require 'pathname'
137
+ require 'fileutils'
138
+ $_origen_invocation_pwd = Pathname.pwd
139
+ require File.join(origen_lib, 'site_config')
140
+ " + BUNDLER_SETUP + %q(
141
+ bundle_binstub = File.expand_path('../bundle', __FILE__)
142
+
143
+ if File.file?(bundle_binstub)
144
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
145
+ load(bundle_binstub)
146
+ else
147
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
148
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
149
+ end
150
+ end
151
+ require 'bundler/setup'
152
+
153
+ load Gem.bin_path('origen', 'origen')
154
+ end
155
+ )
156
+ class << self
157
+ # Boot the application at the given root
158
+ def app!(origen_root)
159
+ # This will be used to collect warnings about the user's application environment, however showing them
160
+ # will be deferred until it has been determined that the application is using Origen >= 0.40.0 - i.e. we
161
+ # don't want to start complaining to the user about existing apps until they have intentionally upgraded
162
+ # their Origen version.
163
+ warnings = []
164
+
165
+ exec_remote = ARGV.include?('--exec_remote') ? true : false
166
+ lbin_dir = File.join(origen_root, 'lbin')
167
+ origen_binstub = File.join(lbin_dir, 'origen')
168
+
169
+ unless exec_remote
170
+ if Origen.os.windows?
171
+ warnings << PATH_WARNING unless ENV['PATH'] =~ /\.\\lbin(;|$)/
172
+ else
173
+ warnings << PATH_WARNING unless ENV['PATH'] =~ /(^|:)\.\/lbin(:|$)/
174
+ end
175
+
176
+ if !File.exist?(origen_binstub) ||
177
+ (File.exist?(origen_binstub) && File.read(origen_binstub) !~ /This file was generated by Origen/)
178
+ warnings << BUNDLER_WARNING
179
+ elsif File.exist?(File.join(origen_root, 'bin', 'fix_my_workspace'))
180
+ warnings << UPDATER_WARNING
181
+ end
182
+
183
+ setup_bundler(origen_root)
184
+ end
185
+
186
+ boot_app = true
187
+
188
+ Dir.chdir origen_root do
189
+ # Overriding bundler here so that bundle install can be automated as required, otherwise if just call
190
+ # require 'bundler/setup' then it will exit in the event of errors
191
+ require 'bundler'
192
+ begin
193
+ Bundler.setup
194
+ rescue Gem::LoadError, Bundler::BundlerError => e
195
+ puts e
196
+ puts
197
+ if exec_remote
198
+ puts 'App failed to boot, run it locally so that this can be resolved before re-submitting to the LSF'
199
+ exit 1
200
+ end
201
+ puts 'Attempting to resolve this...'
202
+ puts
203
+
204
+ passed = false
205
+
206
+ Bundler.with_clean_env do
207
+ cmd = 'bundle install'
208
+ cmd += ' --local' if File.exist?('.origen_archive')
209
+ passed = system(cmd)
210
+ end
211
+
212
+ if passed
213
+ Bundler.with_clean_env do
214
+ exec "origen #{ARGV.join(' ')}"
215
+ end
216
+ exit 0
217
+ else
218
+ puts
219
+ puts "If you have just updated a gem version and are now getting an error that Bundler cannot find compatible versions for it then first try running 'bundle update <gemname>'."
220
+ puts "For example if you have just changed the version of origen run 'bundle update origen'."
221
+ exit 1
222
+ end
223
+ end
224
+ end
225
+ unless exec_remote
226
+ # The application's bundle is safely loaded, do a final check to make sure that Origen's
227
+ # required bin dependencies have binstubs
228
+ if BIN_DEPS.any? { |bin, gem| !File.exist?(File.join(lbin_dir, bin)) }
229
+ system "bundle binstubs #{BIN_DEPS.map { |bin, gem| gem }.join(' ')} --path #{lbin_dir} --force"
230
+ end
231
+ if Origen.site_config.use_bootsnap && !Origen.os.windows?
232
+ ENV['BOOTSNAP_CACHE_DIR'] ||= "#{origen_root}/tmp/cache"
233
+ require 'bootsnap/setup'
234
+ end
235
+ end
236
+ require 'origen'
237
+ warnings
238
+ end
239
+
240
+ def setup(origen_root)
241
+ create_origen_binstub(origen_root)
242
+ bundle_path = setup_bundler(origen_root)
243
+ unless File.exist?(File.join(origen_root, '.origen_archive'))
244
+ copy_system_gems(origen_root, bundle_path)
245
+ end
246
+ end
247
+
248
+ def create_origen_binstub(origen_root)
249
+ lbin_dir = File.join(origen_root, 'lbin')
250
+
251
+ FileUtils.mkdir_p(lbin_dir)
252
+ File.open(File.join(lbin_dir, 'origen'), 'w') do |f|
253
+ f.puts BINSTUB
254
+ end
255
+ FileUtils.chmod('+x', File.join(lbin_dir, 'origen'))
256
+
257
+ if Origen.os.windows?
258
+ Dir.glob("#{origen_root}/lbin/*").each do |bin|
259
+ unless bin =~ /.bat$/
260
+ bat = "#{bin}.bat"
261
+ unless File.exist?(bat)
262
+ File.open(bat, 'w') { |f| f.write('@"ruby.exe" "%~dpn0" %*') }
263
+ end
264
+ end
265
+ end
266
+ end
267
+ end
268
+
269
+ def setup_bundler(origen_root)
270
+ bundle_path = nil
271
+ eval BUNDLER_SETUP # Will update bundle_path
272
+ bundle_path
273
+ end
274
+
275
+ def copy_system_gems(origen_root, bundle_path)
276
+ require 'byebug'
277
+ if Origen.site_config.gem_use_from_system
278
+ local_gem_dir = "#{bundle_path}/ruby/#{Pathname.new(Gem.dir).basename}"
279
+ gem_dir = Pathname.new(Gem.dir)
280
+
281
+ Origen.site_config.gem_use_from_system.each do |gem, version|
282
+ begin
283
+ # This will raise an error if the system doesn't have this gem installed, that
284
+ # will be rescued below
285
+ spec = Gem::Specification.find_by_name(gem, version)
286
+
287
+ # If the spec has returned a handle to a system installed gem. If this script has been invoked through
288
+ # Bundler then it could point to some other gem dir. The only time this should occur is when switching
289
+ # from the old system to the new system, but can't work out how to fix it so just disabling in that case.
290
+ if spec.gem_dir =~ /#{gem_dir}/
291
+
292
+ local_dir = File.join(local_gem_dir, Pathname.new(spec.gem_dir).relative_path_from(gem_dir))
293
+ FileUtils.mkdir_p local_dir
294
+ FileUtils.cp_r("#{spec.gem_dir}/.", local_dir)
295
+
296
+ local_file = Pathname.new(File.join(local_gem_dir, Pathname.new(spec.cache_file).relative_path_from(gem_dir)))
297
+ FileUtils.mkdir_p local_file.dirname
298
+ FileUtils.cp(spec.cache_file, local_file)
299
+
300
+ if spec.extension_dir && File.exist?(spec.extension_dir)
301
+ local_dir = File.join(local_gem_dir, Pathname.new(spec.extension_dir).relative_path_from(gem_dir))
302
+ FileUtils.mkdir_p local_dir
303
+ FileUtils.cp_r("#{spec.extension_dir}/.", local_dir)
304
+ end
305
+
306
+ local_file = Pathname.new(File.join(local_gem_dir, Pathname.new(spec.spec_file).relative_path_from(gem_dir)))
307
+ FileUtils.mkdir_p local_file.dirname
308
+ FileUtils.cp(spec.spec_file, local_file)
309
+
310
+ puts "Copied #{gem} #{version} from the system into #{bundle_path}"
311
+
312
+ end
313
+
314
+ rescue Exception # Gem::LoadError # Rescue everything here, this is a try-our-best operation, better to
315
+ # continue and try and install the gem if this fails rather than crash
316
+ # This just means that one of the gems that should be copied from the system
317
+ # was not actually installed in the system, so nothing we can do about that here
318
+ end
319
+ end
320
+ end
321
+ end
322
+ end
323
+ end
324
+ end