blob: 5b11a879321c709f0a16de7ee8d2bc3735b82d4f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#!/usr/bin/env ruby
def make_param_assigns(num)
(0 ... num)
.map { |n| "#{('A'.ord + n).chr} = *param[#{n}];" }
.join("\n ")
end
if ARGV.length < 1
puts "Usage: #{__FILE__} <PluginName> [<NCtrlPorts>]"
exit
end
root = File.dirname(__FILE__)
plugin_name = ARGV[0]
plugin_slug = plugin_name.downcase
n_ctrl_ports = ARGV[1] || '1'
target_dir = File.join(root, 'src', plugin_name)
template_dir = File.join(root, 'Template')
puts "Creating plugin #{plugin_name}..."
Templates = %w{
manifest.ttl.in
Plugin.ttl
Plugin.h
Plugin.cpp
}
begin
Dir.mkdir(target_dir)
Templates.each do |t|
tpl = IO.read(File.join(template_dir, t))
.gsub('@Plugin@', plugin_name)
.gsub('@plugin@', plugin_slug)
.gsub('@NCtrlPorts@', n_ctrl_ports)
.gsub('@AssignParams@', make_param_assigns(n_ctrl_ports.to_i))
fname = t.sub('Plugin', plugin_name)
puts " - #{fname}..."
File.open(File.join(target_dir, fname), "w") do |f|
f.write(tpl)
end
end
rescue SystemCallError => e
puts "Could not create plugin: #{e}"
puts "Aborting!"
end
|