Class: RedShift::Library
- Defined in:
- lib/redshift/target/c/library.rb,
lib/redshift/target/c/flow/buffer.rb
Defined Under Namespace
Classes: BufferAttribute
Instance Method Summary collapse
- #commit ⇒ Object
-
#component_classes ⇒ Object
Return list of all subclasses of Component (including Component).
- #declare_external_constant(*vars) ⇒ Object
- #define_buffer ⇒ Object
- #extconf ⇒ Object
- #external_constant?(var) ⇒ Boolean
-
#initialize(*args) ⇒ Library
constructor
A new instance of Library.
-
#link_with(*libs) ⇒ Object
Call this to link with external libraries.
- #make(arg = nil) ⇒ Object
-
#precommit ⇒ Object
Operate on Component class specifications gathered by meta.rb, and stored in the component classes.
Constructor Details
#initialize(*args) ⇒ Library
Returns a new instance of Library.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/redshift/target/c/library.rb', line 11 def initialize(*args) super self.purge_source_dir = :delete self.show_times_flag = $REDSHIFT_BUILD_TIMES if $REDSHIFT_DEBUG include_file.include "<assert.h>" ## better to use something that raises a ruby exception else include_file.declare :assert => %{#define assert(cond) 0} end include_file.include '<math.h>' base = File.("../../../../..", __FILE__) ext_rs = File.join(base, "ext/redshift") include_dirs << ext_rs end |
Instance Method Details
#commit ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/redshift/target/c/library.rb', line 61 def commit return if committed? precommit ## this makes it a little trickier to use gdb use_work_dir $REDSHIFT_WORK_DIR do # $REDSHIFT_SKIP_BUILD is normally handled in redshift/target/c.rb. # useful for: turnkey; fast start if no changes; manual lib edits super(!$REDSHIFT_SKIP_BUILD) end ## freeze metadata in comp classes? ## can cgen/cshadow freeze some stuff? end |
#component_classes ⇒ Object
Return list of all subclasses of Component (including Component).
76 77 78 79 80 81 82 83 |
# File 'lib/redshift/target/c/library.rb', line 76 def component_classes return @component_classes if @component_classes cc = Library.sort_class_tree(Component.subclasses) @component_classes = cc if committed? return cc end |
#declare_external_constant(*vars) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/redshift/target/c/library.rb', line 37 def declare_external_constant *vars @external_constants ||= {} vars.each do |var| @external_constants[var.to_s] = true end end |
#define_buffer ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/redshift/target/c/flow/buffer.rb', line 5 def define_buffer unless @buffer_defined @buffer_defined = true text = File.read(File.join(REDSHIFT_BUFFER_DIR, "buffer.h")) buffer_h = CGenerator::CFile.new("buffer.h", self, nil, true) buffer_h.declare :buffer_header_text => text add [buffer_h] end end |
#extconf ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/redshift/target/c/library.rb', line 48 def extconf super do |lines| if @link_libs libstr = " " + @link_libs.flatten.join(" ") lines << %{$LOCAL_LIBS << "#{libstr}"} end end end |
#external_constant?(var) ⇒ Boolean
44 45 46 |
# File 'lib/redshift/target/c/library.rb', line 44 def external_constant? var @external_constants and @external_constants.key?(var.to_s) end |
#link_with(*libs) ⇒ Object
Call this to link with external libraries. See examples/external-lib.rb. Note also include_dirs array.
33 34 35 |
# File 'lib/redshift/target/c/library.rb', line 33 def link_with *libs (@link_libs ||= []) << libs end |
#make(arg = nil) ⇒ Object
57 58 59 |
# File 'lib/redshift/target/c/library.rb', line 57 def make arg=nil super [$REDSHIFT_MAKE_ARGS, arg].join(" ") end |
#precommit ⇒ Object
Operate on Component class specifications gathered by meta.rb, and stored in the component classes.
87 88 89 90 91 92 93 |
# File 'lib/redshift/target/c/library.rb', line 87 def precommit ## no need to precommit Component? Other abstract classes? component_classes.each {|cl| cl.precommit} component_classes.each {|cl| cl.generate_wrappers} ## optimization? ## check if changed end |