6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/protein/proto_compiler.rb', line 6
def call(proto_directory: "./lib", namespace: nil)
proto_files = Dir.glob("#{proto_directory}/**/*.proto")
proto_files.each do |proto_file|
puts "Compiling #{proto_file}"
cmd_args = [
"protoc",
"-I", proto_directory,
"--ruby_out", proto_directory,
proto_file
]
output = `#{cmd_args.shelljoin} 2>&1`
unless $?.success?
raise "Proto compilation failed:\n#{output}"
end
end
rewrite_namespace(proto_directory, namespace) if namespace
end
|