Sha256: 79e3589bb4336d9ecfc25c8a365334e31db1bd688d37c709ea45b5665f56fbf5

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

require 'fileutils'

unless find_header('funchook.h', ext_path)

  FUNCHOOK_DIR_NAME = 'funchook'
  FUNCHOOK_DIR = File.expand_path(File.join(File.dirname(File.expand_path(__FILE__)), '..', FUNCHOOK_DIR_NAME))

  COMMANDS = ['./autogen.sh', './configure', 'make clean', 'make'].freeze

  puts 'Building funchook'
  COMMANDS.each do |command|
    puts "executing: #{ command } in #{ FUNCHOOK_DIR }"
    Dir.chdir(FUNCHOOK_DIR) do
      `#{ command }`
    end
  end

  SOURCE_PATHS = [
    File.join('include', 'funchook.h'),
    File.join('src',     'libfunchook.dylib'),
    File.join('src',     'libfunchook.so')
  ].freeze

  TARGET_PATHS = [
    File.expand_path(File.join(File.expand_path(__dir__), '..', 'shared_libraries')),
    File.expand_path(__dir__) # should be ext/
  ].freeze

  puts 'Copying required files'

  SOURCE_PATHS.each do |source_file|
    source_file_path = File.join(FUNCHOOK_DIR, source_file)
    unless File.exist?(source_file_path)
      puts "Skipping #{ source_file_path }, file doesn't exist"
      next
    end

    TARGET_PATHS.each do |target_path|
      puts "Copying #{ source_file_path } into #{ target_path }"
      FileUtils.cp(source_file_path, target_path)
    end
  end
end

have_header('funchook.h', ext_path)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
contrast-agent-3.8.4 ext/build_funchook.rb