Class: Kompo::MakeMainC
- Inherits:
-
Taski::Task
- Object
- Taski::Task
- Kompo::MakeMainC
- Defined in:
- lib/kompo/tasks/make_main_c.rb
Overview
Generate main.c from ERB template Required context:
- exts: Array of [so_path, init_func] pairs from native gem builds
Dependencies provide:
- WorkDir.path
- CopyProjectFiles.entrypoint_path
Defined Under Namespace
Classes: TemplateContext
Instance Method Summary collapse
Instance Method Details
#clean ⇒ Object
32 33 34 35 36 37 |
# File 'lib/kompo/tasks/make_main_c.rb', line 32 def clean return unless @path && File.exist?(@path) FileUtils.rm_f(@path) puts "Cleaned up main.c" end |
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/kompo/tasks/make_main_c.rb', line 16 def run work_dir = WorkDir.path @path = File.join(work_dir, "main.c") return if File.exist?(@path) template_path = File.join(__dir__, "..", "..", "main.c.erb") template = ERB.new(File.read(template_path)) # Build context object for ERB template context = build_template_context File.write(@path, template.result(binding)) puts "Generated: main.c" end |