class MTBuild::Toolchain
This is the base class for all toolchain types.
Attributes
output_decorator[RW]
Text to append to the name of output files
output_folder[RW]
The toolchain's output folder
parent_configuration[RW]
parent configuration
project_folder[RW]
The project's folder. Relative path references are interpreted as relative to this folder.
Public Class Methods
new(parent_configuration, toolchain_configuration)
click to toggle source
# File lib/mtbuild/toolchain.rb, line 21 def initialize(parent_configuration, toolchain_configuration) @output_folder = '' @project_folder = '' @output_decorator = '' @include_objects = [] @include_paths = [] @library_paths = [] @parent_configuration = parent_configuration add_include_paths(expand_project_relative_paths(toolchain_configuration.fetch(:include_paths, []))) add_include_objects(expand_project_relative_paths(toolchain_configuration.fetch(:include_objects, []))) add_library_paths(expand_project_relative_paths(toolchain_configuration.fetch(:library_paths, []))) end
Private Class Methods
create_toolchain(parent_configuration, toolchain_configuration)
click to toggle source
# File lib/mtbuild/toolchain.rb, line 99 def self.create_toolchain(parent_configuration, toolchain_configuration) toolchain_name = toolchain_configuration.fetch(:name, nil) fail "error: toolchain name not specified." if toolchain_name.nil? toolchain_class = @registered_toolchains.fetch(toolchain_name, nil) if !toolchain_class toolchain_file = File.join('mtbuild', 'toolchains', toolchain_name.to_s) begin require toolchain_file rescue LoadError end end toolchain_class = @registered_toolchains.fetch(toolchain_name, nil) fail "error: toolchain #{toolchain_name} could not be found." if toolchain_class.nil? return Object::const_get(toolchain_class).new(parent_configuration, toolchain_configuration) end
register_toolchain(toolchain_name, toolchain_class)
click to toggle source
# File lib/mtbuild/toolchain.rb, line 95 def self.register_toolchain(toolchain_name, toolchain_class) @registered_toolchains[toolchain_name] = toolchain_class; end
Public Instance Methods
add_include_objects(include_objects)
click to toggle source
Add an additional object to the list of additional objects to link with
# File lib/mtbuild/toolchain.rb, line 51 def add_include_objects(include_objects) include_objects = Utils.ensure_array(include_objects).to_a.flatten @include_objects |= include_objects end
add_include_paths(include_paths)
click to toggle source
Add an include path to the list of include paths to compile with
# File lib/mtbuild/toolchain.rb, line 57 def add_include_paths(include_paths) include_paths = Utils.ensure_array(include_paths).to_a.flatten @include_paths |= include_paths end
add_library_paths(library_paths)
click to toggle source
Add a library path to the list of library paths to link with
# File lib/mtbuild/toolchain.rb, line 63 def add_library_paths(library_paths) library_paths = Utils.ensure_array(library_paths).to_a.flatten @library_paths |= library_paths end
create_application_tasks(objects, executable_name)
click to toggle source
Create Rake
tasks for linking
# File lib/mtbuild/toolchain.rb, line 83 def create_application_tasks(objects, executable_name) fail "Toolchain didn't provide create_executable_tasks" end
create_compile_tasks(source_files)
click to toggle source
Create Rake
tasks for compilation
# File lib/mtbuild/toolchain.rb, line 73 def create_compile_tasks(source_files) fail "Toolchain didn't provide create_compile_tasks" end
create_static_library_tasks(objects, library_name)
click to toggle source
Create Rake
tasks for archival
# File lib/mtbuild/toolchain.rb, line 78 def create_static_library_tasks(objects, library_name) fail "Toolchain didn't provide create_static_library_tasks" end
get_include_objects()
click to toggle source
Retrieve a list of additional objects to link with
# File lib/mtbuild/toolchain.rb, line 36 def get_include_objects @include_objects.collect {|i| File.expand_path(i.gsub('$(PROJECT_DIR)', @project_folder))} end
get_include_paths()
click to toggle source
Retrieve a list of include paths to compile with
# File lib/mtbuild/toolchain.rb, line 41 def get_include_paths @include_paths.collect {|i| File.expand_path(i.gsub('$(PROJECT_DIR)', @project_folder))} end
get_library_paths()
click to toggle source
Retrieve a list of library paths to link with
# File lib/mtbuild/toolchain.rb, line 46 def get_library_paths @library_paths.collect {|i| File.expand_path(i.gsub('$(PROJECT_DIR)', @project_folder))} end
scan_sources(source_files)
click to toggle source
Scan source files for any special processing needs
# File lib/mtbuild/toolchain.rb, line 69 def scan_sources(source_files) end
Private Instance Methods
expand_project_relative_paths(paths)
click to toggle source
# File lib/mtbuild/toolchain.rb, line 89 def expand_project_relative_paths(paths) return Utils.ensure_array(paths).to_a.flatten.collect{ |p| ((Pathname.new p).relative?) ? (File.join('$(PROJECT_DIR)', p)) : p} end