Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 0 additions & 165 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,95 +102,6 @@ end

################ Build Gem Task ################

desc 'alias for fetch_oboe_file_from_staging'
task :fetch do
Rake::Task['fetch_oboe_file'].invoke('stg')
end

desc 'fetch oboe file from different environment'
task :fetch_oboe_file, [:env] do |_t, args|
abort('Missing env argument (abort)') if args['env'].nil? || args['env'].empty?

begin
swig_version = `swig -version`
rescue StandardError => e
swig_version = ''
puts "Error getting swig version: #{e.message}"
end
swig_valid_version = swig_version.scan(/swig version [34].\d*.\d*/i)
if swig_valid_version.empty?
warn '== ERROR ================================================================='
warn "Could not find required swig version > 3.0.8, found #{swig_version.inspect}"
warn 'Please install swig "> 3.0.8" and try again.'
warn '=========================================================================='
raise
else
warn "+++++++++++ Using #{swig_version.strip.split("\n")[0]}"
end

ext_src_dir = File.expand_path('ext/oboe_metal/src')
ext_lib_dir = File.expand_path('ext/oboe_metal/lib')
oboe_version = File.read(File.join(ext_src_dir, 'VERSION')).strip

case args['env']
when 'dev'
oboe_dir = 'https://solarwinds-apm-staging.s3.us-west-2.amazonaws.com/apm/c-lib/nightly/'
puts 'Fetching c-lib from DEVELOPMENT'
puts 'This is an unstable build and this gem should only be used for testing'
when 'stg'
oboe_dir = "https://agent-binaries.global.st-ssp.solarwinds.com/apm/c-lib/#{oboe_version}"
puts "Fetching c-lib from STAGING !!!!!! C-Lib VERSION: #{oboe_version} !!!!!!!"
when 'prod'
oboe_dir = "https://agent-binaries.cloud.solarwinds.com/apm/c-lib/#{oboe_version}"
puts "Fetching c-lib from PRODUCTION !!!!!! C-Lib VERSION: #{oboe_version} !!!!!!!"
end

# remove all oboe* files, they may hang around because of name changes
Dir.glob(File.join(ext_src_dir, 'oboe*')).each do |file|
puts "deleting #{file}"
File.delete(file)
end

# oboe and bson header files
FileUtils.mkdir_p(File.join(ext_src_dir, 'bson'))
files = %w[bson/bson.h bson/platform_hacks.h
oboe.h oboe_api.h oboe_api.cpp oboe_debug.h oboe.i]

fetch_file_from_cloud(files, oboe_dir, ext_src_dir, 'include')

sha_files = ['liboboe-1.0-lambda-x86_64.so.sha256',
'liboboe-1.0-lambda-aarch64.so.sha256',
'liboboe-1.0-x86_64.so.sha256',
'liboboe-1.0-aarch64.so.sha256',
'liboboe-1.0-alpine-x86_64.so.sha256',
'liboboe-1.0-alpine-aarch64.so.sha256']

fetch_file_from_cloud(sha_files, oboe_dir, ext_lib_dir)

FileUtils.cd(ext_src_dir) do
sh 'swig -c++ -ruby -module oboe_metal -o oboe_swig_wrap.cc oboe.i'
FileUtils.rm('oboe.i') if args['env'] != 'prod'
end

puts 'Fetching finished.'
end

def fetch_file_from_cloud(files, oboe_dir, dest_dir, folder = '')
files.each do |filename|
remote_file = File.join(oboe_dir, folder, filename)
local_file = File.join(dest_dir, filename)

puts "fetching #{remote_file}"
puts " to #{local_file}"

begin
IO.copy_stream(URI.parse(remote_file).open, local_file)
rescue StandardError => e
puts "File #{remote_file} missing. #{e.message}"
end
end
end

desc 'Build and publish to Rubygems'
# !!! publishing requires gem >=3.0.5 !!!
# Don't run with Ruby versions < 2.7 they have gem < 3.0.5
Expand All @@ -204,82 +115,6 @@ task :build_and_publish_gem do
exit 1 if ENV['GEM_HOST_API_KEY'] && !system('gem', 'push', gem_file)
end

desc "Build the gem's c extension"
task :compile do
puts "== Building the c extension against Ruby #{RUBY_VERSION}"

pwd = Dir.pwd
ext_dir = File.expand_path('ext/oboe_metal')
final_so = File.expand_path('lib/libsolarwinds_apm.so')
so_file = File.expand_path('ext/oboe_metal/libsolarwinds_apm.so')

Dir.chdir ext_dir
sh "#{Gem.ruby} extconf.rb"
sh '/usr/bin/env make'

FileUtils.rm_f(final_so)

if File.exist?(so_file)
FileUtils.mv(so_file, final_so)
Dir.chdir(pwd)
puts "== Extension built and moved to #{final_so}"
else
Dir.chdir(pwd)
puts '!! Extension failed to build (see above). Have the required binary and header files been fetched?'
puts '!! Try the tasks in this order: clean > fetch > compile'
end
end

desc 'Clean up extension build files'
task :clean do
pwd = Dir.pwd
ext_dir = File.expand_path('ext/oboe_metal')
symlinks = [
File.expand_path('lib/libsolarwinds_apm.so'),
File.expand_path('ext/oboe_metal/lib/liboboe.so'),
File.expand_path('ext/oboe_metal/lib/liboboe-1.0.so.0')
]

symlinks.each do |symlink|
FileUtils.rm_f symlink
end
Dir.chdir ext_dir
sh '/usr/bin/env make clean' if File.exist? 'Makefile'

FileUtils.rm_f 'src/oboe_swig_wrap.cc'
Dir.chdir pwd
end

desc 'Remove all built files and extensions'
task :distclean do
pwd = Dir.pwd
ext_dir = File.expand_path('ext/oboe_metal')
mkmf_log = File.expand_path('ext/oboe_metal/mkmf.log')
symlinks = [
File.expand_path('lib/libsolarwinds_apm.so'),
File.expand_path('ext/oboe_metal/lib/liboboe.so'),
File.expand_path('ext/oboe_metal/lib/liboboe-1.0.so.0')
]

if File.exist? mkmf_log
symlinks.each do |symlink|
FileUtils.rm_f symlink
end
Dir.chdir ext_dir
sh '/usr/bin/env make distclean' if File.exist? 'Makefile'

Dir.chdir pwd
else
puts 'Nothing to distclean. (nothing built yet?)'
end
end

desc 'Rebuild the gem c extension without fetching the oboe files, without recreating the swig wrapper'
task recompile: %i[distclean compile]

desc 'Build the gem c extension ...'
task cfc: %i[clean fetch compile]

desc 'Build gem locally for testing'
task :build_gem do
puts "\n=== building for MRI ===\n"
Expand Down
126 changes: 0 additions & 126 deletions ext/oboe_metal/README.md

This file was deleted.

Loading