class Project
Attributes
app_path[RW]
compile_command_with_flag[RW]
dep_projects[R]
link[RW]
makefile_name[R]
name[RW]
output_path[RW]
prod_path[RW]
source_folder_name[RW]
src_suffix[RW]
test_path[RW]
workspace[R]
Public Class Methods
new(options = {})
click to toggle source
# 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
Public Instance Methods
dep_projects_output_path()
click to toggle source
# File lib/simple-make/project.rb, line 113 def dep_projects_output_path @dep_projects.map(&:output_path).join(" ") end
depend_on(*deps)
click to toggle source
# 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)
click to toggle source
# 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_file()
click to toggle source
# File lib/simple-make/project.rb, line 71 def generate_make_file @makefile_maker.generate_make_file end
header_search_path(*paths)
click to toggle source
# 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_commands()
click to toggle source
# File lib/simple-make/project.rb, line 79 def pack_dep_project_commands @package.pack_dep_project_commands end
package_file()
click to toggle source
# File lib/simple-make/project.rb, line 75 def package_file @package.package_file end
package_part()
click to toggle source
# File lib/simple-make/project.rb, line 83 def package_part @package.pack_deps_command end
package_type=(type)
click to toggle source
# File lib/simple-make/project.rb, line 41 def package_type= type @package = PackageFactory.create_by_type(type, self) end
root_project()
click to toggle source
# File lib/simple-make/project.rb, line 37 def root_project @makefile_maker = RootMakefileMaker.new(self, binding) end
run_test_on_deps()
click to toggle source
# 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_folder()
click to toggle source
# 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
Private Instance Methods
all_sources_in(base)
click to toggle source
# File lib/simple-make/project.rb, line 127 def all_sources_in(base) within_workspace {DirTraverser.all_files_in_path("#{base}/#{@source_folder_name}").join(" \\\n")} end
lib_name_flag(*scopes)
click to toggle source
# File lib/simple-make/project.rb, line 139 def lib_name_flag(*scopes) libs_name = [] scopes.each do |scope| @deps.select { |dep| dep.scope == scope}.each{|dep| libs_name << dep.lib_name} end libs_name.map{|p| "-l#{p}"}.join(" ") end
lib_path_flag(*scopes)
click to toggle source
# File lib/simple-make/project.rb, line 147 def lib_path_flag(*scopes) libs_path = [] scopes.each do |scope| @deps.select { |dep| dep.scope == scope}.each{|dep| libs_path << dep.lib_path} end libs_path.map{|p| "-L#{p}"}.join(" ") end
search_path_flag(*scopes)
click to toggle source
# File lib/simple-make/project.rb, line 155 def search_path_flag(*scopes) includes = [within_workspace{"-I#{get_path(@path_mode, @app_path)}/include"}] scopes.each do |scope| ex_includes = @includes.select { |include| include.scope == scope}.map(&:path) ex_includes += @deps.select { |dep| dep.scope == scope}.map(&:include) includes += ex_includes.map { |include| "-I#{include}" } includes += @dep_projects.select{|dep_project| dep_project.scope == scope}.map(&:export_search_path_flag) end includes.join(" ") end
within_workspace() { || ... }
click to toggle source
# File lib/simple-make/project.rb, line 131 def within_workspace ret = "" Dir.chdir(@workspace) do ret = yield end ret end