Skip to content

Commit

Permalink
Added doc:vm tasks to main Rakefile
Browse files Browse the repository at this point in the history
  * Added doc:vm rake tasks to main Rakefile
  * rake build now also builds VM docs, provided RedCloth is
    available. If not, a warning message is displayed, but the
    build continues.
  • Loading branch information
agardiner committed Nov 28, 2007
1 parent 3068d14 commit 3c0b50e
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 74 deletions.
93 changes: 80 additions & 13 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ end

class Hash
include TSort

alias tsort_each_node each_key

def tsort_each_child(node, &block)
fetch(node).each(&block)
end
end

def newer?(file, cmp)
File.exists?(cmp) and File.mtime(cmp) >= File.mtime(file)
end
Expand Down Expand Up @@ -50,7 +50,7 @@ end

def create_load_order(files, output=".load_order.txt")
d = Hash.new { |h,k| h[k] = [] }

# assume all the files are in the same directory
dir = File.dirname(files.first)
found = false
Expand All @@ -67,15 +67,15 @@ def create_load_order(files, output=".load_order.txt")
end
end
end

File.open(output, "w") do |f|
begin
if found
list = d.tsort
else
list = files.sort
end

f.puts list.collect { |n| compiled_name(n, dir) }.join("\n")
rescue IndexError => e
puts "Unable to generate '.load_order.txt'"
Expand All @@ -94,7 +94,7 @@ def compile(name, output)
unless File.exists?(dir)
FileUtils.mkdir_p dir
end

sh "shotgun/rubinius compile #{name} #{output}", :verbose => $verbose
end

Expand Down Expand Up @@ -258,14 +258,14 @@ namespace :spec do
namespace :diff do
desc 'Run specs and produce a diff against current base'
task :run do
system 'bin/mspec -f ci -o spec/reports/specdiff.txt spec'
system 'bin/mspec -f ci -o spec/reports/specdiff.txt spec'
system 'diff -u spec/reports/base.txt spec/reports/specdiff.txt'
system 'rm spec/reports/specdiff.txt'
end

desc 'Replace the base spec file with a new one'
task :replace do
system 'bin/mspec -f ci -o spec/reports/base.txt spec'
system 'bin/mspec -f ci -o spec/reports/base.txt spec'
end
end

Expand Down Expand Up @@ -365,8 +365,8 @@ namespace :build do
build:extensions
]

# This nobody rule lets use use all the shotgun files as
# prereqs. This rule is run for all those prereqs and just
# This nobody rule lets use use all the shotgun files as
# prereqs. This rule is run for all those prereqs and just
# (obviously) does nothing, but it makes rake happy.
rule '^shotgun/.+'

Expand Down Expand Up @@ -434,9 +434,9 @@ end
] do
sh "./shotgun/rubinius compile lib/ext/syck"
end

task :fcntl => "lib/ext/fcntl/fcntl.#{$dlext}"

file "lib/ext/fcntl/fcntl.#{$dlext}" => FileList[
'lib/ext/fcntl/build.rb',
'lib/ext/fcntl/*.c'
Expand Down Expand Up @@ -474,3 +474,70 @@ end

desc "Build task for CruiseControl"
task :ccrb => [:build, 'spec:ci']


## Include tasks to build documentation
def redcloth_present?
if $redcloth_available.nil?
begin
require 'rubygems'
gem 'RedCloth', '~> 3.0'
$redcloth_available = true
rescue Gem::LoadError
puts
puts "WARNING: RedCloth 3.x is required to build the VM html docs"
puts "Run 'gem install redcloth' to install the latest RedCloth gem"
puts
$redcloth_available = false
end
end
$redcloth_available
end

namespace "doc" do
namespace "vm" do

desc "Remove all generated HTML files under doc/vm"
task "clean" do
Dir.glob('doc/vm/**/*.html').each do |html|
rm_f html unless html =~ /\/?index.html$/
end
end

desc "Generate HTML in doc/vm from YAML and Textile sources"
task "html"

# Define tasks for each opcode html file on the corresponding YAML file
require 'doc/vm/op_code_info'
OpCode::Info.op_codes.each do |op|
html = "doc/vm/op_codes/#{op}.html"
yaml = "doc/vm/op_codes/#{op}.yaml"
file html => yaml do
cd 'doc/vm' do
ruby "gen_op_code_html.rb #{op}"
end
end

task "html" => html
end

# Define tasks for each section html file on the corresponding textile file
# Note: requires redcloth gem to convert textile markup to html
Dir.glob('doc/vm/*.textile').each do |f|
html = f.chomp('.textile') + '.html'
file html => f do
if redcloth_present?
section = File.basename(f)
cd 'doc/vm' do
ruby "gen_section_html.rb #{section}"
end
end
end

task "html" => html
end
end
end

task :build => 'doc:vm:html'

59 changes: 0 additions & 59 deletions doc/vm/Rakefile

This file was deleted.

11 changes: 11 additions & 0 deletions doc/vm/gen_section_html.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
require 'rubygems'
require 'erb'

begin
gem 'RedCloth', '~> 3.0'
rescue Gem::LoadError
puts
puts "ERROR: RedCloth 3.x is required to build the HTML docs"
puts "Run 'gem install redcloth' to install the latest RedCloth gem"
puts
exit 1
end

require 'redcloth'

section_template = ERB.new(File.read('section_template.html.erb'),nil,'<>')
Expand Down
4 changes: 2 additions & 2 deletions doc/vm/op_code_info.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$: << '../../compiler'
$: << File.dirname(__FILE__) + '/../../compiler'
require 'bytecode/encoder'
require 'bytecode/assembler'
require 'yaml'
Expand All @@ -7,7 +7,7 @@
# Read shotgun/lib/instructions.rb, stripping out just the ShotgunInstruction class definition
# Code at the end of the class generates instructions* files, which we don't want to do here
code = ""; output = false
File.foreach('../../shotgun/lib/instructions.rb') do |line|
File.foreach(File.dirname(__FILE__) + '/../../shotgun/lib/instructions.rb') do |line|
output ||= (line =~ /^class ShotgunInstructions$/)
code << line if output
output &&= !(line =~ /^end$/)
Expand Down

0 comments on commit 3c0b50e

Please sign in to comment.