From 405a0dd5514482fa50785873885d0cfb6a69522b Mon Sep 17 00:00:00 2001 From: Niklas van Schrick Date: Mon, 18 Nov 2024 21:40:30 +0100 Subject: [PATCH] Adjust ruby generation for external proto files --- build/ruby/Rakefile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/build/ruby/Rakefile b/build/ruby/Rakefile index 546f73e..8f6dfcf 100644 --- a/build/ruby/Rakefile +++ b/build/ruby/Rakefile @@ -40,7 +40,15 @@ namespace :generate_ruby do Dir["#{output_dir}/*_pb.rb"].each do |file| code = File.read(file) - code = code.gsub(/require '(\S+)_pb'/, "require_relative '\\1_pb'") + code = code.gsub(/require '(\S+)_pb'/) do |str| + match = Regexp.last_match[1] + + if File.exist?("#{output_dir}/#{match}_pb.rb") + "require_relative '#{match}_pb'" + else + str + end + end File.write(file, code) end end