Sha256: c8a8b8f2018f796f290bab77fa4cb4be7a26ebac10678500b14ca25a8ed0a797
Contents?: true
Size: 1.76 KB
Versions: 7
Compression:
Stored size: 1.76 KB
Contents
# encoding: utf-8 # This file is distributed under New Relic's license terms. # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details. namespace :proto do desc "Generate proto files" task :generate do def extract_license_terms file_contents text = [] text << file_contents.shift while !file_contents.empty? && file_contents[0] =~ /^#/ text << "" text end # adds the NewRelic License notice to the top of the generated files # Removes require lines since these are replicated in the proto.rb file. def add_license_preamble_and_remove_requires output_path gemspec_path = File.expand_path(File.join(output_path, '..', '..', '..', '..', '..')) license_terms = extract_license_terms File.readlines(File.join(gemspec_path, "Gemfile")) Dir.glob(File.join output_path, "*.rb") do |filename| contents = File.readlines filename contents.reject! { |r| r =~ /^\s*require\s.*$/ } File.open(filename, 'w') do |output| output.puts license_terms output.puts contents end end end gem_folder = File.expand_path File.join(File.dirname(__FILE__), "..") proto_filename = File.join gem_folder, "lib", "new_relic", "proto", "infinite_tracing.proto" output_path = File.join gem_folder, "lib", "new_relic", "infinite_tracing", "proto" FileUtils.mkdir_p output_path cmd = [ "grpc_tools_ruby_protoc", "-I#{gem_folder}/lib/new_relic/proto", "--ruby_out=#{output_path}", "--grpc_out=#{output_path} #{proto_filename}" ].join(" ") if system cmd puts "Proto file generated!" add_license_preamble_and_remove_requires output_path else puts "Failed to generate proto file." end end end
Version data entries
7 entries across 7 versions & 1 rubygems