class Project
Public Class Methods
all()
click to toggle source
# File lib/rmake.rb, line 24 def self.all $projects.keys end
do(name)
click to toggle source
# File lib/rmake.rb, line 20 def self.do name $projects[name].create_makefile_and_make if $projects.has_key?(name) end
do_all()
click to toggle source
# File lib/rmake.rb, line 16 def self.do_all $projects.values.each{|p| p.create_makefile_and_make } end
new(options = {})
click to toggle source
# File lib/rmake.rb, line 28 def initialize(options = {}) @options = { makefile: 'Makefile', obj_files: 'build/tmp/objects', source_files: [], include_path: ['include', 'inc', './'], libs: [], ld_library_path: [], type: 'app', host: '', target: '', build_dir: 'build' }.merge(options) end
Public Instance Methods
add_include_path(paths)
click to toggle source
# File lib/rmake.rb, line 92 def add_include_path paths @options[:include_path].concat paths end
add_ld_library_path(paths)
click to toggle source
# File lib/rmake.rb, line 96 def add_ld_library_path paths @options[:ld_library_path].concat paths end
add_libs(libs)
click to toggle source
# File lib/rmake.rb, line 100 def add_libs libs @options[:libs].concat libs end
add_sources(files)
click to toggle source
# File lib/rmake.rb, line 88 def add_sources files @options[:source_files].concat files end
chanage_source_to_obj(file)
click to toggle source
# File lib/rmake.rb, line 64 def chanage_source_to_obj file File.join(@options[:build_dir], 'obj', file.gsub(File.extname(file), '.o')) end
create_makefile_and_make()
click to toggle source
# File lib/rmake.rb, line 72 def create_makefile_and_make open @options[:makefile], 'w' do |f| f << ERB.new(IO.read(File.join(__dir__, "../resources/makefile.#{@options[:type]}.erb"))).result(binding) end system("make") end
gcc()
click to toggle source
# File lib/rmake.rb, line 55 def gcc return @options[:host] + '-g++' if @options[:host] != '' return 'g++' end
host(platform)
click to toggle source
set options
# File lib/rmake.rb, line 80 def host platform @options[:host] = platform end
include_info()
click to toggle source
# File lib/rmake.rb, line 43 def include_info @options[:include_path].find_all{|path| File.directory?(path) }.map{|path| "-I" + path }.join(" ") end
ld_info()
click to toggle source
# File lib/rmake.rb, line 47 def ld_info @options[:ld_library_path].find_all{|path| File.directory?(path) }.map{|path| "-L" + path }.join(" ") end
lib_info()
click to toggle source
# File lib/rmake.rb, line 51 def lib_info @options[:libs].map{|path| "-l" + path }.join(" ") end
obj_files()
click to toggle source
# File lib/rmake.rb, line 68 def obj_files source_files.map{|file| chanage_source_to_obj(file) } end
set(key, value)
click to toggle source
# File lib/rmake.rb, line 84 def set key, value @options[key] = value end
source_files()
click to toggle source
# File lib/rmake.rb, line 60 def source_files source_files = @options[:source_files].size == 0 ? Dir["*/**/*.cpp"] + Dir["*/**/*.c"] : @options[:source_files] end