Skip to content

Commit

Permalink
Merge pull request #79 from jakolehm/fix-install-from-gem-gemspec
Browse files Browse the repository at this point in the history
Fix install_from_gem/gemspec
  • Loading branch information
pmq20 committed Apr 16, 2019
2 parents 478cde2 + 71d4667 commit 8df2c1b
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions lib/compiler.rb
@@ -1,5 +1,5 @@
# Copyright (c) 2017 Minqi Pan <pmq2001@gmail.com>
#
#
# This file is part of Ruby Compiler, distributed under the MIT License
# For full terms see the included LICENSE file

Expand Down Expand Up @@ -29,11 +29,11 @@ class Compiler
def self.ruby_api_version
@ruby_api_version ||= peek_ruby_api_version
end

def self.ruby_version
@ruby_version ||= peek_ruby_version
end

def self.peek_ruby_version
version_info = File.read(File.join(PRJ_ROOT, 'ruby/version.h'))
if version_info =~ /RUBY_VERSION\s+"([^"]+)"\s*$/
Expand All @@ -42,7 +42,7 @@ def self.peek_ruby_version
raise 'Cannot peek RUBY_VERSION'
end
end

def self.peek_ruby_api_version
version_info = File.read(File.join(PRJ_ROOT, 'ruby/include/ruby/version.h'))
versions = []
Expand All @@ -63,7 +63,7 @@ def self.peek_ruby_api_version
end
versions.join('.')
end

def initialize(entrance, options = {})
if entrance
if File.exist?(File.expand_path(entrance))
Expand All @@ -77,12 +77,12 @@ def initialize(entrance, options = {})
@options = options
@utils = Utils.new(options)

@gem_package = GemPackage.new(@entrance, @options, @utils) if @options[:gem]

init_options
init_entrance if entrance
init_tmpdir

@gem_package = GemPackage.new(@entrance, @options, @utils) if @options[:gem]

log "Ruby Compiler (rubyc) v#{::Compiler::VERSION}"
if entrance
log "- entrance: #{@entrance}"
Expand Down Expand Up @@ -136,7 +136,7 @@ def init_entrance
break
end
if File.exist?(File.join(@root, 'Gemfile')) || File.exist?(File.join(@root, 'gems.rb')) || Dir.exist?(File.join(@root, '.git'))
break
break
end
end
log "-> Project root not supplied, #{@root} assumed."
Expand Down Expand Up @@ -295,7 +295,8 @@ def install_from_gem(gem)
@utils.chdir(@pre_prepare_dir) do
@utils.run(@local_toolchain,
@gem, "install", gem,
"--no-document")
"--install-dir", @gems_dir,
"--no-document")

if File.exist?(File.join(@gems_dir, "bin/#{@entrance}"))
@memfs_entrance = "#{MEMFS}/lib/ruby/gems/#{self.class.ruby_api_version}/bin/#{@entrance}"
Expand Down Expand Up @@ -407,7 +408,8 @@ def install_from_gemspec(gemspec, gemfiles)

@utils.run(@local_toolchain,
@gem, "install", gem,
"--no-document")
"--install-dir", @gems_dir,
"--no-document")

if File.exist?(File.join(@gems_dir, "bin/#{@entrance}"))
@memfs_entrance = "#{MEMFS}/lib/ruby/gems/#{self.class.ruby_api_version}/bin/#{@entrance}"
Expand Down Expand Up @@ -462,7 +464,7 @@ def stuff(library)

@utils.cp_r source, target, preserve: true

log "=> Stuffing #{library}"
log "=> Stuffing #{library}..."

@utils.capture_run_io "stuff_#{library}" do
@utils.chdir(target) do
Expand Down Expand Up @@ -880,7 +882,7 @@ def make_enclose_io_vars
@utils.chdir(@ruby_source_dir) do
File.open("include/enclose_io.h", "w") do |f|
# remember to change libsquash's sample/enclose_io.h as well
# might need to remove some object files at the 2nd pass
# might need to remove some object files at the 2nd pass
f.puts '#ifndef ENCLOSE_IO_H_999BC1DA'
f.puts '#define ENCLOSE_IO_H_999BC1DA'
f.puts ''
Expand Down Expand Up @@ -930,7 +932,7 @@ def mempath(path)
raise "path #{path} should start with #{@root}" unless @root == path[0...(@root.size)]
"#{MEMFS}/local#{path[(@root.size)..-1]}"
end

def prepare_flags1
@ldflags = ''
@cflags = ''
Expand All @@ -948,7 +950,7 @@ def prepare_flags1
@cflags += ' -fPIC -O3 -fno-fast-math -ggdb3 -Os -fdata-sections -ffunction-sections -pipe '
end
end

if Gem.win_platform?
@compile_env = {
'CI' => 'true',
Expand Down

0 comments on commit 8df2c1b

Please sign in to comment.