flgen 0.19.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93ba3a15351e9da39f2dfbbd23c54790140fe7134be768352aa2430533008194
4
- data.tar.gz: 0e4cc12fae241384ec559682d965b68a63362ca0c934013c1312ac93eaec28cb
3
+ metadata.gz: fe67e7c60ca35355577e56501c46a5745fec3209091ae08adec482291480bfc2
4
+ data.tar.gz: b1b22bab5e3221f0b065d56cd280f6511430f7180954242e0adfc5e1d5199cb7
5
5
  SHA512:
6
- metadata.gz: 01ffbee882b46664e9e77a63977abe0e5c1de2a7c75271a1ce6b0284ce7a0517d1785d8e14d95c524959aedfbc8482f6dba3174001311034fd88d863cb013cd3
7
- data.tar.gz: 398adf788fa50f20d2cdda686b3364b8978a05884e554aecc19ae6c5beb908049a49e6de852b5d7ba41552e0c29310a9826c63c2e49fef2cd65899515133747f
6
+ metadata.gz: a736ba945d947a72ddeccf2c1f09f0f75ed27aa9ec79fc59c81518619bd004094a96dd6911185f861371abeb8c25abc3ebe3b7fae4a1695b40c221e08b47b6c3
7
+ data.tar.gz: b4666bb3afdd53adf29f6a8f6c63d02e660e9c0558b9a5681bf2e33196360eeead5ca6d54a863918915fb3facd4bc57999c6b89c9bdb87d7d3a787c18d5eb4a7
data/README.md CHANGED
@@ -47,6 +47,8 @@ FLGen prives APIs listed below to describe your filelists.
47
47
  * Define a text macro.
48
48
  * `macro?(name)`/`macro_defined?(name)`
49
49
  * Return `true` if the given macro is defined.
50
+ * `macro(name)`
51
+ * Return the value of the given macro.
50
52
  * `env?(name)`
51
53
  * Return `true` if the givne environment variable is defined.
52
54
  * `env(name)`
data/lib/flgen/context.rb CHANGED
@@ -4,6 +4,7 @@ module FLGen
4
4
  class Context
5
5
  def initialize(options)
6
6
  @options = options
7
+ define_predefined_macros
7
8
  end
8
9
 
9
10
  attr_reader :options
@@ -35,11 +36,11 @@ module FLGen
35
36
  else
36
37
  [macro, value]
37
38
  end
38
- add_macro_definition(k.to_sym, v)
39
+ add_macro_definition(k, v, false)
39
40
  end
40
41
 
41
42
  def macros
42
- @macros ||= []
43
+ @macros ||= {}
43
44
  end
44
45
 
45
46
  def add_include_directory(directory)
@@ -95,8 +96,21 @@ module FLGen
95
96
  arguments.none? { |arg| arg.type == :library_file && arg.path == file }
96
97
  end
97
98
 
98
- def add_macro_definition(name, value)
99
- macros << name unless macros.include?(name)
99
+ def define_predefined_macros
100
+ return unless options[:tool]
101
+
102
+ list_name = File.join(__dir__, 'predefined_macros.yaml')
103
+ list = YAML.safe_load_file(list_name, filename: list_name, symbolize_names: true)
104
+ list[options[:tool]]&.each { |macro| add_macro_definition(macro, nil, true) }
105
+ end
106
+
107
+ def add_macro_definition(macro, value, predefined)
108
+ name = macro.to_sym
109
+ macros[name] = value || true
110
+ add_macro_argument(name, value) unless predefined
111
+ end
112
+
113
+ def add_macro_argument(name, value)
100
114
  arguments
101
115
  .delete_if { |argument| argument.type == :define && argument.name == name }
102
116
  add_compile_argument(Arguments::Define.new(name, value))
@@ -31,11 +31,12 @@ module FLGen
31
31
 
32
32
  def find_files(patterns, from: nil, &block)
33
33
  glob_files(patterns, from, __callee__, caller_location)
34
- .then { |e| block ? e.each(&block) : e.to_a }
34
+ .then { |e| block_given? && (return e.each(&block)) || e.to_a }
35
35
  end
36
36
 
37
37
  def find_file(patterns, from: nil)
38
- glob_files(patterns, from, __callee__, caller_location).first
38
+ glob_files(patterns, from, __callee__, caller_location)
39
+ .first&.then { |f| block_given? && (return yield f) || f }
39
40
  end
40
41
 
41
42
  def file?(path, from: :current)
@@ -49,11 +50,15 @@ module FLGen
49
50
  end
50
51
 
51
52
  def macro?(macro)
52
- @context.macros.include?(macro.to_sym)
53
+ @context.macros.key?(macro.to_sym)
53
54
  end
54
55
 
55
56
  alias_method :macro_defined?, :macro?
56
57
 
58
+ def macro(name)
59
+ @context.macros[name.to_sym]
60
+ end
61
+
57
62
  def env?(name)
58
63
  ENV.key?(name.to_s)
59
64
  end
@@ -117,7 +122,7 @@ module FLGen
117
122
  return
118
123
  end
119
124
 
120
- @context.__send__("add_#{method_name}".to_sym, extracted_path)
125
+ @context.__send__("add_#{method_name}", extracted_path)
121
126
  end
122
127
 
123
128
  def raise_no_entry_error(path, location, raise_error)
@@ -0,0 +1,12 @@
1
+ vcs:
2
+ - VCS
3
+ design_compiler:
4
+ - SYNTHESIS
5
+ formality:
6
+ - SYNTHESIS
7
+ xcelium:
8
+ - XCELIUM
9
+ vivado:
10
+ - SYNTHESIS
11
+ vivado_simulator:
12
+ - XILINX_SIMULATOR
data/lib/flgen/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FLGen
4
- VERSION = '0.19.0'
4
+ VERSION = '0.21.0'
5
5
  end
data/lib/flgen.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require 'digest/md5'
4
4
  require 'optparse'
5
5
  require 'pathname'
6
+ require 'yaml'
6
7
  require_relative 'flgen/version'
7
8
  require_relative 'flgen/exceptions'
8
9
  require_relative 'flgen/source_file'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flgen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.0
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taichi Ishitani
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-15 00:00:00.000000000 Z
11
+ date: 2024-04-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Filelist generator
14
14
  email:
@@ -30,6 +30,7 @@ files:
30
30
  - lib/flgen/file_list_formatter.rb
31
31
  - lib/flgen/file_list_xsim_formatter.rb
32
32
  - lib/flgen/formatter.rb
33
+ - lib/flgen/predefined_macros.yaml
33
34
  - lib/flgen/source_file.rb
34
35
  - lib/flgen/version.rb
35
36
  - lib/flgen/vivado_tcl_formatter.rb
@@ -64,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
65
  - !ruby/object:Gem::Version
65
66
  version: '0'
66
67
  requirements: []
67
- rubygems_version: 3.4.19
68
+ rubygems_version: 3.5.9
68
69
  signing_key:
69
70
  specification_version: 4
70
71
  summary: Filelist generator