Skip to content

Commit

Permalink
Removed config_version hackery.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Feb 7, 2014
1 parent 2813c32 commit 318dedd
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 79 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ tmtags
/bootstrap
Gemfile.lock

# .build_ruby tracks the path to the Ruby executable
.build_ruby

# .build_signature tracks changes to the build system files
.build_signature

# .revision tracks configure and code revision consistency
.revision

Expand Down
44 changes: 5 additions & 39 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'bundler/setup'
require 'redcard'
require './rakelib/configure'
require './rakelib/build_signature'

include Rake::DSL if Rake.const_defined? :DSL

Expand All @@ -27,8 +28,8 @@ def load_configuration
config_h = File.expand_path "../vm/gen/config.h", __FILE__

unless File.exist?(config_rb) and File.exist?(config_h)
STDERR.puts "Please run ./configure first"
exit 1
sh "./configure"
return load_configuration
end

load config_rb
Expand All @@ -37,7 +38,8 @@ end

load_configuration

unless BUILD_CONFIG[:config_version] == 189
unless verify_build_signature or
Rake.application.top_level_tasks.include?("clean")
STDERR.puts "Your configuration is outdated, please run ./configure first"
exit 1
end
Expand All @@ -56,42 +58,6 @@ def libprefixdir
end
end

# Records the full path to the ruby executable that runs this configure
# script. That path will be made available to the rest of the build system
# so the same version of ruby is invoked as needed.
#
# This is duplicated from the configure script for now.
@build_ruby = nil

def build_ruby
unless @build_ruby
bin = RbConfig::CONFIG["RUBY_INSTALL_NAME"] || RbConfig::CONFIG["ruby_install_name"]
bin += (RbConfig::CONFIG['EXEEXT'] || RbConfig::CONFIG['exeext'] || '')
@build_ruby = File.join(RbConfig::CONFIG['bindir'], bin)
end
@build_ruby
end

unless BUILD_CONFIG[:build_ruby] == build_ruby || ENV["RBX_SKIP_BUILD_RUBY_CHECK"]
STDERR.puts "\nUnable to build using the running Ruby executable (#{build_ruby}). Expected #{BUILD_CONFIG[:build_ruby]}\n\n"

STDERR.puts "To resolve this issue:"
if ENV['PATH'] =~ /#{BUILD_CONFIG[:bindir]}/
STDERR.puts " * Remove '#{BUILD_CONFIG[:bindir]}' from your PATH."
elsif build_ruby == File.join(BUILD_CONFIG[:bindir], BUILD_CONFIG[:program_name])
# This may occur using rbx from the build directory to build a version
# of rbx to install. The rbx in the build directory will pick up the
# lib/rubinius/build_config.rb that was just written by configure.
# Obviously, this chewing gum, duct tape, bailing wire, and toilet paper
# system needs fixing.
STDERR.puts " * Configure using a Ruby executable other than the one in your build directory."
else
STDERR.puts " * Use '#{BUILD_CONFIG[:build_ruby]}' to build."
end

exit 1
end

# Set the build compiler to the configured compiler unless
# the compiler is set via CC environment variable.
ENV['CC'] = BUILD_CONFIG[:cc] unless ENV['CC']
Expand Down
31 changes: 3 additions & 28 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ require 'rubygems'
require 'bundler/setup'
require './rakelib/configure'
require './rakelib/release'
require './rakelib/build_signature'
require 'rbconfig'
require 'tempfile'
require 'fileutils'
Expand Down Expand Up @@ -190,8 +191,6 @@ class Configure
@release_date = nil

# Configure settings
@build_ruby = nil
@config_version = 189
@release_build = !git_directory
@release_config = false
end
Expand Down Expand Up @@ -1587,18 +1586,6 @@ int main() { return tgetnum(""); }
detect_strerror
end

# Records the full path to the ruby executable that runs this configure
# script. That path will be made available to the rest of the build system
# so the same version of ruby is invoked as needed.
def build_ruby
unless @build_ruby
bin = RbConfig::CONFIG["RUBY_INSTALL_NAME"] || RbConfig::CONFIG["ruby_install_name"]
bin += (RbConfig::CONFIG['EXEEXT'] || RbConfig::CONFIG['exeext'] || '')
@build_ruby = File.join(RbConfig::CONFIG['bindir'], bin)
end
@build_ruby
end

