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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'fileutils'
require 'FelBind'
def print_help
commands = [
" # Prints Help",
" help",
"",
" # prints out intermediate",
" parse -<backend> <input-file list>",
" Valid Backends:",
" -uctags (default)",
"",
" # Creates bindings gem",
" build -<frontend> <input-file> <destination>",
" Valid Frontends:",
" -mruby (default)",
]
commands.each { |cmd| puts cmd }
end
if (ARGV.size == 0) || (ARGV[0] == 'help')
print_help
return
end
if ARGV[0] == 'parse'
file_path = ''
if ARGV[1].start_with? '-'
if ARGV[1] != '-uctags'
puts 'invalid backend'
return
else
file_path = ARGV[2]
end
else
file_path = ARGV[1]
end
if !File.exist?(file_path)
puts "invalid file path"
return
end
pp FelBind::Backends::UCTags.parse(file_path)
elsif ARGV[0] == 'build'
file_path = ''
dest_dir = ''
if ARGV[1] == '-mruby'
file_path = ARGV[2]
dest_dir = ARGV[3]
else
file_path = ARGV[1]
dest_dir = ARGV[2]
end
if !File.exist?(file_path)
puts "invalid file path"
return
end
puts "TEST"
FileUtils.mkpath(dest_dir) unless File.exist?(dest_dir)
#if !File.directory?
# puts "invalid destination"
# return
#end
FelBind::Frontend::Mruby.build(file_path, dest_dir)
else
print_help
return
end
|