Class: Project

Inherits:
Object
  • Object
show all
Includes:
PathHelper
Defined in:
lib/simple-make/project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PathHelper

#get_path

Constructor Details

#initialize(options = {}) ⇒ Project

Returns a new instance of Project.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/simple-make/project.rb', line 17

def initialize(options = {})
  @workspace = options[:workspace] || File.absolute_path(".")
  @name = @workspace.split("/").last
  @app_path = "app"
  @test_path = "test"
  @prod_path = "prod"
  @output_path = "build"
  @source_folder_name = "src"
  @deps = []
  @dep_projects = []
  @includes = []
  @compile_command_with_flag = "g++ -O0 -g3 -Wall"
  @link_command_with_flag = "g++"
  @src_suffix = "cc"
  @path_mode = options[:path_mode] || :absolute
  self.package_type = :executable
  @makefile_name = options[:makefile] || "Makefile"
  @makefile_maker = NormalMakefileMaker.new(self, binding)
end

Instance Attribute Details

#app_pathObject

Returns the value of attribute app_path.



14
15
16
# File 'lib/simple-make/project.rb', line 14

def app_path
  @app_path
end

#compile_command_with_flagObject

Returns the value of attribute compile_command_with_flag.



14
15
16
# File 'lib/simple-make/project.rb', line 14

def compile_command_with_flag
  @compile_command_with_flag
end

#dep_projectsObject (readonly)

Returns the value of attribute dep_projects.



15
16
17
# File 'lib/simple-make/project.rb', line 15

def dep_projects
  @dep_projects
end

Returns the value of attribute link.



14
15
16
# File 'lib/simple-make/project.rb', line 14

def link
  @link
end

#makefile_nameObject (readonly)

Returns the value of attribute makefile_name.



15
16
17
# File 'lib/simple-make/project.rb', line 15

def makefile_name
  @makefile_name
end

#nameObject

Returns the value of attribute name.



14
15
16
# File 'lib/simple-make/project.rb', line 14

def name
  @name
end

#output_pathObject

Returns the value of attribute output_path.



14
15
16
# File 'lib/simple-make/project.rb', line 14

def output_path
  @output_path
end

#prod_pathObject

Returns the value of attribute prod_path.



14
15
16
# File 'lib/simple-make/project.rb', line 14

def prod_path
  @prod_path
end

#source_folder_nameObject

Returns the value of attribute source_folder_name.



14
15
16
# File 'lib/simple-make/project.rb', line 14

def source_folder_name
  @source_folder_name
end

#src_suffixObject

Returns the value of attribute src_suffix.



14
15
16
# File 'lib/simple-make/project.rb', line 14

def src_suffix
  @src_suffix
end

#test_pathObject

Returns the value of attribute test_path.



14
15
16
# File 'lib/simple-make/project.rb', line 14

def test_path
  @test_path
end

#workspaceObject (readonly)

Returns the value of attribute workspace.



15
16
17
# File 'lib/simple-make/project.rb', line 15

def workspace
  @workspace
end

Instance Method Details

#dep_projects_output_pathObject



113
114
115
# File 'lib/simple-make/project.rb', line 113

def dep_projects_output_path
  @dep_projects.map(&:output_path).join(" ")
end

#depend_on(*deps) ⇒ Object



45
46
47
48
49
# File 'lib/simple-make/project.rb', line 45

def depend_on(*deps)
  within_workspace do
    @deps += deps.map{|depHash| Dependency.new(depHash, @path_mode)}
  end
end

#depend_on_project(*projects) ⇒ Object



51
52
53
54
55
# File 'lib/simple-make/project.rb', line 51

def depend_on_project(*projects)
  within_workspace do
    @dep_projects += projects.map{|params| ProjectFactory.create_from_relative_path(params)}
  end
end

#generate_make_fileObject



71
72
73
# File 'lib/simple-make/project.rb', line 71

def generate_make_file
  @makefile_maker.generate_make_file
end

#header_search_path(*paths) ⇒ Object



57
58
59
60
61
# File 'lib/simple-make/project.rb', line 57

def header_search_path *paths
  within_workspace do
    @includes += paths.map{|path| SearchPath.new(path, @path_mode)}
  end
end

#pack_dep_project_commandsObject



79
80
81
# File 'lib/simple-make/project.rb', line 79

def pack_dep_project_commands
  @package.pack_dep_project_commands
end

#package_fileObject



75
76
77
# File 'lib/simple-make/project.rb', line 75

def package_file
  @package.package_file
end

#package_partObject



83
84
85
# File 'lib/simple-make/project.rb', line 83

def package_part
  @package.pack_deps_command
end

#package_type=(type) ⇒ Object



41
42
43
# File 'lib/simple-make/project.rb', line 41

def package_type= type
  @package = PackageFactory.create_by_type(type, self)
end

#root_projectObject



37
38
39
# File 'lib/simple-make/project.rb', line 37

def root_project
  @makefile_maker = RootMakefileMaker.new(self, binding)
end

#run_test_on_depsObject



87
88
89
# File 'lib/simple-make/project.rb', line 87

def run_test_on_deps
  @dep_projects.map(&:test_command).join("\n\t")
end

#sub_folders_in_target_folderObject



63
64
65
66
67
68
69
# File 'lib/simple-make/project.rb', line 63

def sub_folders_in_target_folder
  folders = []
  {"app" => @app_path, "prod" => @prod_path, "test" => @test_path}.each_pair do |k,v|
    folders += all_output_dirs_related_to(k, v)
  end
  folders.map{|raw| "#{@output_path}/#{raw}"}.join(" \\\n")
end