Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Handle release label and date from git, release tar, or random tar.

  • Loading branch information...
commit 304da3f0c696a1918c74cc860fb134e0f1149876 1 parent 43b2b63
@brixen brixen authored
View
3  .gitignore
@@ -50,6 +50,9 @@ tmtags
/work
/staging
+# .revision tracks configure and code revision consistency
+.revision
+
# ignore gems and commands installed by gems
/gems/*
/bin/*
View
2  Rakefile
@@ -53,7 +53,7 @@ end
load_configuration
-unless BUILD_CONFIG[:config_version] == 174
+unless BUILD_CONFIG[:config_version] == 175
STDERR.puts "Your configuration is outdated, please run ./configure first"
exit 1
end
View
41 configure
@@ -5,6 +5,7 @@ if ENV["RUBYLIB"]
exit 1
end
+require './rakelib/release'
require 'rbconfig'
require 'tempfile'
require 'fileutils'
@@ -124,7 +125,8 @@ class Configure
@libversion = "2.0"
@patch_version = "0"
@release = validate_release_label
- @config_version = 174
+ @release_date = validate_release_date
+ @config_version = 175
end
# Set up system commands to run in cmd.exe on Windows. Either Windows
@@ -257,7 +259,7 @@ class Configure
o.doc "\n Release Settings"
o.on "--release", "LABEL", "Set release from { nightly, weekly, monthly, rcN, final }" do |label|
- @release = validate_release label
+ @release = validate_release_label label
end
o.on "--release-date", "DATE", "Set release date to DATE in yyyy-mm-dd format" do |date|
@@ -478,28 +480,6 @@ class Configure
version
end
- def validate_release(label)
- date = Time.now
- case label
- when "nightly"
- "n#{date.strftime("%j").to_i}"
- when "weekly"
- "w#{date.strftime("%V").to_i}"
- when "monthly"
- "m#{date.month}"
- when /^rc\d+/
- label
- when "final"
- nil
- else
- raise "unknown release label #{label}"
- end
- end
-
- def validate_release_date(str)
- Date.parse(str).strftime
- end
-
def normalize_versions(str)
versions = str.gsub(/[^\d,]/, "").split(',')
versions.each do |ver|
@@ -1670,8 +1650,11 @@ module Rubinius
:bin_links => #{@bin_links.inspect},
:use_bin_links => #{@use_bin_links},
:version => "#{version}",
+ :patch_version => "#{@patch_version}",
:libversion => "#{@libversion}",
+ :release => "#{@release}",
:release_date => "#{@release_date}",
+ :revision => "#{read_revision}",
:config_version => #{@config_version},
:windows => #{@windows},
:darwin => #{@darwin},
@@ -1710,11 +1693,9 @@ end
#define RBX_HDR20_PATH "#{@include20dir}"
#define RBX_SITE_PATH "#{@sitedir}"
#define RBX_VENDOR_PATH "#{@vendordir}"
-#define RBX_VERSION "#{version}"
#define RBX_LIB_VERSION "#{@libversion}"
#define RBX_LDSHARED "#{@ldshared}"
#define RBX_LDSHAREDXX "#{@ldsharedxx}"
-#define RBX_RELEASE_DATE "#{@release_date}"
#define RBX_SIZEOF_LONG #{sizeof("long")}
#define RBX_LLVM_API_VER #{@llvm_api_version}
#define RBX_LIBC "#{@libc}"
@@ -1753,8 +1734,11 @@ end
write_have_defines f
end
- FileUtils.cp vm_config_h, "vm/capi/18/include/rbx_config.h"
- FileUtils.cp vm_config_h, "vm/capi/19/include/rbx_config.h"
+ FileUtils.mkdir_p "vm/capi/18/include/gen"
+ FileUtils.mkdir_p "vm/capi/19/include/gen"
+
+ FileUtils.cp vm_config_h, "vm/capi/18/include/gen/rbx_config.h"
+ FileUtils.cp vm_config_h, "vm/capi/19/include/gen/rbx_config.h"
# Write the config file for vendor/oniguruma.
File.open "vendor/oniguruma/config.h", "wb" do |f|
@@ -2030,5 +2014,6 @@ Available commands are:
end
end
+record_revision
STDOUT.sync = true
Configure.new(root).run
View
76 rakelib/release.rb
@@ -0,0 +1,76 @@
+def git_directory
+ git_dir = File.expand_path "../../.git", __FILE__
+ File.directory?(git_dir) && git_dir
+end
+
+def read_revision
+ `git rev-parse HEAD`.chomp
+end
+
+def build_revision
+ if git_directory
+ read_revision
+ elsif File.file? release_revision
+ IO.read release_revision
+ else
+ "build"
+ end
+end
+
+def record_revision
+ if git_directory
+ File.open(release_revision, "wb") { |f| f.write read_revision }
+ end
+end
+
+def release_revision
+ File.expand_path "../../.revision", __FILE__
+end
+
+def rubinius_version
+ "#{BUILD_CONFIG[:libversion]}.#{BUILD_CONFIG[:patch_version]}"
+end
+
+def config_rubinius_version
+ version = rubinius_version
+ version += ".#{BUILD_CONFIG[:release]}" if BUILD_CONFIG[:release]
+ version
+end
+
+def config_release_date
+ BUILD_CONFIG[:release_date]
+end
+
+def default_rubinius_version
+ rubinius_version + ".#{validate_release_label}"
+end
+
+def default_release_date
+ validate_release_date
+end
+
+def validate_revision
+ read_revision == BUILD_CONFIG[:revision]
+end
+
+def validate_release_label(label="nightly")
+ date = Time.now
+ case label
+ when "nightly"
+ "n#{date.strftime("%j").to_i}"
+ when "weekly"
+ "w#{date.strftime("%V").to_i}"
+ when "monthly"
+ "m#{date.month}"
+ when /^rc\d+/
+ label
+ when "final"
+ nil
+ else
+ raise "unknown release label #{label}"
+ end
+end
+
+def validate_release_date(date=Time.now.to_s)
+ Date.parse(date).strftime
+end
View
55 rakelib/vm.rake
@@ -1,6 +1,7 @@
require 'rakelib/rubinius'
require 'rakelib/instruction_parser'
require 'rakelib/generator_task'
+require 'rakelib/release'
require 'tmpdir'
require 'ostruct'
@@ -19,6 +20,10 @@ VM_EXE = RUBY_PLATFORM =~ /mingw|mswin/ ? 'vm/vm.exe' : 'vm/vm'
encoding_database = "vm/gen/encoding_database.cpp"
transcoders_database = "vm/gen/transcoder_database.cpp"
+vm_release_h = "vm/gen/release.h"
+capi_18_release_h = "vm/capi/18/include/gen/rbx_release.h"
+capi_19_release_h = "vm/capi/19/include/gen/rbx_release.h"
+
ENV.delete 'CDPATH' # confuses llvm_config
INSN_GEN = %w[ vm/gen/instruction_names.cpp
@@ -45,12 +50,14 @@ TYPE_GEN = %w[ vm/gen/includes.hpp
vm/gen/jit_resolver.cpp
vm/gen/invoke_resolver.cpp ]
-GENERATED = %W[ vm/gen/revision.h
- vm/gen/config_variables.h
+GENERATED = %W[ vm/gen/config_variables.h
vm/gen/signature.h
vm/dtrace/probes.h
#{encoding_database}
#{transcoders_database}
+ #{vm_release_h}
+ #{capi_18_release_h}
+ #{capi_19_release_h}
] + TYPE_GEN + INSN_GEN
# Files are in order based on dependencies. For example,
@@ -239,18 +246,44 @@ file transcoders_database => [transcoders_lib_dir, transcoders_extract] do |t|
ruby transcoders_extract, transcoders_src_dir, t.name
end
-task 'vm/gen/revision.h' do |t|
- git_dir = File.expand_path "../../.git", __FILE__
-
- if !ENV['RELEASE'] and File.directory? git_dir
- buildrev = `git rev-parse HEAD`.chomp
+task vm_release_h do |t|
+ if git_directory
+ if validate_revision
+ File.open t.name, "wb" do |f|
+ f.puts %[#define RBX_VERSION "#{config_rubinius_version}"]
+ f.puts %[#define RBX_RELEASE_DATE "#{config_release_date}"]
+ f.puts %[#define RBX_BUILD_REV "#{build_revision}"]
+ end
+ else
+ File.open t.name, "wb" do |f|
+ f.puts %[#define RBX_VERSION "#{default_rubinius_version}"]
+ f.puts %[#define RBX_RELEASE_DATE "#{default_release_date}"]
+ f.puts %[#define RBX_BUILD_REV "#{build_revision}"]
+ end
+ end
+ elsif File.file? release_revision
+ unless File.exists? t.name
+ File.open t.name, "wb" do |f|
+ f.puts %[#define RBX_VERSION "#{default_rubinius_version}"]
+ f.puts %[#define RBX_RELEASE_DATE "#{default_release_date}"]
+ f.puts %[#define RBX_BUILD_REV "#{build_revision}"]
+ end
+ end
else
- buildrev = "release"
+ File.open t.name, "wb" do |f|
+ f.puts %[#define RBX_VERSION "#{config_rubinius_version}"]
+ f.puts %[#define RBX_RELEASE_DATE "#{config_release_date}"]
+ f.puts %[#define RBX_BUILD_REV "#{build_revision}"]
+ end
end
+end
- File.open t.name, "wb" do |f|
- f.puts %[#define RBX_BUILD_REV "#{buildrev}"]
- end
+task capi_18_release_h => vm_release_h do |t|
+ FileUtils.cp vm_release_h, t.name
+end
+
+task capi_19_release_h => vm_release_h do |t|
+ FileUtils.cp vm_release_h, t.name
end
file 'vm/gen/config_variables.h' => %w[lib/rubinius/configuration.rb config.rb] do |t|
View
6 vm/.gitignore
@@ -6,9 +6,11 @@ test/test_instructions.hpp
capi/config.h
capi/18/include/config.h
capi/18/include/mri_oop.h
-capi/18/include/rbx_config.h
+capi/18/include/gen/rbx_config.h
+capi/18/include/gen/rbx_release.h
capi/18/include/capi_constants.h
capi/19/include/ruby/config.h
capi/19/include/ruby/mri_oop.h
-capi/19/include/rbx_config.h
+capi/19/include/gen/rbx_config.h
+capi/19/include/gen/rbx_release.h
capi/19/include/ruby/capi_constants.h
View
2  vm/capi/18/include/rbx_config.h
@@ -0,0 +1,2 @@
+#include <gen/rbx_config.h>
+#include <gen/rbx_release.h>
View
2  vm/capi/19/include/rbx_config.h
@@ -0,0 +1,2 @@
+#include <gen/rbx_config.h>
+#include <gen/rbx_release.h>
View
2  vm/ontology.cpp
@@ -61,7 +61,7 @@
#include "environment.hpp"
#include "configuration.hpp"
#include "config.h"
-#include "revision.h"
+#include "release.h"
#include "ontology.hpp"
View
1  vm/release.h
@@ -0,0 +1 @@
+#include "gen/release.h"
View
1  vm/revision.h
@@ -1 +0,0 @@
-#include "gen/revision.h"
Please sign in to comment.
Something went wrong with that request. Please try again.