Class: NormalMakefileMaker

Inherits:
Object
  • Object
show all
Defined in:
lib/simple-make/normal_makefile_maker.rb

Direct Known Subclasses

RootMakefileMaker

Instance Method Summary collapse

Constructor Details

#initialize(project, context, template = "makefile") ⇒ NormalMakefileMaker

Returns a new instance of NormalMakefileMaker.



6
7
8
9
10
# File 'lib/simple-make/normal_makefile_maker.rb', line 6

def initialize project, context, template = "makefile"
  @project = project
  @makefile_template = template
  @context = context
end

Instance Method Details

#generate_make_fileObject



12
13
14
15
16
# File 'lib/simple-make/normal_makefile_maker.rb', line 12

def generate_make_file
  $std_logger.debug "generating makefile for project #{@project.name} and its deps"
  generate_makefile_for_dep_project
  generate_make_file_for_current_project
end

#generate_make_file_for_current_projectObject



24
25
26
27
28
29
30
# File 'lib/simple-make/normal_makefile_maker.rb', line 24

def generate_make_file_for_current_project
  $std_logger.debug  "generating makefile for project #{@project.name}"
  makefile = ERB.new(Template.template_content(@makefile_template))
  File.open("#{@project.workspace}/#{@project.makefile_name}", "w") do |f|
    f.write makefile.result(@context)
  end
end

#generate_makefile_for_dep_projectObject



18
19
20
21
22
# File 'lib/simple-make/normal_makefile_maker.rb', line 18

def generate_makefile_for_dep_project
  $std_logger.debug "generating makefile for dep projects"
  $std_logger.debug "projects: #{@project.dep_projects}"
  @project.dep_projects.each(&:generate_make_file)
end