Class: CommonLibraryBuilder
- Includes:
- Rake::DSL
- Defined in:
- lib/phusion_passenger/common_library.rb
Overview
This file lists all the Phusion Passenger C++ library files and contains code for calculating how to compile and how to link them into executables. It’s used by the build system (build/*.rb) and lib/phusion_passenger/standalone/runtime_installer.rb.
Instance Attribute Summary collapse
-
#all_components ⇒ Object
readonly
Returns the value of attribute all_components.
-
#output_dir ⇒ Object
readonly
Returns the value of attribute output_dir.
-
#selected_components ⇒ Object
readonly
Returns the value of attribute selected_components.
Instance Method Summary collapse
- #define_component(object_name, options) ⇒ Object
- #define_tasks(extra_compiler_flags = nil) ⇒ Object
- #exclude(*selector) ⇒ Object
-
#initialize(&block) ⇒ CommonLibraryBuilder
constructor
A new instance of CommonLibraryBuilder.
- #initialize_copy(other) ⇒ Object
- #link_objects ⇒ Object
- #link_objects_as_string ⇒ Object
- #only(*selector) ⇒ Object
- #set_namespace(namespace) ⇒ Object
- #set_output_dir(dir) ⇒ Object
Constructor Details
#initialize(&block) ⇒ CommonLibraryBuilder
Returns a new instance of CommonLibraryBuilder.
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/phusion_passenger/common_library.rb', line 34 def initialize(&block) @all_components = {} @all_ordered_components = [] @selected_components = {} @namespace = "common" if defined?(COMMON_OUTPUT_DIR) @output_dir = COMMON_OUTPUT_DIR + "libpassenger_common" else @output_dir = "." end instance_eval(&block) if block end |
Instance Attribute Details
#all_components ⇒ Object (readonly)
Returns the value of attribute all_components.
32 33 34 |
# File 'lib/phusion_passenger/common_library.rb', line 32 def all_components @all_components end |
#output_dir ⇒ Object (readonly)
Returns the value of attribute output_dir.
32 33 34 |
# File 'lib/phusion_passenger/common_library.rb', line 32 def output_dir @output_dir end |
#selected_components ⇒ Object (readonly)
Returns the value of attribute selected_components.
32 33 34 |
# File 'lib/phusion_passenger/common_library.rb', line 32 def selected_components @selected_components end |
Instance Method Details
#define_component(object_name, options) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/phusion_passenger/common_library.rb', line 54 def define_component(object_name, ) [:deps] ||= [] @all_components[object_name] = @all_ordered_components << object_name @selected_components[object_name] = end |
#define_tasks(extra_compiler_flags = nil) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/phusion_passenger/common_library.rb', line 103 def define_tasks(extra_compiler_flags = nil) flags = "-Iext -Iext/common #{LIBEV_CFLAGS} #{extra_compiler_flags} " flags << EXTRA_CXXFLAGS flags.strip! group_all_components_by_category.each_pair do |category, object_names| define_category_tasks(category, object_names, flags) end task("#{@namespace}:clean") do sh "rm -rf #{@output_dir}" end return self end |
#exclude(*selector) ⇒ Object
65 66 67 |
# File 'lib/phusion_passenger/common_library.rb', line 65 def exclude(*selector) return dup.send(:exclude!, *selector) end |
#initialize_copy(other) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/phusion_passenger/common_library.rb', line 47 def initialize_copy(other) [:all_components, :all_ordered_components, :selected_components, :namespace, :output_dir].each do |name| var_name = "@#{name}" instance_variable_set(var_name, other.instance_variable_get(var_name).dup) end end |
#link_objects ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/phusion_passenger/common_library.rb', line 77 def link_objects result = [] selected_categories.each do |category| if category_complete?(category) && false # Feature disabled: we don't want to waste too much space when # packaging the runtime ('passenger package-runtime') so we # never generate static libraries. if aggregate_sources? result << "#{@output_dir}/#{category}.o" else result << "#{@output_dir}/#{category}.a" end else object_names = selected_objects_beloging_to_category(category) result.concat(object_filenames_for(object_names)) end end return result end |
#link_objects_as_string ⇒ Object
99 100 101 |
# File 'lib/phusion_passenger/common_library.rb', line 99 def link_objects_as_string return link_objects.join(' ') end |
#only(*selector) ⇒ Object
61 62 63 |
# File 'lib/phusion_passenger/common_library.rb', line 61 def only(*selector) return dup.send(:only!, *selector) end |
#set_namespace(namespace) ⇒ Object
69 70 71 |
# File 'lib/phusion_passenger/common_library.rb', line 69 def set_namespace(namespace) return dup.send(:set_namespace!, namespace) end |
#set_output_dir(dir) ⇒ Object
73 74 75 |
# File 'lib/phusion_passenger/common_library.rb', line 73 def set_output_dir(dir) return dup.send(:set_output_dir!, dir) end |