origen 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ctags +0 -0
- data/bin/origen +165 -1
- data/bin/rgen +2 -0
- data/config/application.rb +141 -0
- data/config/commands.rb +72 -0
- data/config/development.rb +7 -0
- data/config/environment.rb +0 -0
- data/config/rgen.policy +7 -0
- data/config/rubocop/easy.yml +620 -0
- data/config/rubocop/easy_disabled.yml +271 -0
- data/config/rubocop/easy_enabled.yml +731 -0
- data/config/rubocop/strict.yml +620 -0
- data/config/rubocop/strict_disabled.yml +247 -0
- data/config/rubocop/strict_enabled.yml +755 -0
- data/config/users.rb +20 -0
- data/config/version.rb +1 -1
- data/helpers/url.rb +68 -0
- data/lib/c99/doc_interface.rb +56 -0
- data/lib/c99/j750_interface.rb +85 -0
- data/lib/c99/nvm.rb +89 -0
- data/lib/c99/target/mock2.rb +1 -0
- data/lib/c99/target/subdir/mock3.rb +1 -0
- data/lib/option_parser/optparse.rb +12 -0
- data/lib/origen/acronyms.rb +60 -0
- data/lib/origen/application/command_dispatcher.rb +12 -0
- data/lib/origen/application/configuration.rb +206 -0
- data/lib/origen/application/configuration_manager.rb +78 -0
- data/lib/origen/application/deployer.rb +367 -0
- data/lib/origen/application/environment.rb +186 -0
- data/lib/origen/application/lsf.rb +145 -0
- data/lib/origen/application/lsf_manager.rb +657 -0
- data/lib/origen/application/plugins_manager.rb +280 -0
- data/lib/origen/application/release.rb +359 -0
- data/lib/origen/application/runner.rb +246 -0
- data/lib/origen/application/statistics.rb +191 -0
- data/lib/origen/application/target.rb +374 -0
- data/lib/origen/application/version_tracker.rb +59 -0
- data/lib/origen/application/workspace_manager.rb +151 -0
- data/lib/origen/application.rb +746 -0
- data/lib/origen/bugs/bug.rb +36 -0
- data/lib/origen/bugs.rb +45 -0
- data/lib/origen/callbacks.rb +35 -0
- data/lib/origen/chip_mode.rb +118 -0
- data/lib/origen/chip_package.rb +461 -0
- data/lib/origen/client.rb +87 -0
- data/lib/origen/code_generators/actions.rb +258 -0
- data/lib/origen/code_generators/base.rb +57 -0
- data/lib/origen/code_generators/bundler.rb +17 -0
- data/lib/origen/code_generators/gem_setup.rb +49 -0
- data/lib/origen/code_generators/rake.rb +13 -0
- data/lib/origen/code_generators/rspec.rb +12 -0
- data/lib/origen/code_generators/semver.rb +39 -0
- data/lib/origen/code_generators/timever.rb +37 -0
- data/lib/origen/code_generators.rb +111 -0
- data/lib/origen/commands/add.rb +12 -0
- data/lib/origen/commands/compile.rb +62 -0
- data/lib/origen/commands/ctags.rb +9 -0
- data/lib/origen/commands/dispatch.rb +22 -0
- data/lib/origen/commands/environment.rb +11 -0
- data/lib/origen/commands/fetch.rb +63 -0
- data/lib/origen/commands/generate.rb +130 -0
- data/lib/origen/commands/interactive.rb +73 -0
- data/lib/origen/commands/lint.rb +82 -0
- data/lib/origen/commands/lsf.rb +93 -0
- data/lib/origen/commands/merge.rb +55 -0
- data/lib/origen/commands/modifications.rb +12 -0
- data/lib/origen/commands/new.rb +113 -0
- data/lib/origen/commands/plugin.rb +105 -0
- data/lib/origen/commands/program.rb +70 -0
- data/lib/origen/commands/rc.rb +442 -0
- data/lib/origen/commands/save.rb +56 -0
- data/lib/origen/commands/target.rb +27 -0
- data/lib/origen/commands/time.rb +127 -0
- data/lib/origen/commands/version.rb +17 -0
- data/lib/origen/commands/web.rb +221 -0
- data/lib/origen/commands.rb +272 -0
- data/lib/origen/commands_global.rb +76 -0
- data/lib/origen/controller.rb +94 -0
- data/lib/origen/core_ext/array.rb +23 -0
- data/lib/origen/core_ext/bignum.rb +36 -0
- data/lib/origen/core_ext/enumerable.rb +76 -0
- data/lib/origen/core_ext/fixnum.rb +46 -0
- data/lib/origen/core_ext/hash.rb +52 -0
- data/lib/origen/core_ext/module.rb +14 -0
- data/lib/origen/core_ext/numeric.rb +126 -0
- data/lib/origen/core_ext/object.rb +13 -0
- data/lib/origen/core_ext/range.rb +7 -0
- data/lib/origen/core_ext/string.rb +124 -0
- data/lib/origen/core_ext.rb +10 -0
- data/lib/origen/database/key_value_store.rb +111 -0
- data/lib/origen/database/key_value_stores.rb +108 -0
- data/lib/origen/database.rb +6 -0
- data/lib/origen/encodings.rb +102 -0
- data/lib/origen/features/feature.rb +22 -0
- data/lib/origen/features.rb +104 -0
- data/lib/origen/file_handler.rb +429 -0
- data/lib/origen/generator/comparator.rb +56 -0
- data/lib/origen/generator/compiler.rb +277 -0
- data/lib/origen/generator/flow.rb +49 -0
- data/lib/origen/generator/job.rb +131 -0
- data/lib/origen/generator/pattern.rb +356 -0
- data/lib/origen/generator/pattern_finder.rb +155 -0
- data/lib/origen/generator/pattern_iterator.rb +55 -0
- data/lib/origen/generator/renderer.rb +113 -0
- data/lib/origen/generator/resources.rb +40 -0
- data/lib/origen/generator/stage.rb +89 -0
- data/lib/origen/generator.rb +85 -0
- data/lib/origen/global_methods.rb +205 -0
- data/lib/origen/import_manager.rb +596 -0
- data/lib/origen/location/base.rb +116 -0
- data/lib/origen/location/map.rb +83 -0
- data/lib/origen/location.rb +6 -0
- data/lib/origen/log.rb +217 -0
- data/lib/origen/logger_methods.rb +56 -0
- data/lib/origen/mode.rb +61 -0
- data/lib/origen/model.rb +267 -0
- data/lib/origen/model_initializer.rb +45 -0
- data/lib/origen/nvm/block_array.rb +72 -0
- data/lib/origen/nvm.rb +6 -0
- data/lib/origen/parameters/live.rb +22 -0
- data/lib/origen/parameters/missing.rb +28 -0
- data/lib/origen/parameters/set.rb +144 -0
- data/lib/origen/parameters.rb +107 -0
- data/lib/origen/pdm.rb +218 -0
- data/lib/origen/pins/function_proxy.rb +36 -0
- data/lib/origen/pins/ground_pin.rb +6 -0
- data/lib/origen/pins/pin.rb +860 -0
- data/lib/origen/pins/pin_bank.rb +349 -0
- data/lib/origen/pins/pin_clock.rb +124 -0
- data/lib/origen/pins/pin_collection.rb +492 -0
- data/lib/origen/pins/pin_common.rb +206 -0
- data/lib/origen/pins/port.rb +268 -0
- data/lib/origen/pins/power_pin.rb +30 -0
- data/lib/origen/pins.rb +696 -0
- data/lib/origen/registers/bit.rb +562 -0
- data/lib/origen/registers/bit_collection.rb +787 -0
- data/lib/origen/registers/container.rb +288 -0
- data/lib/origen/registers/domain.rb +16 -0
- data/lib/origen/registers/reg.rb +1406 -0
- data/lib/origen/registers/reg_collection.rb +24 -0
- data/lib/origen/registers.rb +652 -0
- data/lib/origen/regression_manager.rb +251 -0
- data/lib/origen/remote_manager.rb +340 -0
- data/lib/origen/revision_control/base.rb +257 -0
- data/lib/origen/revision_control/design_sync.rb +276 -0
- data/lib/origen/revision_control/git.rb +243 -0
- data/lib/origen/revision_control/subversion.rb +6 -0
- data/lib/origen/revision_control.rb +44 -0
- data/lib/origen/ruby_version_check.rb +131 -0
- data/lib/origen/site_config.rb +61 -0
- data/lib/origen/specs/checkers.rb +103 -0
- data/lib/origen/specs/creation_info.rb +17 -0
- data/lib/origen/specs/doc_resource.rb +91 -0
- data/lib/origen/specs/exhibit.rb +17 -0
- data/lib/origen/specs/mode_select.rb +16 -0
- data/lib/origen/specs/note.rb +17 -0
- data/lib/origen/specs/override.rb +21 -0
- data/lib/origen/specs/power_supply.rb +13 -0
- data/lib/origen/specs/spec.rb +226 -0
- data/lib/origen/specs/version_history.rb +14 -0
- data/lib/origen/specs.rb +552 -0
- data/lib/origen/sub_blocks.rb +298 -0
- data/lib/origen/tester/api.rb +277 -0
- data/lib/origen/tester/bdm/bdm.rb +25 -0
- data/lib/origen/tester/command_based_tester.rb +46 -0
- data/lib/origen/tester/doc/doc.rb +226 -0
- data/lib/origen/tester/doc/generator/flow.rb +71 -0
- data/lib/origen/tester/doc/generator/flow_line.rb +203 -0
- data/lib/origen/tester/doc/generator/test.rb +68 -0
- data/lib/origen/tester/doc/generator/test_group.rb +66 -0
- data/lib/origen/tester/doc/generator/tests.rb +47 -0
- data/lib/origen/tester/doc/generator.rb +126 -0
- data/lib/origen/tester/doc/model.rb +162 -0
- data/lib/origen/tester/generator/flow_control_api.rb +606 -0
- data/lib/origen/tester/generator/identity_map.rb +25 -0
- data/lib/origen/tester/generator/placeholder.rb +13 -0
- data/lib/origen/tester/generator/test_numberer.rb +25 -0
- data/lib/origen/tester/generator.rb +271 -0
- data/lib/origen/tester/interface.rb +154 -0
- data/lib/origen/tester/j750/files.rb +45 -0
- data/lib/origen/tester/j750/generator/flow.rb +123 -0
- data/lib/origen/tester/j750/generator/flow_line.rb +288 -0
- data/lib/origen/tester/j750/generator/patgroup.rb +111 -0
- data/lib/origen/tester/j750/generator/patgroups.rb +41 -0
- data/lib/origen/tester/j750/generator/patset.rb +111 -0
- data/lib/origen/tester/j750/generator/patsets.rb +41 -0
- data/lib/origen/tester/j750/generator/templates/flow.txt.erb +9 -0
- data/lib/origen/tester/j750/generator/templates/instances.txt.erb +16 -0
- data/lib/origen/tester/j750/generator/templates/patgroups.txt.erb +8 -0
- data/lib/origen/tester/j750/generator/templates/patsets.txt.erb +10 -0
- data/lib/origen/tester/j750/generator/test_instance.rb +846 -0
- data/lib/origen/tester/j750/generator/test_instance_group.rb +60 -0
- data/lib/origen/tester/j750/generator/test_instances.rb +182 -0
- data/lib/origen/tester/j750/generator.rb +203 -0
- data/lib/origen/tester/j750/j750.rb +845 -0
- data/lib/origen/tester/j750/j750_hpt.rb +35 -0
- data/lib/origen/tester/j750/parser/ac_spec.rb +11 -0
- data/lib/origen/tester/j750/parser/ac_specs.rb +0 -0
- data/lib/origen/tester/j750/parser/dc_spec.rb +36 -0
- data/lib/origen/tester/j750/parser/dc_specs.rb +50 -0
- data/lib/origen/tester/j750/parser/descriptions.rb +340 -0
- data/lib/origen/tester/j750/parser/flow.rb +111 -0
- data/lib/origen/tester/j750/parser/flow_line.rb +207 -0
- data/lib/origen/tester/j750/parser/flows.rb +23 -0
- data/lib/origen/tester/j750/parser/pattern_set.rb +94 -0
- data/lib/origen/tester/j750/parser/pattern_sets.rb +33 -0
- data/lib/origen/tester/j750/parser/test_instance.rb +322 -0
- data/lib/origen/tester/j750/parser/test_instances.rb +26 -0
- data/lib/origen/tester/j750/parser/timeset.rb +15 -0
- data/lib/origen/tester/j750/parser/timesets.rb +0 -0
- data/lib/origen/tester/j750/parser.rb +104 -0
- data/lib/origen/tester/jlink/jlink.rb +33 -0
- data/lib/origen/tester/parser/description_lookup.rb +64 -0
- data/lib/origen/tester/parser/searchable_array.rb +32 -0
- data/lib/origen/tester/parser/searchable_hash.rb +32 -0
- data/lib/origen/tester/parser.rb +24 -0
- data/lib/origen/tester/time.rb +338 -0
- data/lib/origen/tester/timing.rb +253 -0
- data/lib/origen/tester/ultraflex/files.rb +45 -0
- data/lib/origen/tester/ultraflex/generator/flow.rb +119 -0
- data/lib/origen/tester/ultraflex/generator/flow_line.rb +269 -0
- data/lib/origen/tester/ultraflex/generator/patgroup.rb +111 -0
- data/lib/origen/tester/ultraflex/generator/patgroups.rb +41 -0
- data/lib/origen/tester/ultraflex/generator/patset.rb +111 -0
- data/lib/origen/tester/ultraflex/generator/patsets.rb +41 -0
- data/lib/origen/tester/ultraflex/generator/templates/flow.txt.erb +9 -0
- data/lib/origen/tester/ultraflex/generator/templates/instances.txt.erb +16 -0
- data/lib/origen/tester/ultraflex/generator/templates/patgroups.txt.erb +8 -0
- data/lib/origen/tester/ultraflex/generator/templates/patsets.txt.erb +10 -0
- data/lib/origen/tester/ultraflex/generator/test_instance.rb +622 -0
- data/lib/origen/tester/ultraflex/generator/test_instance_group.rb +60 -0
- data/lib/origen/tester/ultraflex/generator/test_instances.rb +174 -0
- data/lib/origen/tester/ultraflex/generator.rb +200 -0
- data/lib/origen/tester/ultraflex/parser/ac_spec.rb +11 -0
- data/lib/origen/tester/ultraflex/parser/ac_specs.rb +0 -0
- data/lib/origen/tester/ultraflex/parser/dc_spec.rb +36 -0
- data/lib/origen/tester/ultraflex/parser/dc_specs.rb +50 -0
- data/lib/origen/tester/ultraflex/parser/descriptions.rb +342 -0
- data/lib/origen/tester/ultraflex/parser/flow.rb +111 -0
- data/lib/origen/tester/ultraflex/parser/flow_line.rb +207 -0
- data/lib/origen/tester/ultraflex/parser/flows.rb +23 -0
- data/lib/origen/tester/ultraflex/parser/pattern_set.rb +94 -0
- data/lib/origen/tester/ultraflex/parser/pattern_sets.rb +33 -0
- data/lib/origen/tester/ultraflex/parser/test_instance.rb +262 -0
- data/lib/origen/tester/ultraflex/parser/test_instances.rb +26 -0
- data/lib/origen/tester/ultraflex/parser/timeset.rb +15 -0
- data/lib/origen/tester/ultraflex/parser/timesets.rb +0 -0
- data/lib/origen/tester/ultraflex/parser.rb +104 -0
- data/lib/origen/tester/ultraflex/ultraflex.rb +759 -0
- data/lib/origen/tester/v93k/generator/flow.rb +63 -0
- data/lib/origen/tester/v93k/generator/flow_node/print.rb +10 -0
- data/lib/origen/tester/v93k/generator/flow_node.rb +17 -0
- data/lib/origen/tester/v93k/generator/pattern.rb +16 -0
- data/lib/origen/tester/v93k/generator/pattern_master.rb +54 -0
- data/lib/origen/tester/v93k/generator/templates/_test_method.txt.erb +6 -0
- data/lib/origen/tester/v93k/generator/templates/_test_suite.txt.erb +11 -0
- data/lib/origen/tester/v93k/generator/templates/template.flow.erb +121 -0
- data/lib/origen/tester/v93k/generator/templates/template.pmfl.erb +9 -0
- data/lib/origen/tester/v93k/generator/test_function.rb +103 -0
- data/lib/origen/tester/v93k/generator/test_functions.rb +79 -0
- data/lib/origen/tester/v93k/generator/test_method.rb +46 -0
- data/lib/origen/tester/v93k/generator/test_methods.rb +75 -0
- data/lib/origen/tester/v93k/generator/test_suite.rb +54 -0
- data/lib/origen/tester/v93k/generator/test_suites.rb +65 -0
- data/lib/origen/tester/v93k/generator.rb +80 -0
- data/lib/origen/tester/v93k/v93k.rb +420 -0
- data/lib/origen/tester/vector.rb +86 -0
- data/lib/origen/tester/vector_generator.rb +633 -0
- data/lib/origen/tester/vector_pipeline.rb +150 -0
- data/lib/origen/tester.rb +56 -0
- data/lib/origen/top_level.rb +134 -0
- data/lib/origen/users/ldap.rb +65 -0
- data/lib/origen/users/user.rb +149 -0
- data/lib/origen/users.rb +30 -0
- data/lib/origen/utility/block_args.rb +93 -0
- data/lib/origen/utility/csv_data.rb +110 -0
- data/lib/origen/utility/design_sync.rb +494 -0
- data/lib/origen/utility/diff.rb +158 -0
- data/lib/origen/utility/input_capture.rb +121 -0
- data/lib/origen/utility/mailer.rb +143 -0
- data/lib/origen/utility/s_record.rb +205 -0
- data/lib/origen/utility/time_and_date.rb +30 -0
- data/lib/origen/utility.rb +12 -0
- data/lib/origen/version_checker.rb +117 -0
- data/lib/origen/version_string.rb +356 -0
- data/lib/origen.rb +648 -0
- data/lib/tasks/gem.rake +27 -22
- data/origen_site_config.yml +36 -0
- data/source_setup +17 -0
- data/spec/format/rgen_formatter.rb +14 -0
- data/templates/api_doc/README.txt.erb +24 -0
- data/templates/code_generators/gemfile_app.rb +4 -0
- data/templates/code_generators/gemfile_plugin.rb +6 -0
- data/templates/code_generators/gemspec.rb +33 -0
- data/templates/code_generators/rakefile.rb +10 -0
- data/templates/code_generators/spec_helper.rb +49 -0
- data/templates/code_generators/version.rb +8 -0
- data/templates/code_generators/version_time.rb +3 -0
- data/templates/git/gitignore.erb +33 -0
- data/templates/j750/_vt_flow.txt.erb +8 -0
- data/templates/j750/_vt_instances.txt.erb +4 -0
- data/templates/j750/program_sheet.txt.erb +9 -0
- data/templates/nanoc/Rules +74 -0
- data/templates/nanoc/config.yaml +77 -0
- data/templates/nanoc/content/favicon.ico +0 -0
- data/templates/nanoc/layouts/bootstrap.html.erb +63 -0
- data/templates/nanoc/layouts/bootstrap3.html.erb +71 -0
- data/templates/nanoc/layouts/freescale.html.erb +79 -0
- data/templates/nanoc/lib/bootstrap_filter.rb +49 -0
- data/templates/nanoc/lib/codeblocks_filter.rb +41 -0
- data/templates/nanoc/lib/default.rb +2 -0
- data/templates/nanoc/lib/gzip_filter.rb +16 -0
- data/templates/nanoc/lib/haml_code_filter.rb +41 -0
- data/templates/nanoc/lib/helpers.rb +1 -0
- data/templates/nanoc/lib/search_filter.rb +62 -0
- data/templates/nanoc_dynamic/content/search.js.erb +92 -0
- data/templates/shared/web/_logo.html +10 -0
- data/templates/test/_inline_sub.txt.erb +2 -0
- data/templates/test/environment.txt.erb +1 -0
- data/templates/test/inline.txt.erb +11 -0
- data/templates/test/inspections.txt.erb +19 -0
- data/templates/test/set1/_sub1.txt.erb +12 -0
- data/templates/test/set1/_sub4.txt.erb +1 -0
- data/templates/test/set1/_sub5.txt.erb +1 -0
- data/templates/test/set1/main.txt.erb +53 -0
- data/templates/test/set1/sub_dir/_sub2.txt.erb +20 -0
- data/templates/test/set1/sub_dir/_sub3.txt.erb +12 -0
- data/templates/test/set1/sub_dir/main2.txt.erb +4 -0
- data/templates/test/set2/template_with_no_erb_1.txt +9 -0
- data/templates/test/set2/template_with_no_erb_2.txt +9 -0
- data/templates/test/set3/_layout.html.erb +4 -0
- data/templates/test/set3/content.html.erb +6 -0
- data/templates/time/filter.rb.erb +15 -0
- data/templates/time/rules.rb.erb +45 -0
- metadata +639 -5
@@ -0,0 +1,429 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
module Origen
|
4
|
+
# All logic for working with files/directories and resolving path names
|
5
|
+
# should be included here.
|
6
|
+
#
|
7
|
+
# An instance of this class is available as Origen.file_handler
|
8
|
+
#
|
9
|
+
# Some portions of Origen may implement local code to do this, but these
|
10
|
+
# should all be transitioned to use this over time.
|
11
|
+
class FileHandler
|
12
|
+
attr_accessor :default_extension
|
13
|
+
|
14
|
+
# Returns an array of file/pattern names lines from a list file.
|
15
|
+
# This will also take care of recursively expanding any embedded
|
16
|
+
# list references.
|
17
|
+
def expand_list(files, options = {})
|
18
|
+
[files].flatten.map do |file|
|
19
|
+
f = file.strip
|
20
|
+
# Takes care of blank or comment lines in a list file
|
21
|
+
if f.empty? || f =~ /^\s*#/
|
22
|
+
nil
|
23
|
+
# Don't expand program lists when submitting to lsf,
|
24
|
+
# there are likely to be relational dependencies between
|
25
|
+
# flows meaning that they must be generated together
|
26
|
+
elsif is_a_list?(f) && !(options[:lsf] && options[:action] == :program)
|
27
|
+
expand_list(open_list(f), options)
|
28
|
+
else
|
29
|
+
f
|
30
|
+
end
|
31
|
+
end.flatten.compact.uniq
|
32
|
+
end
|
33
|
+
|
34
|
+
# Returns the contents of the given list file in an array, if it
|
35
|
+
# can be found, if not will raise an error
|
36
|
+
def open_list(file)
|
37
|
+
f = clean_path_to(file, allow_missing: true)
|
38
|
+
if f
|
39
|
+
f = File.open(f, 'r')
|
40
|
+
elsif File.exist?("#{Origen.root}/list/#{File.basename(file)}")
|
41
|
+
f = File.open("#{Origen.root}/list/#{File.basename(file)}", 'r')
|
42
|
+
elsif @last_opened_list_dir && File.exist?("#{@last_opened_list_dir}/#{file}")
|
43
|
+
f = File.open("#{@last_opened_list_dir}/#{file}", 'r')
|
44
|
+
else
|
45
|
+
fail "Could not find list file: #{file}"
|
46
|
+
end
|
47
|
+
lines = f.readlines
|
48
|
+
f.close
|
49
|
+
# Before we go save the directory of this list, this will help
|
50
|
+
# us to resolve any relative path references to other lists that
|
51
|
+
# it may contain
|
52
|
+
@last_opened_list_dir = clean_path_to(Pathname.new(f).dirname)
|
53
|
+
lines
|
54
|
+
end
|
55
|
+
|
56
|
+
# Returns true if the input argument is a list, for now this is
|
57
|
+
# simply defined by the filename ending in .list
|
58
|
+
def is_a_list?(file)
|
59
|
+
!!(file =~ /list$/)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Yields absolute paths to the given file or directory. If a directory is supplied
|
63
|
+
# the method will recurse into the sub directories and ultimately yield
|
64
|
+
# every file contained within the directory and its children.
|
65
|
+
def resolve_files(file_or_dir_path, options = {}, &block)
|
66
|
+
options = {
|
67
|
+
# Set to :template when calling to consider references to template
|
68
|
+
# files from an import library
|
69
|
+
import: false
|
70
|
+
}.merge(options)
|
71
|
+
[file_or_dir_path].flatten.each do |file_or_dir_path|
|
72
|
+
path = inject_import_path(file_or_dir_path, type: options[:import]) if options[:import]
|
73
|
+
path = clean_path_to(file_or_dir_path, options)
|
74
|
+
self.base_directory = path unless options[:internal_call]
|
75
|
+
if path.directory?
|
76
|
+
Dir.glob("#{path}/*").sort.each do |file|
|
77
|
+
resolve_files(file, { internal_call: true }.merge(options), &block)
|
78
|
+
end
|
79
|
+
else
|
80
|
+
# Ignore files with the given prefix if supplied, but only if this is a file that
|
81
|
+
# has been found, if explicitly asked to compile a file from the caller do it regardless
|
82
|
+
if options[:ignore_with_prefix] && options[:internal_call]
|
83
|
+
return nil if path.basename.to_s =~ /^#{options[:ignore_with_prefix]}/
|
84
|
+
end
|
85
|
+
yield path
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# Returns a full path to the given file or directory, raises an error if it
|
91
|
+
# can't be resolved
|
92
|
+
def clean_path_to(file, options = {})
|
93
|
+
# Allow individual calls to this method to specify additional custom load paths to consider
|
94
|
+
if options[:load_paths]
|
95
|
+
[options[:load_paths]].each do |root|
|
96
|
+
if File.exist?("#{root}/#{file}")
|
97
|
+
return Pathname.new("#{root}/#{file}")
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
if File.exist?(file)
|
102
|
+
if Pathname.new(file).absolute?
|
103
|
+
Pathname.new(file)
|
104
|
+
else
|
105
|
+
Pathname.new("#{Pathname.pwd}/#{file}")
|
106
|
+
end
|
107
|
+
# Is it a relative reference within a list file?
|
108
|
+
elsif @last_opened_list_dir && File.exist?("#{@last_opened_list_dir}/#{file}")
|
109
|
+
Pathname.new("#{@last_opened_list_dir}/#{file}")
|
110
|
+
# Is it a relative reference to the current base directory?
|
111
|
+
elsif File.exist?("#{base_directory}/#{file}")
|
112
|
+
Pathname.new("#{base_directory}/#{file}")
|
113
|
+
# Is it a path relative to Origen.root?
|
114
|
+
elsif File.exist?("#{Origen.root}/#{file}")
|
115
|
+
Pathname.new("#{Origen.root}/#{file}")
|
116
|
+
# Is it a path relative to the current directory?
|
117
|
+
elsif current_directory && File.exist?("#{current_directory}/#{file}")
|
118
|
+
Pathname.new("#{current_directory}/#{file}")
|
119
|
+
# Is it a path relative to the current plugin's Origen.root?
|
120
|
+
elsif Origen.current_plugin.instance && File.exist?("#{Origen.current_plugin.instance.root}/#{file}")
|
121
|
+
Pathname.new("#{Origen.current_plugin.instance.root}/#{file}")
|
122
|
+
elsif options[:default_dir]
|
123
|
+
m = all_matches(file, options)
|
124
|
+
if m
|
125
|
+
Pathname.new(m)
|
126
|
+
else
|
127
|
+
if options[:allow_missing]
|
128
|
+
return nil
|
129
|
+
else
|
130
|
+
fail "Can't find: #{file}"
|
131
|
+
end
|
132
|
+
end
|
133
|
+
else
|
134
|
+
if options[:allow_missing]
|
135
|
+
return nil
|
136
|
+
else
|
137
|
+
fail "Can't find: #{file}"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def check(path)
|
143
|
+
file_plugin = Origen.import_manager.path_within_a_plugin(path)
|
144
|
+
if file_plugin
|
145
|
+
if Origen.current_plugin.name
|
146
|
+
if file_plugin == Origen.current_plugin.name
|
147
|
+
return path
|
148
|
+
else
|
149
|
+
puts "The requested file is from plugin #{file_plugin} and current system plugin is set to plugin #{Origen.current_plugin.name}!"
|
150
|
+
fail 'Incorrect plugin error!'
|
151
|
+
end
|
152
|
+
else
|
153
|
+
Origen.current_plugin.temporary = file_plugin
|
154
|
+
return path
|
155
|
+
end
|
156
|
+
else
|
157
|
+
return path
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
def all_matches(file, options)
|
162
|
+
if Origen.current_plugin.name
|
163
|
+
matches = Dir.glob("#{options[:default_dir]}/#{Origen.current_plugin.name}/**/#{file}").sort
|
164
|
+
matches = matches.flatten.uniq
|
165
|
+
if matches.size == 0
|
166
|
+
matches = Dir.glob("#{options[:default_dir]}/**/#{file}").sort
|
167
|
+
matches = matches.flatten.uniq
|
168
|
+
end
|
169
|
+
else
|
170
|
+
matches = (Dir.glob("#{options[:default_dir]}/**/#{file}") + # Avoids symlinks
|
171
|
+
Dir.glob("#{options[:default_dir]}/#{file}")).sort
|
172
|
+
if matches.size == 0
|
173
|
+
matches = Dir.glob("#{options[:default_dir]}/**{,/*/**}/#{file}").sort # Takes symlinks into consideration
|
174
|
+
matches = matches.flatten.uniq
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
if matches.size == 0
|
179
|
+
return nil
|
180
|
+
elsif matches.size > 1
|
181
|
+
puts 'The following matches were found:'
|
182
|
+
puts matches
|
183
|
+
fail "Ambiguous file #{file}"
|
184
|
+
else
|
185
|
+
return check(matches.first)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
# Returns an absolute path for the given
|
190
|
+
def relative_to_absolute(path)
|
191
|
+
if Pathname.new(path).absolute?
|
192
|
+
Pathname.new(path)
|
193
|
+
else
|
194
|
+
Pathname.new("#{Pathname.pwd}/#{path}")
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def relative_path_to(path)
|
199
|
+
clean_path_to(path).relative_path_from(Pathname.pwd)
|
200
|
+
end
|
201
|
+
|
202
|
+
def clean_path_to_sub_template(file)
|
203
|
+
if File.exist?(file)
|
204
|
+
if Pathname.new(file).absolute?
|
205
|
+
return Pathname.new(file)
|
206
|
+
else
|
207
|
+
return Pathname.new("#{Pathname.pwd}/#{file}")
|
208
|
+
end
|
209
|
+
end
|
210
|
+
file = inject_import_path(file, type: :template)
|
211
|
+
file = add_underscore_to(file)
|
212
|
+
file = add_extension_to(file)
|
213
|
+
begin
|
214
|
+
# Allow relative references to templates/web when compiling a web template
|
215
|
+
if Origen.lsf.current_command == 'web'
|
216
|
+
clean_path_to(file, load_paths: "#{Origen.root}/templates/web")
|
217
|
+
else
|
218
|
+
clean_path_to(file)
|
219
|
+
end
|
220
|
+
rescue
|
221
|
+
# Try again without .erb
|
222
|
+
file = file.gsub('.erb', '')
|
223
|
+
if Origen.lsf.current_command == 'web'
|
224
|
+
clean_path_to(file, load_paths: "#{Origen.root}/templates/web")
|
225
|
+
else
|
226
|
+
clean_path_to(file)
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
def clean_path_to_template(file)
|
232
|
+
file = inject_import_path(file, type: :template)
|
233
|
+
file = add_extension_to(file)
|
234
|
+
clean_path_to(file)
|
235
|
+
end
|
236
|
+
|
237
|
+
# If the current path looks like it is a reference to an import, the
|
238
|
+
# path will be replaced with the absolute path to the local import directory
|
239
|
+
def inject_import_path(path, options = {})
|
240
|
+
path = path.to_s unless path.is_a?(String)
|
241
|
+
if path =~ /(.*?)\/.*/
|
242
|
+
import_name = Regexp.last_match[1].downcase.to_sym
|
243
|
+
if import_name == :origen || import_name == :origen_core || Origen.import_manager.names.include?(import_name)
|
244
|
+
unless import_name == :origen || import_name == :origen_core
|
245
|
+
root = Origen.app(import_name).root
|
246
|
+
end
|
247
|
+
if options[:type] == :template
|
248
|
+
if import_name == :origen || import_name == :origen_core
|
249
|
+
path.sub! 'origen', "#{Origen.top}/templates/shared"
|
250
|
+
else
|
251
|
+
path.sub! Regexp.last_match[1], "#{root}/templates/shared"
|
252
|
+
end
|
253
|
+
else
|
254
|
+
fail 'Unknown import path type!'
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
258
|
+
path
|
259
|
+
end
|
260
|
+
|
261
|
+
def clean_path_to_sub_program(file)
|
262
|
+
file = add_underscore_to(file)
|
263
|
+
file = add_rb_to(file)
|
264
|
+
clean_path_to(file)
|
265
|
+
end
|
266
|
+
|
267
|
+
# Insert _ in file name if not present
|
268
|
+
def add_underscore_to(file)
|
269
|
+
f = Pathname.new(file)
|
270
|
+
if f.basename.to_s =~ /^_/
|
271
|
+
file
|
272
|
+
else
|
273
|
+
"#{f.dirname}/_#{f.basename}"
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
def add_rb_to(file)
|
278
|
+
f = Pathname.new(file)
|
279
|
+
"#{f.dirname}/#{f.basename('.rb')}.rb"
|
280
|
+
end
|
281
|
+
|
282
|
+
def add_extension_to(file)
|
283
|
+
f = Pathname.new(file)
|
284
|
+
if f.basename('.erb').extname.empty?
|
285
|
+
if default_extension
|
286
|
+
"#{f.dirname}/#{f.basename('.erb')}#{default_extension}.erb"
|
287
|
+
else
|
288
|
+
"#{f.dirname}/#{f.basename('.erb')}#{Pathname.new(Origen.file_handler.current_file).basename('.erb').extname}.erb"
|
289
|
+
end
|
290
|
+
else
|
291
|
+
"#{f.dirname}/#{f.basename('.erb')}.erb"
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
def set_output_directory(options = {})
|
296
|
+
options = {
|
297
|
+
create: true
|
298
|
+
}.merge(options)
|
299
|
+
if options[:output]
|
300
|
+
@output_directory = relative_to_absolute(options[:output])
|
301
|
+
else
|
302
|
+
@output_directory = Pathname.new(Origen.config.output_directory)
|
303
|
+
end
|
304
|
+
if options[:create]
|
305
|
+
FileUtils.mkdir_p(@output_directory) unless @output_directory.exist?
|
306
|
+
end
|
307
|
+
@output_directory
|
308
|
+
end
|
309
|
+
|
310
|
+
# Returns an absolute pathname to the current output directory
|
311
|
+
def output_directory
|
312
|
+
@output_directory ||= set_output_directory
|
313
|
+
end
|
314
|
+
|
315
|
+
def set_reference_directory(options = {})
|
316
|
+
options = {
|
317
|
+
create: true
|
318
|
+
}.merge(options)
|
319
|
+
if options[:reference]
|
320
|
+
@reference_directory = relative_to_absolute(options[:reference])
|
321
|
+
else
|
322
|
+
@reference_directory = Pathname.new(Origen.config.reference_directory)
|
323
|
+
end
|
324
|
+
if options[:create]
|
325
|
+
# Delete any broken symlinks in the top level .ref
|
326
|
+
dir = "#{Origen.root}/.ref"
|
327
|
+
if File.symlink?(dir)
|
328
|
+
FileUtils.rm_f(dir) unless File.exist?(dir)
|
329
|
+
end
|
330
|
+
FileUtils.mkdir_p(@reference_directory) unless @reference_directory.exist?
|
331
|
+
end
|
332
|
+
@reference_directory
|
333
|
+
end
|
334
|
+
|
335
|
+
# Returns an absolute pathname to the current reference directory
|
336
|
+
def reference_directory
|
337
|
+
@reference_directory ||= set_reference_directory
|
338
|
+
end
|
339
|
+
|
340
|
+
# Returns the base directory containing the source files being generated/compiled.
|
341
|
+
#
|
342
|
+
# When operating on a single file this will return the directory containing that
|
343
|
+
# file, when operating on a directory this will return the directory.
|
344
|
+
def base_directory
|
345
|
+
@base_directory
|
346
|
+
end
|
347
|
+
|
348
|
+
def base_directory=(file_or_dir)
|
349
|
+
# puts "Base directory changed by: #{caller[0]}"
|
350
|
+
if file_or_dir.directory?
|
351
|
+
@base_directory = file_or_dir
|
352
|
+
else
|
353
|
+
@base_directory = file_or_dir.dirname
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
def current_directory
|
358
|
+
return @current_directory if @current_directory
|
359
|
+
@current_directory = clean_path_to(current_file).dirname if current_file
|
360
|
+
end
|
361
|
+
|
362
|
+
def current_file=(file)
|
363
|
+
@current_directory = nil
|
364
|
+
@current_file = file
|
365
|
+
end
|
366
|
+
|
367
|
+
def current_file
|
368
|
+
@current_file
|
369
|
+
end
|
370
|
+
|
371
|
+
def preserve_current_file
|
372
|
+
file = current_file
|
373
|
+
yield
|
374
|
+
self.current_file = file
|
375
|
+
end
|
376
|
+
|
377
|
+
def preserve_state
|
378
|
+
file = current_file
|
379
|
+
dir = base_directory
|
380
|
+
output = output_directory
|
381
|
+
ref = reference_directory
|
382
|
+
yield
|
383
|
+
self.base_directory = dir if dir
|
384
|
+
self.current_file = file if file
|
385
|
+
set_output_directory(output: output) if output
|
386
|
+
set_reference_directory(reference: ref) if ref
|
387
|
+
end
|
388
|
+
|
389
|
+
def preserve_and_clear_state
|
390
|
+
file = current_file
|
391
|
+
dir = base_directory
|
392
|
+
output = output_directory
|
393
|
+
ref = reference_directory
|
394
|
+
current_file = nil
|
395
|
+
base_directory = nil
|
396
|
+
output_directory = nil
|
397
|
+
reference_directory = nil
|
398
|
+
yield
|
399
|
+
self.base_directory = dir if dir
|
400
|
+
self.current_file = file if file
|
401
|
+
set_output_directory(output: output) if output
|
402
|
+
set_reference_directory(reference: ref) if ref
|
403
|
+
end
|
404
|
+
|
405
|
+
# Returns the sub directory of the current base directory that the
|
406
|
+
# given file is in
|
407
|
+
def sub_dir_of(file, base = base_directory)
|
408
|
+
file = Pathname.new(file) unless file.respond_to?(:relative_path_from)
|
409
|
+
base = Pathname.new(base) unless base.respond_to?(:relative_path_from)
|
410
|
+
rel = file.relative_path_from(base)
|
411
|
+
if file.directory?
|
412
|
+
rel
|
413
|
+
else
|
414
|
+
rel.dirname
|
415
|
+
end
|
416
|
+
end
|
417
|
+
|
418
|
+
# Convenience method to use when you want to write to a file, this takes
|
419
|
+
# care of ensuring that the directory exists prior to attempting to open
|
420
|
+
# the file
|
421
|
+
def open_for_write(path)
|
422
|
+
dir = Pathname.new(path).dirname
|
423
|
+
FileUtils.mkdir_p(dir) unless File.exist?(dir)
|
424
|
+
File.open(path, 'w') do |f|
|
425
|
+
yield f
|
426
|
+
end
|
427
|
+
end
|
428
|
+
end
|
429
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Origen
|
2
|
+
class Generator
|
3
|
+
module Comparator
|
4
|
+
# Will check if the supplied file has changed from the last time it was generated
|
5
|
+
# Returns true if it is a new file, or if a change has been detected
|
6
|
+
def check_for_changes(new, old, options = {})
|
7
|
+
options = {
|
8
|
+
comment_char: Origen.app.tester ? Origen.app.tester.comment_char : nil,
|
9
|
+
quiet: false,
|
10
|
+
compile_job: false,
|
11
|
+
suspend_string: 'STOPDIFF',
|
12
|
+
resume_string: 'STARTDIFF'
|
13
|
+
}.merge(options)
|
14
|
+
|
15
|
+
if File.exist?(old)
|
16
|
+
if Utility::Diff.new(file_a: new, file_b: old, ignore_blank_lines: true,
|
17
|
+
comment_char: options[:comment_char],
|
18
|
+
suspend_string: options[:suspend_string],
|
19
|
+
resume_string: options[:resume_string]).diffs?
|
20
|
+
|
21
|
+
unless options[:quiet]
|
22
|
+
cmd = "*** CHANGE DETECTED *** To update the reference: #{Origen.config.copy_command} #{relative_path_to(new)} #{relative_path_to(old)}"
|
23
|
+
cmd += ' /Y' if Origen.running_on_windows?
|
24
|
+
Origen.log.info cmd
|
25
|
+
Origen.log.info "#{Origen.config.diff_command} #{relative_path_to(old)} #{relative_path_to(new)} &"
|
26
|
+
Origen.log.info '**********************************************************************'
|
27
|
+
end
|
28
|
+
if options[:compile_job]
|
29
|
+
stats.changed_files += 1
|
30
|
+
else
|
31
|
+
stats.changed_patterns += 1
|
32
|
+
end
|
33
|
+
true
|
34
|
+
end
|
35
|
+
else
|
36
|
+
unless options[:quiet]
|
37
|
+
Origen.log.info "*** NEW FILE *** To save it: #{Origen.config.copy_command} #{relative_path_to(new)} #{relative_path_to(old)}"
|
38
|
+
Origen.log.info '**********************************************************************'
|
39
|
+
end
|
40
|
+
if options[:compile_job]
|
41
|
+
stats.new_files += 1
|
42
|
+
else
|
43
|
+
stats.new_patterns += 1
|
44
|
+
end
|
45
|
+
true
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def relative_path_to(file)
|
50
|
+
p = Pathname(file).relative_path_from(Pathname.pwd).to_s
|
51
|
+
p.gsub!('/', '\\') if Origen.running_on_windows?
|
52
|
+
p
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|