Class: Project
- Inherits:
-
Object
- Object
- Project
- Defined in:
- lib/simple-make/project.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
writeonly
Sets the attribute name.
Instance Method Summary collapse
- #compile_command_with_flag(cc) ⇒ Object
- #default_name ⇒ Object
- #depend_on(*deps) ⇒ Object
- #generate_make_file(filename = "Makefile") ⇒ Object
- #header_search_path(*paths) ⇒ Object
-
#initialize(name = nil) ⇒ Project
constructor
A new instance of Project.
- #link_command_with_flag(link) ⇒ Object
- #prod_srcs ⇒ Object
- #srcs ⇒ Object
- #sub_folders_in_target_folder ⇒ Object
- #test_srcs ⇒ Object
Constructor Details
#initialize(name = nil) ⇒ Project
Returns a new instance of Project.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/simple-make/project.rb', line 9 def initialize(name=nil) @name = name || default_name @app_path = "app" @test_path = "test" @prod_path = "prod" @output_path = "build" @source_folder_name = "src" @deps = [] @includes = [] @cc = "g++ -O0 -g3 -Wall" @link = "g++" end |
Instance Attribute Details
#name=(value) ⇒ Object (writeonly)
Sets the attribute name
7 8 9 |
# File 'lib/simple-make/project.rb', line 7 def name=(value) @name = value end |
Instance Method Details
#compile_command_with_flag(cc) ⇒ Object
52 53 54 |
# File 'lib/simple-make/project.rb', line 52 def compile_command_with_flag cc @cc = cc end |
#default_name ⇒ Object
22 23 24 |
# File 'lib/simple-make/project.rb', line 22 def default_name File.absolute_path(".").split("/").last end |
#depend_on(*deps) ⇒ Object
26 27 28 29 |
# File 'lib/simple-make/project.rb', line 26 def depend_on(*deps) raise "depend_on only accept array of dependencies, use [] to wrap your dependency if there is only one" if !(deps.is_a? Array) @deps += deps.map{|depHash| Dependency.new(depHash)} end |
#generate_make_file(filename = "Makefile") ⇒ Object
60 61 62 63 64 65 |
# File 'lib/simple-make/project.rb', line 60 def generate_make_file(filename = "Makefile") makefile = ERB.new(File.open(File.(File.dirname(__FILE__) + "/../../template/makefile.erb")).read) File.open(filename, "w") do |f| f.write makefile.result(binding) end end |
#header_search_path(*paths) ⇒ Object
47 48 49 50 |
# File 'lib/simple-make/project.rb', line 47 def header_search_path *paths raise "search path only accept array of paths, use [] to wrap your search paths if there is only one" if !(paths.is_a? Array) @includes += paths.map{|path| SearchPath.new(path)} end |
#link_command_with_flag(link) ⇒ Object
56 57 58 |
# File 'lib/simple-make/project.rb', line 56 def link_command_with_flag link @link = link end |
#prod_srcs ⇒ Object
39 40 41 |
# File 'lib/simple-make/project.rb', line 39 def prod_srcs all_sources_in(@prod_path) end |
#srcs ⇒ Object
31 32 33 |
# File 'lib/simple-make/project.rb', line 31 def srcs all_sources_in(@app_path) end |
#sub_folders_in_target_folder ⇒ Object
43 44 45 |
# File 'lib/simple-make/project.rb', line 43 def sub_folders_in_target_folder ((@app_path) + (@prod_path) + (@test_path)).join(" \\\n") end |
#test_srcs ⇒ Object
35 36 37 |
# File 'lib/simple-make/project.rb', line 35 def test_srcs all_sources_in(@test_path) end |