ext/pyroscope/extconf.rb in pyroscope-0.0.12 vs ext/pyroscope/extconf.rb in pyroscope-0.0.13

- old
+ new

@@ -7,11 +7,11 @@ HEADER_DIRS = [INCLUDEDIR] LIB_DIRS = [LIBDIR, File.expand_path(File.join(File.dirname(__FILE__), "lib"))] -COMMIT = "bfb9a32" +COMMIT = "39a3d9c" # TODO: this is not very accurate, but it works for now OS = RUBY_PLATFORM.include?("darwin") ? "mac" : "linux" ARCH = RUBY_PLATFORM.include?("arm64") ? "arm64" : "amd64" @@ -23,27 +23,45 @@ puts "PYROSCOPE_RUBY_LOCAL yes" system "cp #{ENV["HOME"]}/pyroscope/out/libpyroscope.rbspy.a #{File.join(ROOT, "lib/libpyroscope.rbspy.a")}" system "cp #{ENV["HOME"]}/pyroscope/out/librustdeps.a #{File.join(ROOT, "lib/librustdeps.a")}" else Net::HTTP.start("dl.pyroscope.io", 443, :use_ssl => true) do |http| - res1 = http.get(PREFIX+"/libpyroscope.rbspy.a") - raise "HTTP error: #{res1.code}" unless res1.code == "200" - lib1 = res1.body - File.binwrite(File.join(ROOT, "lib/libpyroscope.rbspy.a"), lib1) + req = Net::HTTP::Get.new(PREFIX+"/libpyroscope.rbspy.combo.a.gz") + http.request(req) do |resp| + raise "HTTP error: #{resp.code}" unless resp.code == "200" - res2 = http.get(PREFIX+"/librustdeps.a") - raise "HTTP error: #{res2.code}" unless res2.code == "200" - lib2 = res2.body - File.binwrite(File.join(ROOT, "lib/librustdeps.a"), lib2) + r, w = IO.pipe + + t = Thread.new do + zreader = Zlib::GzipReader.new(r) + File.open(File.join(ROOT, "lib/libpyroscope.rbspy.combo.a"), "wb") do |f| + loop do + begin + chunk = zreader.readpartial(32768) + break if chunk.nil? + rescue EOFError + break + end + f.write(chunk) + end + end + end + + resp.read_body do |chunk| + w.write(chunk) + end + + t.join + end end end -# TODO: figure out how to fix this bug -system "strip --strip-debug #{File.join(ROOT, "lib/libpyroscope.rbspy.a")}" +# this is now done upstream +# system "strip --strip-debug #{File.join(ROOT, "lib/libpyroscope.rbspy.combo.a")}" dir_config('pyroscope', HEADER_DIRS, LIB_DIRS) -libs = ['-lpyroscope.rbspy', '-lrustdeps'] +libs = ['-lpyroscope.rbspy.combo'] libs.each do |lib| $LOCAL_LIBS << "#{lib} " end create_makefile('pyroscope_c')