# Checks whether the given config file is a Perl script by checking its first
# line for a Perl hashbang.
def llvm_config_cmd(config)
Expand Down Expand Up @@ -1702,13 +1689,11 @@ int main() { return tgetnum(""); }
:patch_version => @patch_version,
:release_date => @release_date || default_release_date,
:revision => build_revision,
:config_version => @config_version,
}
end

build_config = {
:command_line => @command_line,
:build_ruby => build_ruby,
:build_make => @make,
:build_rake => @rake,
:build_perl => @perl,
Expand Down Expand Up @@ -1924,7 +1909,7 @@ int main() { return tgetnum(""); }
end

def check_force_clean
if Rubinius::BUILD_CONFIG[:config_version] != @config_version
unless verify_build_signature
@log.write "\nDetected old configuration settings, forcing a clean build"
system("#{build_ruby} -S #{@rake} clean")
end
Expand Down Expand Up @@ -2109,17 +2094,6 @@ int main() { return tgetnum(""); }

set_filesystem_paths

if File.join(@bindir, @program_name) == build_ruby
@log.error "\nYou are attempting to build using the instance of Rubinius that you are building.\n\n"

@log.error "To resolve this issue:"
if ENV['PATH'] =~ /#{@bindir}/
@log.error " * Remove '#{@bindir}' from your PATH."
end

failure " * Use a Ruby executable other than '#{build_ruby}' to build."
end

process
if @release_build
verify_gems
Expand All @@ -2128,6 +2102,7 @@ int main() { return tgetnum(""); }
end
setup_gems unless @release_config
write_configure_files
write_build_signature

return if @release_config

Expand Down
40 changes: 40 additions & 0 deletions rakelib/build_signature.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
require './rakelib/digest_files'

def build_ruby
bin = RbConfig::CONFIG["RUBY_INSTALL_NAME"] || RbConfig::CONFIG["ruby_install_name"]
bin += (RbConfig::CONFIG['EXEEXT'] || RbConfig::CONFIG['exeext'] || '')
File.join(RbConfig::CONFIG['bindir'], bin)
end

def build_signature_name
".build_signature"
end

def load_build_signature
File.read(build_signature_name).chomp if File.exist? build_signature_name
end

def write_build_signature
File.open build_signature_name, "w" do |f|
f.puts build_signature
end
end

def build_ruby_name
".build_ruby"
end

def write_build_ruby
File.open build_ruby_name, "w" do |f|
f.puts build_ruby
end
end

def build_signature
write_build_ruby
digest_files Dir[*%W[configure config.rb #{build_ruby} Rakefile rakelib/*]]
end

def verify_build_signature
load_build_signature == build_signature
end
15 changes: 15 additions & 0 deletions rakelib/digest_files.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'digest/sha1'

def digest_files(files)
digest = Digest::SHA1.new

files.each do |name|
File.open name, "r" do |file|
while chunk = file.read(1024)
digest << chunk
end
end
end

digest.hexdigest
end
15 changes: 3 additions & 12 deletions rakelib/kernel.rake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# parts of the build (including the top-level build task for generating the
# entire kernel).

require "rakelib/digest_files"

# drake does not allow invoke to be called inside tasks
def kernel_clean
rm_rf Dir["**/*.rbc",
Expand Down Expand Up @@ -125,19 +127,8 @@ config_files = FileList[
signature_files = kernel_files + config_files + runtime_gem_files + ext_files - ffi_files

file signature_file => signature_files do
require 'digest/sha1'
digest = Digest::SHA1.new

signature_files.each do |name|
File.open name, "r" do |file|
while chunk = file.read(1024)
digest << chunk
end
end
end

# Collapse the digest to a 64bit quantity
hd = digest.hexdigest
hd = digest_files signature_files
SIGNATURE_HASH = hd[0, 16].to_i(16) ^ hd[16,16].to_i(16) ^ hd[32,8].to_i(16)

File.open signature_file, "wb" do |file|
Expand Down

0 comments on commit 318dedd

Please sign in to comment.