Class: Buildfile::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/buildfile.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(yaml) ⇒ Project

Returns a new instance of Project.



12
13
14
# File 'lib/buildfile.rb', line 12

def initialize(yaml)
	@project_yaml = yaml["project"]
end

Instance Attribute Details

#project_yamlObject (readonly)

Returns the value of attribute project_yaml.



9
10
11
# File 'lib/buildfile.rb', line 9

def project_yaml
  @project_yaml
end

Instance Method Details

#get_compilerObject



30
31
32
33
# File 'lib/buildfile.rb', line 30

def get_compiler
	default_compiler = "clang++"
	@project_yaml["compiler"] || default_compiler
end

#get_custom_flagsObject



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/buildfile.rb', line 72

def get_custom_flags

	custom_flags = ""

	begin
		@project_yaml["custom_flags"].each do |i|
			custom_flags += concat_list(i["prefix"],
																	i["list"],
																	(i["space"] || false))
			custom_flags += ' '
		end

		custom_flags.strip!
	rescue
		""
	end

	return custom_flags;
end

#get_file_listObject



36
37
38
# File 'lib/buildfile.rb', line 36

def get_file_list
	concat_list('', @project_yaml["source_files"])
end

#get_inc_dirsObject



41
42
43
# File 'lib/buildfile.rb', line 41

def get_inc_dirs
	concat_list('-I', @project_yaml["include_dirs"])
end

#get_lib_dirsObject



46
47
48
# File 'lib/buildfile.rb', line 46

def get_lib_dirs
	concat_list('-L', @project_yaml["library_dirs"])
end

#get_libsObject



51
52
53
# File 'lib/buildfile.rb', line 51

def get_libs
	concat_list('-', @project_yaml["libraries"])
end

#get_other_flagsObject



56
57
58
# File 'lib/buildfile.rb', line 56

def get_other_flags
	concat_list('-', @project_yaml["other_flags"])
end

#get_output_nameObject



25
26
27
# File 'lib/buildfile.rb', line 25

def get_output_name
	@project_yaml["output_name"] || get_project_name()
end

#get_output_typeObject



16
17
18
# File 'lib/buildfile.rb', line 16

def get_output_type
  @project_yaml["type"]
end

#get_pre_processor_definesObject



61
62
63
64
65
66
67
68
69
# File 'lib/buildfile.rb', line 61

def get_pre_processor_defines
	begin
		@project_yaml["pre_processor_defines"].map {
			|i| "-D" + i[0].to_s + (if i[1] then "=" + i[1].to_s else "" end)
		}.flatten.join(' ') || ""
	rescue
		""
	end
end

#get_project_nameObject



20
21
22
23
# File 'lib/buildfile.rb', line 20

def get_project_name
    default_type = if get_output_type == "static_lib" then "lib.a" else "a.out" end
	@project_yaml["name"] || default_type
end